babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643
  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. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. subMeshFaceId: number;
  10488. /** Id of the the submesh that was picked */
  10489. subMeshId: number;
  10490. /** If a sprite was picked, this will be the sprite the pick collided with */
  10491. pickedSprite: Nullable<Sprite>;
  10492. /**
  10493. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10494. */
  10495. originMesh: Nullable<AbstractMesh>;
  10496. /**
  10497. * The ray that was used to perform the picking.
  10498. */
  10499. ray: Nullable<Ray>;
  10500. /**
  10501. * Gets the normal correspodning to the face the pick collided with
  10502. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10503. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10504. * @returns The normal correspodning to the face the pick collided with
  10505. */
  10506. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10507. /**
  10508. * Gets the texture coordinates of where the pick occured
  10509. * @returns the vector containing the coordnates of the texture
  10510. */
  10511. getTextureCoordinates(): Nullable<Vector2>;
  10512. }
  10513. }
  10514. declare module "babylonjs/Culling/ray" {
  10515. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10516. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10518. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10519. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10520. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10521. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10522. import { Plane } from "babylonjs/Maths/math.plane";
  10523. /**
  10524. * Class representing a ray with position and direction
  10525. */
  10526. export class Ray {
  10527. /** origin point */
  10528. origin: Vector3;
  10529. /** direction */
  10530. direction: Vector3;
  10531. /** length of the ray */
  10532. length: number;
  10533. private static readonly TmpVector3;
  10534. private _tmpRay;
  10535. /**
  10536. * Creates a new ray
  10537. * @param origin origin point
  10538. * @param direction direction
  10539. * @param length length of the ray
  10540. */
  10541. constructor(
  10542. /** origin point */
  10543. origin: Vector3,
  10544. /** direction */
  10545. direction: Vector3,
  10546. /** length of the ray */
  10547. length?: number);
  10548. /**
  10549. * Checks if the ray intersects a box
  10550. * This does not account for the ray lenght by design to improve perfs.
  10551. * @param minimum bound of the box
  10552. * @param maximum bound of the box
  10553. * @param intersectionTreshold extra extend to be added to the box in all direction
  10554. * @returns if the box was hit
  10555. */
  10556. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10557. /**
  10558. * Checks if the ray intersects a box
  10559. * This does not account for the ray lenght by design to improve perfs.
  10560. * @param box the bounding box to check
  10561. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10562. * @returns if the box was hit
  10563. */
  10564. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10565. /**
  10566. * If the ray hits a sphere
  10567. * @param sphere the bounding sphere to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10569. * @returns true if it hits the sphere
  10570. */
  10571. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a triange
  10574. * @param vertex0 triangle vertex
  10575. * @param vertex1 triangle vertex
  10576. * @param vertex2 triangle vertex
  10577. * @returns intersection information if hit
  10578. */
  10579. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10580. /**
  10581. * Checks if ray intersects a plane
  10582. * @param plane the plane to check
  10583. * @returns the distance away it was hit
  10584. */
  10585. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10586. /**
  10587. * Calculate the intercept of a ray on a given axis
  10588. * @param axis to check 'x' | 'y' | 'z'
  10589. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10590. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10591. */
  10592. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10593. /**
  10594. * Checks if ray intersects a mesh
  10595. * @param mesh the mesh to check
  10596. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10597. * @returns picking info of the intersecton
  10598. */
  10599. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param meshes the meshes to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @param results array to store result in
  10605. * @returns Array of picking infos
  10606. */
  10607. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10608. private _comparePickingInfo;
  10609. private static smallnum;
  10610. private static rayl;
  10611. /**
  10612. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10613. * @param sega the first point of the segment to test the intersection against
  10614. * @param segb the second point of the segment to test the intersection against
  10615. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10616. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10617. */
  10618. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10619. /**
  10620. * Update the ray from viewport position
  10621. * @param x position
  10622. * @param y y position
  10623. * @param viewportWidth viewport width
  10624. * @param viewportHeight viewport height
  10625. * @param world world matrix
  10626. * @param view view matrix
  10627. * @param projection projection matrix
  10628. * @returns this ray updated
  10629. */
  10630. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10631. /**
  10632. * Creates a ray with origin and direction of 0,0,0
  10633. * @returns the new ray
  10634. */
  10635. static Zero(): Ray;
  10636. /**
  10637. * Creates a new ray from screen space and viewport
  10638. * @param x position
  10639. * @param y y position
  10640. * @param viewportWidth viewport width
  10641. * @param viewportHeight viewport height
  10642. * @param world world matrix
  10643. * @param view view matrix
  10644. * @param projection projection matrix
  10645. * @returns new ray
  10646. */
  10647. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10648. /**
  10649. * 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
  10650. * transformed to the given world matrix.
  10651. * @param origin The origin point
  10652. * @param end The end point
  10653. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10654. * @returns the new ray
  10655. */
  10656. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10657. /**
  10658. * Transforms a ray by a matrix
  10659. * @param ray ray to transform
  10660. * @param matrix matrix to apply
  10661. * @returns the resulting new ray
  10662. */
  10663. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @param result ray to store result in
  10669. */
  10670. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10671. /**
  10672. * Unproject a ray from screen space to object space
  10673. * @param sourceX defines the screen space x coordinate to use
  10674. * @param sourceY defines the screen space y coordinate to use
  10675. * @param viewportWidth defines the current width of the viewport
  10676. * @param viewportHeight defines the current height of the viewport
  10677. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10678. * @param view defines the view matrix to use
  10679. * @param projection defines the projection matrix to use
  10680. */
  10681. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10682. }
  10683. /**
  10684. * Type used to define predicate used to select faces when a mesh intersection is detected
  10685. */
  10686. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10687. module "babylonjs/scene" {
  10688. interface Scene {
  10689. /** @hidden */
  10690. _tempPickingRay: Nullable<Ray>;
  10691. /** @hidden */
  10692. _cachedRayForTransform: Ray;
  10693. /** @hidden */
  10694. _pickWithRayInverseMatrix: Matrix;
  10695. /** @hidden */
  10696. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10697. /** @hidden */
  10698. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10699. }
  10700. }
  10701. }
  10702. declare module "babylonjs/sceneComponent" {
  10703. import { Scene } from "babylonjs/scene";
  10704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10705. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10706. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10707. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10708. import { Nullable } from "babylonjs/types";
  10709. import { Camera } from "babylonjs/Cameras/camera";
  10710. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10711. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10712. import { AbstractScene } from "babylonjs/abstractScene";
  10713. import { Mesh } from "babylonjs/Meshes/mesh";
  10714. /**
  10715. * Groups all the scene component constants in one place to ease maintenance.
  10716. * @hidden
  10717. */
  10718. export class SceneComponentConstants {
  10719. static readonly NAME_EFFECTLAYER: string;
  10720. static readonly NAME_LAYER: string;
  10721. static readonly NAME_LENSFLARESYSTEM: string;
  10722. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10723. static readonly NAME_PARTICLESYSTEM: string;
  10724. static readonly NAME_GAMEPAD: string;
  10725. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10726. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10727. static readonly NAME_DEPTHRENDERER: string;
  10728. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10729. static readonly NAME_SPRITE: string;
  10730. static readonly NAME_OUTLINERENDERER: string;
  10731. static readonly NAME_PROCEDURALTEXTURE: string;
  10732. static readonly NAME_SHADOWGENERATOR: string;
  10733. static readonly NAME_OCTREE: string;
  10734. static readonly NAME_PHYSICSENGINE: string;
  10735. static readonly NAME_AUDIO: string;
  10736. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10737. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10739. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10740. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10742. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10744. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10747. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10749. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10750. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10751. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10753. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10754. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10755. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_POINTERMOVE_SPRITE: number;
  10763. static readonly STEP_POINTERDOWN_SPRITE: number;
  10764. static readonly STEP_POINTERUP_SPRITE: number;
  10765. }
  10766. /**
  10767. * This represents a scene component.
  10768. *
  10769. * This is used to decouple the dependency the scene is having on the different workloads like
  10770. * layers, post processes...
  10771. */
  10772. export interface ISceneComponent {
  10773. /**
  10774. * The name of the component. Each component must have a unique name.
  10775. */
  10776. name: string;
  10777. /**
  10778. * The scene the component belongs to.
  10779. */
  10780. scene: Scene;
  10781. /**
  10782. * Register the component to one instance of a scene.
  10783. */
  10784. register(): void;
  10785. /**
  10786. * Rebuilds the elements related to this component in case of
  10787. * context lost for instance.
  10788. */
  10789. rebuild(): void;
  10790. /**
  10791. * Disposes the component and the associated ressources.
  10792. */
  10793. dispose(): void;
  10794. }
  10795. /**
  10796. * This represents a SERIALIZABLE scene component.
  10797. *
  10798. * This extends Scene Component to add Serialization methods on top.
  10799. */
  10800. export interface ISceneSerializableComponent extends ISceneComponent {
  10801. /**
  10802. * Adds all the elements from the container to the scene
  10803. * @param container the container holding the elements
  10804. */
  10805. addFromContainer(container: AbstractScene): void;
  10806. /**
  10807. * Removes all the elements in the container from the scene
  10808. * @param container contains the elements to remove
  10809. * @param dispose if the removed element should be disposed (default: false)
  10810. */
  10811. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10812. /**
  10813. * Serializes the component data to the specified json object
  10814. * @param serializationObject The object to serialize to
  10815. */
  10816. serialize(serializationObject: any): void;
  10817. }
  10818. /**
  10819. * Strong typing of a Mesh related stage step action
  10820. */
  10821. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10822. /**
  10823. * Strong typing of a Evaluate Sub Mesh related stage step action
  10824. */
  10825. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10826. /**
  10827. * Strong typing of a Active Mesh related stage step action
  10828. */
  10829. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10830. /**
  10831. * Strong typing of a Camera related stage step action
  10832. */
  10833. export type CameraStageAction = (camera: Camera) => void;
  10834. /**
  10835. * Strong typing of a Camera Frame buffer related stage step action
  10836. */
  10837. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10838. /**
  10839. * Strong typing of a Render Target related stage step action
  10840. */
  10841. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10842. /**
  10843. * Strong typing of a RenderingGroup related stage step action
  10844. */
  10845. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10846. /**
  10847. * Strong typing of a Mesh Render related stage step action
  10848. */
  10849. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10850. /**
  10851. * Strong typing of a simple stage step action
  10852. */
  10853. export type SimpleStageAction = () => void;
  10854. /**
  10855. * Strong typing of a render target action.
  10856. */
  10857. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10858. /**
  10859. * Strong typing of a pointer move action.
  10860. */
  10861. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10862. /**
  10863. * Strong typing of a pointer up/down action.
  10864. */
  10865. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10866. /**
  10867. * Representation of a stage in the scene (Basically a list of ordered steps)
  10868. * @hidden
  10869. */
  10870. export class Stage<T extends Function> extends Array<{
  10871. index: number;
  10872. component: ISceneComponent;
  10873. action: T;
  10874. }> {
  10875. /**
  10876. * Hide ctor from the rest of the world.
  10877. * @param items The items to add.
  10878. */
  10879. private constructor();
  10880. /**
  10881. * Creates a new Stage.
  10882. * @returns A new instance of a Stage
  10883. */
  10884. static Create<T extends Function>(): Stage<T>;
  10885. /**
  10886. * Registers a step in an ordered way in the targeted stage.
  10887. * @param index Defines the position to register the step in
  10888. * @param component Defines the component attached to the step
  10889. * @param action Defines the action to launch during the step
  10890. */
  10891. registerStep(index: number, component: ISceneComponent, action: T): void;
  10892. /**
  10893. * Clears all the steps from the stage.
  10894. */
  10895. clear(): void;
  10896. }
  10897. }
  10898. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10899. import { Nullable } from "babylonjs/types";
  10900. import { Observable } from "babylonjs/Misc/observable";
  10901. import { Scene } from "babylonjs/scene";
  10902. import { Sprite } from "babylonjs/Sprites/sprite";
  10903. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10904. import { Ray } from "babylonjs/Culling/ray";
  10905. import { Camera } from "babylonjs/Cameras/camera";
  10906. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10907. import { ISceneComponent } from "babylonjs/sceneComponent";
  10908. module "babylonjs/scene" {
  10909. interface Scene {
  10910. /** @hidden */
  10911. _pointerOverSprite: Nullable<Sprite>;
  10912. /** @hidden */
  10913. _pickedDownSprite: Nullable<Sprite>;
  10914. /** @hidden */
  10915. _tempSpritePickingRay: Nullable<Ray>;
  10916. /**
  10917. * All of the sprite managers added to this scene
  10918. * @see http://doc.babylonjs.com/babylon101/sprites
  10919. */
  10920. spriteManagers: Array<ISpriteManager>;
  10921. /**
  10922. * An event triggered when sprites rendering is about to start
  10923. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10924. */
  10925. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10926. /**
  10927. * An event triggered when sprites rendering is done
  10928. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10929. */
  10930. onAfterSpritesRenderingObservable: Observable<Scene>;
  10931. /** @hidden */
  10932. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Launch a ray to try to pick a sprite in the scene
  10934. * @param x position on screen
  10935. * @param y position on screen
  10936. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10937. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10938. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10939. * @returns a PickingInfo
  10940. */
  10941. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10942. /** Use the given ray to pick a sprite in the scene
  10943. * @param ray The ray (in world space) to use to pick meshes
  10944. * @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
  10945. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10946. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10947. * @returns a PickingInfo
  10948. */
  10949. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10950. /** @hidden */
  10951. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10952. /** Launch a ray to try to pick sprites in the scene
  10953. * @param x position on screen
  10954. * @param y position on screen
  10955. * @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
  10956. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10957. * @returns a PickingInfo array
  10958. */
  10959. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10960. /** Use the given ray to pick sprites in the scene
  10961. * @param ray The ray (in world space) to use to pick meshes
  10962. * @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
  10963. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10964. * @returns a PickingInfo array
  10965. */
  10966. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10967. /**
  10968. * Force the sprite under the pointer
  10969. * @param sprite defines the sprite to use
  10970. */
  10971. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10972. /**
  10973. * Gets the sprite under the pointer
  10974. * @returns a Sprite or null if no sprite is under the pointer
  10975. */
  10976. getPointerOverSprite(): Nullable<Sprite>;
  10977. }
  10978. }
  10979. /**
  10980. * Defines the sprite scene component responsible to manage sprites
  10981. * in a given scene.
  10982. */
  10983. export class SpriteSceneComponent implements ISceneComponent {
  10984. /**
  10985. * The component name helpfull to identify the component in the list of scene components.
  10986. */
  10987. readonly name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /** @hidden */
  10993. private _spritePredicate;
  10994. /**
  10995. * Creates a new instance of the component for the given scene
  10996. * @param scene Defines the scene to register the component in
  10997. */
  10998. constructor(scene: Scene);
  10999. /**
  11000. * Registers the component in a given scene
  11001. */
  11002. register(): void;
  11003. /**
  11004. * Rebuilds the elements related to this component in case of
  11005. * context lost for instance.
  11006. */
  11007. rebuild(): void;
  11008. /**
  11009. * Disposes the component and the associated ressources.
  11010. */
  11011. dispose(): void;
  11012. private _pickSpriteButKeepRay;
  11013. private _pointerMove;
  11014. private _pointerDown;
  11015. private _pointerUp;
  11016. }
  11017. }
  11018. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11019. /** @hidden */
  11020. export var fogFragmentDeclaration: {
  11021. name: string;
  11022. shader: string;
  11023. };
  11024. }
  11025. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11026. /** @hidden */
  11027. export var fogFragment: {
  11028. name: string;
  11029. shader: string;
  11030. };
  11031. }
  11032. declare module "babylonjs/Shaders/sprites.fragment" {
  11033. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11034. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11035. /** @hidden */
  11036. export var spritesPixelShader: {
  11037. name: string;
  11038. shader: string;
  11039. };
  11040. }
  11041. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11042. /** @hidden */
  11043. export var fogVertexDeclaration: {
  11044. name: string;
  11045. shader: string;
  11046. };
  11047. }
  11048. declare module "babylonjs/Shaders/sprites.vertex" {
  11049. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11050. /** @hidden */
  11051. export var spritesVertexShader: {
  11052. name: string;
  11053. shader: string;
  11054. };
  11055. }
  11056. declare module "babylonjs/Sprites/spriteManager" {
  11057. import { IDisposable, Scene } from "babylonjs/scene";
  11058. import { Nullable } from "babylonjs/types";
  11059. import { Observable } from "babylonjs/Misc/observable";
  11060. import { Sprite } from "babylonjs/Sprites/sprite";
  11061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11062. import { Camera } from "babylonjs/Cameras/camera";
  11063. import { Texture } from "babylonjs/Materials/Textures/texture";
  11064. import "babylonjs/Shaders/sprites.fragment";
  11065. import "babylonjs/Shaders/sprites.vertex";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. /**
  11068. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11069. */
  11070. export interface ISpriteManager extends IDisposable {
  11071. /**
  11072. * Gets manager's name
  11073. */
  11074. name: string;
  11075. /**
  11076. * Restricts the camera to viewing objects with the same layerMask.
  11077. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11078. */
  11079. layerMask: number;
  11080. /**
  11081. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11082. */
  11083. isPickable: boolean;
  11084. /**
  11085. * Gets the hosting scene
  11086. */
  11087. scene: Scene;
  11088. /**
  11089. * Specifies the rendering group id for this mesh (0 by default)
  11090. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11091. */
  11092. renderingGroupId: number;
  11093. /**
  11094. * Defines the list of sprites managed by the manager.
  11095. */
  11096. sprites: Array<Sprite>;
  11097. /**
  11098. * Gets or sets the spritesheet texture
  11099. */
  11100. texture: Texture;
  11101. /** Defines the default width of a cell in the spritesheet */
  11102. cellWidth: number;
  11103. /** Defines the default height of a cell in the spritesheet */
  11104. cellHeight: number;
  11105. /**
  11106. * Tests the intersection of a sprite with a specific ray.
  11107. * @param ray The ray we are sending to test the collision
  11108. * @param camera The camera space we are sending rays in
  11109. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11110. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11111. * @returns picking info or null.
  11112. */
  11113. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11114. /**
  11115. * Intersects the sprites with a ray
  11116. * @param ray defines the ray to intersect with
  11117. * @param camera defines the current active camera
  11118. * @param predicate defines a predicate used to select candidate sprites
  11119. * @returns null if no hit or a PickingInfo array
  11120. */
  11121. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11122. /**
  11123. * Renders the list of sprites on screen.
  11124. */
  11125. render(): void;
  11126. }
  11127. /**
  11128. * Class used to manage multiple sprites on the same spritesheet
  11129. * @see http://doc.babylonjs.com/babylon101/sprites
  11130. */
  11131. export class SpriteManager implements ISpriteManager {
  11132. /** defines the manager's name */
  11133. name: string;
  11134. /** Define the Url to load snippets */
  11135. static SnippetUrl: string;
  11136. /** Snippet ID if the manager was created from the snippet server */
  11137. snippetId: string;
  11138. /** Gets the list of sprites */
  11139. sprites: Sprite[];
  11140. /** Gets or sets the rendering group id (0 by default) */
  11141. renderingGroupId: number;
  11142. /** Gets or sets camera layer mask */
  11143. layerMask: number;
  11144. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11145. fogEnabled: boolean;
  11146. /** Gets or sets a boolean indicating if the sprites are pickable */
  11147. isPickable: boolean;
  11148. /** Defines the default width of a cell in the spritesheet */
  11149. cellWidth: number;
  11150. /** Defines the default height of a cell in the spritesheet */
  11151. cellHeight: number;
  11152. /** Associative array from JSON sprite data file */
  11153. private _cellData;
  11154. /** Array of sprite names from JSON sprite data file */
  11155. private _spriteMap;
  11156. /** True when packed cell data from JSON file is ready*/
  11157. private _packedAndReady;
  11158. private _textureContent;
  11159. /**
  11160. * An event triggered when the manager is disposed.
  11161. */
  11162. onDisposeObservable: Observable<SpriteManager>;
  11163. private _onDisposeObserver;
  11164. /**
  11165. * Callback called when the manager is disposed
  11166. */
  11167. set onDispose(callback: () => void);
  11168. private _capacity;
  11169. private _fromPacked;
  11170. private _spriteTexture;
  11171. private _epsilon;
  11172. private _scene;
  11173. private _vertexData;
  11174. private _buffer;
  11175. private _vertexBuffers;
  11176. private _indexBuffer;
  11177. private _effectBase;
  11178. private _effectFog;
  11179. /**
  11180. * Gets or sets the unique id of the sprite
  11181. */
  11182. uniqueId: number;
  11183. /**
  11184. * Gets the array of sprites
  11185. */
  11186. get children(): Sprite[];
  11187. /**
  11188. * Gets the hosting scene
  11189. */
  11190. get scene(): Scene;
  11191. /**
  11192. * Gets the capacity of the manager
  11193. */
  11194. get capacity(): number;
  11195. /**
  11196. * Gets or sets the spritesheet texture
  11197. */
  11198. get texture(): Texture;
  11199. set texture(value: Texture);
  11200. private _blendMode;
  11201. /**
  11202. * Blend mode use to render the particle, it can be any of
  11203. * the static Constants.ALPHA_x properties provided in this class.
  11204. * Default value is Constants.ALPHA_COMBINE
  11205. */
  11206. get blendMode(): number;
  11207. set blendMode(blendMode: number);
  11208. /** Disables writing to the depth buffer when rendering the sprites.
  11209. * It can be handy to disable depth writing when using textures without alpha channel
  11210. * and setting some specific blend modes.
  11211. */
  11212. disableDepthWrite: boolean;
  11213. /**
  11214. * Creates a new sprite manager
  11215. * @param name defines the manager's name
  11216. * @param imgUrl defines the sprite sheet url
  11217. * @param capacity defines the maximum allowed number of sprites
  11218. * @param cellSize defines the size of a sprite cell
  11219. * @param scene defines the hosting scene
  11220. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11221. * @param samplingMode defines the smapling mode to use with spritesheet
  11222. * @param fromPacked set to false; do not alter
  11223. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11224. */
  11225. constructor(
  11226. /** defines the manager's name */
  11227. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11228. /**
  11229. * Returns the string "SpriteManager"
  11230. * @returns "SpriteManager"
  11231. */
  11232. getClassName(): string;
  11233. private _makePacked;
  11234. private _appendSpriteVertex;
  11235. private _checkTextureAlpha;
  11236. /**
  11237. * Intersects the sprites with a ray
  11238. * @param ray defines the ray to intersect with
  11239. * @param camera defines the current active camera
  11240. * @param predicate defines a predicate used to select candidate sprites
  11241. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11242. * @returns null if no hit or a PickingInfo
  11243. */
  11244. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11245. /**
  11246. * Intersects the sprites with a ray
  11247. * @param ray defines the ray to intersect with
  11248. * @param camera defines the current active camera
  11249. * @param predicate defines a predicate used to select candidate sprites
  11250. * @returns null if no hit or a PickingInfo array
  11251. */
  11252. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11253. /**
  11254. * Render all child sprites
  11255. */
  11256. render(): void;
  11257. /**
  11258. * Release associated resources
  11259. */
  11260. dispose(): void;
  11261. /**
  11262. * Serializes the sprite manager to a JSON object
  11263. * @param serializeTexture defines if the texture must be serialized as well
  11264. * @returns the JSON object
  11265. */
  11266. serialize(serializeTexture?: boolean): any;
  11267. /**
  11268. * Parses a JSON object to create a new sprite manager.
  11269. * @param parsedManager The JSON object to parse
  11270. * @param scene The scene to create the sprite managerin
  11271. * @param rootUrl The root url to use to load external dependencies like texture
  11272. * @returns the new sprite manager
  11273. */
  11274. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11275. /**
  11276. * Creates a sprite manager from a snippet saved in a remote file
  11277. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11278. * @param url defines the url to load from
  11279. * @param scene defines the hosting scene
  11280. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11281. * @returns a promise that will resolve to the new sprite manager
  11282. */
  11283. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11284. /**
  11285. * Creates a sprite manager from a snippet saved by the sprite editor
  11286. * @param snippetId defines the snippet to load
  11287. * @param scene defines the hosting scene
  11288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11289. * @returns a promise that will resolve to the new sprite manager
  11290. */
  11291. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11292. }
  11293. }
  11294. declare module "babylonjs/Misc/gradients" {
  11295. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11296. /** Interface used by value gradients (color, factor, ...) */
  11297. export interface IValueGradient {
  11298. /**
  11299. * Gets or sets the gradient value (between 0 and 1)
  11300. */
  11301. gradient: number;
  11302. }
  11303. /** Class used to store color4 gradient */
  11304. export class ColorGradient implements IValueGradient {
  11305. /**
  11306. * Gets or sets the gradient value (between 0 and 1)
  11307. */
  11308. gradient: number;
  11309. /**
  11310. * Gets or sets first associated color
  11311. */
  11312. color1: Color4;
  11313. /**
  11314. * Gets or sets second associated color
  11315. */
  11316. color2?: Color4 | undefined;
  11317. /**
  11318. * Creates a new color4 gradient
  11319. * @param gradient gets or sets the gradient value (between 0 and 1)
  11320. * @param color1 gets or sets first associated color
  11321. * @param color2 gets or sets first second color
  11322. */
  11323. constructor(
  11324. /**
  11325. * Gets or sets the gradient value (between 0 and 1)
  11326. */
  11327. gradient: number,
  11328. /**
  11329. * Gets or sets first associated color
  11330. */
  11331. color1: Color4,
  11332. /**
  11333. * Gets or sets second associated color
  11334. */
  11335. color2?: Color4 | undefined);
  11336. /**
  11337. * Will get a color picked randomly between color1 and color2.
  11338. * If color2 is undefined then color1 will be used
  11339. * @param result defines the target Color4 to store the result in
  11340. */
  11341. getColorToRef(result: Color4): void;
  11342. }
  11343. /** Class used to store color 3 gradient */
  11344. export class Color3Gradient implements IValueGradient {
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number;
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3;
  11353. /**
  11354. * Creates a new color3 gradient
  11355. * @param gradient gets or sets the gradient value (between 0 and 1)
  11356. * @param color gets or sets associated color
  11357. */
  11358. constructor(
  11359. /**
  11360. * Gets or sets the gradient value (between 0 and 1)
  11361. */
  11362. gradient: number,
  11363. /**
  11364. * Gets or sets the associated color
  11365. */
  11366. color: Color3);
  11367. }
  11368. /** Class used to store factor gradient */
  11369. export class FactorGradient implements IValueGradient {
  11370. /**
  11371. * Gets or sets the gradient value (between 0 and 1)
  11372. */
  11373. gradient: number;
  11374. /**
  11375. * Gets or sets first associated factor
  11376. */
  11377. factor1: number;
  11378. /**
  11379. * Gets or sets second associated factor
  11380. */
  11381. factor2?: number | undefined;
  11382. /**
  11383. * Creates a new factor gradient
  11384. * @param gradient gets or sets the gradient value (between 0 and 1)
  11385. * @param factor1 gets or sets first associated factor
  11386. * @param factor2 gets or sets second associated factor
  11387. */
  11388. constructor(
  11389. /**
  11390. * Gets or sets the gradient value (between 0 and 1)
  11391. */
  11392. gradient: number,
  11393. /**
  11394. * Gets or sets first associated factor
  11395. */
  11396. factor1: number,
  11397. /**
  11398. * Gets or sets second associated factor
  11399. */
  11400. factor2?: number | undefined);
  11401. /**
  11402. * Will get a number picked randomly between factor1 and factor2.
  11403. * If factor2 is undefined then factor1 will be used
  11404. * @returns the picked number
  11405. */
  11406. getFactor(): number;
  11407. }
  11408. /**
  11409. * Helper used to simplify some generic gradient tasks
  11410. */
  11411. export class GradientHelper {
  11412. /**
  11413. * Gets the current gradient from an array of IValueGradient
  11414. * @param ratio defines the current ratio to get
  11415. * @param gradients defines the array of IValueGradient
  11416. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11417. */
  11418. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11419. }
  11420. }
  11421. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11423. import { Nullable } from "babylonjs/types";
  11424. module "babylonjs/Engines/thinEngine" {
  11425. interface ThinEngine {
  11426. /**
  11427. * Creates a dynamic texture
  11428. * @param width defines the width of the texture
  11429. * @param height defines the height of the texture
  11430. * @param generateMipMaps defines if the engine should generate the mip levels
  11431. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11432. * @returns the dynamic texture inside an InternalTexture
  11433. */
  11434. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11435. /**
  11436. * Update the content of a dynamic texture
  11437. * @param texture defines the texture to update
  11438. * @param canvas defines the canvas containing the source
  11439. * @param invertY defines if data must be stored with Y axis inverted
  11440. * @param premulAlpha defines if alpha is stored as premultiplied
  11441. * @param format defines the format of the data
  11442. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11443. */
  11444. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11445. }
  11446. }
  11447. }
  11448. declare module "babylonjs/Misc/canvasGenerator" {
  11449. /**
  11450. * Helper class used to generate a canvas to manipulate images
  11451. */
  11452. export class CanvasGenerator {
  11453. /**
  11454. * Create a new canvas (or offscreen canvas depending on the context)
  11455. * @param width defines the expected width
  11456. * @param height defines the expected height
  11457. * @return a new canvas or offscreen canvas
  11458. */
  11459. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11460. }
  11461. }
  11462. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11463. import { Scene } from "babylonjs/scene";
  11464. import { Texture } from "babylonjs/Materials/Textures/texture";
  11465. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11466. /**
  11467. * A class extending Texture allowing drawing on a texture
  11468. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11469. */
  11470. export class DynamicTexture extends Texture {
  11471. private _generateMipMaps;
  11472. private _canvas;
  11473. private _context;
  11474. /**
  11475. * Creates a DynamicTexture
  11476. * @param name defines the name of the texture
  11477. * @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
  11478. * @param scene defines the scene where you want the texture
  11479. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11480. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11481. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11482. */
  11483. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11484. /**
  11485. * Get the current class name of the texture useful for serialization or dynamic coding.
  11486. * @returns "DynamicTexture"
  11487. */
  11488. getClassName(): string;
  11489. /**
  11490. * Gets the current state of canRescale
  11491. */
  11492. get canRescale(): boolean;
  11493. private _recreate;
  11494. /**
  11495. * Scales the texture
  11496. * @param ratio the scale factor to apply to both width and height
  11497. */
  11498. scale(ratio: number): void;
  11499. /**
  11500. * Resizes the texture
  11501. * @param width the new width
  11502. * @param height the new height
  11503. */
  11504. scaleTo(width: number, height: number): void;
  11505. /**
  11506. * Gets the context of the canvas used by the texture
  11507. * @returns the canvas context of the dynamic texture
  11508. */
  11509. getContext(): CanvasRenderingContext2D;
  11510. /**
  11511. * Clears the texture
  11512. */
  11513. clear(): void;
  11514. /**
  11515. * Updates the texture
  11516. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11517. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11518. */
  11519. update(invertY?: boolean, premulAlpha?: boolean): void;
  11520. /**
  11521. * Draws text onto the texture
  11522. * @param text defines the text to be drawn
  11523. * @param x defines the placement of the text from the left
  11524. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11525. * @param font defines the font to be used with font-style, font-size, font-name
  11526. * @param color defines the color used for the text
  11527. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11528. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11529. * @param update defines whether texture is immediately update (default is true)
  11530. */
  11531. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11532. /**
  11533. * Clones the texture
  11534. * @returns the clone of the texture.
  11535. */
  11536. clone(): DynamicTexture;
  11537. /**
  11538. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11539. * @returns a serialized dynamic texture object
  11540. */
  11541. serialize(): any;
  11542. /** @hidden */
  11543. _rebuild(): void;
  11544. }
  11545. }
  11546. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11547. import { Nullable } from "babylonjs/types";
  11548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11549. import { Scene } from "babylonjs/scene";
  11550. module "babylonjs/Engines/thinEngine" {
  11551. interface ThinEngine {
  11552. /**
  11553. * Creates a raw texture
  11554. * @param data defines the data to store in the texture
  11555. * @param width defines the width of the texture
  11556. * @param height defines the height of the texture
  11557. * @param format defines the format of the data
  11558. * @param generateMipMaps defines if the engine should generate the mip levels
  11559. * @param invertY defines if data must be stored with Y axis inverted
  11560. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11561. * @param compression defines the compression used (null by default)
  11562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11563. * @returns the raw texture inside an InternalTexture
  11564. */
  11565. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11566. /**
  11567. * Update a raw texture
  11568. * @param texture defines the texture to update
  11569. * @param data defines the data to store in the texture
  11570. * @param format defines the format of the data
  11571. * @param invertY defines if data must be stored with Y axis inverted
  11572. */
  11573. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11574. /**
  11575. * Update a raw texture
  11576. * @param texture defines the texture to update
  11577. * @param data defines the data to store in the texture
  11578. * @param format defines the format of the data
  11579. * @param invertY defines if data must be stored with Y axis inverted
  11580. * @param compression defines the compression used (null by default)
  11581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11582. */
  11583. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11584. /**
  11585. * Creates a new raw cube texture
  11586. * @param data defines the array of data to use to create each face
  11587. * @param size defines the size of the textures
  11588. * @param format defines the format of the data
  11589. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11590. * @param generateMipMaps defines if the engine should generate the mip levels
  11591. * @param invertY defines if data must be stored with Y axis inverted
  11592. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11593. * @param compression defines the compression used (null by default)
  11594. * @returns the cube texture as an InternalTexture
  11595. */
  11596. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11597. /**
  11598. * Update a raw cube texture
  11599. * @param texture defines the texture to udpdate
  11600. * @param data defines the data to store
  11601. * @param format defines the data format
  11602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11603. * @param invertY defines if data must be stored with Y axis inverted
  11604. */
  11605. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11606. /**
  11607. * Update a raw cube texture
  11608. * @param texture defines the texture to udpdate
  11609. * @param data defines the data to store
  11610. * @param format defines the data format
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. * @param invertY defines if data must be stored with Y axis inverted
  11613. * @param compression defines the compression used (null by default)
  11614. */
  11615. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11616. /**
  11617. * Update a raw cube texture
  11618. * @param texture defines the texture to udpdate
  11619. * @param data defines the data to store
  11620. * @param format defines the data format
  11621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11622. * @param invertY defines if data must be stored with Y axis inverted
  11623. * @param compression defines the compression used (null by default)
  11624. * @param level defines which level of the texture to update
  11625. */
  11626. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11627. /**
  11628. * Creates a new raw cube texture from a specified url
  11629. * @param url defines the url where the data is located
  11630. * @param scene defines the current scene
  11631. * @param size defines the size of the textures
  11632. * @param format defines the format of the data
  11633. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11634. * @param noMipmap defines if the engine should avoid generating the mip levels
  11635. * @param callback defines a callback used to extract texture data from loaded data
  11636. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11637. * @param onLoad defines a callback called when texture is loaded
  11638. * @param onError defines a callback called if there is an error
  11639. * @returns the cube texture as an InternalTexture
  11640. */
  11641. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11642. /**
  11643. * Creates a new raw cube texture from a specified url
  11644. * @param url defines the url where the data is located
  11645. * @param scene defines the current scene
  11646. * @param size defines the size of the textures
  11647. * @param format defines the format of the data
  11648. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11649. * @param noMipmap defines if the engine should avoid generating the mip levels
  11650. * @param callback defines a callback used to extract texture data from loaded data
  11651. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11652. * @param onLoad defines a callback called when texture is loaded
  11653. * @param onError defines a callback called if there is an error
  11654. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11655. * @param invertY defines if data must be stored with Y axis inverted
  11656. * @returns the cube texture as an InternalTexture
  11657. */
  11658. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11659. /**
  11660. * Creates a new raw 3D texture
  11661. * @param data defines the data used to create the texture
  11662. * @param width defines the width of the texture
  11663. * @param height defines the height of the texture
  11664. * @param depth defines the depth of the texture
  11665. * @param format defines the format of the texture
  11666. * @param generateMipMaps defines if the engine must generate mip levels
  11667. * @param invertY defines if data must be stored with Y axis inverted
  11668. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11669. * @param compression defines the compressed used (can be null)
  11670. * @param textureType defines the compressed used (can be null)
  11671. * @returns a new raw 3D texture (stored in an InternalTexture)
  11672. */
  11673. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11674. /**
  11675. * Update a raw 3D texture
  11676. * @param texture defines the texture to update
  11677. * @param data defines the data to store
  11678. * @param format defines the data format
  11679. * @param invertY defines if data must be stored with Y axis inverted
  11680. */
  11681. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11682. /**
  11683. * Update a raw 3D texture
  11684. * @param texture defines the texture to update
  11685. * @param data defines the data to store
  11686. * @param format defines the data format
  11687. * @param invertY defines if data must be stored with Y axis inverted
  11688. * @param compression defines the used compression (can be null)
  11689. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11690. */
  11691. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11692. /**
  11693. * Creates a new raw 2D array texture
  11694. * @param data defines the data used to create the texture
  11695. * @param width defines the width of the texture
  11696. * @param height defines the height of the texture
  11697. * @param depth defines the number of layers of the texture
  11698. * @param format defines the format of the texture
  11699. * @param generateMipMaps defines if the engine must generate mip levels
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11702. * @param compression defines the compressed used (can be null)
  11703. * @param textureType defines the compressed used (can be null)
  11704. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11705. */
  11706. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11707. /**
  11708. * Update a raw 2D array texture
  11709. * @param texture defines the texture to update
  11710. * @param data defines the data to store
  11711. * @param format defines the data format
  11712. * @param invertY defines if data must be stored with Y axis inverted
  11713. */
  11714. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11715. /**
  11716. * Update a raw 2D array texture
  11717. * @param texture defines the texture to update
  11718. * @param data defines the data to store
  11719. * @param format defines the data format
  11720. * @param invertY defines if data must be stored with Y axis inverted
  11721. * @param compression defines the used compression (can be null)
  11722. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11723. */
  11724. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11725. }
  11726. }
  11727. }
  11728. declare module "babylonjs/Materials/Textures/rawTexture" {
  11729. import { Scene } from "babylonjs/scene";
  11730. import { Texture } from "babylonjs/Materials/Textures/texture";
  11731. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11732. /**
  11733. * Raw texture can help creating a texture directly from an array of data.
  11734. * This can be super useful if you either get the data from an uncompressed source or
  11735. * if you wish to create your texture pixel by pixel.
  11736. */
  11737. export class RawTexture extends Texture {
  11738. /**
  11739. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11740. */
  11741. format: number;
  11742. /**
  11743. * Instantiates a new RawTexture.
  11744. * Raw texture can help creating a texture directly from an array of data.
  11745. * This can be super useful if you either get the data from an uncompressed source or
  11746. * if you wish to create your texture pixel by pixel.
  11747. * @param data define the array of data to use to create the texture
  11748. * @param width define the width of the texture
  11749. * @param height define the height of the texture
  11750. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11751. * @param scene define the scene the texture belongs to
  11752. * @param generateMipMaps define whether mip maps should be generated or not
  11753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11755. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11756. */
  11757. constructor(data: ArrayBufferView, width: number, height: number,
  11758. /**
  11759. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11760. */
  11761. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11762. /**
  11763. * Updates the texture underlying data.
  11764. * @param data Define the new data of the texture
  11765. */
  11766. update(data: ArrayBufferView): void;
  11767. /**
  11768. * Creates a luminance texture from some data.
  11769. * @param data Define the texture data
  11770. * @param width Define the width of the texture
  11771. * @param height Define the height of the texture
  11772. * @param scene Define the scene the texture belongs to
  11773. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11776. * @returns the luminance texture
  11777. */
  11778. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11779. /**
  11780. * Creates a luminance alpha texture from some data.
  11781. * @param data Define the texture data
  11782. * @param width Define the width of the texture
  11783. * @param height Define the height of the texture
  11784. * @param scene Define the scene the texture belongs to
  11785. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11788. * @returns the luminance alpha texture
  11789. */
  11790. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11791. /**
  11792. * Creates an alpha texture from some data.
  11793. * @param data Define the texture data
  11794. * @param width Define the width of the texture
  11795. * @param height Define the height of the texture
  11796. * @param scene Define the scene the texture belongs to
  11797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11800. * @returns the alpha texture
  11801. */
  11802. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11803. /**
  11804. * Creates a RGB texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param scene Define the scene the texture belongs to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the RGB alpha texture
  11814. */
  11815. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. /**
  11817. * Creates a RGBA texture from some data.
  11818. * @param data Define the texture data
  11819. * @param width Define the width of the texture
  11820. * @param height Define the height of the texture
  11821. * @param scene Define the scene the texture belongs to
  11822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11825. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11826. * @returns the RGBA texture
  11827. */
  11828. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11829. /**
  11830. * Creates a R texture from some data.
  11831. * @param data Define the texture data
  11832. * @param width Define the width of the texture
  11833. * @param height Define the height of the texture
  11834. * @param scene Define the scene the texture belongs to
  11835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11838. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11839. * @returns the R texture
  11840. */
  11841. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11842. }
  11843. }
  11844. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11845. import { Scene } from "babylonjs/scene";
  11846. import { ISceneComponent } from "babylonjs/sceneComponent";
  11847. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11848. module "babylonjs/abstractScene" {
  11849. interface AbstractScene {
  11850. /**
  11851. * The list of procedural textures added to the scene
  11852. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11853. */
  11854. proceduralTextures: Array<ProceduralTexture>;
  11855. }
  11856. }
  11857. /**
  11858. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11859. * in a given scene.
  11860. */
  11861. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11862. /**
  11863. * The component name helpfull to identify the component in the list of scene components.
  11864. */
  11865. readonly name: string;
  11866. /**
  11867. * The scene the component belongs to.
  11868. */
  11869. scene: Scene;
  11870. /**
  11871. * Creates a new instance of the component for the given scene
  11872. * @param scene Defines the scene to register the component in
  11873. */
  11874. constructor(scene: Scene);
  11875. /**
  11876. * Registers the component in a given scene
  11877. */
  11878. register(): void;
  11879. /**
  11880. * Rebuilds the elements related to this component in case of
  11881. * context lost for instance.
  11882. */
  11883. rebuild(): void;
  11884. /**
  11885. * Disposes the component and the associated ressources.
  11886. */
  11887. dispose(): void;
  11888. private _beforeClear;
  11889. }
  11890. }
  11891. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11893. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11894. module "babylonjs/Engines/thinEngine" {
  11895. interface ThinEngine {
  11896. /**
  11897. * Creates a new render target cube texture
  11898. * @param size defines the size of the texture
  11899. * @param options defines the options used to create the texture
  11900. * @returns a new render target cube texture stored in an InternalTexture
  11901. */
  11902. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11903. }
  11904. }
  11905. }
  11906. declare module "babylonjs/Shaders/procedural.vertex" {
  11907. /** @hidden */
  11908. export var proceduralVertexShader: {
  11909. name: string;
  11910. shader: string;
  11911. };
  11912. }
  11913. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11914. import { Observable } from "babylonjs/Misc/observable";
  11915. import { Nullable } from "babylonjs/types";
  11916. import { Scene } from "babylonjs/scene";
  11917. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11918. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11919. import { Effect } from "babylonjs/Materials/effect";
  11920. import { Texture } from "babylonjs/Materials/Textures/texture";
  11921. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11922. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11923. import "babylonjs/Shaders/procedural.vertex";
  11924. /**
  11925. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11926. * This is the base class of any Procedural texture and contains most of the shareable code.
  11927. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11928. */
  11929. export class ProceduralTexture extends Texture {
  11930. isCube: boolean;
  11931. /**
  11932. * Define if the texture is enabled or not (disabled texture will not render)
  11933. */
  11934. isEnabled: boolean;
  11935. /**
  11936. * Define if the texture must be cleared before rendering (default is true)
  11937. */
  11938. autoClear: boolean;
  11939. /**
  11940. * Callback called when the texture is generated
  11941. */
  11942. onGenerated: () => void;
  11943. /**
  11944. * Event raised when the texture is generated
  11945. */
  11946. onGeneratedObservable: Observable<ProceduralTexture>;
  11947. /** @hidden */
  11948. _generateMipMaps: boolean;
  11949. /** @hidden **/
  11950. _effect: Effect;
  11951. /** @hidden */
  11952. _textures: {
  11953. [key: string]: Texture;
  11954. };
  11955. /** @hidden */
  11956. protected _fallbackTexture: Nullable<Texture>;
  11957. private _size;
  11958. private _currentRefreshId;
  11959. private _frameId;
  11960. private _refreshRate;
  11961. private _vertexBuffers;
  11962. private _indexBuffer;
  11963. private _uniforms;
  11964. private _samplers;
  11965. private _fragment;
  11966. private _floats;
  11967. private _ints;
  11968. private _floatsArrays;
  11969. private _colors3;
  11970. private _colors4;
  11971. private _vectors2;
  11972. private _vectors3;
  11973. private _matrices;
  11974. private _fallbackTextureUsed;
  11975. private _fullEngine;
  11976. private _cachedDefines;
  11977. private _contentUpdateId;
  11978. private _contentData;
  11979. /**
  11980. * Instantiates a new procedural texture.
  11981. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11982. * This is the base class of any Procedural texture and contains most of the shareable code.
  11983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11984. * @param name Define the name of the texture
  11985. * @param size Define the size of the texture to create
  11986. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11987. * @param scene Define the scene the texture belongs to
  11988. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11989. * @param generateMipMaps Define if the texture should creates mip maps or not
  11990. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11991. */
  11992. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11993. /**
  11994. * The effect that is created when initializing the post process.
  11995. * @returns The created effect corresponding the the postprocess.
  11996. */
  11997. getEffect(): Effect;
  11998. /**
  11999. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12000. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12001. */
  12002. getContent(): Nullable<ArrayBufferView>;
  12003. private _createIndexBuffer;
  12004. /** @hidden */
  12005. _rebuild(): void;
  12006. /**
  12007. * Resets the texture in order to recreate its associated resources.
  12008. * This can be called in case of context loss
  12009. */
  12010. reset(): void;
  12011. protected _getDefines(): string;
  12012. /**
  12013. * Is the texture ready to be used ? (rendered at least once)
  12014. * @returns true if ready, otherwise, false.
  12015. */
  12016. isReady(): boolean;
  12017. /**
  12018. * Resets the refresh counter of the texture and start bak from scratch.
  12019. * Could be useful to regenerate the texture if it is setup to render only once.
  12020. */
  12021. resetRefreshCounter(): void;
  12022. /**
  12023. * Set the fragment shader to use in order to render the texture.
  12024. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12025. */
  12026. setFragment(fragment: any): void;
  12027. /**
  12028. * Define the refresh rate of the texture or the rendering frequency.
  12029. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12030. */
  12031. get refreshRate(): number;
  12032. set refreshRate(value: number);
  12033. /** @hidden */
  12034. _shouldRender(): boolean;
  12035. /**
  12036. * Get the size the texture is rendering at.
  12037. * @returns the size (texture is always squared)
  12038. */
  12039. getRenderSize(): number;
  12040. /**
  12041. * Resize the texture to new value.
  12042. * @param size Define the new size the texture should have
  12043. * @param generateMipMaps Define whether the new texture should create mip maps
  12044. */
  12045. resize(size: number, generateMipMaps: boolean): void;
  12046. private _checkUniform;
  12047. /**
  12048. * Set a texture in the shader program used to render.
  12049. * @param name Define the name of the uniform samplers as defined in the shader
  12050. * @param texture Define the texture to bind to this sampler
  12051. * @return the texture itself allowing "fluent" like uniform updates
  12052. */
  12053. setTexture(name: string, texture: Texture): ProceduralTexture;
  12054. /**
  12055. * Set a float in the shader.
  12056. * @param name Define the name of the uniform as defined in the shader
  12057. * @param value Define the value to give to the uniform
  12058. * @return the texture itself allowing "fluent" like uniform updates
  12059. */
  12060. setFloat(name: string, value: number): ProceduralTexture;
  12061. /**
  12062. * Set a int in the shader.
  12063. * @param name Define the name of the uniform as defined in the shader
  12064. * @param value Define the value to give to the uniform
  12065. * @return the texture itself allowing "fluent" like uniform updates
  12066. */
  12067. setInt(name: string, value: number): ProceduralTexture;
  12068. /**
  12069. * Set an array of floats in the shader.
  12070. * @param name Define the name of the uniform as defined in the shader
  12071. * @param value Define the value to give to the uniform
  12072. * @return the texture itself allowing "fluent" like uniform updates
  12073. */
  12074. setFloats(name: string, value: number[]): ProceduralTexture;
  12075. /**
  12076. * Set a vec3 in the shader from a Color3.
  12077. * @param name Define the name of the uniform as defined in the shader
  12078. * @param value Define the value to give to the uniform
  12079. * @return the texture itself allowing "fluent" like uniform updates
  12080. */
  12081. setColor3(name: string, value: Color3): ProceduralTexture;
  12082. /**
  12083. * Set a vec4 in the shader from a Color4.
  12084. * @param name Define the name of the uniform as defined in the shader
  12085. * @param value Define the value to give to the uniform
  12086. * @return the texture itself allowing "fluent" like uniform updates
  12087. */
  12088. setColor4(name: string, value: Color4): ProceduralTexture;
  12089. /**
  12090. * Set a vec2 in the shader from a Vector2.
  12091. * @param name Define the name of the uniform as defined in the shader
  12092. * @param value Define the value to give to the uniform
  12093. * @return the texture itself allowing "fluent" like uniform updates
  12094. */
  12095. setVector2(name: string, value: Vector2): ProceduralTexture;
  12096. /**
  12097. * Set a vec3 in the shader from a Vector3.
  12098. * @param name Define the name of the uniform as defined in the shader
  12099. * @param value Define the value to give to the uniform
  12100. * @return the texture itself allowing "fluent" like uniform updates
  12101. */
  12102. setVector3(name: string, value: Vector3): ProceduralTexture;
  12103. /**
  12104. * Set a mat4 in the shader from a MAtrix.
  12105. * @param name Define the name of the uniform as defined in the shader
  12106. * @param value Define the value to give to the uniform
  12107. * @return the texture itself allowing "fluent" like uniform updates
  12108. */
  12109. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12110. /**
  12111. * Render the texture to its associated render target.
  12112. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12113. */
  12114. render(useCameraPostProcess?: boolean): void;
  12115. /**
  12116. * Clone the texture.
  12117. * @returns the cloned texture
  12118. */
  12119. clone(): ProceduralTexture;
  12120. /**
  12121. * Dispose the texture and release its asoociated resources.
  12122. */
  12123. dispose(): void;
  12124. }
  12125. }
  12126. declare module "babylonjs/Particles/baseParticleSystem" {
  12127. import { Nullable } from "babylonjs/types";
  12128. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12130. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12131. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12133. import { Scene } from "babylonjs/scene";
  12134. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12135. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12136. import { Texture } from "babylonjs/Materials/Textures/texture";
  12137. import { Color4 } from "babylonjs/Maths/math.color";
  12138. import { Animation } from "babylonjs/Animations/animation";
  12139. /**
  12140. * This represents the base class for particle system in Babylon.
  12141. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12142. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12143. * @example https://doc.babylonjs.com/babylon101/particles
  12144. */
  12145. export class BaseParticleSystem {
  12146. /**
  12147. * Source color is added to the destination color without alpha affecting the result
  12148. */
  12149. static BLENDMODE_ONEONE: number;
  12150. /**
  12151. * Blend current color and particle color using particle’s alpha
  12152. */
  12153. static BLENDMODE_STANDARD: number;
  12154. /**
  12155. * Add current color and particle color multiplied by particle’s alpha
  12156. */
  12157. static BLENDMODE_ADD: number;
  12158. /**
  12159. * Multiply current color with particle color
  12160. */
  12161. static BLENDMODE_MULTIPLY: number;
  12162. /**
  12163. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12164. */
  12165. static BLENDMODE_MULTIPLYADD: number;
  12166. /**
  12167. * List of animations used by the particle system.
  12168. */
  12169. animations: Animation[];
  12170. /**
  12171. * Gets or sets the unique id of the particle system
  12172. */
  12173. uniqueId: number;
  12174. /**
  12175. * The id of the Particle system.
  12176. */
  12177. id: string;
  12178. /**
  12179. * The friendly name of the Particle system.
  12180. */
  12181. name: string;
  12182. /**
  12183. * Snippet ID if the particle system was created from the snippet server
  12184. */
  12185. snippetId: string;
  12186. /**
  12187. * The rendering group used by the Particle system to chose when to render.
  12188. */
  12189. renderingGroupId: number;
  12190. /**
  12191. * The emitter represents the Mesh or position we are attaching the particle system to.
  12192. */
  12193. emitter: Nullable<AbstractMesh | Vector3>;
  12194. /**
  12195. * The maximum number of particles to emit per frame
  12196. */
  12197. emitRate: number;
  12198. /**
  12199. * If you want to launch only a few particles at once, that can be done, as well.
  12200. */
  12201. manualEmitCount: number;
  12202. /**
  12203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12204. */
  12205. updateSpeed: number;
  12206. /**
  12207. * The amount of time the particle system is running (depends of the overall update speed).
  12208. */
  12209. targetStopDuration: number;
  12210. /**
  12211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12212. */
  12213. disposeOnStop: boolean;
  12214. /**
  12215. * Minimum power of emitting particles.
  12216. */
  12217. minEmitPower: number;
  12218. /**
  12219. * Maximum power of emitting particles.
  12220. */
  12221. maxEmitPower: number;
  12222. /**
  12223. * Minimum life time of emitting particles.
  12224. */
  12225. minLifeTime: number;
  12226. /**
  12227. * Maximum life time of emitting particles.
  12228. */
  12229. maxLifeTime: number;
  12230. /**
  12231. * Minimum Size of emitting particles.
  12232. */
  12233. minSize: number;
  12234. /**
  12235. * Maximum Size of emitting particles.
  12236. */
  12237. maxSize: number;
  12238. /**
  12239. * Minimum scale of emitting particles on X axis.
  12240. */
  12241. minScaleX: number;
  12242. /**
  12243. * Maximum scale of emitting particles on X axis.
  12244. */
  12245. maxScaleX: number;
  12246. /**
  12247. * Minimum scale of emitting particles on Y axis.
  12248. */
  12249. minScaleY: number;
  12250. /**
  12251. * Maximum scale of emitting particles on Y axis.
  12252. */
  12253. maxScaleY: number;
  12254. /**
  12255. * Gets or sets the minimal initial rotation in radians.
  12256. */
  12257. minInitialRotation: number;
  12258. /**
  12259. * Gets or sets the maximal initial rotation in radians.
  12260. */
  12261. maxInitialRotation: number;
  12262. /**
  12263. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12264. */
  12265. minAngularSpeed: number;
  12266. /**
  12267. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12268. */
  12269. maxAngularSpeed: number;
  12270. /**
  12271. * The texture used to render each particle. (this can be a spritesheet)
  12272. */
  12273. particleTexture: Nullable<Texture>;
  12274. /**
  12275. * The layer mask we are rendering the particles through.
  12276. */
  12277. layerMask: number;
  12278. /**
  12279. * This can help using your own shader to render the particle system.
  12280. * The according effect will be created
  12281. */
  12282. customShader: any;
  12283. /**
  12284. * By default particle system starts as soon as they are created. This prevents the
  12285. * automatic start to happen and let you decide when to start emitting particles.
  12286. */
  12287. preventAutoStart: boolean;
  12288. private _noiseTexture;
  12289. /**
  12290. * Gets or sets a texture used to add random noise to particle positions
  12291. */
  12292. get noiseTexture(): Nullable<ProceduralTexture>;
  12293. set noiseTexture(value: Nullable<ProceduralTexture>);
  12294. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12295. noiseStrength: Vector3;
  12296. /**
  12297. * Callback triggered when the particle animation is ending.
  12298. */
  12299. onAnimationEnd: Nullable<() => void>;
  12300. /**
  12301. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12302. */
  12303. blendMode: number;
  12304. /**
  12305. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12306. * to override the particles.
  12307. */
  12308. forceDepthWrite: boolean;
  12309. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12310. preWarmCycles: number;
  12311. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12312. preWarmStepOffset: number;
  12313. /**
  12314. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12315. */
  12316. spriteCellChangeSpeed: number;
  12317. /**
  12318. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12319. */
  12320. startSpriteCellID: number;
  12321. /**
  12322. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12323. */
  12324. endSpriteCellID: number;
  12325. /**
  12326. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12327. */
  12328. spriteCellWidth: number;
  12329. /**
  12330. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12331. */
  12332. spriteCellHeight: number;
  12333. /**
  12334. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12335. */
  12336. spriteRandomStartCell: boolean;
  12337. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12338. translationPivot: Vector2;
  12339. /** @hidden */
  12340. protected _isAnimationSheetEnabled: boolean;
  12341. /**
  12342. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12343. */
  12344. beginAnimationOnStart: boolean;
  12345. /**
  12346. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12347. */
  12348. beginAnimationFrom: number;
  12349. /**
  12350. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12351. */
  12352. beginAnimationTo: number;
  12353. /**
  12354. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12355. */
  12356. beginAnimationLoop: boolean;
  12357. /**
  12358. * Gets or sets a world offset applied to all particles
  12359. */
  12360. worldOffset: Vector3;
  12361. /**
  12362. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12363. */
  12364. get isAnimationSheetEnabled(): boolean;
  12365. set isAnimationSheetEnabled(value: boolean);
  12366. /**
  12367. * Get hosting scene
  12368. * @returns the scene
  12369. */
  12370. getScene(): Scene;
  12371. /**
  12372. * You can use gravity if you want to give an orientation to your particles.
  12373. */
  12374. gravity: Vector3;
  12375. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12376. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12378. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12379. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12381. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12382. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12383. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12384. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12385. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12387. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12388. /**
  12389. * Defines the delay in milliseconds before starting the system (0 by default)
  12390. */
  12391. startDelay: number;
  12392. /**
  12393. * Gets the current list of drag gradients.
  12394. * You must use addDragGradient and removeDragGradient to udpate this list
  12395. * @returns the list of drag gradients
  12396. */
  12397. getDragGradients(): Nullable<Array<FactorGradient>>;
  12398. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12399. limitVelocityDamping: number;
  12400. /**
  12401. * Gets the current list of limit velocity gradients.
  12402. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12403. * @returns the list of limit velocity gradients
  12404. */
  12405. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12406. /**
  12407. * Gets the current list of color gradients.
  12408. * You must use addColorGradient and removeColorGradient to udpate this list
  12409. * @returns the list of color gradients
  12410. */
  12411. getColorGradients(): Nullable<Array<ColorGradient>>;
  12412. /**
  12413. * Gets the current list of size gradients.
  12414. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12415. * @returns the list of size gradients
  12416. */
  12417. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12418. /**
  12419. * Gets the current list of color remap gradients.
  12420. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12421. * @returns the list of color remap gradients
  12422. */
  12423. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12424. /**
  12425. * Gets the current list of alpha remap gradients.
  12426. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12427. * @returns the list of alpha remap gradients
  12428. */
  12429. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12430. /**
  12431. * Gets the current list of life time gradients.
  12432. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12433. * @returns the list of life time gradients
  12434. */
  12435. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12436. /**
  12437. * Gets the current list of angular speed gradients.
  12438. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12439. * @returns the list of angular speed gradients
  12440. */
  12441. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12442. /**
  12443. * Gets the current list of velocity gradients.
  12444. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12445. * @returns the list of velocity gradients
  12446. */
  12447. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12448. /**
  12449. * Gets the current list of start size gradients.
  12450. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12451. * @returns the list of start size gradients
  12452. */
  12453. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12454. /**
  12455. * Gets the current list of emit rate gradients.
  12456. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12457. * @returns the list of emit rate gradients
  12458. */
  12459. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12460. /**
  12461. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12462. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12463. */
  12464. get direction1(): Vector3;
  12465. set direction1(value: Vector3);
  12466. /**
  12467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12468. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12469. */
  12470. get direction2(): Vector3;
  12471. set direction2(value: Vector3);
  12472. /**
  12473. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12474. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12475. */
  12476. get minEmitBox(): Vector3;
  12477. set minEmitBox(value: Vector3);
  12478. /**
  12479. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12480. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12481. */
  12482. get maxEmitBox(): Vector3;
  12483. set maxEmitBox(value: Vector3);
  12484. /**
  12485. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12486. */
  12487. color1: Color4;
  12488. /**
  12489. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12490. */
  12491. color2: Color4;
  12492. /**
  12493. * Color the particle will have at the end of its lifetime
  12494. */
  12495. colorDead: Color4;
  12496. /**
  12497. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12498. */
  12499. textureMask: Color4;
  12500. /**
  12501. * The particle emitter type defines the emitter used by the particle system.
  12502. * It can be for example box, sphere, or cone...
  12503. */
  12504. particleEmitterType: IParticleEmitterType;
  12505. /** @hidden */
  12506. _isSubEmitter: boolean;
  12507. /**
  12508. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12509. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12510. */
  12511. billboardMode: number;
  12512. protected _isBillboardBased: boolean;
  12513. /**
  12514. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12515. */
  12516. get isBillboardBased(): boolean;
  12517. set isBillboardBased(value: boolean);
  12518. /**
  12519. * The scene the particle system belongs to.
  12520. */
  12521. protected _scene: Scene;
  12522. /**
  12523. * Local cache of defines for image processing.
  12524. */
  12525. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12526. /**
  12527. * Default configuration related to image processing available in the standard Material.
  12528. */
  12529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12530. /**
  12531. * Gets the image processing configuration used either in this material.
  12532. */
  12533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12534. /**
  12535. * Sets the Default image processing configuration used either in the this material.
  12536. *
  12537. * If sets to null, the scene one is in use.
  12538. */
  12539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12540. /**
  12541. * Attaches a new image processing configuration to the Standard Material.
  12542. * @param configuration
  12543. */
  12544. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12545. /** @hidden */
  12546. protected _reset(): void;
  12547. /** @hidden */
  12548. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12549. /**
  12550. * Instantiates a particle system.
  12551. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12552. * @param name The name of the particle system
  12553. */
  12554. constructor(name: string);
  12555. /**
  12556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12559. * @returns the emitter
  12560. */
  12561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12562. /**
  12563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12564. * @param radius The radius of the hemisphere to emit from
  12565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12566. * @returns the emitter
  12567. */
  12568. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12569. /**
  12570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12571. * @param radius The radius of the sphere to emit from
  12572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12573. * @returns the emitter
  12574. */
  12575. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12576. /**
  12577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12578. * @param radius The radius of the sphere to emit from
  12579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12581. * @returns the emitter
  12582. */
  12583. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12584. /**
  12585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12586. * @param radius The radius of the emission cylinder
  12587. * @param height The height of the emission cylinder
  12588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12590. * @returns the emitter
  12591. */
  12592. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12593. /**
  12594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12595. * @param radius The radius of the cylinder to emit from
  12596. * @param height The height of the emission cylinder
  12597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12600. * @returns the emitter
  12601. */
  12602. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12603. /**
  12604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12605. * @param radius The radius of the cone to emit from
  12606. * @param angle The base angle of the cone
  12607. * @returns the emitter
  12608. */
  12609. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12610. /**
  12611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12616. * @returns the emitter
  12617. */
  12618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12619. }
  12620. }
  12621. declare module "babylonjs/Particles/subEmitter" {
  12622. import { Scene } from "babylonjs/scene";
  12623. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12624. /**
  12625. * Type of sub emitter
  12626. */
  12627. export enum SubEmitterType {
  12628. /**
  12629. * Attached to the particle over it's lifetime
  12630. */
  12631. ATTACHED = 0,
  12632. /**
  12633. * Created when the particle dies
  12634. */
  12635. END = 1
  12636. }
  12637. /**
  12638. * Sub emitter class used to emit particles from an existing particle
  12639. */
  12640. export class SubEmitter {
  12641. /**
  12642. * the particle system to be used by the sub emitter
  12643. */
  12644. particleSystem: ParticleSystem;
  12645. /**
  12646. * Type of the submitter (Default: END)
  12647. */
  12648. type: SubEmitterType;
  12649. /**
  12650. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12651. * Note: This only is supported when using an emitter of type Mesh
  12652. */
  12653. inheritDirection: boolean;
  12654. /**
  12655. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12656. */
  12657. inheritedVelocityAmount: number;
  12658. /**
  12659. * Creates a sub emitter
  12660. * @param particleSystem the particle system to be used by the sub emitter
  12661. */
  12662. constructor(
  12663. /**
  12664. * the particle system to be used by the sub emitter
  12665. */
  12666. particleSystem: ParticleSystem);
  12667. /**
  12668. * Clones the sub emitter
  12669. * @returns the cloned sub emitter
  12670. */
  12671. clone(): SubEmitter;
  12672. /**
  12673. * Serialize current object to a JSON object
  12674. * @returns the serialized object
  12675. */
  12676. serialize(): any;
  12677. /** @hidden */
  12678. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12679. /**
  12680. * Creates a new SubEmitter from a serialized JSON version
  12681. * @param serializationObject defines the JSON object to read from
  12682. * @param scene defines the hosting scene
  12683. * @param rootUrl defines the rootUrl for data loading
  12684. * @returns a new SubEmitter
  12685. */
  12686. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12687. /** Release associated resources */
  12688. dispose(): void;
  12689. }
  12690. }
  12691. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12692. /** @hidden */
  12693. export var imageProcessingDeclaration: {
  12694. name: string;
  12695. shader: string;
  12696. };
  12697. }
  12698. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12699. /** @hidden */
  12700. export var imageProcessingFunctions: {
  12701. name: string;
  12702. shader: string;
  12703. };
  12704. }
  12705. declare module "babylonjs/Shaders/particles.fragment" {
  12706. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12708. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12709. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12711. /** @hidden */
  12712. export var particlesPixelShader: {
  12713. name: string;
  12714. shader: string;
  12715. };
  12716. }
  12717. declare module "babylonjs/Shaders/particles.vertex" {
  12718. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12719. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12720. /** @hidden */
  12721. export var particlesVertexShader: {
  12722. name: string;
  12723. shader: string;
  12724. };
  12725. }
  12726. declare module "babylonjs/Particles/particleSystem" {
  12727. import { Nullable } from "babylonjs/types";
  12728. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12729. import { Observable } from "babylonjs/Misc/observable";
  12730. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12731. import { Effect } from "babylonjs/Materials/effect";
  12732. import { Scene, IDisposable } from "babylonjs/scene";
  12733. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12734. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12735. import { Particle } from "babylonjs/Particles/particle";
  12736. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12737. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12738. import "babylonjs/Shaders/particles.fragment";
  12739. import "babylonjs/Shaders/particles.vertex";
  12740. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12741. /**
  12742. * This represents a particle system in Babylon.
  12743. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12744. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12745. * @example https://doc.babylonjs.com/babylon101/particles
  12746. */
  12747. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12748. /**
  12749. * Billboard mode will only apply to Y axis
  12750. */
  12751. static readonly BILLBOARDMODE_Y: number;
  12752. /**
  12753. * Billboard mode will apply to all axes
  12754. */
  12755. static readonly BILLBOARDMODE_ALL: number;
  12756. /**
  12757. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12758. */
  12759. static readonly BILLBOARDMODE_STRETCHED: number;
  12760. /**
  12761. * This function can be defined to provide custom update for active particles.
  12762. * This function will be called instead of regular update (age, position, color, etc.).
  12763. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12764. */
  12765. updateFunction: (particles: Particle[]) => void;
  12766. private _emitterWorldMatrix;
  12767. /**
  12768. * This function can be defined to specify initial direction for every new particle.
  12769. * It by default use the emitterType defined function
  12770. */
  12771. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12772. /**
  12773. * This function can be defined to specify initial position for every new particle.
  12774. * It by default use the emitterType defined function
  12775. */
  12776. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12777. /**
  12778. * @hidden
  12779. */
  12780. _inheritedVelocityOffset: Vector3;
  12781. /**
  12782. * An event triggered when the system is disposed
  12783. */
  12784. onDisposeObservable: Observable<IParticleSystem>;
  12785. private _onDisposeObserver;
  12786. /**
  12787. * Sets a callback that will be triggered when the system is disposed
  12788. */
  12789. set onDispose(callback: () => void);
  12790. private _particles;
  12791. private _epsilon;
  12792. private _capacity;
  12793. private _stockParticles;
  12794. private _newPartsExcess;
  12795. private _vertexData;
  12796. private _vertexBuffer;
  12797. private _vertexBuffers;
  12798. private _spriteBuffer;
  12799. private _indexBuffer;
  12800. private _effect;
  12801. private _customEffect;
  12802. private _cachedDefines;
  12803. private _scaledColorStep;
  12804. private _colorDiff;
  12805. private _scaledDirection;
  12806. private _scaledGravity;
  12807. private _currentRenderId;
  12808. private _alive;
  12809. private _useInstancing;
  12810. private _started;
  12811. private _stopped;
  12812. private _actualFrame;
  12813. private _scaledUpdateSpeed;
  12814. private _vertexBufferSize;
  12815. /** @hidden */
  12816. _currentEmitRateGradient: Nullable<FactorGradient>;
  12817. /** @hidden */
  12818. _currentEmitRate1: number;
  12819. /** @hidden */
  12820. _currentEmitRate2: number;
  12821. /** @hidden */
  12822. _currentStartSizeGradient: Nullable<FactorGradient>;
  12823. /** @hidden */
  12824. _currentStartSize1: number;
  12825. /** @hidden */
  12826. _currentStartSize2: number;
  12827. private readonly _rawTextureWidth;
  12828. private _rampGradientsTexture;
  12829. private _useRampGradients;
  12830. /** Gets or sets a boolean indicating that ramp gradients must be used
  12831. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12832. */
  12833. get useRampGradients(): boolean;
  12834. set useRampGradients(value: boolean);
  12835. /**
  12836. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12837. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12838. */
  12839. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12840. private _subEmitters;
  12841. /**
  12842. * @hidden
  12843. * If the particle systems emitter should be disposed when the particle system is disposed
  12844. */
  12845. _disposeEmitterOnDispose: boolean;
  12846. /**
  12847. * The current active Sub-systems, this property is used by the root particle system only.
  12848. */
  12849. activeSubSystems: Array<ParticleSystem>;
  12850. /**
  12851. * Specifies if the particles are updated in emitter local space or world space
  12852. */
  12853. isLocal: boolean;
  12854. private _rootParticleSystem;
  12855. /**
  12856. * Gets the current list of active particles
  12857. */
  12858. get particles(): Particle[];
  12859. /**
  12860. * Gets the number of particles active at the same time.
  12861. * @returns The number of active particles.
  12862. */
  12863. getActiveCount(): number;
  12864. /**
  12865. * Returns the string "ParticleSystem"
  12866. * @returns a string containing the class name
  12867. */
  12868. getClassName(): string;
  12869. /**
  12870. * Gets a boolean indicating that the system is stopping
  12871. * @returns true if the system is currently stopping
  12872. */
  12873. isStopping(): boolean;
  12874. /**
  12875. * Gets the custom effect used to render the particles
  12876. * @param blendMode Blend mode for which the effect should be retrieved
  12877. * @returns The effect
  12878. */
  12879. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12880. /**
  12881. * Sets the custom effect used to render the particles
  12882. * @param effect The effect to set
  12883. * @param blendMode Blend mode for which the effect should be set
  12884. */
  12885. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12886. /** @hidden */
  12887. private _onBeforeDrawParticlesObservable;
  12888. /**
  12889. * Observable that will be called just before the particles are drawn
  12890. */
  12891. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12892. /**
  12893. * Gets the name of the particle vertex shader
  12894. */
  12895. get vertexShaderName(): string;
  12896. /**
  12897. * Instantiates a particle system.
  12898. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12899. * @param name The name of the particle system
  12900. * @param capacity The max number of particles alive at the same time
  12901. * @param scene The scene the particle system belongs to
  12902. * @param customEffect a custom effect used to change the way particles are rendered by default
  12903. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12904. * @param epsilon Offset used to render the particles
  12905. */
  12906. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12907. private _addFactorGradient;
  12908. private _removeFactorGradient;
  12909. /**
  12910. * Adds a new life time gradient
  12911. * @param gradient defines the gradient to use (between 0 and 1)
  12912. * @param factor defines the life time factor to affect to the specified gradient
  12913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12914. * @returns the current particle system
  12915. */
  12916. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12917. /**
  12918. * Remove a specific life time gradient
  12919. * @param gradient defines the gradient to remove
  12920. * @returns the current particle system
  12921. */
  12922. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12923. /**
  12924. * Adds a new size gradient
  12925. * @param gradient defines the gradient to use (between 0 and 1)
  12926. * @param factor defines the size factor to affect to the specified gradient
  12927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12928. * @returns the current particle system
  12929. */
  12930. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12931. /**
  12932. * Remove a specific size gradient
  12933. * @param gradient defines the gradient to remove
  12934. * @returns the current particle system
  12935. */
  12936. removeSizeGradient(gradient: number): IParticleSystem;
  12937. /**
  12938. * Adds a new color remap gradient
  12939. * @param gradient defines the gradient to use (between 0 and 1)
  12940. * @param min defines the color remap minimal range
  12941. * @param max defines the color remap maximal range
  12942. * @returns the current particle system
  12943. */
  12944. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12945. /**
  12946. * Remove a specific color remap gradient
  12947. * @param gradient defines the gradient to remove
  12948. * @returns the current particle system
  12949. */
  12950. removeColorRemapGradient(gradient: number): IParticleSystem;
  12951. /**
  12952. * Adds a new alpha remap gradient
  12953. * @param gradient defines the gradient to use (between 0 and 1)
  12954. * @param min defines the alpha remap minimal range
  12955. * @param max defines the alpha remap maximal range
  12956. * @returns the current particle system
  12957. */
  12958. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12959. /**
  12960. * Remove a specific alpha remap gradient
  12961. * @param gradient defines the gradient to remove
  12962. * @returns the current particle system
  12963. */
  12964. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12965. /**
  12966. * Adds a new angular speed gradient
  12967. * @param gradient defines the gradient to use (between 0 and 1)
  12968. * @param factor defines the angular speed to affect to the specified gradient
  12969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12970. * @returns the current particle system
  12971. */
  12972. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12973. /**
  12974. * Remove a specific angular speed gradient
  12975. * @param gradient defines the gradient to remove
  12976. * @returns the current particle system
  12977. */
  12978. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12979. /**
  12980. * Adds a new velocity gradient
  12981. * @param gradient defines the gradient to use (between 0 and 1)
  12982. * @param factor defines the velocity to affect to the specified gradient
  12983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12984. * @returns the current particle system
  12985. */
  12986. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12987. /**
  12988. * Remove a specific velocity gradient
  12989. * @param gradient defines the gradient to remove
  12990. * @returns the current particle system
  12991. */
  12992. removeVelocityGradient(gradient: number): IParticleSystem;
  12993. /**
  12994. * Adds a new limit velocity gradient
  12995. * @param gradient defines the gradient to use (between 0 and 1)
  12996. * @param factor defines the limit velocity value to affect to the specified gradient
  12997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12998. * @returns the current particle system
  12999. */
  13000. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13001. /**
  13002. * Remove a specific limit velocity gradient
  13003. * @param gradient defines the gradient to remove
  13004. * @returns the current particle system
  13005. */
  13006. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13007. /**
  13008. * Adds a new drag gradient
  13009. * @param gradient defines the gradient to use (between 0 and 1)
  13010. * @param factor defines the drag value to affect to the specified gradient
  13011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13012. * @returns the current particle system
  13013. */
  13014. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13015. /**
  13016. * Remove a specific drag gradient
  13017. * @param gradient defines the gradient to remove
  13018. * @returns the current particle system
  13019. */
  13020. removeDragGradient(gradient: number): IParticleSystem;
  13021. /**
  13022. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13023. * @param gradient defines the gradient to use (between 0 and 1)
  13024. * @param factor defines the emit rate value to affect to the specified gradient
  13025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13026. * @returns the current particle system
  13027. */
  13028. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13029. /**
  13030. * Remove a specific emit rate gradient
  13031. * @param gradient defines the gradient to remove
  13032. * @returns the current particle system
  13033. */
  13034. removeEmitRateGradient(gradient: number): IParticleSystem;
  13035. /**
  13036. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13037. * @param gradient defines the gradient to use (between 0 and 1)
  13038. * @param factor defines the start size value to affect to the specified gradient
  13039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13040. * @returns the current particle system
  13041. */
  13042. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13043. /**
  13044. * Remove a specific start size gradient
  13045. * @param gradient defines the gradient to remove
  13046. * @returns the current particle system
  13047. */
  13048. removeStartSizeGradient(gradient: number): IParticleSystem;
  13049. private _createRampGradientTexture;
  13050. /**
  13051. * Gets the current list of ramp gradients.
  13052. * You must use addRampGradient and removeRampGradient to udpate this list
  13053. * @returns the list of ramp gradients
  13054. */
  13055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13056. /** Force the system to rebuild all gradients that need to be resync */
  13057. forceRefreshGradients(): void;
  13058. private _syncRampGradientTexture;
  13059. /**
  13060. * Adds a new ramp gradient used to remap particle colors
  13061. * @param gradient defines the gradient to use (between 0 and 1)
  13062. * @param color defines the color to affect to the specified gradient
  13063. * @returns the current particle system
  13064. */
  13065. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13066. /**
  13067. * Remove a specific ramp gradient
  13068. * @param gradient defines the gradient to remove
  13069. * @returns the current particle system
  13070. */
  13071. removeRampGradient(gradient: number): ParticleSystem;
  13072. /**
  13073. * Adds a new color gradient
  13074. * @param gradient defines the gradient to use (between 0 and 1)
  13075. * @param color1 defines the color to affect to the specified gradient
  13076. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13077. * @returns this particle system
  13078. */
  13079. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13080. /**
  13081. * Remove a specific color gradient
  13082. * @param gradient defines the gradient to remove
  13083. * @returns this particle system
  13084. */
  13085. removeColorGradient(gradient: number): IParticleSystem;
  13086. private _fetchR;
  13087. protected _reset(): void;
  13088. private _resetEffect;
  13089. private _createVertexBuffers;
  13090. private _createIndexBuffer;
  13091. /**
  13092. * Gets the maximum number of particles active at the same time.
  13093. * @returns The max number of active particles.
  13094. */
  13095. getCapacity(): number;
  13096. /**
  13097. * Gets whether there are still active particles in the system.
  13098. * @returns True if it is alive, otherwise false.
  13099. */
  13100. isAlive(): boolean;
  13101. /**
  13102. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13103. * @returns True if it has been started, otherwise false.
  13104. */
  13105. isStarted(): boolean;
  13106. private _prepareSubEmitterInternalArray;
  13107. /**
  13108. * Starts the particle system and begins to emit
  13109. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13110. */
  13111. start(delay?: number): void;
  13112. /**
  13113. * Stops the particle system.
  13114. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  13115. */
  13116. stop(stopSubEmitters?: boolean): void;
  13117. /**
  13118. * Remove all active particles
  13119. */
  13120. reset(): void;
  13121. /**
  13122. * @hidden (for internal use only)
  13123. */
  13124. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13125. /**
  13126. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13127. * Its lifetime will start back at 0.
  13128. */
  13129. recycleParticle: (particle: Particle) => void;
  13130. private _stopSubEmitters;
  13131. private _createParticle;
  13132. private _removeFromRoot;
  13133. private _emitFromParticle;
  13134. private _update;
  13135. /** @hidden */
  13136. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13137. /** @hidden */
  13138. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13139. /**
  13140. * Fill the defines array according to the current settings of the particle system
  13141. * @param defines Array to be updated
  13142. * @param blendMode blend mode to take into account when updating the array
  13143. */
  13144. fillDefines(defines: Array<string>, blendMode: number): void;
  13145. /**
  13146. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13147. * @param uniforms Uniforms array to fill
  13148. * @param attributes Attributes array to fill
  13149. * @param samplers Samplers array to fill
  13150. */
  13151. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13152. /** @hidden */
  13153. private _getEffect;
  13154. /**
  13155. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13156. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13157. */
  13158. animate(preWarmOnly?: boolean): void;
  13159. private _appendParticleVertices;
  13160. /**
  13161. * Rebuilds the particle system.
  13162. */
  13163. rebuild(): void;
  13164. /**
  13165. * Is this system ready to be used/rendered
  13166. * @return true if the system is ready
  13167. */
  13168. isReady(): boolean;
  13169. private _render;
  13170. /**
  13171. * Renders the particle system in its current state.
  13172. * @returns the current number of particles
  13173. */
  13174. render(): number;
  13175. /**
  13176. * Disposes the particle system and free the associated resources
  13177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13178. */
  13179. dispose(disposeTexture?: boolean): void;
  13180. /**
  13181. * Clones the particle system.
  13182. * @param name The name of the cloned object
  13183. * @param newEmitter The new emitter to use
  13184. * @returns the cloned particle system
  13185. */
  13186. clone(name: string, newEmitter: any): ParticleSystem;
  13187. /**
  13188. * Serializes the particle system to a JSON object
  13189. * @param serializeTexture defines if the texture must be serialized as well
  13190. * @returns the JSON object
  13191. */
  13192. serialize(serializeTexture?: boolean): any;
  13193. /** @hidden */
  13194. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13195. /** @hidden */
  13196. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13197. /**
  13198. * Parses a JSON object to create a particle system.
  13199. * @param parsedParticleSystem The JSON object to parse
  13200. * @param scene The scene to create the particle system in
  13201. * @param rootUrl The root url to use to load external dependencies like texture
  13202. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13203. * @returns the Parsed particle system
  13204. */
  13205. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13206. }
  13207. }
  13208. declare module "babylonjs/Particles/particle" {
  13209. import { Nullable } from "babylonjs/types";
  13210. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13211. import { Color4 } from "babylonjs/Maths/math.color";
  13212. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13213. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13214. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13215. /**
  13216. * A particle represents one of the element emitted by a particle system.
  13217. * This is mainly define by its coordinates, direction, velocity and age.
  13218. */
  13219. export class Particle {
  13220. /**
  13221. * The particle system the particle belongs to.
  13222. */
  13223. particleSystem: ParticleSystem;
  13224. private static _Count;
  13225. /**
  13226. * Unique ID of the particle
  13227. */
  13228. id: number;
  13229. /**
  13230. * The world position of the particle in the scene.
  13231. */
  13232. position: Vector3;
  13233. /**
  13234. * The world direction of the particle in the scene.
  13235. */
  13236. direction: Vector3;
  13237. /**
  13238. * The color of the particle.
  13239. */
  13240. color: Color4;
  13241. /**
  13242. * The color change of the particle per step.
  13243. */
  13244. colorStep: Color4;
  13245. /**
  13246. * Defines how long will the life of the particle be.
  13247. */
  13248. lifeTime: number;
  13249. /**
  13250. * The current age of the particle.
  13251. */
  13252. age: number;
  13253. /**
  13254. * The current size of the particle.
  13255. */
  13256. size: number;
  13257. /**
  13258. * The current scale of the particle.
  13259. */
  13260. scale: Vector2;
  13261. /**
  13262. * The current angle of the particle.
  13263. */
  13264. angle: number;
  13265. /**
  13266. * Defines how fast is the angle changing.
  13267. */
  13268. angularSpeed: number;
  13269. /**
  13270. * Defines the cell index used by the particle to be rendered from a sprite.
  13271. */
  13272. cellIndex: number;
  13273. /**
  13274. * The information required to support color remapping
  13275. */
  13276. remapData: Vector4;
  13277. /** @hidden */
  13278. _randomCellOffset?: number;
  13279. /** @hidden */
  13280. _initialDirection: Nullable<Vector3>;
  13281. /** @hidden */
  13282. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13283. /** @hidden */
  13284. _initialStartSpriteCellID: number;
  13285. /** @hidden */
  13286. _initialEndSpriteCellID: number;
  13287. /** @hidden */
  13288. _currentColorGradient: Nullable<ColorGradient>;
  13289. /** @hidden */
  13290. _currentColor1: Color4;
  13291. /** @hidden */
  13292. _currentColor2: Color4;
  13293. /** @hidden */
  13294. _currentSizeGradient: Nullable<FactorGradient>;
  13295. /** @hidden */
  13296. _currentSize1: number;
  13297. /** @hidden */
  13298. _currentSize2: number;
  13299. /** @hidden */
  13300. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13301. /** @hidden */
  13302. _currentAngularSpeed1: number;
  13303. /** @hidden */
  13304. _currentAngularSpeed2: number;
  13305. /** @hidden */
  13306. _currentVelocityGradient: Nullable<FactorGradient>;
  13307. /** @hidden */
  13308. _currentVelocity1: number;
  13309. /** @hidden */
  13310. _currentVelocity2: number;
  13311. /** @hidden */
  13312. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13313. /** @hidden */
  13314. _currentLimitVelocity1: number;
  13315. /** @hidden */
  13316. _currentLimitVelocity2: number;
  13317. /** @hidden */
  13318. _currentDragGradient: Nullable<FactorGradient>;
  13319. /** @hidden */
  13320. _currentDrag1: number;
  13321. /** @hidden */
  13322. _currentDrag2: number;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates1: Vector3;
  13325. /** @hidden */
  13326. _randomNoiseCoordinates2: Vector3;
  13327. /** @hidden */
  13328. _localPosition?: Vector3;
  13329. /**
  13330. * Creates a new instance Particle
  13331. * @param particleSystem the particle system the particle belongs to
  13332. */
  13333. constructor(
  13334. /**
  13335. * The particle system the particle belongs to.
  13336. */
  13337. particleSystem: ParticleSystem);
  13338. private updateCellInfoFromSystem;
  13339. /**
  13340. * Defines how the sprite cell index is updated for the particle
  13341. */
  13342. updateCellIndex(): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13345. /** @hidden */
  13346. _inheritParticleInfoToSubEmitters(): void;
  13347. /** @hidden */
  13348. _reset(): void;
  13349. /**
  13350. * Copy the properties of particle to another one.
  13351. * @param other the particle to copy the information to.
  13352. */
  13353. copyTo(other: Particle): void;
  13354. }
  13355. }
  13356. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13357. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13358. import { Effect } from "babylonjs/Materials/effect";
  13359. import { Particle } from "babylonjs/Particles/particle";
  13360. import { Scene } from "babylonjs/scene";
  13361. /**
  13362. * Particle emitter represents a volume emitting particles.
  13363. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13364. */
  13365. export interface IParticleEmitterType {
  13366. /**
  13367. * Called by the particle System when the direction is computed for the created particle.
  13368. * @param worldMatrix is the world matrix of the particle system
  13369. * @param directionToUpdate is the direction vector to update with the result
  13370. * @param particle is the particle we are computed the direction for
  13371. * @param isLocal defines if the direction should be set in local space
  13372. */
  13373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13374. /**
  13375. * Called by the particle System when the position is computed for the created particle.
  13376. * @param worldMatrix is the world matrix of the particle system
  13377. * @param positionToUpdate is the position vector to update with the result
  13378. * @param particle is the particle we are computed the position for
  13379. * @param isLocal defines if the position should be set in local space
  13380. */
  13381. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13382. /**
  13383. * Clones the current emitter and returns a copy of it
  13384. * @returns the new emitter
  13385. */
  13386. clone(): IParticleEmitterType;
  13387. /**
  13388. * Called by the GPUParticleSystem to setup the update shader
  13389. * @param effect defines the update shader
  13390. */
  13391. applyToShader(effect: Effect): void;
  13392. /**
  13393. * Returns a string to use to update the GPU particles update shader
  13394. * @returns the effect defines string
  13395. */
  13396. getEffectDefines(): string;
  13397. /**
  13398. * Returns a string representing the class name
  13399. * @returns a string containing the class name
  13400. */
  13401. getClassName(): string;
  13402. /**
  13403. * Serializes the particle system to a JSON object.
  13404. * @returns the JSON object
  13405. */
  13406. serialize(): any;
  13407. /**
  13408. * Parse properties from a JSON object
  13409. * @param serializationObject defines the JSON object
  13410. * @param scene defines the hosting scene
  13411. */
  13412. parse(serializationObject: any, scene: Scene): void;
  13413. }
  13414. }
  13415. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13416. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13417. import { Effect } from "babylonjs/Materials/effect";
  13418. import { Particle } from "babylonjs/Particles/particle";
  13419. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13420. /**
  13421. * Particle emitter emitting particles from the inside of a box.
  13422. * It emits the particles randomly between 2 given directions.
  13423. */
  13424. export class BoxParticleEmitter implements IParticleEmitterType {
  13425. /**
  13426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13427. */
  13428. direction1: Vector3;
  13429. /**
  13430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13431. */
  13432. direction2: Vector3;
  13433. /**
  13434. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13435. */
  13436. minEmitBox: Vector3;
  13437. /**
  13438. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13439. */
  13440. maxEmitBox: Vector3;
  13441. /**
  13442. * Creates a new instance BoxParticleEmitter
  13443. */
  13444. constructor();
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): BoxParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "BoxParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13494. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13495. import { Effect } from "babylonjs/Materials/effect";
  13496. import { Particle } from "babylonjs/Particles/particle";
  13497. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13498. /**
  13499. * Particle emitter emitting particles from the inside of a cone.
  13500. * It emits the particles alongside the cone volume from the base to the particle.
  13501. * The emission direction might be randomized.
  13502. */
  13503. export class ConeParticleEmitter implements IParticleEmitterType {
  13504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13505. directionRandomizer: number;
  13506. private _radius;
  13507. private _angle;
  13508. private _height;
  13509. /**
  13510. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13511. */
  13512. radiusRange: number;
  13513. /**
  13514. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13515. */
  13516. heightRange: number;
  13517. /**
  13518. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13519. */
  13520. emitFromSpawnPointOnly: boolean;
  13521. /**
  13522. * Gets or sets the radius of the emission cone
  13523. */
  13524. get radius(): number;
  13525. set radius(value: number);
  13526. /**
  13527. * Gets or sets the angle of the emission cone
  13528. */
  13529. get angle(): number;
  13530. set angle(value: number);
  13531. private _buildHeight;
  13532. /**
  13533. * Creates a new instance ConeParticleEmitter
  13534. * @param radius the radius of the emission cone (1 by default)
  13535. * @param angle the cone base angle (PI by default)
  13536. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13537. */
  13538. constructor(radius?: number, angle?: number,
  13539. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13540. directionRandomizer?: number);
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): ConeParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "ConeParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13590. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13591. import { Effect } from "babylonjs/Materials/effect";
  13592. import { Particle } from "babylonjs/Particles/particle";
  13593. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13594. /**
  13595. * Particle emitter emitting particles from the inside of a cylinder.
  13596. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13597. */
  13598. export class CylinderParticleEmitter implements IParticleEmitterType {
  13599. /**
  13600. * The radius of the emission cylinder.
  13601. */
  13602. radius: number;
  13603. /**
  13604. * The height of the emission cylinder.
  13605. */
  13606. height: number;
  13607. /**
  13608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13609. */
  13610. radiusRange: number;
  13611. /**
  13612. * How much to randomize the particle direction [0-1].
  13613. */
  13614. directionRandomizer: number;
  13615. /**
  13616. * Creates a new instance CylinderParticleEmitter
  13617. * @param radius the radius of the emission cylinder (1 by default)
  13618. * @param height the height of the emission cylinder (1 by default)
  13619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13620. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13621. */
  13622. constructor(
  13623. /**
  13624. * The radius of the emission cylinder.
  13625. */
  13626. radius?: number,
  13627. /**
  13628. * The height of the emission cylinder.
  13629. */
  13630. height?: number,
  13631. /**
  13632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13633. */
  13634. radiusRange?: number,
  13635. /**
  13636. * How much to randomize the particle direction [0-1].
  13637. */
  13638. directionRandomizer?: number);
  13639. /**
  13640. * Called by the particle System when the direction is computed for the created particle.
  13641. * @param worldMatrix is the world matrix of the particle system
  13642. * @param directionToUpdate is the direction vector to update with the result
  13643. * @param particle is the particle we are computed the direction for
  13644. * @param isLocal defines if the direction should be set in local space
  13645. */
  13646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13647. /**
  13648. * Called by the particle System when the position is computed for the created particle.
  13649. * @param worldMatrix is the world matrix of the particle system
  13650. * @param positionToUpdate is the position vector to update with the result
  13651. * @param particle is the particle we are computed the position for
  13652. * @param isLocal defines if the position should be set in local space
  13653. */
  13654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13655. /**
  13656. * Clones the current emitter and returns a copy of it
  13657. * @returns the new emitter
  13658. */
  13659. clone(): CylinderParticleEmitter;
  13660. /**
  13661. * Called by the GPUParticleSystem to setup the update shader
  13662. * @param effect defines the update shader
  13663. */
  13664. applyToShader(effect: Effect): void;
  13665. /**
  13666. * Returns a string to use to update the GPU particles update shader
  13667. * @returns a string containng the defines string
  13668. */
  13669. getEffectDefines(): string;
  13670. /**
  13671. * Returns the string "CylinderParticleEmitter"
  13672. * @returns a string containing the class name
  13673. */
  13674. getClassName(): string;
  13675. /**
  13676. * Serializes the particle system to a JSON object.
  13677. * @returns the JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Parse properties from a JSON object
  13682. * @param serializationObject defines the JSON object
  13683. */
  13684. parse(serializationObject: any): void;
  13685. }
  13686. /**
  13687. * Particle emitter emitting particles from the inside of a cylinder.
  13688. * It emits the particles randomly between two vectors.
  13689. */
  13690. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1: Vector3;
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2: Vector3;
  13699. /**
  13700. * Creates a new instance CylinderDirectedParticleEmitter
  13701. * @param radius the radius of the emission cylinder (1 by default)
  13702. * @param height the height of the emission cylinder (1 by default)
  13703. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13704. * @param direction1 the min limit of the emission direction (up vector by default)
  13705. * @param direction2 the max limit of the emission direction (up vector by default)
  13706. */
  13707. constructor(radius?: number, height?: number, radiusRange?: number,
  13708. /**
  13709. * The min limit of the emission direction.
  13710. */
  13711. direction1?: Vector3,
  13712. /**
  13713. * The max limit of the emission direction.
  13714. */
  13715. direction2?: Vector3);
  13716. /**
  13717. * Called by the particle System when the direction is computed for the created particle.
  13718. * @param worldMatrix is the world matrix of the particle system
  13719. * @param directionToUpdate is the direction vector to update with the result
  13720. * @param particle is the particle we are computed the direction for
  13721. */
  13722. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13723. /**
  13724. * Clones the current emitter and returns a copy of it
  13725. * @returns the new emitter
  13726. */
  13727. clone(): CylinderDirectedParticleEmitter;
  13728. /**
  13729. * Called by the GPUParticleSystem to setup the update shader
  13730. * @param effect defines the update shader
  13731. */
  13732. applyToShader(effect: Effect): void;
  13733. /**
  13734. * Returns a string to use to update the GPU particles update shader
  13735. * @returns a string containng the defines string
  13736. */
  13737. getEffectDefines(): string;
  13738. /**
  13739. * Returns the string "CylinderDirectedParticleEmitter"
  13740. * @returns a string containing the class name
  13741. */
  13742. getClassName(): string;
  13743. /**
  13744. * Serializes the particle system to a JSON object.
  13745. * @returns the JSON object
  13746. */
  13747. serialize(): any;
  13748. /**
  13749. * Parse properties from a JSON object
  13750. * @param serializationObject defines the JSON object
  13751. */
  13752. parse(serializationObject: any): void;
  13753. }
  13754. }
  13755. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13756. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13757. import { Effect } from "babylonjs/Materials/effect";
  13758. import { Particle } from "babylonjs/Particles/particle";
  13759. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13760. /**
  13761. * Particle emitter emitting particles from the inside of a hemisphere.
  13762. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13763. */
  13764. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13765. /**
  13766. * The radius of the emission hemisphere.
  13767. */
  13768. radius: number;
  13769. /**
  13770. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13771. */
  13772. radiusRange: number;
  13773. /**
  13774. * How much to randomize the particle direction [0-1].
  13775. */
  13776. directionRandomizer: number;
  13777. /**
  13778. * Creates a new instance HemisphericParticleEmitter
  13779. * @param radius the radius of the emission hemisphere (1 by default)
  13780. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13781. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13782. */
  13783. constructor(
  13784. /**
  13785. * The radius of the emission hemisphere.
  13786. */
  13787. radius?: number,
  13788. /**
  13789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13790. */
  13791. radiusRange?: number,
  13792. /**
  13793. * How much to randomize the particle direction [0-1].
  13794. */
  13795. directionRandomizer?: number);
  13796. /**
  13797. * Called by the particle System when the direction is computed for the created particle.
  13798. * @param worldMatrix is the world matrix of the particle system
  13799. * @param directionToUpdate is the direction vector to update with the result
  13800. * @param particle is the particle we are computed the direction for
  13801. * @param isLocal defines if the direction should be set in local space
  13802. */
  13803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13804. /**
  13805. * Called by the particle System when the position is computed for the created particle.
  13806. * @param worldMatrix is the world matrix of the particle system
  13807. * @param positionToUpdate is the position vector to update with the result
  13808. * @param particle is the particle we are computed the position for
  13809. * @param isLocal defines if the position should be set in local space
  13810. */
  13811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13812. /**
  13813. * Clones the current emitter and returns a copy of it
  13814. * @returns the new emitter
  13815. */
  13816. clone(): HemisphericParticleEmitter;
  13817. /**
  13818. * Called by the GPUParticleSystem to setup the update shader
  13819. * @param effect defines the update shader
  13820. */
  13821. applyToShader(effect: Effect): void;
  13822. /**
  13823. * Returns a string to use to update the GPU particles update shader
  13824. * @returns a string containng the defines string
  13825. */
  13826. getEffectDefines(): string;
  13827. /**
  13828. * Returns the string "HemisphericParticleEmitter"
  13829. * @returns a string containing the class name
  13830. */
  13831. getClassName(): string;
  13832. /**
  13833. * Serializes the particle system to a JSON object.
  13834. * @returns the JSON object
  13835. */
  13836. serialize(): any;
  13837. /**
  13838. * Parse properties from a JSON object
  13839. * @param serializationObject defines the JSON object
  13840. */
  13841. parse(serializationObject: any): void;
  13842. }
  13843. }
  13844. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13845. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13846. import { Effect } from "babylonjs/Materials/effect";
  13847. import { Particle } from "babylonjs/Particles/particle";
  13848. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13849. /**
  13850. * Particle emitter emitting particles from a point.
  13851. * It emits the particles randomly between 2 given directions.
  13852. */
  13853. export class PointParticleEmitter implements IParticleEmitterType {
  13854. /**
  13855. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13856. */
  13857. direction1: Vector3;
  13858. /**
  13859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13860. */
  13861. direction2: Vector3;
  13862. /**
  13863. * Creates a new instance PointParticleEmitter
  13864. */
  13865. constructor();
  13866. /**
  13867. * Called by the particle System when the direction is computed for the created particle.
  13868. * @param worldMatrix is the world matrix of the particle system
  13869. * @param directionToUpdate is the direction vector to update with the result
  13870. * @param particle is the particle we are computed the direction for
  13871. * @param isLocal defines if the direction should be set in local space
  13872. */
  13873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13874. /**
  13875. * Called by the particle System when the position is computed for the created particle.
  13876. * @param worldMatrix is the world matrix of the particle system
  13877. * @param positionToUpdate is the position vector to update with the result
  13878. * @param particle is the particle we are computed the position for
  13879. * @param isLocal defines if the position should be set in local space
  13880. */
  13881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13882. /**
  13883. * Clones the current emitter and returns a copy of it
  13884. * @returns the new emitter
  13885. */
  13886. clone(): PointParticleEmitter;
  13887. /**
  13888. * Called by the GPUParticleSystem to setup the update shader
  13889. * @param effect defines the update shader
  13890. */
  13891. applyToShader(effect: Effect): void;
  13892. /**
  13893. * Returns a string to use to update the GPU particles update shader
  13894. * @returns a string containng the defines string
  13895. */
  13896. getEffectDefines(): string;
  13897. /**
  13898. * Returns the string "PointParticleEmitter"
  13899. * @returns a string containing the class name
  13900. */
  13901. getClassName(): string;
  13902. /**
  13903. * Serializes the particle system to a JSON object.
  13904. * @returns the JSON object
  13905. */
  13906. serialize(): any;
  13907. /**
  13908. * Parse properties from a JSON object
  13909. * @param serializationObject defines the JSON object
  13910. */
  13911. parse(serializationObject: any): void;
  13912. }
  13913. }
  13914. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13916. import { Effect } from "babylonjs/Materials/effect";
  13917. import { Particle } from "babylonjs/Particles/particle";
  13918. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13919. /**
  13920. * Particle emitter emitting particles from the inside of a sphere.
  13921. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13922. */
  13923. export class SphereParticleEmitter implements IParticleEmitterType {
  13924. /**
  13925. * The radius of the emission sphere.
  13926. */
  13927. radius: number;
  13928. /**
  13929. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13930. */
  13931. radiusRange: number;
  13932. /**
  13933. * How much to randomize the particle direction [0-1].
  13934. */
  13935. directionRandomizer: number;
  13936. /**
  13937. * Creates a new instance SphereParticleEmitter
  13938. * @param radius the radius of the emission sphere (1 by default)
  13939. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13940. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13941. */
  13942. constructor(
  13943. /**
  13944. * The radius of the emission sphere.
  13945. */
  13946. radius?: number,
  13947. /**
  13948. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13949. */
  13950. radiusRange?: number,
  13951. /**
  13952. * How much to randomize the particle direction [0-1].
  13953. */
  13954. directionRandomizer?: number);
  13955. /**
  13956. * Called by the particle System when the direction is computed for the created particle.
  13957. * @param worldMatrix is the world matrix of the particle system
  13958. * @param directionToUpdate is the direction vector to update with the result
  13959. * @param particle is the particle we are computed the direction for
  13960. * @param isLocal defines if the direction should be set in local space
  13961. */
  13962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13963. /**
  13964. * Called by the particle System when the position is computed for the created particle.
  13965. * @param worldMatrix is the world matrix of the particle system
  13966. * @param positionToUpdate is the position vector to update with the result
  13967. * @param particle is the particle we are computed the position for
  13968. * @param isLocal defines if the position should be set in local space
  13969. */
  13970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13971. /**
  13972. * Clones the current emitter and returns a copy of it
  13973. * @returns the new emitter
  13974. */
  13975. clone(): SphereParticleEmitter;
  13976. /**
  13977. * Called by the GPUParticleSystem to setup the update shader
  13978. * @param effect defines the update shader
  13979. */
  13980. applyToShader(effect: Effect): void;
  13981. /**
  13982. * Returns a string to use to update the GPU particles update shader
  13983. * @returns a string containng the defines string
  13984. */
  13985. getEffectDefines(): string;
  13986. /**
  13987. * Returns the string "SphereParticleEmitter"
  13988. * @returns a string containing the class name
  13989. */
  13990. getClassName(): string;
  13991. /**
  13992. * Serializes the particle system to a JSON object.
  13993. * @returns the JSON object
  13994. */
  13995. serialize(): any;
  13996. /**
  13997. * Parse properties from a JSON object
  13998. * @param serializationObject defines the JSON object
  13999. */
  14000. parse(serializationObject: any): void;
  14001. }
  14002. /**
  14003. * Particle emitter emitting particles from the inside of a sphere.
  14004. * It emits the particles randomly between two vectors.
  14005. */
  14006. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14007. /**
  14008. * The min limit of the emission direction.
  14009. */
  14010. direction1: Vector3;
  14011. /**
  14012. * The max limit of the emission direction.
  14013. */
  14014. direction2: Vector3;
  14015. /**
  14016. * Creates a new instance SphereDirectedParticleEmitter
  14017. * @param radius the radius of the emission sphere (1 by default)
  14018. * @param direction1 the min limit of the emission direction (up vector by default)
  14019. * @param direction2 the max limit of the emission direction (up vector by default)
  14020. */
  14021. constructor(radius?: number,
  14022. /**
  14023. * The min limit of the emission direction.
  14024. */
  14025. direction1?: Vector3,
  14026. /**
  14027. * The max limit of the emission direction.
  14028. */
  14029. direction2?: Vector3);
  14030. /**
  14031. * Called by the particle System when the direction is computed for the created particle.
  14032. * @param worldMatrix is the world matrix of the particle system
  14033. * @param directionToUpdate is the direction vector to update with the result
  14034. * @param particle is the particle we are computed the direction for
  14035. */
  14036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14037. /**
  14038. * Clones the current emitter and returns a copy of it
  14039. * @returns the new emitter
  14040. */
  14041. clone(): SphereDirectedParticleEmitter;
  14042. /**
  14043. * Called by the GPUParticleSystem to setup the update shader
  14044. * @param effect defines the update shader
  14045. */
  14046. applyToShader(effect: Effect): void;
  14047. /**
  14048. * Returns a string to use to update the GPU particles update shader
  14049. * @returns a string containng the defines string
  14050. */
  14051. getEffectDefines(): string;
  14052. /**
  14053. * Returns the string "SphereDirectedParticleEmitter"
  14054. * @returns a string containing the class name
  14055. */
  14056. getClassName(): string;
  14057. /**
  14058. * Serializes the particle system to a JSON object.
  14059. * @returns the JSON object
  14060. */
  14061. serialize(): any;
  14062. /**
  14063. * Parse properties from a JSON object
  14064. * @param serializationObject defines the JSON object
  14065. */
  14066. parse(serializationObject: any): void;
  14067. }
  14068. }
  14069. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14070. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14071. import { Effect } from "babylonjs/Materials/effect";
  14072. import { Particle } from "babylonjs/Particles/particle";
  14073. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14074. import { Nullable } from "babylonjs/types";
  14075. /**
  14076. * Particle emitter emitting particles from a custom list of positions.
  14077. */
  14078. export class CustomParticleEmitter implements IParticleEmitterType {
  14079. /**
  14080. * Gets or sets the position generator that will create the inital position of each particle.
  14081. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14082. */
  14083. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14084. /**
  14085. * Gets or sets the destination generator that will create the final destination of each particle.
  14086. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14087. */
  14088. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14089. /**
  14090. * Creates a new instance CustomParticleEmitter
  14091. */
  14092. constructor();
  14093. /**
  14094. * Called by the particle System when the direction is computed for the created particle.
  14095. * @param worldMatrix is the world matrix of the particle system
  14096. * @param directionToUpdate is the direction vector to update with the result
  14097. * @param particle is the particle we are computed the direction for
  14098. * @param isLocal defines if the direction should be set in local space
  14099. */
  14100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14101. /**
  14102. * Called by the particle System when the position is computed for the created particle.
  14103. * @param worldMatrix is the world matrix of the particle system
  14104. * @param positionToUpdate is the position vector to update with the result
  14105. * @param particle is the particle we are computed the position for
  14106. * @param isLocal defines if the position should be set in local space
  14107. */
  14108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14109. /**
  14110. * Clones the current emitter and returns a copy of it
  14111. * @returns the new emitter
  14112. */
  14113. clone(): CustomParticleEmitter;
  14114. /**
  14115. * Called by the GPUParticleSystem to setup the update shader
  14116. * @param effect defines the update shader
  14117. */
  14118. applyToShader(effect: Effect): void;
  14119. /**
  14120. * Returns a string to use to update the GPU particles update shader
  14121. * @returns a string containng the defines string
  14122. */
  14123. getEffectDefines(): string;
  14124. /**
  14125. * Returns the string "PointParticleEmitter"
  14126. * @returns a string containing the class name
  14127. */
  14128. getClassName(): string;
  14129. /**
  14130. * Serializes the particle system to a JSON object.
  14131. * @returns the JSON object
  14132. */
  14133. serialize(): any;
  14134. /**
  14135. * Parse properties from a JSON object
  14136. * @param serializationObject defines the JSON object
  14137. */
  14138. parse(serializationObject: any): void;
  14139. }
  14140. }
  14141. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14142. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14143. import { Effect } from "babylonjs/Materials/effect";
  14144. import { Particle } from "babylonjs/Particles/particle";
  14145. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14146. import { Nullable } from "babylonjs/types";
  14147. import { Scene } from "babylonjs/scene";
  14148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14149. /**
  14150. * Particle emitter emitting particles from the inside of a box.
  14151. * It emits the particles randomly between 2 given directions.
  14152. */
  14153. export class MeshParticleEmitter implements IParticleEmitterType {
  14154. private _indices;
  14155. private _positions;
  14156. private _normals;
  14157. private _storedNormal;
  14158. private _mesh;
  14159. /**
  14160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14161. */
  14162. direction1: Vector3;
  14163. /**
  14164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14165. */
  14166. direction2: Vector3;
  14167. /**
  14168. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14169. */
  14170. useMeshNormalsForDirection: boolean;
  14171. /** Defines the mesh to use as source */
  14172. get mesh(): Nullable<AbstractMesh>;
  14173. set mesh(value: Nullable<AbstractMesh>);
  14174. /**
  14175. * Creates a new instance MeshParticleEmitter
  14176. * @param mesh defines the mesh to use as source
  14177. */
  14178. constructor(mesh?: Nullable<AbstractMesh>);
  14179. /**
  14180. * Called by the particle System when the direction is computed for the created particle.
  14181. * @param worldMatrix is the world matrix of the particle system
  14182. * @param directionToUpdate is the direction vector to update with the result
  14183. * @param particle is the particle we are computed the direction for
  14184. * @param isLocal defines if the direction should be set in local space
  14185. */
  14186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14187. /**
  14188. * Called by the particle System when the position is computed for the created particle.
  14189. * @param worldMatrix is the world matrix of the particle system
  14190. * @param positionToUpdate is the position vector to update with the result
  14191. * @param particle is the particle we are computed the position for
  14192. * @param isLocal defines if the position should be set in local space
  14193. */
  14194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14195. /**
  14196. * Clones the current emitter and returns a copy of it
  14197. * @returns the new emitter
  14198. */
  14199. clone(): MeshParticleEmitter;
  14200. /**
  14201. * Called by the GPUParticleSystem to setup the update shader
  14202. * @param effect defines the update shader
  14203. */
  14204. applyToShader(effect: Effect): void;
  14205. /**
  14206. * Returns a string to use to update the GPU particles update shader
  14207. * @returns a string containng the defines string
  14208. */
  14209. getEffectDefines(): string;
  14210. /**
  14211. * Returns the string "BoxParticleEmitter"
  14212. * @returns a string containing the class name
  14213. */
  14214. getClassName(): string;
  14215. /**
  14216. * Serializes the particle system to a JSON object.
  14217. * @returns the JSON object
  14218. */
  14219. serialize(): any;
  14220. /**
  14221. * Parse properties from a JSON object
  14222. * @param serializationObject defines the JSON object
  14223. * @param scene defines the hosting scene
  14224. */
  14225. parse(serializationObject: any, scene: Scene): void;
  14226. }
  14227. }
  14228. declare module "babylonjs/Particles/EmitterTypes/index" {
  14229. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14232. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14234. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14236. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14237. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14238. }
  14239. declare module "babylonjs/Particles/IParticleSystem" {
  14240. import { Nullable } from "babylonjs/types";
  14241. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14242. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14244. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14245. import { Texture } from "babylonjs/Materials/Textures/texture";
  14246. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14247. import { Scene } from "babylonjs/scene";
  14248. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14249. import { Effect } from "babylonjs/Materials/effect";
  14250. import { Observable } from "babylonjs/Misc/observable";
  14251. import { Animation } from "babylonjs/Animations/animation";
  14252. /**
  14253. * Interface representing a particle system in Babylon.js.
  14254. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14255. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14256. */
  14257. export interface IParticleSystem {
  14258. /**
  14259. * List of animations used by the particle system.
  14260. */
  14261. animations: Animation[];
  14262. /**
  14263. * The id of the Particle system.
  14264. */
  14265. id: string;
  14266. /**
  14267. * The name of the Particle system.
  14268. */
  14269. name: string;
  14270. /**
  14271. * The emitter represents the Mesh or position we are attaching the particle system to.
  14272. */
  14273. emitter: Nullable<AbstractMesh | Vector3>;
  14274. /**
  14275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14276. */
  14277. isBillboardBased: boolean;
  14278. /**
  14279. * The rendering group used by the Particle system to chose when to render.
  14280. */
  14281. renderingGroupId: number;
  14282. /**
  14283. * The layer mask we are rendering the particles through.
  14284. */
  14285. layerMask: number;
  14286. /**
  14287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14288. */
  14289. updateSpeed: number;
  14290. /**
  14291. * The amount of time the particle system is running (depends of the overall update speed).
  14292. */
  14293. targetStopDuration: number;
  14294. /**
  14295. * The texture used to render each particle. (this can be a spritesheet)
  14296. */
  14297. particleTexture: Nullable<Texture>;
  14298. /**
  14299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14300. */
  14301. blendMode: number;
  14302. /**
  14303. * Minimum life time of emitting particles.
  14304. */
  14305. minLifeTime: number;
  14306. /**
  14307. * Maximum life time of emitting particles.
  14308. */
  14309. maxLifeTime: number;
  14310. /**
  14311. * Minimum Size of emitting particles.
  14312. */
  14313. minSize: number;
  14314. /**
  14315. * Maximum Size of emitting particles.
  14316. */
  14317. maxSize: number;
  14318. /**
  14319. * Minimum scale of emitting particles on X axis.
  14320. */
  14321. minScaleX: number;
  14322. /**
  14323. * Maximum scale of emitting particles on X axis.
  14324. */
  14325. maxScaleX: number;
  14326. /**
  14327. * Minimum scale of emitting particles on Y axis.
  14328. */
  14329. minScaleY: number;
  14330. /**
  14331. * Maximum scale of emitting particles on Y axis.
  14332. */
  14333. maxScaleY: number;
  14334. /**
  14335. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14336. */
  14337. color1: Color4;
  14338. /**
  14339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14340. */
  14341. color2: Color4;
  14342. /**
  14343. * Color the particle will have at the end of its lifetime.
  14344. */
  14345. colorDead: Color4;
  14346. /**
  14347. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14348. */
  14349. emitRate: number;
  14350. /**
  14351. * You can use gravity if you want to give an orientation to your particles.
  14352. */
  14353. gravity: Vector3;
  14354. /**
  14355. * Minimum power of emitting particles.
  14356. */
  14357. minEmitPower: number;
  14358. /**
  14359. * Maximum power of emitting particles.
  14360. */
  14361. maxEmitPower: number;
  14362. /**
  14363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14364. */
  14365. minAngularSpeed: number;
  14366. /**
  14367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14368. */
  14369. maxAngularSpeed: number;
  14370. /**
  14371. * Gets or sets the minimal initial rotation in radians.
  14372. */
  14373. minInitialRotation: number;
  14374. /**
  14375. * Gets or sets the maximal initial rotation in radians.
  14376. */
  14377. maxInitialRotation: number;
  14378. /**
  14379. * The particle emitter type defines the emitter used by the particle system.
  14380. * It can be for example box, sphere, or cone...
  14381. */
  14382. particleEmitterType: Nullable<IParticleEmitterType>;
  14383. /**
  14384. * Defines the delay in milliseconds before starting the system (0 by default)
  14385. */
  14386. startDelay: number;
  14387. /**
  14388. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14389. */
  14390. preWarmCycles: number;
  14391. /**
  14392. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14393. */
  14394. preWarmStepOffset: number;
  14395. /**
  14396. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14397. */
  14398. spriteCellChangeSpeed: number;
  14399. /**
  14400. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14401. */
  14402. startSpriteCellID: number;
  14403. /**
  14404. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14405. */
  14406. endSpriteCellID: number;
  14407. /**
  14408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14409. */
  14410. spriteCellWidth: number;
  14411. /**
  14412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14413. */
  14414. spriteCellHeight: number;
  14415. /**
  14416. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14417. */
  14418. spriteRandomStartCell: boolean;
  14419. /**
  14420. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14421. */
  14422. isAnimationSheetEnabled: boolean;
  14423. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14424. translationPivot: Vector2;
  14425. /**
  14426. * Gets or sets a texture used to add random noise to particle positions
  14427. */
  14428. noiseTexture: Nullable<BaseTexture>;
  14429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14430. noiseStrength: Vector3;
  14431. /**
  14432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14434. */
  14435. billboardMode: number;
  14436. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14437. limitVelocityDamping: number;
  14438. /**
  14439. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14440. */
  14441. beginAnimationOnStart: boolean;
  14442. /**
  14443. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14444. */
  14445. beginAnimationFrom: number;
  14446. /**
  14447. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14448. */
  14449. beginAnimationTo: number;
  14450. /**
  14451. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14452. */
  14453. beginAnimationLoop: boolean;
  14454. /**
  14455. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14456. */
  14457. disposeOnStop: boolean;
  14458. /**
  14459. * Specifies if the particles are updated in emitter local space or world space
  14460. */
  14461. isLocal: boolean;
  14462. /** Snippet ID if the particle system was created from the snippet server */
  14463. snippetId: string;
  14464. /**
  14465. * Gets the maximum number of particles active at the same time.
  14466. * @returns The max number of active particles.
  14467. */
  14468. getCapacity(): number;
  14469. /**
  14470. * Gets the number of particles active at the same time.
  14471. * @returns The number of active particles.
  14472. */
  14473. getActiveCount(): number;
  14474. /**
  14475. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14476. * @returns True if it has been started, otherwise false.
  14477. */
  14478. isStarted(): boolean;
  14479. /**
  14480. * Animates the particle system for this frame.
  14481. */
  14482. animate(): void;
  14483. /**
  14484. * Renders the particle system in its current state.
  14485. * @returns the current number of particles
  14486. */
  14487. render(): number;
  14488. /**
  14489. * Dispose the particle system and frees its associated resources.
  14490. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14491. */
  14492. dispose(disposeTexture?: boolean): void;
  14493. /**
  14494. * An event triggered when the system is disposed
  14495. */
  14496. onDisposeObservable: Observable<IParticleSystem>;
  14497. /**
  14498. * Clones the particle system.
  14499. * @param name The name of the cloned object
  14500. * @param newEmitter The new emitter to use
  14501. * @returns the cloned particle system
  14502. */
  14503. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14504. /**
  14505. * Serializes the particle system to a JSON object
  14506. * @param serializeTexture defines if the texture must be serialized as well
  14507. * @returns the JSON object
  14508. */
  14509. serialize(serializeTexture: boolean): any;
  14510. /**
  14511. * Rebuild the particle system
  14512. */
  14513. rebuild(): void;
  14514. /** Force the system to rebuild all gradients that need to be resync */
  14515. forceRefreshGradients(): void;
  14516. /**
  14517. * Starts the particle system and begins to emit
  14518. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14519. */
  14520. start(delay?: number): void;
  14521. /**
  14522. * Stops the particle system.
  14523. */
  14524. stop(): void;
  14525. /**
  14526. * Remove all active particles
  14527. */
  14528. reset(): void;
  14529. /**
  14530. * Gets a boolean indicating that the system is stopping
  14531. * @returns true if the system is currently stopping
  14532. */
  14533. isStopping(): boolean;
  14534. /**
  14535. * Is this system ready to be used/rendered
  14536. * @return true if the system is ready
  14537. */
  14538. isReady(): boolean;
  14539. /**
  14540. * Returns the string "ParticleSystem"
  14541. * @returns a string containing the class name
  14542. */
  14543. getClassName(): string;
  14544. /**
  14545. * Gets the custom effect used to render the particles
  14546. * @param blendMode Blend mode for which the effect should be retrieved
  14547. * @returns The effect
  14548. */
  14549. getCustomEffect(blendMode: number): Nullable<Effect>;
  14550. /**
  14551. * Sets the custom effect used to render the particles
  14552. * @param effect The effect to set
  14553. * @param blendMode Blend mode for which the effect should be set
  14554. */
  14555. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14556. /**
  14557. * Fill the defines array according to the current settings of the particle system
  14558. * @param defines Array to be updated
  14559. * @param blendMode blend mode to take into account when updating the array
  14560. */
  14561. fillDefines(defines: Array<string>, blendMode: number): void;
  14562. /**
  14563. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14564. * @param uniforms Uniforms array to fill
  14565. * @param attributes Attributes array to fill
  14566. * @param samplers Samplers array to fill
  14567. */
  14568. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14569. /**
  14570. * Observable that will be called just before the particles are drawn
  14571. */
  14572. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14573. /**
  14574. * Gets the name of the particle vertex shader
  14575. */
  14576. vertexShaderName: string;
  14577. /**
  14578. * Adds a new color gradient
  14579. * @param gradient defines the gradient to use (between 0 and 1)
  14580. * @param color1 defines the color to affect to the specified gradient
  14581. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14582. * @returns the current particle system
  14583. */
  14584. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14585. /**
  14586. * Remove a specific color gradient
  14587. * @param gradient defines the gradient to remove
  14588. * @returns the current particle system
  14589. */
  14590. removeColorGradient(gradient: number): IParticleSystem;
  14591. /**
  14592. * Adds a new size gradient
  14593. * @param gradient defines the gradient to use (between 0 and 1)
  14594. * @param factor defines the size factor to affect to the specified gradient
  14595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14596. * @returns the current particle system
  14597. */
  14598. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14599. /**
  14600. * Remove a specific size gradient
  14601. * @param gradient defines the gradient to remove
  14602. * @returns the current particle system
  14603. */
  14604. removeSizeGradient(gradient: number): IParticleSystem;
  14605. /**
  14606. * Gets the current list of color gradients.
  14607. * You must use addColorGradient and removeColorGradient to udpate this list
  14608. * @returns the list of color gradients
  14609. */
  14610. getColorGradients(): Nullable<Array<ColorGradient>>;
  14611. /**
  14612. * Gets the current list of size gradients.
  14613. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14614. * @returns the list of size gradients
  14615. */
  14616. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14617. /**
  14618. * Gets the current list of angular speed gradients.
  14619. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14620. * @returns the list of angular speed gradients
  14621. */
  14622. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14623. /**
  14624. * Adds a new angular speed gradient
  14625. * @param gradient defines the gradient to use (between 0 and 1)
  14626. * @param factor defines the angular speed to affect to the specified gradient
  14627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14628. * @returns the current particle system
  14629. */
  14630. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14631. /**
  14632. * Remove a specific angular speed gradient
  14633. * @param gradient defines the gradient to remove
  14634. * @returns the current particle system
  14635. */
  14636. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14637. /**
  14638. * Gets the current list of velocity gradients.
  14639. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14640. * @returns the list of velocity gradients
  14641. */
  14642. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14643. /**
  14644. * Adds a new velocity gradient
  14645. * @param gradient defines the gradient to use (between 0 and 1)
  14646. * @param factor defines the velocity to affect to the specified gradient
  14647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14648. * @returns the current particle system
  14649. */
  14650. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14651. /**
  14652. * Remove a specific velocity gradient
  14653. * @param gradient defines the gradient to remove
  14654. * @returns the current particle system
  14655. */
  14656. removeVelocityGradient(gradient: number): IParticleSystem;
  14657. /**
  14658. * Gets the current list of limit velocity gradients.
  14659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14660. * @returns the list of limit velocity gradients
  14661. */
  14662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14663. /**
  14664. * Adds a new limit velocity gradient
  14665. * @param gradient defines the gradient to use (between 0 and 1)
  14666. * @param factor defines the limit velocity to affect to the specified gradient
  14667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14668. * @returns the current particle system
  14669. */
  14670. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14671. /**
  14672. * Remove a specific limit velocity gradient
  14673. * @param gradient defines the gradient to remove
  14674. * @returns the current particle system
  14675. */
  14676. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14677. /**
  14678. * Adds a new drag gradient
  14679. * @param gradient defines the gradient to use (between 0 and 1)
  14680. * @param factor defines the drag to affect to the specified gradient
  14681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14682. * @returns the current particle system
  14683. */
  14684. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14685. /**
  14686. * Remove a specific drag gradient
  14687. * @param gradient defines the gradient to remove
  14688. * @returns the current particle system
  14689. */
  14690. removeDragGradient(gradient: number): IParticleSystem;
  14691. /**
  14692. * Gets the current list of drag gradients.
  14693. * You must use addDragGradient and removeDragGradient to udpate this list
  14694. * @returns the list of drag gradients
  14695. */
  14696. getDragGradients(): Nullable<Array<FactorGradient>>;
  14697. /**
  14698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14699. * @param gradient defines the gradient to use (between 0 and 1)
  14700. * @param factor defines the emit rate to affect to the specified gradient
  14701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14702. * @returns the current particle system
  14703. */
  14704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14705. /**
  14706. * Remove a specific emit rate gradient
  14707. * @param gradient defines the gradient to remove
  14708. * @returns the current particle system
  14709. */
  14710. removeEmitRateGradient(gradient: number): IParticleSystem;
  14711. /**
  14712. * Gets the current list of emit rate gradients.
  14713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14714. * @returns the list of emit rate gradients
  14715. */
  14716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14719. * @param gradient defines the gradient to use (between 0 and 1)
  14720. * @param factor defines the start size to affect to the specified gradient
  14721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14722. * @returns the current particle system
  14723. */
  14724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14725. /**
  14726. * Remove a specific start size gradient
  14727. * @param gradient defines the gradient to remove
  14728. * @returns the current particle system
  14729. */
  14730. removeStartSizeGradient(gradient: number): IParticleSystem;
  14731. /**
  14732. * Gets the current list of start size gradients.
  14733. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14734. * @returns the list of start size gradients
  14735. */
  14736. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14737. /**
  14738. * Adds a new life time gradient
  14739. * @param gradient defines the gradient to use (between 0 and 1)
  14740. * @param factor defines the life time factor to affect to the specified gradient
  14741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14742. * @returns the current particle system
  14743. */
  14744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14745. /**
  14746. * Remove a specific life time gradient
  14747. * @param gradient defines the gradient to remove
  14748. * @returns the current particle system
  14749. */
  14750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14751. /**
  14752. * Gets the current list of life time gradients.
  14753. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14754. * @returns the list of life time gradients
  14755. */
  14756. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14757. /**
  14758. * Gets the current list of color gradients.
  14759. * You must use addColorGradient and removeColorGradient to udpate this list
  14760. * @returns the list of color gradients
  14761. */
  14762. getColorGradients(): Nullable<Array<ColorGradient>>;
  14763. /**
  14764. * Adds a new ramp gradient used to remap particle colors
  14765. * @param gradient defines the gradient to use (between 0 and 1)
  14766. * @param color defines the color to affect to the specified gradient
  14767. * @returns the current particle system
  14768. */
  14769. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14770. /**
  14771. * Gets the current list of ramp gradients.
  14772. * You must use addRampGradient and removeRampGradient to udpate this list
  14773. * @returns the list of ramp gradients
  14774. */
  14775. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14776. /** Gets or sets a boolean indicating that ramp gradients must be used
  14777. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14778. */
  14779. useRampGradients: boolean;
  14780. /**
  14781. * Adds a new color remap gradient
  14782. * @param gradient defines the gradient to use (between 0 and 1)
  14783. * @param min defines the color remap minimal range
  14784. * @param max defines the color remap maximal range
  14785. * @returns the current particle system
  14786. */
  14787. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14788. /**
  14789. * Gets the current list of color remap gradients.
  14790. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14791. * @returns the list of color remap gradients
  14792. */
  14793. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14794. /**
  14795. * Adds a new alpha remap gradient
  14796. * @param gradient defines the gradient to use (between 0 and 1)
  14797. * @param min defines the alpha remap minimal range
  14798. * @param max defines the alpha remap maximal range
  14799. * @returns the current particle system
  14800. */
  14801. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14802. /**
  14803. * Gets the current list of alpha remap gradients.
  14804. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14805. * @returns the list of alpha remap gradients
  14806. */
  14807. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14808. /**
  14809. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14812. * @returns the emitter
  14813. */
  14814. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14815. /**
  14816. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14817. * @param radius The radius of the hemisphere to emit from
  14818. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14819. * @returns the emitter
  14820. */
  14821. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14822. /**
  14823. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14824. * @param radius The radius of the sphere to emit from
  14825. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14826. * @returns the emitter
  14827. */
  14828. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14829. /**
  14830. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14831. * @param radius The radius of the sphere to emit from
  14832. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14833. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14834. * @returns the emitter
  14835. */
  14836. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14837. /**
  14838. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14839. * @param radius The radius of the emission cylinder
  14840. * @param height The height of the emission cylinder
  14841. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14842. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14843. * @returns the emitter
  14844. */
  14845. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14846. /**
  14847. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14848. * @param radius The radius of the cylinder to emit from
  14849. * @param height The height of the emission cylinder
  14850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14853. * @returns the emitter
  14854. */
  14855. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14856. /**
  14857. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14858. * @param radius The radius of the cone to emit from
  14859. * @param angle The base angle of the cone
  14860. * @returns the emitter
  14861. */
  14862. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14863. /**
  14864. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14867. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14868. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14869. * @returns the emitter
  14870. */
  14871. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14872. /**
  14873. * Get hosting scene
  14874. * @returns the scene
  14875. */
  14876. getScene(): Scene;
  14877. }
  14878. }
  14879. declare module "babylonjs/Meshes/transformNode" {
  14880. import { DeepImmutable } from "babylonjs/types";
  14881. import { Observable } from "babylonjs/Misc/observable";
  14882. import { Nullable } from "babylonjs/types";
  14883. import { Camera } from "babylonjs/Cameras/camera";
  14884. import { Scene } from "babylonjs/scene";
  14885. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14886. import { Node } from "babylonjs/node";
  14887. import { Bone } from "babylonjs/Bones/bone";
  14888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14889. import { Space } from "babylonjs/Maths/math.axis";
  14890. /**
  14891. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14892. * @see https://doc.babylonjs.com/how_to/transformnode
  14893. */
  14894. export class TransformNode extends Node {
  14895. /**
  14896. * Object will not rotate to face the camera
  14897. */
  14898. static BILLBOARDMODE_NONE: number;
  14899. /**
  14900. * Object will rotate to face the camera but only on the x axis
  14901. */
  14902. static BILLBOARDMODE_X: number;
  14903. /**
  14904. * Object will rotate to face the camera but only on the y axis
  14905. */
  14906. static BILLBOARDMODE_Y: number;
  14907. /**
  14908. * Object will rotate to face the camera but only on the z axis
  14909. */
  14910. static BILLBOARDMODE_Z: number;
  14911. /**
  14912. * Object will rotate to face the camera
  14913. */
  14914. static BILLBOARDMODE_ALL: number;
  14915. /**
  14916. * Object will rotate to face the camera's position instead of orientation
  14917. */
  14918. static BILLBOARDMODE_USE_POSITION: number;
  14919. private _forward;
  14920. private _forwardInverted;
  14921. private _up;
  14922. private _right;
  14923. private _rightInverted;
  14924. private _position;
  14925. private _rotation;
  14926. private _rotationQuaternion;
  14927. protected _scaling: Vector3;
  14928. protected _isDirty: boolean;
  14929. private _transformToBoneReferal;
  14930. private _isAbsoluteSynced;
  14931. private _billboardMode;
  14932. /**
  14933. * Gets or sets the billboard mode. Default is 0.
  14934. *
  14935. * | Value | Type | Description |
  14936. * | --- | --- | --- |
  14937. * | 0 | BILLBOARDMODE_NONE | |
  14938. * | 1 | BILLBOARDMODE_X | |
  14939. * | 2 | BILLBOARDMODE_Y | |
  14940. * | 4 | BILLBOARDMODE_Z | |
  14941. * | 7 | BILLBOARDMODE_ALL | |
  14942. *
  14943. */
  14944. get billboardMode(): number;
  14945. set billboardMode(value: number);
  14946. private _preserveParentRotationForBillboard;
  14947. /**
  14948. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14949. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14950. */
  14951. get preserveParentRotationForBillboard(): boolean;
  14952. set preserveParentRotationForBillboard(value: boolean);
  14953. /**
  14954. * 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
  14955. */
  14956. scalingDeterminant: number;
  14957. private _infiniteDistance;
  14958. /**
  14959. * Gets or sets the distance of the object to max, often used by skybox
  14960. */
  14961. get infiniteDistance(): boolean;
  14962. set infiniteDistance(value: boolean);
  14963. /**
  14964. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14965. * By default the system will update normals to compensate
  14966. */
  14967. ignoreNonUniformScaling: boolean;
  14968. /**
  14969. * 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
  14970. */
  14971. reIntegrateRotationIntoRotationQuaternion: boolean;
  14972. /** @hidden */
  14973. _poseMatrix: Nullable<Matrix>;
  14974. /** @hidden */
  14975. _localMatrix: Matrix;
  14976. private _usePivotMatrix;
  14977. private _absolutePosition;
  14978. private _absoluteScaling;
  14979. private _absoluteRotationQuaternion;
  14980. private _pivotMatrix;
  14981. private _pivotMatrixInverse;
  14982. protected _postMultiplyPivotMatrix: boolean;
  14983. protected _isWorldMatrixFrozen: boolean;
  14984. /** @hidden */
  14985. _indexInSceneTransformNodesArray: number;
  14986. /**
  14987. * An event triggered after the world matrix is updated
  14988. */
  14989. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14990. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14991. /**
  14992. * Gets a string identifying the name of the class
  14993. * @returns "TransformNode" string
  14994. */
  14995. getClassName(): string;
  14996. /**
  14997. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14998. */
  14999. get position(): Vector3;
  15000. set position(newPosition: Vector3);
  15001. /**
  15002. * 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)).
  15003. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15004. */
  15005. get rotation(): Vector3;
  15006. set rotation(newRotation: Vector3);
  15007. /**
  15008. * 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)).
  15009. */
  15010. get scaling(): Vector3;
  15011. set scaling(newScaling: Vector3);
  15012. /**
  15013. * 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).
  15014. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15015. */
  15016. get rotationQuaternion(): Nullable<Quaternion>;
  15017. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15018. /**
  15019. * The forward direction of that transform in world space.
  15020. */
  15021. get forward(): Vector3;
  15022. /**
  15023. * The up direction of that transform in world space.
  15024. */
  15025. get up(): Vector3;
  15026. /**
  15027. * The right direction of that transform in world space.
  15028. */
  15029. get right(): Vector3;
  15030. /**
  15031. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15032. * @param matrix the matrix to copy the pose from
  15033. * @returns this TransformNode.
  15034. */
  15035. updatePoseMatrix(matrix: Matrix): TransformNode;
  15036. /**
  15037. * Returns the mesh Pose matrix.
  15038. * @returns the pose matrix
  15039. */
  15040. getPoseMatrix(): Matrix;
  15041. /** @hidden */
  15042. _isSynchronized(): boolean;
  15043. /** @hidden */
  15044. _initCache(): void;
  15045. /**
  15046. * Flag the transform node as dirty (Forcing it to update everything)
  15047. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15048. * @returns this transform node
  15049. */
  15050. markAsDirty(property: string): TransformNode;
  15051. /**
  15052. * Returns the current mesh absolute position.
  15053. * Returns a Vector3.
  15054. */
  15055. get absolutePosition(): Vector3;
  15056. /**
  15057. * Returns the current mesh absolute scaling.
  15058. * Returns a Vector3.
  15059. */
  15060. get absoluteScaling(): Vector3;
  15061. /**
  15062. * Returns the current mesh absolute rotation.
  15063. * Returns a Quaternion.
  15064. */
  15065. get absoluteRotationQuaternion(): Quaternion;
  15066. /**
  15067. * Sets a new matrix to apply before all other transformation
  15068. * @param matrix defines the transform matrix
  15069. * @returns the current TransformNode
  15070. */
  15071. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15072. /**
  15073. * Sets a new pivot matrix to the current node
  15074. * @param matrix defines the new pivot matrix to use
  15075. * @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
  15076. * @returns the current TransformNode
  15077. */
  15078. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15079. /**
  15080. * Returns the mesh pivot matrix.
  15081. * Default : Identity.
  15082. * @returns the matrix
  15083. */
  15084. getPivotMatrix(): Matrix;
  15085. /**
  15086. * Instantiate (when possible) or clone that node with its hierarchy
  15087. * @param newParent defines the new parent to use for the instance (or clone)
  15088. * @param options defines options to configure how copy is done
  15089. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15090. * @returns an instance (or a clone) of the current node with its hiearchy
  15091. */
  15092. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15093. doNotInstantiate: boolean;
  15094. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15095. /**
  15096. * Prevents the World matrix to be computed any longer
  15097. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15098. * @returns the TransformNode.
  15099. */
  15100. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15101. /**
  15102. * Allows back the World matrix computation.
  15103. * @returns the TransformNode.
  15104. */
  15105. unfreezeWorldMatrix(): this;
  15106. /**
  15107. * True if the World matrix has been frozen.
  15108. */
  15109. get isWorldMatrixFrozen(): boolean;
  15110. /**
  15111. * Retuns the mesh absolute position in the World.
  15112. * @returns a Vector3.
  15113. */
  15114. getAbsolutePosition(): Vector3;
  15115. /**
  15116. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15117. * @param absolutePosition the absolute position to set
  15118. * @returns the TransformNode.
  15119. */
  15120. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15121. /**
  15122. * Sets the mesh position in its local space.
  15123. * @param vector3 the position to set in localspace
  15124. * @returns the TransformNode.
  15125. */
  15126. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15127. /**
  15128. * Returns the mesh position in the local space from the current World matrix values.
  15129. * @returns a new Vector3.
  15130. */
  15131. getPositionExpressedInLocalSpace(): Vector3;
  15132. /**
  15133. * Translates the mesh along the passed Vector3 in its local space.
  15134. * @param vector3 the distance to translate in localspace
  15135. * @returns the TransformNode.
  15136. */
  15137. locallyTranslate(vector3: Vector3): TransformNode;
  15138. private static _lookAtVectorCache;
  15139. /**
  15140. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15141. * @param targetPoint the position (must be in same space as current mesh) to look at
  15142. * @param yawCor optional yaw (y-axis) correction in radians
  15143. * @param pitchCor optional pitch (x-axis) correction in radians
  15144. * @param rollCor optional roll (z-axis) correction in radians
  15145. * @param space the choosen space of the target
  15146. * @returns the TransformNode.
  15147. */
  15148. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15149. /**
  15150. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15151. * This Vector3 is expressed in the World space.
  15152. * @param localAxis axis to rotate
  15153. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15154. */
  15155. getDirection(localAxis: Vector3): Vector3;
  15156. /**
  15157. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15158. * localAxis is expressed in the mesh local space.
  15159. * result is computed in the Wordl space from the mesh World matrix.
  15160. * @param localAxis axis to rotate
  15161. * @param result the resulting transformnode
  15162. * @returns this TransformNode.
  15163. */
  15164. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15165. /**
  15166. * Sets this transform node rotation to the given local axis.
  15167. * @param localAxis the axis in local space
  15168. * @param yawCor optional yaw (y-axis) correction in radians
  15169. * @param pitchCor optional pitch (x-axis) correction in radians
  15170. * @param rollCor optional roll (z-axis) correction in radians
  15171. * @returns this TransformNode
  15172. */
  15173. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15174. /**
  15175. * Sets a new pivot point to the current node
  15176. * @param point defines the new pivot point to use
  15177. * @param space defines if the point is in world or local space (local by default)
  15178. * @returns the current TransformNode
  15179. */
  15180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15181. /**
  15182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15183. * @returns the pivot point
  15184. */
  15185. getPivotPoint(): Vector3;
  15186. /**
  15187. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15188. * @param result the vector3 to store the result
  15189. * @returns this TransformNode.
  15190. */
  15191. getPivotPointToRef(result: Vector3): TransformNode;
  15192. /**
  15193. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15194. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15195. */
  15196. getAbsolutePivotPoint(): Vector3;
  15197. /**
  15198. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15199. * @param result vector3 to store the result
  15200. * @returns this TransformNode.
  15201. */
  15202. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15203. /**
  15204. * Defines the passed node as the parent of the current node.
  15205. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15206. * @see https://doc.babylonjs.com/how_to/parenting
  15207. * @param node the node ot set as the parent
  15208. * @returns this TransformNode.
  15209. */
  15210. setParent(node: Nullable<Node>): TransformNode;
  15211. private _nonUniformScaling;
  15212. /**
  15213. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15214. */
  15215. get nonUniformScaling(): boolean;
  15216. /** @hidden */
  15217. _updateNonUniformScalingState(value: boolean): boolean;
  15218. /**
  15219. * Attach the current TransformNode to another TransformNode associated with a bone
  15220. * @param bone Bone affecting the TransformNode
  15221. * @param affectedTransformNode TransformNode associated with the bone
  15222. * @returns this object
  15223. */
  15224. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15225. /**
  15226. * Detach the transform node if its associated with a bone
  15227. * @returns this object
  15228. */
  15229. detachFromBone(): TransformNode;
  15230. private static _rotationAxisCache;
  15231. /**
  15232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15233. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15235. * The passed axis is also normalized.
  15236. * @param axis the axis to rotate around
  15237. * @param amount the amount to rotate in radians
  15238. * @param space Space to rotate in (Default: local)
  15239. * @returns the TransformNode.
  15240. */
  15241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15242. /**
  15243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15244. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15245. * The passed axis is also normalized. .
  15246. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15247. * @param point the point to rotate around
  15248. * @param axis the axis to rotate around
  15249. * @param amount the amount to rotate in radians
  15250. * @returns the TransformNode
  15251. */
  15252. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15253. /**
  15254. * Translates the mesh along the axis vector for the passed distance in the given space.
  15255. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15256. * @param axis the axis to translate in
  15257. * @param distance the distance to translate
  15258. * @param space Space to rotate in (Default: local)
  15259. * @returns the TransformNode.
  15260. */
  15261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15262. /**
  15263. * Adds a rotation step to the mesh current rotation.
  15264. * x, y, z are Euler angles expressed in radians.
  15265. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15266. * This means this rotation is made in the mesh local space only.
  15267. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15268. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15269. * ```javascript
  15270. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15271. * ```
  15272. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15273. * 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.
  15274. * @param x Rotation to add
  15275. * @param y Rotation to add
  15276. * @param z Rotation to add
  15277. * @returns the TransformNode.
  15278. */
  15279. addRotation(x: number, y: number, z: number): TransformNode;
  15280. /**
  15281. * @hidden
  15282. */
  15283. protected _getEffectiveParent(): Nullable<Node>;
  15284. /**
  15285. * Computes the world matrix of the node
  15286. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15287. * @returns the world matrix
  15288. */
  15289. computeWorldMatrix(force?: boolean): Matrix;
  15290. /**
  15291. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15292. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15293. */
  15294. resetLocalMatrix(independentOfChildren?: boolean): void;
  15295. protected _afterComputeWorldMatrix(): void;
  15296. /**
  15297. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15298. * @param func callback function to add
  15299. *
  15300. * @returns the TransformNode.
  15301. */
  15302. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15303. /**
  15304. * Removes a registered callback function.
  15305. * @param func callback function to remove
  15306. * @returns the TransformNode.
  15307. */
  15308. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15309. /**
  15310. * Gets the position of the current mesh in camera space
  15311. * @param camera defines the camera to use
  15312. * @returns a position
  15313. */
  15314. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15315. /**
  15316. * Returns the distance from the mesh to the active camera
  15317. * @param camera defines the camera to use
  15318. * @returns the distance
  15319. */
  15320. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15321. /**
  15322. * Clone the current transform node
  15323. * @param name Name of the new clone
  15324. * @param newParent New parent for the clone
  15325. * @param doNotCloneChildren Do not clone children hierarchy
  15326. * @returns the new transform node
  15327. */
  15328. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15329. /**
  15330. * Serializes the objects information.
  15331. * @param currentSerializationObject defines the object to serialize in
  15332. * @returns the serialized object
  15333. */
  15334. serialize(currentSerializationObject?: any): any;
  15335. /**
  15336. * Returns a new TransformNode object parsed from the source provided.
  15337. * @param parsedTransformNode is the source.
  15338. * @param scene the scne the object belongs to
  15339. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15340. * @returns a new TransformNode object parsed from the source provided.
  15341. */
  15342. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15343. /**
  15344. * Get all child-transformNodes of this node
  15345. * @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
  15346. * @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
  15347. * @returns an array of TransformNode
  15348. */
  15349. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15350. /**
  15351. * Releases resources associated with this transform node.
  15352. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15353. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15354. */
  15355. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15356. /**
  15357. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15358. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15359. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15360. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15361. * @returns the current mesh
  15362. */
  15363. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15364. private _syncAbsoluteScalingAndRotation;
  15365. }
  15366. }
  15367. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15368. /**
  15369. * Class used to override all child animations of a given target
  15370. */
  15371. export class AnimationPropertiesOverride {
  15372. /**
  15373. * Gets or sets a value indicating if animation blending must be used
  15374. */
  15375. enableBlending: boolean;
  15376. /**
  15377. * Gets or sets the blending speed to use when enableBlending is true
  15378. */
  15379. blendingSpeed: number;
  15380. /**
  15381. * Gets or sets the default loop mode to use
  15382. */
  15383. loopMode: number;
  15384. }
  15385. }
  15386. declare module "babylonjs/Bones/bone" {
  15387. import { Skeleton } from "babylonjs/Bones/skeleton";
  15388. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15389. import { Nullable } from "babylonjs/types";
  15390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15392. import { Node } from "babylonjs/node";
  15393. import { Space } from "babylonjs/Maths/math.axis";
  15394. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15395. /**
  15396. * Class used to store bone information
  15397. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15398. */
  15399. export class Bone extends Node {
  15400. /**
  15401. * defines the bone name
  15402. */
  15403. name: string;
  15404. private static _tmpVecs;
  15405. private static _tmpQuat;
  15406. private static _tmpMats;
  15407. /**
  15408. * Gets the list of child bones
  15409. */
  15410. children: Bone[];
  15411. /** Gets the animations associated with this bone */
  15412. animations: import("babylonjs/Animations/animation").Animation[];
  15413. /**
  15414. * Gets or sets bone length
  15415. */
  15416. length: number;
  15417. /**
  15418. * @hidden Internal only
  15419. * Set this value to map this bone to a different index in the transform matrices
  15420. * Set this value to -1 to exclude the bone from the transform matrices
  15421. */
  15422. _index: Nullable<number>;
  15423. private _skeleton;
  15424. private _localMatrix;
  15425. private _restPose;
  15426. private _baseMatrix;
  15427. private _absoluteTransform;
  15428. private _invertedAbsoluteTransform;
  15429. private _parent;
  15430. private _scalingDeterminant;
  15431. private _worldTransform;
  15432. private _localScaling;
  15433. private _localRotation;
  15434. private _localPosition;
  15435. private _needToDecompose;
  15436. private _needToCompose;
  15437. /** @hidden */
  15438. _linkedTransformNode: Nullable<TransformNode>;
  15439. /** @hidden */
  15440. _waitingTransformNodeId: Nullable<string>;
  15441. /** @hidden */
  15442. get _matrix(): Matrix;
  15443. /** @hidden */
  15444. set _matrix(value: Matrix);
  15445. /**
  15446. * Create a new bone
  15447. * @param name defines the bone name
  15448. * @param skeleton defines the parent skeleton
  15449. * @param parentBone defines the parent (can be null if the bone is the root)
  15450. * @param localMatrix defines the local matrix
  15451. * @param restPose defines the rest pose matrix
  15452. * @param baseMatrix defines the base matrix
  15453. * @param index defines index of the bone in the hiearchy
  15454. */
  15455. constructor(
  15456. /**
  15457. * defines the bone name
  15458. */
  15459. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15460. /**
  15461. * Gets the current object class name.
  15462. * @return the class name
  15463. */
  15464. getClassName(): string;
  15465. /**
  15466. * Gets the parent skeleton
  15467. * @returns a skeleton
  15468. */
  15469. getSkeleton(): Skeleton;
  15470. /**
  15471. * Gets parent bone
  15472. * @returns a bone or null if the bone is the root of the bone hierarchy
  15473. */
  15474. getParent(): Nullable<Bone>;
  15475. /**
  15476. * Returns an array containing the root bones
  15477. * @returns an array containing the root bones
  15478. */
  15479. getChildren(): Array<Bone>;
  15480. /**
  15481. * Gets the node index in matrix array generated for rendering
  15482. * @returns the node index
  15483. */
  15484. getIndex(): number;
  15485. /**
  15486. * Sets the parent bone
  15487. * @param parent defines the parent (can be null if the bone is the root)
  15488. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15489. */
  15490. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15491. /**
  15492. * Gets the local matrix
  15493. * @returns a matrix
  15494. */
  15495. getLocalMatrix(): Matrix;
  15496. /**
  15497. * Gets the base matrix (initial matrix which remains unchanged)
  15498. * @returns a matrix
  15499. */
  15500. getBaseMatrix(): Matrix;
  15501. /**
  15502. * Gets the rest pose matrix
  15503. * @returns a matrix
  15504. */
  15505. getRestPose(): Matrix;
  15506. /**
  15507. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15508. */
  15509. getWorldMatrix(): Matrix;
  15510. /**
  15511. * Sets the local matrix to rest pose matrix
  15512. */
  15513. returnToRest(): void;
  15514. /**
  15515. * Gets the inverse of the absolute transform matrix.
  15516. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15517. * @returns a matrix
  15518. */
  15519. getInvertedAbsoluteTransform(): Matrix;
  15520. /**
  15521. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15522. * @returns a matrix
  15523. */
  15524. getAbsoluteTransform(): Matrix;
  15525. /**
  15526. * Links with the given transform node.
  15527. * The local matrix of this bone is copied from the transform node every frame.
  15528. * @param transformNode defines the transform node to link to
  15529. */
  15530. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15531. /**
  15532. * Gets the node used to drive the bone's transformation
  15533. * @returns a transform node or null
  15534. */
  15535. getTransformNode(): Nullable<TransformNode>;
  15536. /** Gets or sets current position (in local space) */
  15537. get position(): Vector3;
  15538. set position(newPosition: Vector3);
  15539. /** Gets or sets current rotation (in local space) */
  15540. get rotation(): Vector3;
  15541. set rotation(newRotation: Vector3);
  15542. /** Gets or sets current rotation quaternion (in local space) */
  15543. get rotationQuaternion(): Quaternion;
  15544. set rotationQuaternion(newRotation: Quaternion);
  15545. /** Gets or sets current scaling (in local space) */
  15546. get scaling(): Vector3;
  15547. set scaling(newScaling: Vector3);
  15548. /**
  15549. * Gets the animation properties override
  15550. */
  15551. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15552. private _decompose;
  15553. private _compose;
  15554. /**
  15555. * Update the base and local matrices
  15556. * @param matrix defines the new base or local matrix
  15557. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15558. * @param updateLocalMatrix defines if the local matrix should be updated
  15559. */
  15560. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15561. /** @hidden */
  15562. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15563. /**
  15564. * Flag the bone as dirty (Forcing it to update everything)
  15565. */
  15566. markAsDirty(): void;
  15567. /** @hidden */
  15568. _markAsDirtyAndCompose(): void;
  15569. private _markAsDirtyAndDecompose;
  15570. /**
  15571. * Translate the bone in local or world space
  15572. * @param vec The amount to translate the bone
  15573. * @param space The space that the translation is in
  15574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15575. */
  15576. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15577. /**
  15578. * Set the postion of the bone in local or world space
  15579. * @param position The position to set the bone
  15580. * @param space The space that the position is in
  15581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15582. */
  15583. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15584. /**
  15585. * Set the absolute position of the bone (world space)
  15586. * @param position The position to set the bone
  15587. * @param mesh The mesh that this bone is attached to
  15588. */
  15589. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15590. /**
  15591. * Scale the bone on the x, y and z axes (in local space)
  15592. * @param x The amount to scale the bone on the x axis
  15593. * @param y The amount to scale the bone on the y axis
  15594. * @param z The amount to scale the bone on the z axis
  15595. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15596. */
  15597. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15598. /**
  15599. * Set the bone scaling in local space
  15600. * @param scale defines the scaling vector
  15601. */
  15602. setScale(scale: Vector3): void;
  15603. /**
  15604. * Gets the current scaling in local space
  15605. * @returns the current scaling vector
  15606. */
  15607. getScale(): Vector3;
  15608. /**
  15609. * Gets the current scaling in local space and stores it in a target vector
  15610. * @param result defines the target vector
  15611. */
  15612. getScaleToRef(result: Vector3): void;
  15613. /**
  15614. * Set the yaw, pitch, and roll of the bone in local or world space
  15615. * @param yaw The rotation of the bone on the y axis
  15616. * @param pitch The rotation of the bone on the x axis
  15617. * @param roll The rotation of the bone on the z axis
  15618. * @param space The space that the axes of rotation are in
  15619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15620. */
  15621. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15622. /**
  15623. * Add a rotation to the bone on an axis in local or world space
  15624. * @param axis The axis to rotate the bone on
  15625. * @param amount The amount to rotate the bone
  15626. * @param space The space that the axis is in
  15627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15628. */
  15629. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15630. /**
  15631. * Set the rotation of the bone to a particular axis angle in local or world space
  15632. * @param axis The axis to rotate the bone on
  15633. * @param angle The angle that the bone should be rotated to
  15634. * @param space The space that the axis is in
  15635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15636. */
  15637. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15638. /**
  15639. * Set the euler rotation of the bone in local of world space
  15640. * @param rotation The euler rotation that the bone should be set to
  15641. * @param space The space that the rotation is in
  15642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15643. */
  15644. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15645. /**
  15646. * Set the quaternion rotation of the bone in local of world space
  15647. * @param quat The quaternion rotation that the bone should be set to
  15648. * @param space The space that the rotation is in
  15649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15650. */
  15651. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15652. /**
  15653. * Set the rotation matrix of the bone in local of world space
  15654. * @param rotMat The rotation matrix that the bone should be set to
  15655. * @param space The space that the rotation is in
  15656. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15657. */
  15658. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15659. private _rotateWithMatrix;
  15660. private _getNegativeRotationToRef;
  15661. /**
  15662. * Get the position of the bone in local or world space
  15663. * @param space The space that the returned position is in
  15664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15665. * @returns The position of the bone
  15666. */
  15667. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15668. /**
  15669. * Copy the position of the bone to a vector3 in local or world space
  15670. * @param space The space that the returned position is in
  15671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15672. * @param result The vector3 to copy the position to
  15673. */
  15674. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15675. /**
  15676. * Get the absolute position of the bone (world space)
  15677. * @param mesh The mesh that this bone is attached to
  15678. * @returns The absolute position of the bone
  15679. */
  15680. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15681. /**
  15682. * Copy the absolute position of the bone (world space) to the result param
  15683. * @param mesh The mesh that this bone is attached to
  15684. * @param result The vector3 to copy the absolute position to
  15685. */
  15686. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15687. /**
  15688. * Compute the absolute transforms of this bone and its children
  15689. */
  15690. computeAbsoluteTransforms(): void;
  15691. /**
  15692. * Get the world direction from an axis that is in the local space of the bone
  15693. * @param localAxis The local direction that is used to compute the world direction
  15694. * @param mesh The mesh that this bone is attached to
  15695. * @returns The world direction
  15696. */
  15697. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15698. /**
  15699. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15700. * @param localAxis The local direction that is used to compute the world direction
  15701. * @param mesh The mesh that this bone is attached to
  15702. * @param result The vector3 that the world direction will be copied to
  15703. */
  15704. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15705. /**
  15706. * Get the euler rotation of the bone in local or world space
  15707. * @param space The space that the rotation should be in
  15708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15709. * @returns The euler rotation
  15710. */
  15711. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15712. /**
  15713. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15714. * @param space The space that the rotation should be in
  15715. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15716. * @param result The vector3 that the rotation should be copied to
  15717. */
  15718. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15719. /**
  15720. * Get the quaternion rotation of the bone in either local or world space
  15721. * @param space The space that the rotation should be in
  15722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15723. * @returns The quaternion rotation
  15724. */
  15725. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15726. /**
  15727. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15728. * @param space The space that the rotation should be in
  15729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15730. * @param result The quaternion that the rotation should be copied to
  15731. */
  15732. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15733. /**
  15734. * Get the rotation matrix of the bone in local or world space
  15735. * @param space The space that the rotation should be in
  15736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15737. * @returns The rotation matrix
  15738. */
  15739. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15740. /**
  15741. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15742. * @param space The space that the rotation should be in
  15743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15744. * @param result The quaternion that the rotation should be copied to
  15745. */
  15746. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15747. /**
  15748. * Get the world position of a point that is in the local space of the bone
  15749. * @param position The local position
  15750. * @param mesh The mesh that this bone is attached to
  15751. * @returns The world position
  15752. */
  15753. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15754. /**
  15755. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15756. * @param position The local position
  15757. * @param mesh The mesh that this bone is attached to
  15758. * @param result The vector3 that the world position should be copied to
  15759. */
  15760. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15761. /**
  15762. * Get the local position of a point that is in world space
  15763. * @param position The world position
  15764. * @param mesh The mesh that this bone is attached to
  15765. * @returns The local position
  15766. */
  15767. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15768. /**
  15769. * Get the local position of a point that is in world space and copy it to the result param
  15770. * @param position The world position
  15771. * @param mesh The mesh that this bone is attached to
  15772. * @param result The vector3 that the local position should be copied to
  15773. */
  15774. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15775. }
  15776. }
  15777. declare module "babylonjs/Animations/runtimeAnimation" {
  15778. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15779. import { Animatable } from "babylonjs/Animations/animatable";
  15780. import { Scene } from "babylonjs/scene";
  15781. /**
  15782. * Defines a runtime animation
  15783. */
  15784. export class RuntimeAnimation {
  15785. private _events;
  15786. /**
  15787. * The current frame of the runtime animation
  15788. */
  15789. private _currentFrame;
  15790. /**
  15791. * The animation used by the runtime animation
  15792. */
  15793. private _animation;
  15794. /**
  15795. * The target of the runtime animation
  15796. */
  15797. private _target;
  15798. /**
  15799. * The initiating animatable
  15800. */
  15801. private _host;
  15802. /**
  15803. * The original value of the runtime animation
  15804. */
  15805. private _originalValue;
  15806. /**
  15807. * The original blend value of the runtime animation
  15808. */
  15809. private _originalBlendValue;
  15810. /**
  15811. * The offsets cache of the runtime animation
  15812. */
  15813. private _offsetsCache;
  15814. /**
  15815. * The high limits cache of the runtime animation
  15816. */
  15817. private _highLimitsCache;
  15818. /**
  15819. * Specifies if the runtime animation has been stopped
  15820. */
  15821. private _stopped;
  15822. /**
  15823. * The blending factor of the runtime animation
  15824. */
  15825. private _blendingFactor;
  15826. /**
  15827. * The BabylonJS scene
  15828. */
  15829. private _scene;
  15830. /**
  15831. * The current value of the runtime animation
  15832. */
  15833. private _currentValue;
  15834. /** @hidden */
  15835. _animationState: _IAnimationState;
  15836. /**
  15837. * The active target of the runtime animation
  15838. */
  15839. private _activeTargets;
  15840. private _currentActiveTarget;
  15841. private _directTarget;
  15842. /**
  15843. * The target path of the runtime animation
  15844. */
  15845. private _targetPath;
  15846. /**
  15847. * The weight of the runtime animation
  15848. */
  15849. private _weight;
  15850. /**
  15851. * The ratio offset of the runtime animation
  15852. */
  15853. private _ratioOffset;
  15854. /**
  15855. * The previous delay of the runtime animation
  15856. */
  15857. private _previousDelay;
  15858. /**
  15859. * The previous ratio of the runtime animation
  15860. */
  15861. private _previousRatio;
  15862. private _enableBlending;
  15863. private _keys;
  15864. private _minFrame;
  15865. private _maxFrame;
  15866. private _minValue;
  15867. private _maxValue;
  15868. private _targetIsArray;
  15869. /**
  15870. * Gets the current frame of the runtime animation
  15871. */
  15872. get currentFrame(): number;
  15873. /**
  15874. * Gets the weight of the runtime animation
  15875. */
  15876. get weight(): number;
  15877. /**
  15878. * Gets the current value of the runtime animation
  15879. */
  15880. get currentValue(): any;
  15881. /**
  15882. * Gets the target path of the runtime animation
  15883. */
  15884. get targetPath(): string;
  15885. /**
  15886. * Gets the actual target of the runtime animation
  15887. */
  15888. get target(): any;
  15889. /**
  15890. * Gets the additive state of the runtime animation
  15891. */
  15892. get isAdditive(): boolean;
  15893. /** @hidden */
  15894. _onLoop: () => void;
  15895. /**
  15896. * Create a new RuntimeAnimation object
  15897. * @param target defines the target of the animation
  15898. * @param animation defines the source animation object
  15899. * @param scene defines the hosting scene
  15900. * @param host defines the initiating Animatable
  15901. */
  15902. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15903. private _preparePath;
  15904. /**
  15905. * Gets the animation from the runtime animation
  15906. */
  15907. get animation(): Animation;
  15908. /**
  15909. * Resets the runtime animation to the beginning
  15910. * @param restoreOriginal defines whether to restore the target property to the original value
  15911. */
  15912. reset(restoreOriginal?: boolean): void;
  15913. /**
  15914. * Specifies if the runtime animation is stopped
  15915. * @returns Boolean specifying if the runtime animation is stopped
  15916. */
  15917. isStopped(): boolean;
  15918. /**
  15919. * Disposes of the runtime animation
  15920. */
  15921. dispose(): void;
  15922. /**
  15923. * Apply the interpolated value to the target
  15924. * @param currentValue defines the value computed by the animation
  15925. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15926. */
  15927. setValue(currentValue: any, weight: number): void;
  15928. private _getOriginalValues;
  15929. private _setValue;
  15930. /**
  15931. * Gets the loop pmode of the runtime animation
  15932. * @returns Loop Mode
  15933. */
  15934. private _getCorrectLoopMode;
  15935. /**
  15936. * Move the current animation to a given frame
  15937. * @param frame defines the frame to move to
  15938. */
  15939. goToFrame(frame: number): void;
  15940. /**
  15941. * @hidden Internal use only
  15942. */
  15943. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15944. /**
  15945. * Execute the current animation
  15946. * @param delay defines the delay to add to the current frame
  15947. * @param from defines the lower bound of the animation range
  15948. * @param to defines the upper bound of the animation range
  15949. * @param loop defines if the current animation must loop
  15950. * @param speedRatio defines the current speed ratio
  15951. * @param weight defines the weight of the animation (default is -1 so no weight)
  15952. * @param onLoop optional callback called when animation loops
  15953. * @returns a boolean indicating if the animation is running
  15954. */
  15955. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15956. }
  15957. }
  15958. declare module "babylonjs/Animations/animatable" {
  15959. import { Animation } from "babylonjs/Animations/animation";
  15960. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15961. import { Nullable } from "babylonjs/types";
  15962. import { Observable } from "babylonjs/Misc/observable";
  15963. import { Scene } from "babylonjs/scene";
  15964. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15965. import { Node } from "babylonjs/node";
  15966. /**
  15967. * Class used to store an actual running animation
  15968. */
  15969. export class Animatable {
  15970. /** defines the target object */
  15971. target: any;
  15972. /** defines the starting frame number (default is 0) */
  15973. fromFrame: number;
  15974. /** defines the ending frame number (default is 100) */
  15975. toFrame: number;
  15976. /** defines if the animation must loop (default is false) */
  15977. loopAnimation: boolean;
  15978. /** defines a callback to call when animation ends if it is not looping */
  15979. onAnimationEnd?: (() => void) | null | undefined;
  15980. /** defines a callback to call when animation loops */
  15981. onAnimationLoop?: (() => void) | null | undefined;
  15982. /** defines whether the animation should be evaluated additively */
  15983. isAdditive: boolean;
  15984. private _localDelayOffset;
  15985. private _pausedDelay;
  15986. private _runtimeAnimations;
  15987. private _paused;
  15988. private _scene;
  15989. private _speedRatio;
  15990. private _weight;
  15991. private _syncRoot;
  15992. /**
  15993. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15994. * This will only apply for non looping animation (default is true)
  15995. */
  15996. disposeOnEnd: boolean;
  15997. /**
  15998. * Gets a boolean indicating if the animation has started
  15999. */
  16000. animationStarted: boolean;
  16001. /**
  16002. * Observer raised when the animation ends
  16003. */
  16004. onAnimationEndObservable: Observable<Animatable>;
  16005. /**
  16006. * Observer raised when the animation loops
  16007. */
  16008. onAnimationLoopObservable: Observable<Animatable>;
  16009. /**
  16010. * Gets the root Animatable used to synchronize and normalize animations
  16011. */
  16012. get syncRoot(): Nullable<Animatable>;
  16013. /**
  16014. * Gets the current frame of the first RuntimeAnimation
  16015. * Used to synchronize Animatables
  16016. */
  16017. get masterFrame(): number;
  16018. /**
  16019. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16020. */
  16021. get weight(): number;
  16022. set weight(value: number);
  16023. /**
  16024. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16025. */
  16026. get speedRatio(): number;
  16027. set speedRatio(value: number);
  16028. /**
  16029. * Creates a new Animatable
  16030. * @param scene defines the hosting scene
  16031. * @param target defines the target object
  16032. * @param fromFrame defines the starting frame number (default is 0)
  16033. * @param toFrame defines the ending frame number (default is 100)
  16034. * @param loopAnimation defines if the animation must loop (default is false)
  16035. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16036. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16037. * @param animations defines a group of animation to add to the new Animatable
  16038. * @param onAnimationLoop defines a callback to call when animation loops
  16039. * @param isAdditive defines whether the animation should be evaluated additively
  16040. */
  16041. constructor(scene: Scene,
  16042. /** defines the target object */
  16043. target: any,
  16044. /** defines the starting frame number (default is 0) */
  16045. fromFrame?: number,
  16046. /** defines the ending frame number (default is 100) */
  16047. toFrame?: number,
  16048. /** defines if the animation must loop (default is false) */
  16049. loopAnimation?: boolean, speedRatio?: number,
  16050. /** defines a callback to call when animation ends if it is not looping */
  16051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16052. /** defines a callback to call when animation loops */
  16053. onAnimationLoop?: (() => void) | null | undefined,
  16054. /** defines whether the animation should be evaluated additively */
  16055. isAdditive?: boolean);
  16056. /**
  16057. * Synchronize and normalize current Animatable with a source Animatable
  16058. * This is useful when using animation weights and when animations are not of the same length
  16059. * @param root defines the root Animatable to synchronize with
  16060. * @returns the current Animatable
  16061. */
  16062. syncWith(root: Animatable): Animatable;
  16063. /**
  16064. * Gets the list of runtime animations
  16065. * @returns an array of RuntimeAnimation
  16066. */
  16067. getAnimations(): RuntimeAnimation[];
  16068. /**
  16069. * Adds more animations to the current animatable
  16070. * @param target defines the target of the animations
  16071. * @param animations defines the new animations to add
  16072. */
  16073. appendAnimations(target: any, animations: Animation[]): void;
  16074. /**
  16075. * Gets the source animation for a specific property
  16076. * @param property defines the propertyu to look for
  16077. * @returns null or the source animation for the given property
  16078. */
  16079. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16080. /**
  16081. * Gets the runtime animation for a specific property
  16082. * @param property defines the propertyu to look for
  16083. * @returns null or the runtime animation for the given property
  16084. */
  16085. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16086. /**
  16087. * Resets the animatable to its original state
  16088. */
  16089. reset(): void;
  16090. /**
  16091. * Allows the animatable to blend with current running animations
  16092. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16093. * @param blendingSpeed defines the blending speed to use
  16094. */
  16095. enableBlending(blendingSpeed: number): void;
  16096. /**
  16097. * Disable animation blending
  16098. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16099. */
  16100. disableBlending(): void;
  16101. /**
  16102. * Jump directly to a given frame
  16103. * @param frame defines the frame to jump to
  16104. */
  16105. goToFrame(frame: number): void;
  16106. /**
  16107. * Pause the animation
  16108. */
  16109. pause(): void;
  16110. /**
  16111. * Restart the animation
  16112. */
  16113. restart(): void;
  16114. private _raiseOnAnimationEnd;
  16115. /**
  16116. * Stop and delete the current animation
  16117. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16118. * @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)
  16119. */
  16120. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16121. /**
  16122. * Wait asynchronously for the animation to end
  16123. * @returns a promise which will be fullfilled when the animation ends
  16124. */
  16125. waitAsync(): Promise<Animatable>;
  16126. /** @hidden */
  16127. _animate(delay: number): boolean;
  16128. }
  16129. module "babylonjs/scene" {
  16130. interface Scene {
  16131. /** @hidden */
  16132. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16133. /** @hidden */
  16134. _processLateAnimationBindingsForMatrices(holder: {
  16135. totalWeight: number;
  16136. totalAdditiveWeight: number;
  16137. animations: RuntimeAnimation[];
  16138. additiveAnimations: RuntimeAnimation[];
  16139. originalValue: Matrix;
  16140. }): any;
  16141. /** @hidden */
  16142. _processLateAnimationBindingsForQuaternions(holder: {
  16143. totalWeight: number;
  16144. totalAdditiveWeight: number;
  16145. animations: RuntimeAnimation[];
  16146. additiveAnimations: RuntimeAnimation[];
  16147. originalValue: Quaternion;
  16148. }, refQuaternion: Quaternion): Quaternion;
  16149. /** @hidden */
  16150. _processLateAnimationBindings(): void;
  16151. /**
  16152. * Will start the animation sequence of a given target
  16153. * @param target defines the target
  16154. * @param from defines from which frame should animation start
  16155. * @param to defines until which frame should animation run.
  16156. * @param weight defines the weight to apply to the animation (1.0 by default)
  16157. * @param loop defines if the animation loops
  16158. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16159. * @param onAnimationEnd defines the function to be executed when the animation ends
  16160. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16161. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16162. * @param onAnimationLoop defines the callback to call when an animation loops
  16163. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16164. * @returns the animatable object created for this animation
  16165. */
  16166. 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;
  16167. /**
  16168. * Will start the animation sequence of a given target
  16169. * @param target defines the target
  16170. * @param from defines from which frame should animation start
  16171. * @param to defines until which frame should animation run.
  16172. * @param loop defines if the animation loops
  16173. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16174. * @param onAnimationEnd defines the function to be executed when the animation ends
  16175. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16176. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16177. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16178. * @param onAnimationLoop defines the callback to call when an animation loops
  16179. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16180. * @returns the animatable object created for this animation
  16181. */
  16182. 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;
  16183. /**
  16184. * Will start the animation sequence of a given target and its hierarchy
  16185. * @param target defines the target
  16186. * @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.
  16187. * @param from defines from which frame should animation start
  16188. * @param to defines until which frame should animation run.
  16189. * @param loop defines if the animation loops
  16190. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16191. * @param onAnimationEnd defines the function to be executed when the animation ends
  16192. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16193. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16194. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16195. * @param onAnimationLoop defines the callback to call when an animation loops
  16196. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16197. * @returns the list of created animatables
  16198. */
  16199. 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[];
  16200. /**
  16201. * Begin a new animation on a given node
  16202. * @param target defines the target where the animation will take place
  16203. * @param animations defines the list of animations to start
  16204. * @param from defines the initial value
  16205. * @param to defines the final value
  16206. * @param loop defines if you want animation to loop (off by default)
  16207. * @param speedRatio defines the speed ratio to apply to all animations
  16208. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16209. * @param onAnimationLoop defines the callback to call when an animation loops
  16210. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16211. * @returns the list of created animatables
  16212. */
  16213. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16214. /**
  16215. * Begin a new animation on a given node and its hierarchy
  16216. * @param target defines the root node where the animation will take place
  16217. * @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.
  16218. * @param animations defines the list of animations to start
  16219. * @param from defines the initial value
  16220. * @param to defines the final value
  16221. * @param loop defines if you want animation to loop (off by default)
  16222. * @param speedRatio defines the speed ratio to apply to all animations
  16223. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16224. * @param onAnimationLoop defines the callback to call when an animation loops
  16225. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16226. * @returns the list of animatables created for all nodes
  16227. */
  16228. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16229. /**
  16230. * Gets the animatable associated with a specific target
  16231. * @param target defines the target of the animatable
  16232. * @returns the required animatable if found
  16233. */
  16234. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16235. /**
  16236. * Gets all animatables associated with a given target
  16237. * @param target defines the target to look animatables for
  16238. * @returns an array of Animatables
  16239. */
  16240. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16241. /**
  16242. * Stops and removes all animations that have been applied to the scene
  16243. */
  16244. stopAllAnimations(): void;
  16245. /**
  16246. * Gets the current delta time used by animation engine
  16247. */
  16248. deltaTime: number;
  16249. }
  16250. }
  16251. module "babylonjs/Bones/bone" {
  16252. interface Bone {
  16253. /**
  16254. * Copy an animation range from another bone
  16255. * @param source defines the source bone
  16256. * @param rangeName defines the range name to copy
  16257. * @param frameOffset defines the frame offset
  16258. * @param rescaleAsRequired defines if rescaling must be applied if required
  16259. * @param skelDimensionsRatio defines the scaling ratio
  16260. * @returns true if operation was successful
  16261. */
  16262. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16263. }
  16264. }
  16265. }
  16266. declare module "babylonjs/Bones/skeleton" {
  16267. import { Bone } from "babylonjs/Bones/bone";
  16268. import { Observable } from "babylonjs/Misc/observable";
  16269. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16270. import { Scene } from "babylonjs/scene";
  16271. import { Nullable } from "babylonjs/types";
  16272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16273. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16274. import { Animatable } from "babylonjs/Animations/animatable";
  16275. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16276. import { Animation } from "babylonjs/Animations/animation";
  16277. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16278. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16280. /**
  16281. * Class used to handle skinning animations
  16282. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16283. */
  16284. export class Skeleton implements IAnimatable {
  16285. /** defines the skeleton name */
  16286. name: string;
  16287. /** defines the skeleton Id */
  16288. id: string;
  16289. /**
  16290. * Defines the list of child bones
  16291. */
  16292. bones: Bone[];
  16293. /**
  16294. * Defines an estimate of the dimension of the skeleton at rest
  16295. */
  16296. dimensionsAtRest: Vector3;
  16297. /**
  16298. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16299. */
  16300. needInitialSkinMatrix: boolean;
  16301. /**
  16302. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16303. */
  16304. overrideMesh: Nullable<AbstractMesh>;
  16305. /**
  16306. * Gets the list of animations attached to this skeleton
  16307. */
  16308. animations: Array<Animation>;
  16309. private _scene;
  16310. private _isDirty;
  16311. private _transformMatrices;
  16312. private _transformMatrixTexture;
  16313. private _meshesWithPoseMatrix;
  16314. private _animatables;
  16315. private _identity;
  16316. private _synchronizedWithMesh;
  16317. private _ranges;
  16318. private _lastAbsoluteTransformsUpdateId;
  16319. private _canUseTextureForBones;
  16320. private _uniqueId;
  16321. /** @hidden */
  16322. _numBonesWithLinkedTransformNode: number;
  16323. /** @hidden */
  16324. _hasWaitingData: Nullable<boolean>;
  16325. /**
  16326. * Specifies if the skeleton should be serialized
  16327. */
  16328. doNotSerialize: boolean;
  16329. private _useTextureToStoreBoneMatrices;
  16330. /**
  16331. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16332. * Please note that this option is not available if the hardware does not support it
  16333. */
  16334. get useTextureToStoreBoneMatrices(): boolean;
  16335. set useTextureToStoreBoneMatrices(value: boolean);
  16336. private _animationPropertiesOverride;
  16337. /**
  16338. * Gets or sets the animation properties override
  16339. */
  16340. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16341. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16342. /**
  16343. * List of inspectable custom properties (used by the Inspector)
  16344. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16345. */
  16346. inspectableCustomProperties: IInspectable[];
  16347. /**
  16348. * An observable triggered before computing the skeleton's matrices
  16349. */
  16350. onBeforeComputeObservable: Observable<Skeleton>;
  16351. /**
  16352. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16353. */
  16354. get isUsingTextureForMatrices(): boolean;
  16355. /**
  16356. * Gets the unique ID of this skeleton
  16357. */
  16358. get uniqueId(): number;
  16359. /**
  16360. * Creates a new skeleton
  16361. * @param name defines the skeleton name
  16362. * @param id defines the skeleton Id
  16363. * @param scene defines the hosting scene
  16364. */
  16365. constructor(
  16366. /** defines the skeleton name */
  16367. name: string,
  16368. /** defines the skeleton Id */
  16369. id: string, scene: Scene);
  16370. /**
  16371. * Gets the current object class name.
  16372. * @return the class name
  16373. */
  16374. getClassName(): string;
  16375. /**
  16376. * Returns an array containing the root bones
  16377. * @returns an array containing the root bones
  16378. */
  16379. getChildren(): Array<Bone>;
  16380. /**
  16381. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16382. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16383. * @returns a Float32Array containing matrices data
  16384. */
  16385. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16386. /**
  16387. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16389. * @returns a raw texture containing the data
  16390. */
  16391. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16392. /**
  16393. * Gets the current hosting scene
  16394. * @returns a scene object
  16395. */
  16396. getScene(): Scene;
  16397. /**
  16398. * Gets a string representing the current skeleton data
  16399. * @param fullDetails defines a boolean indicating if we want a verbose version
  16400. * @returns a string representing the current skeleton data
  16401. */
  16402. toString(fullDetails?: boolean): string;
  16403. /**
  16404. * Get bone's index searching by name
  16405. * @param name defines bone's name to search for
  16406. * @return the indice of the bone. Returns -1 if not found
  16407. */
  16408. getBoneIndexByName(name: string): number;
  16409. /**
  16410. * Creater a new animation range
  16411. * @param name defines the name of the range
  16412. * @param from defines the start key
  16413. * @param to defines the end key
  16414. */
  16415. createAnimationRange(name: string, from: number, to: number): void;
  16416. /**
  16417. * Delete a specific animation range
  16418. * @param name defines the name of the range
  16419. * @param deleteFrames defines if frames must be removed as well
  16420. */
  16421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16422. /**
  16423. * Gets a specific animation range
  16424. * @param name defines the name of the range to look for
  16425. * @returns the requested animation range or null if not found
  16426. */
  16427. getAnimationRange(name: string): Nullable<AnimationRange>;
  16428. /**
  16429. * Gets the list of all animation ranges defined on this skeleton
  16430. * @returns an array
  16431. */
  16432. getAnimationRanges(): Nullable<AnimationRange>[];
  16433. /**
  16434. * Copy animation range from a source skeleton.
  16435. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16436. * @param source defines the source skeleton
  16437. * @param name defines the name of the range to copy
  16438. * @param rescaleAsRequired defines if rescaling must be applied if required
  16439. * @returns true if operation was successful
  16440. */
  16441. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16442. /**
  16443. * Forces the skeleton to go to rest pose
  16444. */
  16445. returnToRest(): void;
  16446. private _getHighestAnimationFrame;
  16447. /**
  16448. * Begin a specific animation range
  16449. * @param name defines the name of the range to start
  16450. * @param loop defines if looping must be turned on (false by default)
  16451. * @param speedRatio defines the speed ratio to apply (1 by default)
  16452. * @param onAnimationEnd defines a callback which will be called when animation will end
  16453. * @returns a new animatable
  16454. */
  16455. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16456. /**
  16457. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16458. * @param skeleton defines the Skeleton containing the animation range to convert
  16459. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16460. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16461. * @returns the original skeleton
  16462. */
  16463. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16464. /** @hidden */
  16465. _markAsDirty(): void;
  16466. /** @hidden */
  16467. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16468. /** @hidden */
  16469. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16470. private _computeTransformMatrices;
  16471. /**
  16472. * Build all resources required to render a skeleton
  16473. */
  16474. prepare(): void;
  16475. /**
  16476. * Gets the list of animatables currently running for this skeleton
  16477. * @returns an array of animatables
  16478. */
  16479. getAnimatables(): IAnimatable[];
  16480. /**
  16481. * Clone the current skeleton
  16482. * @param name defines the name of the new skeleton
  16483. * @param id defines the id of the new skeleton
  16484. * @returns the new skeleton
  16485. */
  16486. clone(name: string, id?: string): Skeleton;
  16487. /**
  16488. * Enable animation blending for this skeleton
  16489. * @param blendingSpeed defines the blending speed to apply
  16490. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16491. */
  16492. enableBlending(blendingSpeed?: number): void;
  16493. /**
  16494. * Releases all resources associated with the current skeleton
  16495. */
  16496. dispose(): void;
  16497. /**
  16498. * Serialize the skeleton in a JSON object
  16499. * @returns a JSON object
  16500. */
  16501. serialize(): any;
  16502. /**
  16503. * Creates a new skeleton from serialized data
  16504. * @param parsedSkeleton defines the serialized data
  16505. * @param scene defines the hosting scene
  16506. * @returns a new skeleton
  16507. */
  16508. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16509. /**
  16510. * Compute all node absolute transforms
  16511. * @param forceUpdate defines if computation must be done even if cache is up to date
  16512. */
  16513. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16514. /**
  16515. * Gets the root pose matrix
  16516. * @returns a matrix
  16517. */
  16518. getPoseMatrix(): Nullable<Matrix>;
  16519. /**
  16520. * Sorts bones per internal index
  16521. */
  16522. sortBones(): void;
  16523. private _sortBones;
  16524. }
  16525. }
  16526. declare module "babylonjs/Meshes/instancedMesh" {
  16527. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16528. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16529. import { Camera } from "babylonjs/Cameras/camera";
  16530. import { Node } from "babylonjs/node";
  16531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16532. import { Mesh } from "babylonjs/Meshes/mesh";
  16533. import { Material } from "babylonjs/Materials/material";
  16534. import { Skeleton } from "babylonjs/Bones/skeleton";
  16535. import { Light } from "babylonjs/Lights/light";
  16536. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16537. /**
  16538. * Creates an instance based on a source mesh.
  16539. */
  16540. export class InstancedMesh extends AbstractMesh {
  16541. private _sourceMesh;
  16542. private _currentLOD;
  16543. /** @hidden */
  16544. _indexInSourceMeshInstanceArray: number;
  16545. constructor(name: string, source: Mesh);
  16546. /**
  16547. * Returns the string "InstancedMesh".
  16548. */
  16549. getClassName(): string;
  16550. /** Gets the list of lights affecting that mesh */
  16551. get lightSources(): Light[];
  16552. _resyncLightSources(): void;
  16553. _resyncLightSource(light: Light): void;
  16554. _removeLightSource(light: Light, dispose: boolean): void;
  16555. /**
  16556. * If the source mesh receives shadows
  16557. */
  16558. get receiveShadows(): boolean;
  16559. /**
  16560. * The material of the source mesh
  16561. */
  16562. get material(): Nullable<Material>;
  16563. /**
  16564. * Visibility of the source mesh
  16565. */
  16566. get visibility(): number;
  16567. /**
  16568. * Skeleton of the source mesh
  16569. */
  16570. get skeleton(): Nullable<Skeleton>;
  16571. /**
  16572. * Rendering ground id of the source mesh
  16573. */
  16574. get renderingGroupId(): number;
  16575. set renderingGroupId(value: number);
  16576. /**
  16577. * Returns the total number of vertices (integer).
  16578. */
  16579. getTotalVertices(): number;
  16580. /**
  16581. * Returns a positive integer : the total number of indices in this mesh geometry.
  16582. * @returns the numner of indices or zero if the mesh has no geometry.
  16583. */
  16584. getTotalIndices(): number;
  16585. /**
  16586. * The source mesh of the instance
  16587. */
  16588. get sourceMesh(): Mesh;
  16589. /**
  16590. * Creates a new InstancedMesh object from the mesh model.
  16591. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16592. * @param name defines the name of the new instance
  16593. * @returns a new InstancedMesh
  16594. */
  16595. createInstance(name: string): InstancedMesh;
  16596. /**
  16597. * Is this node ready to be used/rendered
  16598. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16599. * @return {boolean} is it ready
  16600. */
  16601. isReady(completeCheck?: boolean): boolean;
  16602. /**
  16603. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16604. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16605. * @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.
  16606. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16607. */
  16608. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16609. /**
  16610. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16611. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16612. * The `data` are either a numeric array either a Float32Array.
  16613. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16614. * 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).
  16615. * Note that a new underlying VertexBuffer object is created each call.
  16616. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16617. *
  16618. * Possible `kind` values :
  16619. * - VertexBuffer.PositionKind
  16620. * - VertexBuffer.UVKind
  16621. * - VertexBuffer.UV2Kind
  16622. * - VertexBuffer.UV3Kind
  16623. * - VertexBuffer.UV4Kind
  16624. * - VertexBuffer.UV5Kind
  16625. * - VertexBuffer.UV6Kind
  16626. * - VertexBuffer.ColorKind
  16627. * - VertexBuffer.MatricesIndicesKind
  16628. * - VertexBuffer.MatricesIndicesExtraKind
  16629. * - VertexBuffer.MatricesWeightsKind
  16630. * - VertexBuffer.MatricesWeightsExtraKind
  16631. *
  16632. * Returns the Mesh.
  16633. */
  16634. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16635. /**
  16636. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16637. * If the mesh has no geometry, it is simply returned as it is.
  16638. * The `data` are either a numeric array either a Float32Array.
  16639. * No new underlying VertexBuffer object is created.
  16640. * 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.
  16641. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16642. *
  16643. * Possible `kind` values :
  16644. * - VertexBuffer.PositionKind
  16645. * - VertexBuffer.UVKind
  16646. * - VertexBuffer.UV2Kind
  16647. * - VertexBuffer.UV3Kind
  16648. * - VertexBuffer.UV4Kind
  16649. * - VertexBuffer.UV5Kind
  16650. * - VertexBuffer.UV6Kind
  16651. * - VertexBuffer.ColorKind
  16652. * - VertexBuffer.MatricesIndicesKind
  16653. * - VertexBuffer.MatricesIndicesExtraKind
  16654. * - VertexBuffer.MatricesWeightsKind
  16655. * - VertexBuffer.MatricesWeightsExtraKind
  16656. *
  16657. * Returns the Mesh.
  16658. */
  16659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16660. /**
  16661. * Sets the mesh indices.
  16662. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16663. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16664. * This method creates a new index buffer each call.
  16665. * Returns the Mesh.
  16666. */
  16667. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16668. /**
  16669. * Boolean : True if the mesh owns the requested kind of data.
  16670. */
  16671. isVerticesDataPresent(kind: string): boolean;
  16672. /**
  16673. * Returns an array of indices (IndicesArray).
  16674. */
  16675. getIndices(): Nullable<IndicesArray>;
  16676. get _positions(): Nullable<Vector3[]>;
  16677. /**
  16678. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16679. * This means the mesh underlying bounding box and sphere are recomputed.
  16680. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16681. * @returns the current mesh
  16682. */
  16683. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16684. /** @hidden */
  16685. _preActivate(): InstancedMesh;
  16686. /** @hidden */
  16687. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16688. /** @hidden */
  16689. _postActivate(): void;
  16690. getWorldMatrix(): Matrix;
  16691. get isAnInstance(): boolean;
  16692. /**
  16693. * Returns the current associated LOD AbstractMesh.
  16694. */
  16695. getLOD(camera: Camera): AbstractMesh;
  16696. /** @hidden */
  16697. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16698. /** @hidden */
  16699. _syncSubMeshes(): InstancedMesh;
  16700. /** @hidden */
  16701. _generatePointsArray(): boolean;
  16702. /**
  16703. * Creates a new InstancedMesh from the current mesh.
  16704. * - name (string) : the cloned mesh name
  16705. * - newParent (optional Node) : the optional Node to parent the clone to.
  16706. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16707. *
  16708. * Returns the clone.
  16709. */
  16710. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16711. /**
  16712. * Disposes the InstancedMesh.
  16713. * Returns nothing.
  16714. */
  16715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16716. }
  16717. module "babylonjs/Meshes/mesh" {
  16718. interface Mesh {
  16719. /**
  16720. * Register a custom buffer that will be instanced
  16721. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16722. * @param kind defines the buffer kind
  16723. * @param stride defines the stride in floats
  16724. */
  16725. registerInstancedBuffer(kind: string, stride: number): void;
  16726. /**
  16727. * true to use the edge renderer for all instances of this mesh
  16728. */
  16729. edgesShareWithInstances: boolean;
  16730. /** @hidden */
  16731. _userInstancedBuffersStorage: {
  16732. data: {
  16733. [key: string]: Float32Array;
  16734. };
  16735. sizes: {
  16736. [key: string]: number;
  16737. };
  16738. vertexBuffers: {
  16739. [key: string]: Nullable<VertexBuffer>;
  16740. };
  16741. strides: {
  16742. [key: string]: number;
  16743. };
  16744. };
  16745. }
  16746. }
  16747. module "babylonjs/Meshes/abstractMesh" {
  16748. interface AbstractMesh {
  16749. /**
  16750. * Object used to store instanced buffers defined by user
  16751. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16752. */
  16753. instancedBuffers: {
  16754. [key: string]: any;
  16755. };
  16756. }
  16757. }
  16758. }
  16759. declare module "babylonjs/Materials/shaderMaterial" {
  16760. import { Nullable } from "babylonjs/types";
  16761. import { Scene } from "babylonjs/scene";
  16762. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16764. import { Mesh } from "babylonjs/Meshes/mesh";
  16765. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16767. import { Effect } from "babylonjs/Materials/effect";
  16768. import { Material } from "babylonjs/Materials/material";
  16769. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16770. /**
  16771. * Defines the options associated with the creation of a shader material.
  16772. */
  16773. export interface IShaderMaterialOptions {
  16774. /**
  16775. * Does the material work in alpha blend mode
  16776. */
  16777. needAlphaBlending: boolean;
  16778. /**
  16779. * Does the material work in alpha test mode
  16780. */
  16781. needAlphaTesting: boolean;
  16782. /**
  16783. * The list of attribute names used in the shader
  16784. */
  16785. attributes: string[];
  16786. /**
  16787. * The list of unifrom names used in the shader
  16788. */
  16789. uniforms: string[];
  16790. /**
  16791. * The list of UBO names used in the shader
  16792. */
  16793. uniformBuffers: string[];
  16794. /**
  16795. * The list of sampler names used in the shader
  16796. */
  16797. samplers: string[];
  16798. /**
  16799. * The list of defines used in the shader
  16800. */
  16801. defines: string[];
  16802. }
  16803. /**
  16804. * 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.
  16805. *
  16806. * This returned material effects how the mesh will look based on the code in the shaders.
  16807. *
  16808. * @see http://doc.babylonjs.com/how_to/shader_material
  16809. */
  16810. export class ShaderMaterial extends Material {
  16811. private _shaderPath;
  16812. private _options;
  16813. private _textures;
  16814. private _textureArrays;
  16815. private _floats;
  16816. private _ints;
  16817. private _floatsArrays;
  16818. private _colors3;
  16819. private _colors3Arrays;
  16820. private _colors4;
  16821. private _colors4Arrays;
  16822. private _vectors2;
  16823. private _vectors3;
  16824. private _vectors4;
  16825. private _matrices;
  16826. private _matrixArrays;
  16827. private _matrices3x3;
  16828. private _matrices2x2;
  16829. private _vectors2Arrays;
  16830. private _vectors3Arrays;
  16831. private _vectors4Arrays;
  16832. private _cachedWorldViewMatrix;
  16833. private _cachedWorldViewProjectionMatrix;
  16834. private _renderId;
  16835. private _multiview;
  16836. private _cachedDefines;
  16837. /** Define the Url to load snippets */
  16838. static SnippetUrl: string;
  16839. /** Snippet ID if the material was created from the snippet server */
  16840. snippetId: string;
  16841. /**
  16842. * Instantiate a new shader material.
  16843. * 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.
  16844. * This returned material effects how the mesh will look based on the code in the shaders.
  16845. * @see http://doc.babylonjs.com/how_to/shader_material
  16846. * @param name Define the name of the material in the scene
  16847. * @param scene Define the scene the material belongs to
  16848. * @param shaderPath Defines the route to the shader code in one of three ways:
  16849. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16850. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16851. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16852. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16853. * @param options Define the options used to create the shader
  16854. */
  16855. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16856. /**
  16857. * Gets the shader path used to define the shader code
  16858. * It can be modified to trigger a new compilation
  16859. */
  16860. get shaderPath(): any;
  16861. /**
  16862. * Sets the shader path used to define the shader code
  16863. * It can be modified to trigger a new compilation
  16864. */
  16865. set shaderPath(shaderPath: any);
  16866. /**
  16867. * Gets the options used to compile the shader.
  16868. * They can be modified to trigger a new compilation
  16869. */
  16870. get options(): IShaderMaterialOptions;
  16871. /**
  16872. * Gets the current class name of the material e.g. "ShaderMaterial"
  16873. * Mainly use in serialization.
  16874. * @returns the class name
  16875. */
  16876. getClassName(): string;
  16877. /**
  16878. * Specifies if the material will require alpha blending
  16879. * @returns a boolean specifying if alpha blending is needed
  16880. */
  16881. needAlphaBlending(): boolean;
  16882. /**
  16883. * Specifies if this material should be rendered in alpha test mode
  16884. * @returns a boolean specifying if an alpha test is needed.
  16885. */
  16886. needAlphaTesting(): boolean;
  16887. private _checkUniform;
  16888. /**
  16889. * Set a texture in the shader.
  16890. * @param name Define the name of the uniform samplers as defined in the shader
  16891. * @param texture Define the texture to bind to this sampler
  16892. * @return the material itself allowing "fluent" like uniform updates
  16893. */
  16894. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16895. /**
  16896. * Set a texture array in the shader.
  16897. * @param name Define the name of the uniform sampler array as defined in the shader
  16898. * @param textures Define the list of textures to bind to this sampler
  16899. * @return the material itself allowing "fluent" like uniform updates
  16900. */
  16901. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16902. /**
  16903. * Set a float in the shader.
  16904. * @param name Define the name of the uniform as defined in the shader
  16905. * @param value Define the value to give to the uniform
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setFloat(name: string, value: number): ShaderMaterial;
  16909. /**
  16910. * Set a int in the shader.
  16911. * @param name Define the name of the uniform as defined in the shader
  16912. * @param value Define the value to give to the uniform
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setInt(name: string, value: number): ShaderMaterial;
  16916. /**
  16917. * Set an array of floats in the shader.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setFloats(name: string, value: number[]): ShaderMaterial;
  16923. /**
  16924. * Set a vec3 in the shader from a Color3.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setColor3(name: string, value: Color3): ShaderMaterial;
  16930. /**
  16931. * Set a vec3 array in the shader from a Color3 array.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16937. /**
  16938. * Set a vec4 in the shader from a Color4.
  16939. * @param name Define the name of the uniform as defined in the shader
  16940. * @param value Define the value to give to the uniform
  16941. * @return the material itself allowing "fluent" like uniform updates
  16942. */
  16943. setColor4(name: string, value: Color4): ShaderMaterial;
  16944. /**
  16945. * Set a vec4 array in the shader from a Color4 array.
  16946. * @param name Define the name of the uniform as defined in the shader
  16947. * @param value Define the value to give to the uniform
  16948. * @return the material itself allowing "fluent" like uniform updates
  16949. */
  16950. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16951. /**
  16952. * Set a vec2 in the shader from a Vector2.
  16953. * @param name Define the name of the uniform as defined in the shader
  16954. * @param value Define the value to give to the uniform
  16955. * @return the material itself allowing "fluent" like uniform updates
  16956. */
  16957. setVector2(name: string, value: Vector2): ShaderMaterial;
  16958. /**
  16959. * Set a vec3 in the shader from a Vector3.
  16960. * @param name Define the name of the uniform as defined in the shader
  16961. * @param value Define the value to give to the uniform
  16962. * @return the material itself allowing "fluent" like uniform updates
  16963. */
  16964. setVector3(name: string, value: Vector3): ShaderMaterial;
  16965. /**
  16966. * Set a vec4 in the shader from a Vector4.
  16967. * @param name Define the name of the uniform as defined in the shader
  16968. * @param value Define the value to give to the uniform
  16969. * @return the material itself allowing "fluent" like uniform updates
  16970. */
  16971. setVector4(name: string, value: Vector4): ShaderMaterial;
  16972. /**
  16973. * Set a mat4 in the shader from a Matrix.
  16974. * @param name Define the name of the uniform as defined in the shader
  16975. * @param value Define the value to give to the uniform
  16976. * @return the material itself allowing "fluent" like uniform updates
  16977. */
  16978. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16979. /**
  16980. * Set a float32Array in the shader from a matrix array.
  16981. * @param name Define the name of the uniform as defined in the shader
  16982. * @param value Define the value to give to the uniform
  16983. * @return the material itself allowing "fluent" like uniform updates
  16984. */
  16985. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16986. /**
  16987. * Set a mat3 in the shader from a Float32Array.
  16988. * @param name Define the name of the uniform as defined in the shader
  16989. * @param value Define the value to give to the uniform
  16990. * @return the material itself allowing "fluent" like uniform updates
  16991. */
  16992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16993. /**
  16994. * Set a mat2 in the shader from a Float32Array.
  16995. * @param name Define the name of the uniform as defined in the shader
  16996. * @param value Define the value to give to the uniform
  16997. * @return the material itself allowing "fluent" like uniform updates
  16998. */
  16999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17000. /**
  17001. * Set a vec2 array in the shader from a number array.
  17002. * @param name Define the name of the uniform as defined in the shader
  17003. * @param value Define the value to give to the uniform
  17004. * @return the material itself allowing "fluent" like uniform updates
  17005. */
  17006. setArray2(name: string, value: number[]): ShaderMaterial;
  17007. /**
  17008. * Set a vec3 array in the shader from a number array.
  17009. * @param name Define the name of the uniform as defined in the shader
  17010. * @param value Define the value to give to the uniform
  17011. * @return the material itself allowing "fluent" like uniform updates
  17012. */
  17013. setArray3(name: string, value: number[]): ShaderMaterial;
  17014. /**
  17015. * Set a vec4 array in the shader from a number array.
  17016. * @param name Define the name of the uniform as defined in the shader
  17017. * @param value Define the value to give to the uniform
  17018. * @return the material itself allowing "fluent" like uniform updates
  17019. */
  17020. setArray4(name: string, value: number[]): ShaderMaterial;
  17021. private _checkCache;
  17022. /**
  17023. * Specifies that the submesh is ready to be used
  17024. * @param mesh defines the mesh to check
  17025. * @param subMesh defines which submesh to check
  17026. * @param useInstances specifies that instances should be used
  17027. * @returns a boolean indicating that the submesh is ready or not
  17028. */
  17029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17030. /**
  17031. * Checks if the material is ready to render the requested mesh
  17032. * @param mesh Define the mesh to render
  17033. * @param useInstances Define whether or not the material is used with instances
  17034. * @returns true if ready, otherwise false
  17035. */
  17036. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17037. /**
  17038. * Binds the world matrix to the material
  17039. * @param world defines the world transformation matrix
  17040. * @param effectOverride - If provided, use this effect instead of internal effect
  17041. */
  17042. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17043. /**
  17044. * Binds the submesh to this material by preparing the effect and shader to draw
  17045. * @param world defines the world transformation matrix
  17046. * @param mesh defines the mesh containing the submesh
  17047. * @param subMesh defines the submesh to bind the material to
  17048. */
  17049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17050. /**
  17051. * Binds the material to the mesh
  17052. * @param world defines the world transformation matrix
  17053. * @param mesh defines the mesh to bind the material to
  17054. * @param effectOverride - If provided, use this effect instead of internal effect
  17055. */
  17056. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17057. protected _afterBind(mesh?: Mesh): void;
  17058. /**
  17059. * Gets the active textures from the material
  17060. * @returns an array of textures
  17061. */
  17062. getActiveTextures(): BaseTexture[];
  17063. /**
  17064. * Specifies if the material uses a texture
  17065. * @param texture defines the texture to check against the material
  17066. * @returns a boolean specifying if the material uses the texture
  17067. */
  17068. hasTexture(texture: BaseTexture): boolean;
  17069. /**
  17070. * Makes a duplicate of the material, and gives it a new name
  17071. * @param name defines the new name for the duplicated material
  17072. * @returns the cloned material
  17073. */
  17074. clone(name: string): ShaderMaterial;
  17075. /**
  17076. * Disposes the material
  17077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17080. */
  17081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17082. /**
  17083. * Serializes this material in a JSON representation
  17084. * @returns the serialized material object
  17085. */
  17086. serialize(): any;
  17087. /**
  17088. * Creates a shader material from parsed shader material data
  17089. * @param source defines the JSON represnetation of the material
  17090. * @param scene defines the hosting scene
  17091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17092. * @returns a new material
  17093. */
  17094. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17095. /**
  17096. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17097. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17098. * @param url defines the url to load from
  17099. * @param scene defines the hosting scene
  17100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17101. * @returns a promise that will resolve to the new ShaderMaterial
  17102. */
  17103. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17104. /**
  17105. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17106. * @param snippetId defines the snippet to load
  17107. * @param scene defines the hosting scene
  17108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17109. * @returns a promise that will resolve to the new ShaderMaterial
  17110. */
  17111. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17112. }
  17113. }
  17114. declare module "babylonjs/Shaders/color.fragment" {
  17115. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17116. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17117. /** @hidden */
  17118. export var colorPixelShader: {
  17119. name: string;
  17120. shader: string;
  17121. };
  17122. }
  17123. declare module "babylonjs/Shaders/color.vertex" {
  17124. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17125. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17126. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17127. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17128. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17129. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17130. /** @hidden */
  17131. export var colorVertexShader: {
  17132. name: string;
  17133. shader: string;
  17134. };
  17135. }
  17136. declare module "babylonjs/Meshes/linesMesh" {
  17137. import { Nullable } from "babylonjs/types";
  17138. import { Scene } from "babylonjs/scene";
  17139. import { Color3 } from "babylonjs/Maths/math.color";
  17140. import { Node } from "babylonjs/node";
  17141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17142. import { Mesh } from "babylonjs/Meshes/mesh";
  17143. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17144. import { Effect } from "babylonjs/Materials/effect";
  17145. import { Material } from "babylonjs/Materials/material";
  17146. import "babylonjs/Shaders/color.fragment";
  17147. import "babylonjs/Shaders/color.vertex";
  17148. /**
  17149. * Line mesh
  17150. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17151. */
  17152. export class LinesMesh extends Mesh {
  17153. /**
  17154. * If vertex color should be applied to the mesh
  17155. */
  17156. readonly useVertexColor?: boolean | undefined;
  17157. /**
  17158. * If vertex alpha should be applied to the mesh
  17159. */
  17160. readonly useVertexAlpha?: boolean | undefined;
  17161. /**
  17162. * Color of the line (Default: White)
  17163. */
  17164. color: Color3;
  17165. /**
  17166. * Alpha of the line (Default: 1)
  17167. */
  17168. alpha: number;
  17169. /**
  17170. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17171. * This margin is expressed in world space coordinates, so its value may vary.
  17172. * Default value is 0.1
  17173. */
  17174. intersectionThreshold: number;
  17175. private _colorShader;
  17176. private color4;
  17177. /**
  17178. * Creates a new LinesMesh
  17179. * @param name defines the name
  17180. * @param scene defines the hosting scene
  17181. * @param parent defines the parent mesh if any
  17182. * @param source defines the optional source LinesMesh used to clone data from
  17183. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17184. * When false, achieved by calling a clone(), also passing False.
  17185. * This will make creation of children, recursive.
  17186. * @param useVertexColor defines if this LinesMesh supports vertex color
  17187. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17188. */
  17189. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17190. /**
  17191. * If vertex color should be applied to the mesh
  17192. */
  17193. useVertexColor?: boolean | undefined,
  17194. /**
  17195. * If vertex alpha should be applied to the mesh
  17196. */
  17197. useVertexAlpha?: boolean | undefined);
  17198. private _addClipPlaneDefine;
  17199. private _removeClipPlaneDefine;
  17200. isReady(): boolean;
  17201. /**
  17202. * Returns the string "LineMesh"
  17203. */
  17204. getClassName(): string;
  17205. /**
  17206. * @hidden
  17207. */
  17208. get material(): Material;
  17209. /**
  17210. * @hidden
  17211. */
  17212. set material(value: Material);
  17213. /**
  17214. * @hidden
  17215. */
  17216. get checkCollisions(): boolean;
  17217. /** @hidden */
  17218. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17219. /** @hidden */
  17220. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17221. /**
  17222. * Disposes of the line mesh
  17223. * @param doNotRecurse If children should be disposed
  17224. */
  17225. dispose(doNotRecurse?: boolean): void;
  17226. /**
  17227. * Returns a new LineMesh object cloned from the current one.
  17228. */
  17229. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17230. /**
  17231. * Creates a new InstancedLinesMesh object from the mesh model.
  17232. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17233. * @param name defines the name of the new instance
  17234. * @returns a new InstancedLinesMesh
  17235. */
  17236. createInstance(name: string): InstancedLinesMesh;
  17237. }
  17238. /**
  17239. * Creates an instance based on a source LinesMesh
  17240. */
  17241. export class InstancedLinesMesh extends InstancedMesh {
  17242. /**
  17243. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17244. * This margin is expressed in world space coordinates, so its value may vary.
  17245. * Initilized with the intersectionThreshold value of the source LinesMesh
  17246. */
  17247. intersectionThreshold: number;
  17248. constructor(name: string, source: LinesMesh);
  17249. /**
  17250. * Returns the string "InstancedLinesMesh".
  17251. */
  17252. getClassName(): string;
  17253. }
  17254. }
  17255. declare module "babylonjs/Shaders/line.fragment" {
  17256. /** @hidden */
  17257. export var linePixelShader: {
  17258. name: string;
  17259. shader: string;
  17260. };
  17261. }
  17262. declare module "babylonjs/Shaders/line.vertex" {
  17263. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17264. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17265. /** @hidden */
  17266. export var lineVertexShader: {
  17267. name: string;
  17268. shader: string;
  17269. };
  17270. }
  17271. declare module "babylonjs/Rendering/edgesRenderer" {
  17272. import { Nullable } from "babylonjs/types";
  17273. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17275. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17276. import { IDisposable } from "babylonjs/scene";
  17277. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17278. import "babylonjs/Shaders/line.fragment";
  17279. import "babylonjs/Shaders/line.vertex";
  17280. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17281. import { SmartArray } from "babylonjs/Misc/smartArray";
  17282. module "babylonjs/scene" {
  17283. interface Scene {
  17284. /** @hidden */
  17285. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17286. }
  17287. }
  17288. module "babylonjs/Meshes/abstractMesh" {
  17289. interface AbstractMesh {
  17290. /**
  17291. * Gets the edgesRenderer associated with the mesh
  17292. */
  17293. edgesRenderer: Nullable<EdgesRenderer>;
  17294. }
  17295. }
  17296. module "babylonjs/Meshes/linesMesh" {
  17297. interface LinesMesh {
  17298. /**
  17299. * Enables the edge rendering mode on the mesh.
  17300. * This mode makes the mesh edges visible
  17301. * @param epsilon defines the maximal distance between two angles to detect a face
  17302. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17303. * @returns the currentAbstractMesh
  17304. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17305. */
  17306. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17307. }
  17308. }
  17309. module "babylonjs/Meshes/linesMesh" {
  17310. interface InstancedLinesMesh {
  17311. /**
  17312. * Enables the edge rendering mode on the mesh.
  17313. * This mode makes the mesh edges visible
  17314. * @param epsilon defines the maximal distance between two angles to detect a face
  17315. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17316. * @returns the current InstancedLinesMesh
  17317. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17318. */
  17319. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17320. }
  17321. }
  17322. /**
  17323. * Defines the minimum contract an Edges renderer should follow.
  17324. */
  17325. export interface IEdgesRenderer extends IDisposable {
  17326. /**
  17327. * Gets or sets a boolean indicating if the edgesRenderer is active
  17328. */
  17329. isEnabled: boolean;
  17330. /**
  17331. * Renders the edges of the attached mesh,
  17332. */
  17333. render(): void;
  17334. /**
  17335. * Checks wether or not the edges renderer is ready to render.
  17336. * @return true if ready, otherwise false.
  17337. */
  17338. isReady(): boolean;
  17339. /**
  17340. * List of instances to render in case the source mesh has instances
  17341. */
  17342. customInstances: SmartArray<Matrix>;
  17343. }
  17344. /**
  17345. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17346. */
  17347. export class EdgesRenderer implements IEdgesRenderer {
  17348. /**
  17349. * Define the size of the edges with an orthographic camera
  17350. */
  17351. edgesWidthScalerForOrthographic: number;
  17352. /**
  17353. * Define the size of the edges with a perspective camera
  17354. */
  17355. edgesWidthScalerForPerspective: number;
  17356. protected _source: AbstractMesh;
  17357. protected _linesPositions: number[];
  17358. protected _linesNormals: number[];
  17359. protected _linesIndices: number[];
  17360. protected _epsilon: number;
  17361. protected _indicesCount: number;
  17362. protected _lineShader: ShaderMaterial;
  17363. protected _ib: DataBuffer;
  17364. protected _buffers: {
  17365. [key: string]: Nullable<VertexBuffer>;
  17366. };
  17367. protected _buffersForInstances: {
  17368. [key: string]: Nullable<VertexBuffer>;
  17369. };
  17370. protected _checkVerticesInsteadOfIndices: boolean;
  17371. private _meshRebuildObserver;
  17372. private _meshDisposeObserver;
  17373. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17374. isEnabled: boolean;
  17375. /**
  17376. * List of instances to render in case the source mesh has instances
  17377. */
  17378. customInstances: SmartArray<Matrix>;
  17379. private static GetShader;
  17380. /**
  17381. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17382. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17383. * @param source Mesh used to create edges
  17384. * @param epsilon sum of angles in adjacency to check for edge
  17385. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17386. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17387. */
  17388. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17389. protected _prepareRessources(): void;
  17390. /** @hidden */
  17391. _rebuild(): void;
  17392. /**
  17393. * Releases the required resources for the edges renderer
  17394. */
  17395. dispose(): void;
  17396. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17397. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17398. /**
  17399. * Checks if the pair of p0 and p1 is en edge
  17400. * @param faceIndex
  17401. * @param edge
  17402. * @param faceNormals
  17403. * @param p0
  17404. * @param p1
  17405. * @private
  17406. */
  17407. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17408. /**
  17409. * push line into the position, normal and index buffer
  17410. * @protected
  17411. */
  17412. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17413. /**
  17414. * Generates lines edges from adjacencjes
  17415. * @private
  17416. */
  17417. _generateEdgesLines(): void;
  17418. /**
  17419. * Checks wether or not the edges renderer is ready to render.
  17420. * @return true if ready, otherwise false.
  17421. */
  17422. isReady(): boolean;
  17423. /**
  17424. * Renders the edges of the attached mesh,
  17425. */
  17426. render(): void;
  17427. }
  17428. /**
  17429. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17430. */
  17431. export class LineEdgesRenderer extends EdgesRenderer {
  17432. /**
  17433. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17434. * @param source LineMesh used to generate edges
  17435. * @param epsilon not important (specified angle for edge detection)
  17436. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17437. */
  17438. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17439. /**
  17440. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17441. */
  17442. _generateEdgesLines(): void;
  17443. }
  17444. }
  17445. declare module "babylonjs/Rendering/renderingGroup" {
  17446. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17449. import { Nullable } from "babylonjs/types";
  17450. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17451. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17452. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17453. import { Material } from "babylonjs/Materials/material";
  17454. import { Scene } from "babylonjs/scene";
  17455. /**
  17456. * This represents the object necessary to create a rendering group.
  17457. * This is exclusively used and created by the rendering manager.
  17458. * To modify the behavior, you use the available helpers in your scene or meshes.
  17459. * @hidden
  17460. */
  17461. export class RenderingGroup {
  17462. index: number;
  17463. private static _zeroVector;
  17464. private _scene;
  17465. private _opaqueSubMeshes;
  17466. private _transparentSubMeshes;
  17467. private _alphaTestSubMeshes;
  17468. private _depthOnlySubMeshes;
  17469. private _particleSystems;
  17470. private _spriteManagers;
  17471. private _opaqueSortCompareFn;
  17472. private _alphaTestSortCompareFn;
  17473. private _transparentSortCompareFn;
  17474. private _renderOpaque;
  17475. private _renderAlphaTest;
  17476. private _renderTransparent;
  17477. /** @hidden */
  17478. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17479. onBeforeTransparentRendering: () => void;
  17480. /**
  17481. * Set the opaque sort comparison function.
  17482. * If null the sub meshes will be render in the order they were created
  17483. */
  17484. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17485. /**
  17486. * Set the alpha test sort comparison function.
  17487. * If null the sub meshes will be render in the order they were created
  17488. */
  17489. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17490. /**
  17491. * Set the transparent sort comparison function.
  17492. * If null the sub meshes will be render in the order they were created
  17493. */
  17494. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17495. /**
  17496. * Creates a new rendering group.
  17497. * @param index The rendering group index
  17498. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17499. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17500. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17501. */
  17502. 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>);
  17503. /**
  17504. * Render all the sub meshes contained in the group.
  17505. * @param customRenderFunction Used to override the default render behaviour of the group.
  17506. * @returns true if rendered some submeshes.
  17507. */
  17508. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17509. /**
  17510. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17511. * @param subMeshes The submeshes to render
  17512. */
  17513. private renderOpaqueSorted;
  17514. /**
  17515. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17516. * @param subMeshes The submeshes to render
  17517. */
  17518. private renderAlphaTestSorted;
  17519. /**
  17520. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17521. * @param subMeshes The submeshes to render
  17522. */
  17523. private renderTransparentSorted;
  17524. /**
  17525. * Renders the submeshes in a specified order.
  17526. * @param subMeshes The submeshes to sort before render
  17527. * @param sortCompareFn The comparison function use to sort
  17528. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17529. * @param transparent Specifies to activate blending if true
  17530. */
  17531. private static renderSorted;
  17532. /**
  17533. * Renders the submeshes in the order they were dispatched (no sort applied).
  17534. * @param subMeshes The submeshes to render
  17535. */
  17536. private static renderUnsorted;
  17537. /**
  17538. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17539. * are rendered back to front if in the same alpha index.
  17540. *
  17541. * @param a The first submesh
  17542. * @param b The second submesh
  17543. * @returns The result of the comparison
  17544. */
  17545. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17546. /**
  17547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17548. * are rendered back to front.
  17549. *
  17550. * @param a The first submesh
  17551. * @param b The second submesh
  17552. * @returns The result of the comparison
  17553. */
  17554. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17555. /**
  17556. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17557. * are rendered front to back (prevent overdraw).
  17558. *
  17559. * @param a The first submesh
  17560. * @param b The second submesh
  17561. * @returns The result of the comparison
  17562. */
  17563. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17564. /**
  17565. * Resets the different lists of submeshes to prepare a new frame.
  17566. */
  17567. prepare(): void;
  17568. dispose(): void;
  17569. /**
  17570. * Inserts the submesh in its correct queue depending on its material.
  17571. * @param subMesh The submesh to dispatch
  17572. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17573. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17574. */
  17575. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17576. dispatchSprites(spriteManager: ISpriteManager): void;
  17577. dispatchParticles(particleSystem: IParticleSystem): void;
  17578. private _renderParticles;
  17579. private _renderSprites;
  17580. }
  17581. }
  17582. declare module "babylonjs/Rendering/renderingManager" {
  17583. import { Nullable } from "babylonjs/types";
  17584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17586. import { SmartArray } from "babylonjs/Misc/smartArray";
  17587. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17588. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17589. import { Material } from "babylonjs/Materials/material";
  17590. import { Scene } from "babylonjs/scene";
  17591. import { Camera } from "babylonjs/Cameras/camera";
  17592. /**
  17593. * Interface describing the different options available in the rendering manager
  17594. * regarding Auto Clear between groups.
  17595. */
  17596. export interface IRenderingManagerAutoClearSetup {
  17597. /**
  17598. * Defines whether or not autoclear is enable.
  17599. */
  17600. autoClear: boolean;
  17601. /**
  17602. * Defines whether or not to autoclear the depth buffer.
  17603. */
  17604. depth: boolean;
  17605. /**
  17606. * Defines whether or not to autoclear the stencil buffer.
  17607. */
  17608. stencil: boolean;
  17609. }
  17610. /**
  17611. * This class is used by the onRenderingGroupObservable
  17612. */
  17613. export class RenderingGroupInfo {
  17614. /**
  17615. * The Scene that being rendered
  17616. */
  17617. scene: Scene;
  17618. /**
  17619. * The camera currently used for the rendering pass
  17620. */
  17621. camera: Nullable<Camera>;
  17622. /**
  17623. * The ID of the renderingGroup being processed
  17624. */
  17625. renderingGroupId: number;
  17626. }
  17627. /**
  17628. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17629. * It is enable to manage the different groups as well as the different necessary sort functions.
  17630. * This should not be used directly aside of the few static configurations
  17631. */
  17632. export class RenderingManager {
  17633. /**
  17634. * The max id used for rendering groups (not included)
  17635. */
  17636. static MAX_RENDERINGGROUPS: number;
  17637. /**
  17638. * The min id used for rendering groups (included)
  17639. */
  17640. static MIN_RENDERINGGROUPS: number;
  17641. /**
  17642. * Used to globally prevent autoclearing scenes.
  17643. */
  17644. static AUTOCLEAR: boolean;
  17645. /**
  17646. * @hidden
  17647. */
  17648. _useSceneAutoClearSetup: boolean;
  17649. private _scene;
  17650. private _renderingGroups;
  17651. private _depthStencilBufferAlreadyCleaned;
  17652. private _autoClearDepthStencil;
  17653. private _customOpaqueSortCompareFn;
  17654. private _customAlphaTestSortCompareFn;
  17655. private _customTransparentSortCompareFn;
  17656. private _renderingGroupInfo;
  17657. /**
  17658. * Instantiates a new rendering group for a particular scene
  17659. * @param scene Defines the scene the groups belongs to
  17660. */
  17661. constructor(scene: Scene);
  17662. private _clearDepthStencilBuffer;
  17663. /**
  17664. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17665. * @hidden
  17666. */
  17667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17668. /**
  17669. * Resets the different information of the group to prepare a new frame
  17670. * @hidden
  17671. */
  17672. reset(): void;
  17673. /**
  17674. * Dispose and release the group and its associated resources.
  17675. * @hidden
  17676. */
  17677. dispose(): void;
  17678. /**
  17679. * Clear the info related to rendering groups preventing retention points during dispose.
  17680. */
  17681. freeRenderingGroups(): void;
  17682. private _prepareRenderingGroup;
  17683. /**
  17684. * Add a sprite manager to the rendering manager in order to render it this frame.
  17685. * @param spriteManager Define the sprite manager to render
  17686. */
  17687. dispatchSprites(spriteManager: ISpriteManager): void;
  17688. /**
  17689. * Add a particle system to the rendering manager in order to render it this frame.
  17690. * @param particleSystem Define the particle system to render
  17691. */
  17692. dispatchParticles(particleSystem: IParticleSystem): void;
  17693. /**
  17694. * Add a submesh to the manager in order to render it this frame
  17695. * @param subMesh The submesh to dispatch
  17696. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17697. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17698. */
  17699. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17700. /**
  17701. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17702. * This allowed control for front to back rendering or reversly depending of the special needs.
  17703. *
  17704. * @param renderingGroupId The rendering group id corresponding to its index
  17705. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17706. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17707. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17708. */
  17709. 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;
  17710. /**
  17711. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17712. *
  17713. * @param renderingGroupId The rendering group id corresponding to its index
  17714. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17715. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17716. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17717. */
  17718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17719. /**
  17720. * Gets the current auto clear configuration for one rendering group of the rendering
  17721. * manager.
  17722. * @param index the rendering group index to get the information for
  17723. * @returns The auto clear setup for the requested rendering group
  17724. */
  17725. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17726. }
  17727. }
  17728. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17729. import { SmartArray } from "babylonjs/Misc/smartArray";
  17730. import { Nullable } from "babylonjs/types";
  17731. import { Scene } from "babylonjs/scene";
  17732. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17733. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17735. import { Mesh } from "babylonjs/Meshes/mesh";
  17736. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17737. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17738. import { Effect } from "babylonjs/Materials/effect";
  17739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17740. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17741. import "babylonjs/Shaders/shadowMap.fragment";
  17742. import "babylonjs/Shaders/shadowMap.vertex";
  17743. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17744. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17745. import { Observable } from "babylonjs/Misc/observable";
  17746. /**
  17747. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17748. */
  17749. export interface ICustomShaderOptions {
  17750. /**
  17751. * Gets or sets the custom shader name to use
  17752. */
  17753. shaderName: string;
  17754. /**
  17755. * The list of attribute names used in the shader
  17756. */
  17757. attributes?: string[];
  17758. /**
  17759. * The list of unifrom names used in the shader
  17760. */
  17761. uniforms?: string[];
  17762. /**
  17763. * The list of sampler names used in the shader
  17764. */
  17765. samplers?: string[];
  17766. /**
  17767. * The list of defines used in the shader
  17768. */
  17769. defines?: string[];
  17770. }
  17771. /**
  17772. * Interface to implement to create a shadow generator compatible with BJS.
  17773. */
  17774. export interface IShadowGenerator {
  17775. /**
  17776. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17777. * @returns The render target texture if present otherwise, null
  17778. */
  17779. getShadowMap(): Nullable<RenderTargetTexture>;
  17780. /**
  17781. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17782. * @param subMesh The submesh we want to render in the shadow map
  17783. * @param useInstances Defines wether will draw in the map using instances
  17784. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17785. * @returns true if ready otherwise, false
  17786. */
  17787. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17788. /**
  17789. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17790. * @param defines Defines of the material we want to update
  17791. * @param lightIndex Index of the light in the enabled light list of the material
  17792. */
  17793. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17794. /**
  17795. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17796. * defined in the generator but impacting the effect).
  17797. * It implies the unifroms available on the materials are the standard BJS ones.
  17798. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17799. * @param effect The effect we are binfing the information for
  17800. */
  17801. bindShadowLight(lightIndex: string, effect: Effect): void;
  17802. /**
  17803. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17804. * (eq to shadow prjection matrix * light transform matrix)
  17805. * @returns The transform matrix used to create the shadow map
  17806. */
  17807. getTransformMatrix(): Matrix;
  17808. /**
  17809. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17810. * Cube and 2D textures for instance.
  17811. */
  17812. recreateShadowMap(): void;
  17813. /**
  17814. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17815. * @param onCompiled Callback triggered at the and of the effects compilation
  17816. * @param options Sets of optional options forcing the compilation with different modes
  17817. */
  17818. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17819. useInstances: boolean;
  17820. }>): void;
  17821. /**
  17822. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17823. * @param options Sets of optional options forcing the compilation with different modes
  17824. * @returns A promise that resolves when the compilation completes
  17825. */
  17826. forceCompilationAsync(options?: Partial<{
  17827. useInstances: boolean;
  17828. }>): Promise<void>;
  17829. /**
  17830. * Serializes the shadow generator setup to a json object.
  17831. * @returns The serialized JSON object
  17832. */
  17833. serialize(): any;
  17834. /**
  17835. * Disposes the Shadow map and related Textures and effects.
  17836. */
  17837. dispose(): void;
  17838. }
  17839. /**
  17840. * Default implementation IShadowGenerator.
  17841. * This is the main object responsible of generating shadows in the framework.
  17842. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17843. */
  17844. export class ShadowGenerator implements IShadowGenerator {
  17845. /**
  17846. * Name of the shadow generator class
  17847. */
  17848. static CLASSNAME: string;
  17849. /**
  17850. * Shadow generator mode None: no filtering applied.
  17851. */
  17852. static readonly FILTER_NONE: number;
  17853. /**
  17854. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17855. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17856. */
  17857. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17858. /**
  17859. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17860. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17861. */
  17862. static readonly FILTER_POISSONSAMPLING: number;
  17863. /**
  17864. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17865. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17866. */
  17867. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17868. /**
  17869. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17870. * edge artifacts on steep falloff.
  17871. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17872. */
  17873. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17874. /**
  17875. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17876. * edge artifacts on steep falloff.
  17877. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17878. */
  17879. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17880. /**
  17881. * Shadow generator mode PCF: Percentage Closer Filtering
  17882. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17883. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17884. */
  17885. static readonly FILTER_PCF: number;
  17886. /**
  17887. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17888. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17889. * Contact Hardening
  17890. */
  17891. static readonly FILTER_PCSS: number;
  17892. /**
  17893. * Reserved for PCF and PCSS
  17894. * Highest Quality.
  17895. *
  17896. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17897. *
  17898. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17899. */
  17900. static readonly QUALITY_HIGH: number;
  17901. /**
  17902. * Reserved for PCF and PCSS
  17903. * Good tradeoff for quality/perf cross devices
  17904. *
  17905. * Execute PCF on a 3*3 kernel.
  17906. *
  17907. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17908. */
  17909. static readonly QUALITY_MEDIUM: number;
  17910. /**
  17911. * Reserved for PCF and PCSS
  17912. * The lowest quality but the fastest.
  17913. *
  17914. * Execute PCF on a 1*1 kernel.
  17915. *
  17916. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17917. */
  17918. static readonly QUALITY_LOW: number;
  17919. /** Gets or sets the custom shader name to use */
  17920. customShaderOptions: ICustomShaderOptions;
  17921. /**
  17922. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17923. */
  17924. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17925. /**
  17926. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17927. */
  17928. onAfterShadowMapRenderObservable: Observable<Effect>;
  17929. /**
  17930. * Observable triggered before a mesh is rendered in the shadow map.
  17931. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17932. */
  17933. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17934. /**
  17935. * Observable triggered after a mesh is rendered in the shadow map.
  17936. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17937. */
  17938. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17939. protected _bias: number;
  17940. /**
  17941. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17942. */
  17943. get bias(): number;
  17944. /**
  17945. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17946. */
  17947. set bias(bias: number);
  17948. protected _normalBias: number;
  17949. /**
  17950. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17951. */
  17952. get normalBias(): number;
  17953. /**
  17954. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17955. */
  17956. set normalBias(normalBias: number);
  17957. protected _blurBoxOffset: number;
  17958. /**
  17959. * Gets the blur box offset: offset applied during the blur pass.
  17960. * Only useful if useKernelBlur = false
  17961. */
  17962. get blurBoxOffset(): number;
  17963. /**
  17964. * Sets the blur box offset: offset applied during the blur pass.
  17965. * Only useful if useKernelBlur = false
  17966. */
  17967. set blurBoxOffset(value: number);
  17968. protected _blurScale: number;
  17969. /**
  17970. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17971. * 2 means half of the size.
  17972. */
  17973. get blurScale(): number;
  17974. /**
  17975. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17976. * 2 means half of the size.
  17977. */
  17978. set blurScale(value: number);
  17979. protected _blurKernel: number;
  17980. /**
  17981. * Gets the blur kernel: kernel size of the blur pass.
  17982. * Only useful if useKernelBlur = true
  17983. */
  17984. get blurKernel(): number;
  17985. /**
  17986. * Sets the blur kernel: kernel size of the blur pass.
  17987. * Only useful if useKernelBlur = true
  17988. */
  17989. set blurKernel(value: number);
  17990. protected _useKernelBlur: boolean;
  17991. /**
  17992. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17993. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17994. */
  17995. get useKernelBlur(): boolean;
  17996. /**
  17997. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17998. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17999. */
  18000. set useKernelBlur(value: boolean);
  18001. protected _depthScale: number;
  18002. /**
  18003. * Gets the depth scale used in ESM mode.
  18004. */
  18005. get depthScale(): number;
  18006. /**
  18007. * Sets the depth scale used in ESM mode.
  18008. * This can override the scale stored on the light.
  18009. */
  18010. set depthScale(value: number);
  18011. protected _validateFilter(filter: number): number;
  18012. protected _filter: number;
  18013. /**
  18014. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18015. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18016. */
  18017. get filter(): number;
  18018. /**
  18019. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18020. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18021. */
  18022. set filter(value: number);
  18023. /**
  18024. * Gets if the current filter is set to Poisson Sampling.
  18025. */
  18026. get usePoissonSampling(): boolean;
  18027. /**
  18028. * Sets the current filter to Poisson Sampling.
  18029. */
  18030. set usePoissonSampling(value: boolean);
  18031. /**
  18032. * Gets if the current filter is set to ESM.
  18033. */
  18034. get useExponentialShadowMap(): boolean;
  18035. /**
  18036. * Sets the current filter is to ESM.
  18037. */
  18038. set useExponentialShadowMap(value: boolean);
  18039. /**
  18040. * Gets if the current filter is set to filtered ESM.
  18041. */
  18042. get useBlurExponentialShadowMap(): boolean;
  18043. /**
  18044. * Gets if the current filter is set to filtered ESM.
  18045. */
  18046. set useBlurExponentialShadowMap(value: boolean);
  18047. /**
  18048. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18049. * exponential to prevent steep falloff artifacts).
  18050. */
  18051. get useCloseExponentialShadowMap(): boolean;
  18052. /**
  18053. * Sets the current filter to "close ESM" (using the inverse of the
  18054. * exponential to prevent steep falloff artifacts).
  18055. */
  18056. set useCloseExponentialShadowMap(value: boolean);
  18057. /**
  18058. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18059. * exponential to prevent steep falloff artifacts).
  18060. */
  18061. get useBlurCloseExponentialShadowMap(): boolean;
  18062. /**
  18063. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18064. * exponential to prevent steep falloff artifacts).
  18065. */
  18066. set useBlurCloseExponentialShadowMap(value: boolean);
  18067. /**
  18068. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18069. */
  18070. get usePercentageCloserFiltering(): boolean;
  18071. /**
  18072. * Sets the current filter to "PCF" (percentage closer filtering).
  18073. */
  18074. set usePercentageCloserFiltering(value: boolean);
  18075. protected _filteringQuality: number;
  18076. /**
  18077. * Gets the PCF or PCSS Quality.
  18078. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18079. */
  18080. get filteringQuality(): number;
  18081. /**
  18082. * Sets the PCF or PCSS Quality.
  18083. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18084. */
  18085. set filteringQuality(filteringQuality: number);
  18086. /**
  18087. * Gets if the current filter is set to "PCSS" (contact hardening).
  18088. */
  18089. get useContactHardeningShadow(): boolean;
  18090. /**
  18091. * Sets the current filter to "PCSS" (contact hardening).
  18092. */
  18093. set useContactHardeningShadow(value: boolean);
  18094. protected _contactHardeningLightSizeUVRatio: number;
  18095. /**
  18096. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18097. * Using a ratio helps keeping shape stability independently of the map size.
  18098. *
  18099. * It does not account for the light projection as it was having too much
  18100. * instability during the light setup or during light position changes.
  18101. *
  18102. * Only valid if useContactHardeningShadow is true.
  18103. */
  18104. get contactHardeningLightSizeUVRatio(): number;
  18105. /**
  18106. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18107. * Using a ratio helps keeping shape stability independently of the map size.
  18108. *
  18109. * It does not account for the light projection as it was having too much
  18110. * instability during the light setup or during light position changes.
  18111. *
  18112. * Only valid if useContactHardeningShadow is true.
  18113. */
  18114. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18115. protected _darkness: number;
  18116. /** Gets or sets the actual darkness of a shadow */
  18117. get darkness(): number;
  18118. set darkness(value: number);
  18119. /**
  18120. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18121. * 0 means strongest and 1 would means no shadow.
  18122. * @returns the darkness.
  18123. */
  18124. getDarkness(): number;
  18125. /**
  18126. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18127. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18128. * @returns the shadow generator allowing fluent coding.
  18129. */
  18130. setDarkness(darkness: number): ShadowGenerator;
  18131. protected _transparencyShadow: boolean;
  18132. /** Gets or sets the ability to have transparent shadow */
  18133. get transparencyShadow(): boolean;
  18134. set transparencyShadow(value: boolean);
  18135. /**
  18136. * Sets the ability to have transparent shadow (boolean).
  18137. * @param transparent True if transparent else False
  18138. * @returns the shadow generator allowing fluent coding
  18139. */
  18140. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18141. /**
  18142. * Enables or disables shadows with varying strength based on the transparency
  18143. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18144. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18145. * mesh.visibility * alphaTexture.a
  18146. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18147. */
  18148. enableSoftTransparentShadow: boolean;
  18149. protected _shadowMap: Nullable<RenderTargetTexture>;
  18150. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18151. /**
  18152. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18153. * @returns The render target texture if present otherwise, null
  18154. */
  18155. getShadowMap(): Nullable<RenderTargetTexture>;
  18156. /**
  18157. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18158. * @returns The render target texture if the shadow map is present otherwise, null
  18159. */
  18160. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18161. /**
  18162. * Gets the class name of that object
  18163. * @returns "ShadowGenerator"
  18164. */
  18165. getClassName(): string;
  18166. /**
  18167. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18168. * @param mesh Mesh to add
  18169. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18170. * @returns the Shadow Generator itself
  18171. */
  18172. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18173. /**
  18174. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18175. * @param mesh Mesh to remove
  18176. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18177. * @returns the Shadow Generator itself
  18178. */
  18179. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18180. /**
  18181. * Controls the extent to which the shadows fade out at the edge of the frustum
  18182. */
  18183. frustumEdgeFalloff: number;
  18184. protected _light: IShadowLight;
  18185. /**
  18186. * Returns the associated light object.
  18187. * @returns the light generating the shadow
  18188. */
  18189. getLight(): IShadowLight;
  18190. /**
  18191. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18192. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18193. * It might on the other hand introduce peter panning.
  18194. */
  18195. forceBackFacesOnly: boolean;
  18196. protected _scene: Scene;
  18197. protected _lightDirection: Vector3;
  18198. protected _effect: Effect;
  18199. protected _viewMatrix: Matrix;
  18200. protected _projectionMatrix: Matrix;
  18201. protected _transformMatrix: Matrix;
  18202. protected _cachedPosition: Vector3;
  18203. protected _cachedDirection: Vector3;
  18204. protected _cachedDefines: string;
  18205. protected _currentRenderID: number;
  18206. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18207. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18208. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18209. protected _blurPostProcesses: PostProcess[];
  18210. protected _mapSize: number;
  18211. protected _currentFaceIndex: number;
  18212. protected _currentFaceIndexCache: number;
  18213. protected _textureType: number;
  18214. protected _defaultTextureMatrix: Matrix;
  18215. protected _storedUniqueId: Nullable<number>;
  18216. /** @hidden */
  18217. static _SceneComponentInitialization: (scene: Scene) => void;
  18218. /**
  18219. * Creates a ShadowGenerator object.
  18220. * A ShadowGenerator is the required tool to use the shadows.
  18221. * Each light casting shadows needs to use its own ShadowGenerator.
  18222. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18223. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18224. * @param light The light object generating the shadows.
  18225. * @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.
  18226. */
  18227. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18228. protected _initializeGenerator(): void;
  18229. protected _createTargetRenderTexture(): void;
  18230. protected _initializeShadowMap(): void;
  18231. protected _initializeBlurRTTAndPostProcesses(): void;
  18232. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18233. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18234. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18235. protected _applyFilterValues(): void;
  18236. /**
  18237. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18238. * @param onCompiled Callback triggered at the and of the effects compilation
  18239. * @param options Sets of optional options forcing the compilation with different modes
  18240. */
  18241. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18242. useInstances: boolean;
  18243. }>): void;
  18244. /**
  18245. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18246. * @param options Sets of optional options forcing the compilation with different modes
  18247. * @returns A promise that resolves when the compilation completes
  18248. */
  18249. forceCompilationAsync(options?: Partial<{
  18250. useInstances: boolean;
  18251. }>): Promise<void>;
  18252. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18253. private _prepareShadowDefines;
  18254. /**
  18255. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18256. * @param subMesh The submesh we want to render in the shadow map
  18257. * @param useInstances Defines wether will draw in the map using instances
  18258. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18259. * @returns true if ready otherwise, false
  18260. */
  18261. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18262. /**
  18263. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18264. * @param defines Defines of the material we want to update
  18265. * @param lightIndex Index of the light in the enabled light list of the material
  18266. */
  18267. prepareDefines(defines: any, lightIndex: number): void;
  18268. /**
  18269. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18270. * defined in the generator but impacting the effect).
  18271. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18272. * @param effect The effect we are binfing the information for
  18273. */
  18274. bindShadowLight(lightIndex: string, effect: Effect): void;
  18275. /**
  18276. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18277. * (eq to shadow prjection matrix * light transform matrix)
  18278. * @returns The transform matrix used to create the shadow map
  18279. */
  18280. getTransformMatrix(): Matrix;
  18281. /**
  18282. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18283. * Cube and 2D textures for instance.
  18284. */
  18285. recreateShadowMap(): void;
  18286. protected _disposeBlurPostProcesses(): void;
  18287. protected _disposeRTTandPostProcesses(): void;
  18288. /**
  18289. * Disposes the ShadowGenerator.
  18290. * Returns nothing.
  18291. */
  18292. dispose(): void;
  18293. /**
  18294. * Serializes the shadow generator setup to a json object.
  18295. * @returns The serialized JSON object
  18296. */
  18297. serialize(): any;
  18298. /**
  18299. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18300. * @param parsedShadowGenerator The JSON object to parse
  18301. * @param scene The scene to create the shadow map for
  18302. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18303. * @returns The parsed shadow generator
  18304. */
  18305. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18306. }
  18307. }
  18308. declare module "babylonjs/Lights/light" {
  18309. import { Nullable } from "babylonjs/types";
  18310. import { Scene } from "babylonjs/scene";
  18311. import { Vector3 } from "babylonjs/Maths/math.vector";
  18312. import { Color3 } from "babylonjs/Maths/math.color";
  18313. import { Node } from "babylonjs/node";
  18314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18315. import { Effect } from "babylonjs/Materials/effect";
  18316. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18317. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18318. /**
  18319. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18320. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18321. * 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.
  18322. */
  18323. export abstract class Light extends Node {
  18324. /**
  18325. * Falloff Default: light is falling off following the material specification:
  18326. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18327. */
  18328. static readonly FALLOFF_DEFAULT: number;
  18329. /**
  18330. * Falloff Physical: light is falling off following the inverse squared distance law.
  18331. */
  18332. static readonly FALLOFF_PHYSICAL: number;
  18333. /**
  18334. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18335. * to enhance interoperability with other engines.
  18336. */
  18337. static readonly FALLOFF_GLTF: number;
  18338. /**
  18339. * Falloff Standard: light is falling off like in the standard material
  18340. * to enhance interoperability with other materials.
  18341. */
  18342. static readonly FALLOFF_STANDARD: number;
  18343. /**
  18344. * If every light affecting the material is in this lightmapMode,
  18345. * material.lightmapTexture adds or multiplies
  18346. * (depends on material.useLightmapAsShadowmap)
  18347. * after every other light calculations.
  18348. */
  18349. static readonly LIGHTMAP_DEFAULT: number;
  18350. /**
  18351. * material.lightmapTexture as only diffuse lighting from this light
  18352. * adds only specular lighting from this light
  18353. * adds dynamic shadows
  18354. */
  18355. static readonly LIGHTMAP_SPECULAR: number;
  18356. /**
  18357. * material.lightmapTexture as only lighting
  18358. * no light calculation from this light
  18359. * only adds dynamic shadows from this light
  18360. */
  18361. static readonly LIGHTMAP_SHADOWSONLY: number;
  18362. /**
  18363. * Each light type uses the default quantity according to its type:
  18364. * point/spot lights use luminous intensity
  18365. * directional lights use illuminance
  18366. */
  18367. static readonly INTENSITYMODE_AUTOMATIC: number;
  18368. /**
  18369. * lumen (lm)
  18370. */
  18371. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18372. /**
  18373. * candela (lm/sr)
  18374. */
  18375. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18376. /**
  18377. * lux (lm/m^2)
  18378. */
  18379. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18380. /**
  18381. * nit (cd/m^2)
  18382. */
  18383. static readonly INTENSITYMODE_LUMINANCE: number;
  18384. /**
  18385. * Light type const id of the point light.
  18386. */
  18387. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18388. /**
  18389. * Light type const id of the directional light.
  18390. */
  18391. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18392. /**
  18393. * Light type const id of the spot light.
  18394. */
  18395. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18396. /**
  18397. * Light type const id of the hemispheric light.
  18398. */
  18399. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18400. /**
  18401. * Diffuse gives the basic color to an object.
  18402. */
  18403. diffuse: Color3;
  18404. /**
  18405. * Specular produces a highlight color on an object.
  18406. * Note: This is note affecting PBR materials.
  18407. */
  18408. specular: Color3;
  18409. /**
  18410. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18411. * falling off base on range or angle.
  18412. * This can be set to any values in Light.FALLOFF_x.
  18413. *
  18414. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18415. * other types of materials.
  18416. */
  18417. falloffType: number;
  18418. /**
  18419. * Strength of the light.
  18420. * Note: By default it is define in the framework own unit.
  18421. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18422. */
  18423. intensity: number;
  18424. private _range;
  18425. protected _inverseSquaredRange: number;
  18426. /**
  18427. * Defines how far from the source the light is impacting in scene units.
  18428. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18429. */
  18430. get range(): number;
  18431. /**
  18432. * Defines how far from the source the light is impacting in scene units.
  18433. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18434. */
  18435. set range(value: number);
  18436. /**
  18437. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18438. * of light.
  18439. */
  18440. private _photometricScale;
  18441. private _intensityMode;
  18442. /**
  18443. * Gets the photometric scale used to interpret the intensity.
  18444. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18445. */
  18446. get intensityMode(): number;
  18447. /**
  18448. * Sets the photometric scale used to interpret the intensity.
  18449. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18450. */
  18451. set intensityMode(value: number);
  18452. private _radius;
  18453. /**
  18454. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18455. */
  18456. get radius(): number;
  18457. /**
  18458. * sets the light radius used by PBR Materials to simulate soft area lights.
  18459. */
  18460. set radius(value: number);
  18461. private _renderPriority;
  18462. /**
  18463. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18464. * exceeding the number allowed of the materials.
  18465. */
  18466. renderPriority: number;
  18467. private _shadowEnabled;
  18468. /**
  18469. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18470. * the current shadow generator.
  18471. */
  18472. get shadowEnabled(): boolean;
  18473. /**
  18474. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18475. * the current shadow generator.
  18476. */
  18477. set shadowEnabled(value: boolean);
  18478. private _includedOnlyMeshes;
  18479. /**
  18480. * Gets the only meshes impacted by this light.
  18481. */
  18482. get includedOnlyMeshes(): AbstractMesh[];
  18483. /**
  18484. * Sets the only meshes impacted by this light.
  18485. */
  18486. set includedOnlyMeshes(value: AbstractMesh[]);
  18487. private _excludedMeshes;
  18488. /**
  18489. * Gets the meshes not impacted by this light.
  18490. */
  18491. get excludedMeshes(): AbstractMesh[];
  18492. /**
  18493. * Sets the meshes not impacted by this light.
  18494. */
  18495. set excludedMeshes(value: AbstractMesh[]);
  18496. private _excludeWithLayerMask;
  18497. /**
  18498. * Gets the layer id use to find what meshes are not impacted by the light.
  18499. * Inactive if 0
  18500. */
  18501. get excludeWithLayerMask(): number;
  18502. /**
  18503. * Sets the layer id use to find what meshes are not impacted by the light.
  18504. * Inactive if 0
  18505. */
  18506. set excludeWithLayerMask(value: number);
  18507. private _includeOnlyWithLayerMask;
  18508. /**
  18509. * Gets the layer id use to find what meshes are impacted by the light.
  18510. * Inactive if 0
  18511. */
  18512. get includeOnlyWithLayerMask(): number;
  18513. /**
  18514. * Sets the layer id use to find what meshes are impacted by the light.
  18515. * Inactive if 0
  18516. */
  18517. set includeOnlyWithLayerMask(value: number);
  18518. private _lightmapMode;
  18519. /**
  18520. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18521. */
  18522. get lightmapMode(): number;
  18523. /**
  18524. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18525. */
  18526. set lightmapMode(value: number);
  18527. /**
  18528. * Shadow generator associted to the light.
  18529. * @hidden Internal use only.
  18530. */
  18531. _shadowGenerator: Nullable<IShadowGenerator>;
  18532. /**
  18533. * @hidden Internal use only.
  18534. */
  18535. _excludedMeshesIds: string[];
  18536. /**
  18537. * @hidden Internal use only.
  18538. */
  18539. _includedOnlyMeshesIds: string[];
  18540. /**
  18541. * The current light unifom buffer.
  18542. * @hidden Internal use only.
  18543. */
  18544. _uniformBuffer: UniformBuffer;
  18545. /** @hidden */
  18546. _renderId: number;
  18547. /**
  18548. * Creates a Light object in the scene.
  18549. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18550. * @param name The firendly name of the light
  18551. * @param scene The scene the light belongs too
  18552. */
  18553. constructor(name: string, scene: Scene);
  18554. protected abstract _buildUniformLayout(): void;
  18555. /**
  18556. * Sets the passed Effect "effect" with the Light information.
  18557. * @param effect The effect to update
  18558. * @param lightIndex The index of the light in the effect to update
  18559. * @returns The light
  18560. */
  18561. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18562. /**
  18563. * Sets the passed Effect "effect" with the Light textures.
  18564. * @param effect The effect to update
  18565. * @param lightIndex The index of the light in the effect to update
  18566. * @returns The light
  18567. */
  18568. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18569. /**
  18570. * Binds the lights information from the scene to the effect for the given mesh.
  18571. * @param lightIndex Light index
  18572. * @param scene The scene where the light belongs to
  18573. * @param effect The effect we are binding the data to
  18574. * @param useSpecular Defines if specular is supported
  18575. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18576. */
  18577. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18578. /**
  18579. * Sets the passed Effect "effect" with the Light information.
  18580. * @param effect The effect to update
  18581. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18582. * @returns The light
  18583. */
  18584. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18585. /**
  18586. * Returns the string "Light".
  18587. * @returns the class name
  18588. */
  18589. getClassName(): string;
  18590. /** @hidden */
  18591. readonly _isLight: boolean;
  18592. /**
  18593. * Converts the light information to a readable string for debug purpose.
  18594. * @param fullDetails Supports for multiple levels of logging within scene loading
  18595. * @returns the human readable light info
  18596. */
  18597. toString(fullDetails?: boolean): string;
  18598. /** @hidden */
  18599. protected _syncParentEnabledState(): void;
  18600. /**
  18601. * Set the enabled state of this node.
  18602. * @param value - the new enabled state
  18603. */
  18604. setEnabled(value: boolean): void;
  18605. /**
  18606. * Returns the Light associated shadow generator if any.
  18607. * @return the associated shadow generator.
  18608. */
  18609. getShadowGenerator(): Nullable<IShadowGenerator>;
  18610. /**
  18611. * Returns a Vector3, the absolute light position in the World.
  18612. * @returns the world space position of the light
  18613. */
  18614. getAbsolutePosition(): Vector3;
  18615. /**
  18616. * Specifies if the light will affect the passed mesh.
  18617. * @param mesh The mesh to test against the light
  18618. * @return true the mesh is affected otherwise, false.
  18619. */
  18620. canAffectMesh(mesh: AbstractMesh): boolean;
  18621. /**
  18622. * Sort function to order lights for rendering.
  18623. * @param a First Light object to compare to second.
  18624. * @param b Second Light object to compare first.
  18625. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18626. */
  18627. static CompareLightsPriority(a: Light, b: Light): number;
  18628. /**
  18629. * Releases resources associated with this node.
  18630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18632. */
  18633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18634. /**
  18635. * Returns the light type ID (integer).
  18636. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18637. */
  18638. getTypeID(): number;
  18639. /**
  18640. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18641. * @returns the scaled intensity in intensity mode unit
  18642. */
  18643. getScaledIntensity(): number;
  18644. /**
  18645. * Returns a new Light object, named "name", from the current one.
  18646. * @param name The name of the cloned light
  18647. * @param newParent The parent of this light, if it has one
  18648. * @returns the new created light
  18649. */
  18650. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18651. /**
  18652. * Serializes the current light into a Serialization object.
  18653. * @returns the serialized object.
  18654. */
  18655. serialize(): any;
  18656. /**
  18657. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18658. * This new light is named "name" and added to the passed scene.
  18659. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18660. * @param name The friendly name of the light
  18661. * @param scene The scene the new light will belong to
  18662. * @returns the constructor function
  18663. */
  18664. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18665. /**
  18666. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18667. * @param parsedLight The JSON representation of the light
  18668. * @param scene The scene to create the parsed light in
  18669. * @returns the created light after parsing
  18670. */
  18671. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18672. private _hookArrayForExcluded;
  18673. private _hookArrayForIncludedOnly;
  18674. private _resyncMeshes;
  18675. /**
  18676. * Forces the meshes to update their light related information in their rendering used effects
  18677. * @hidden Internal Use Only
  18678. */
  18679. _markMeshesAsLightDirty(): void;
  18680. /**
  18681. * Recomputes the cached photometric scale if needed.
  18682. */
  18683. private _computePhotometricScale;
  18684. /**
  18685. * Returns the Photometric Scale according to the light type and intensity mode.
  18686. */
  18687. private _getPhotometricScale;
  18688. /**
  18689. * Reorder the light in the scene according to their defined priority.
  18690. * @hidden Internal Use Only
  18691. */
  18692. _reorderLightsInScene(): void;
  18693. /**
  18694. * Prepares the list of defines specific to the light type.
  18695. * @param defines the list of defines
  18696. * @param lightIndex defines the index of the light for the effect
  18697. */
  18698. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18699. }
  18700. }
  18701. declare module "babylonjs/Cameras/targetCamera" {
  18702. import { Nullable } from "babylonjs/types";
  18703. import { Camera } from "babylonjs/Cameras/camera";
  18704. import { Scene } from "babylonjs/scene";
  18705. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18706. /**
  18707. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18708. * This is the base of the follow, arc rotate cameras and Free camera
  18709. * @see http://doc.babylonjs.com/features/cameras
  18710. */
  18711. export class TargetCamera extends Camera {
  18712. private static _RigCamTransformMatrix;
  18713. private static _TargetTransformMatrix;
  18714. private static _TargetFocalPoint;
  18715. /**
  18716. * Define the current direction the camera is moving to
  18717. */
  18718. cameraDirection: Vector3;
  18719. /**
  18720. * Define the current rotation the camera is rotating to
  18721. */
  18722. cameraRotation: Vector2;
  18723. /**
  18724. * When set, the up vector of the camera will be updated by the rotation of the camera
  18725. */
  18726. updateUpVectorFromRotation: boolean;
  18727. private _tmpQuaternion;
  18728. /**
  18729. * Define the current rotation of the camera
  18730. */
  18731. rotation: Vector3;
  18732. /**
  18733. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18734. */
  18735. rotationQuaternion: Quaternion;
  18736. /**
  18737. * Define the current speed of the camera
  18738. */
  18739. speed: number;
  18740. /**
  18741. * Add constraint to the camera to prevent it to move freely in all directions and
  18742. * around all axis.
  18743. */
  18744. noRotationConstraint: boolean;
  18745. /**
  18746. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18747. * panning
  18748. */
  18749. invertRotation: boolean;
  18750. /**
  18751. * Speed multiplier for inverse camera panning
  18752. */
  18753. inverseRotationSpeed: number;
  18754. /**
  18755. * Define the current target of the camera as an object or a position.
  18756. */
  18757. lockedTarget: any;
  18758. /** @hidden */
  18759. _currentTarget: Vector3;
  18760. /** @hidden */
  18761. _initialFocalDistance: number;
  18762. /** @hidden */
  18763. _viewMatrix: Matrix;
  18764. /** @hidden */
  18765. _camMatrix: Matrix;
  18766. /** @hidden */
  18767. _cameraTransformMatrix: Matrix;
  18768. /** @hidden */
  18769. _cameraRotationMatrix: Matrix;
  18770. /** @hidden */
  18771. _referencePoint: Vector3;
  18772. /** @hidden */
  18773. _transformedReferencePoint: Vector3;
  18774. protected _globalCurrentTarget: Vector3;
  18775. protected _globalCurrentUpVector: Vector3;
  18776. /** @hidden */
  18777. _reset: () => void;
  18778. private _defaultUp;
  18779. /**
  18780. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18781. * This is the base of the follow, arc rotate cameras and Free camera
  18782. * @see http://doc.babylonjs.com/features/cameras
  18783. * @param name Defines the name of the camera in the scene
  18784. * @param position Defines the start position of the camera in the scene
  18785. * @param scene Defines the scene the camera belongs to
  18786. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18787. */
  18788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18789. /**
  18790. * Gets the position in front of the camera at a given distance.
  18791. * @param distance The distance from the camera we want the position to be
  18792. * @returns the position
  18793. */
  18794. getFrontPosition(distance: number): Vector3;
  18795. /** @hidden */
  18796. _getLockedTargetPosition(): Nullable<Vector3>;
  18797. private _storedPosition;
  18798. private _storedRotation;
  18799. private _storedRotationQuaternion;
  18800. /**
  18801. * Store current camera state of the camera (fov, position, rotation, etc..)
  18802. * @returns the camera
  18803. */
  18804. storeState(): Camera;
  18805. /**
  18806. * Restored camera state. You must call storeState() first
  18807. * @returns whether it was successful or not
  18808. * @hidden
  18809. */
  18810. _restoreStateValues(): boolean;
  18811. /** @hidden */
  18812. _initCache(): void;
  18813. /** @hidden */
  18814. _updateCache(ignoreParentClass?: boolean): void;
  18815. /** @hidden */
  18816. _isSynchronizedViewMatrix(): boolean;
  18817. /** @hidden */
  18818. _computeLocalCameraSpeed(): number;
  18819. /**
  18820. * Defines the target the camera should look at.
  18821. * @param target Defines the new target as a Vector or a mesh
  18822. */
  18823. setTarget(target: Vector3): void;
  18824. /**
  18825. * Return the current target position of the camera. This value is expressed in local space.
  18826. * @returns the target position
  18827. */
  18828. getTarget(): Vector3;
  18829. /** @hidden */
  18830. _decideIfNeedsToMove(): boolean;
  18831. /** @hidden */
  18832. _updatePosition(): void;
  18833. /** @hidden */
  18834. _checkInputs(): void;
  18835. protected _updateCameraRotationMatrix(): void;
  18836. /**
  18837. * 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)
  18838. * @returns the current camera
  18839. */
  18840. private _rotateUpVectorWithCameraRotationMatrix;
  18841. private _cachedRotationZ;
  18842. private _cachedQuaternionRotationZ;
  18843. /** @hidden */
  18844. _getViewMatrix(): Matrix;
  18845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18846. /**
  18847. * @hidden
  18848. */
  18849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18850. /**
  18851. * @hidden
  18852. */
  18853. _updateRigCameras(): void;
  18854. private _getRigCamPositionAndTarget;
  18855. /**
  18856. * Gets the current object class name.
  18857. * @return the class name
  18858. */
  18859. getClassName(): string;
  18860. }
  18861. }
  18862. declare module "babylonjs/Events/keyboardEvents" {
  18863. /**
  18864. * Gather the list of keyboard event types as constants.
  18865. */
  18866. export class KeyboardEventTypes {
  18867. /**
  18868. * The keydown event is fired when a key becomes active (pressed).
  18869. */
  18870. static readonly KEYDOWN: number;
  18871. /**
  18872. * The keyup event is fired when a key has been released.
  18873. */
  18874. static readonly KEYUP: number;
  18875. }
  18876. /**
  18877. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18878. */
  18879. export class KeyboardInfo {
  18880. /**
  18881. * Defines the type of event (KeyboardEventTypes)
  18882. */
  18883. type: number;
  18884. /**
  18885. * Defines the related dom event
  18886. */
  18887. event: KeyboardEvent;
  18888. /**
  18889. * Instantiates a new keyboard info.
  18890. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18891. * @param type Defines the type of event (KeyboardEventTypes)
  18892. * @param event Defines the related dom event
  18893. */
  18894. constructor(
  18895. /**
  18896. * Defines the type of event (KeyboardEventTypes)
  18897. */
  18898. type: number,
  18899. /**
  18900. * Defines the related dom event
  18901. */
  18902. event: KeyboardEvent);
  18903. }
  18904. /**
  18905. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18906. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18907. */
  18908. export class KeyboardInfoPre extends KeyboardInfo {
  18909. /**
  18910. * Defines the type of event (KeyboardEventTypes)
  18911. */
  18912. type: number;
  18913. /**
  18914. * Defines the related dom event
  18915. */
  18916. event: KeyboardEvent;
  18917. /**
  18918. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18919. */
  18920. skipOnPointerObservable: boolean;
  18921. /**
  18922. * Instantiates a new keyboard pre info.
  18923. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18924. * @param type Defines the type of event (KeyboardEventTypes)
  18925. * @param event Defines the related dom event
  18926. */
  18927. constructor(
  18928. /**
  18929. * Defines the type of event (KeyboardEventTypes)
  18930. */
  18931. type: number,
  18932. /**
  18933. * Defines the related dom event
  18934. */
  18935. event: KeyboardEvent);
  18936. }
  18937. }
  18938. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18939. import { Nullable } from "babylonjs/types";
  18940. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18941. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18942. /**
  18943. * Manage the keyboard inputs to control the movement of a free camera.
  18944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18945. */
  18946. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18947. /**
  18948. * Defines the camera the input is attached to.
  18949. */
  18950. camera: FreeCamera;
  18951. /**
  18952. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18953. */
  18954. keysUp: number[];
  18955. /**
  18956. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18957. */
  18958. keysUpward: number[];
  18959. /**
  18960. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18961. */
  18962. keysDown: number[];
  18963. /**
  18964. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18965. */
  18966. keysDownward: number[];
  18967. /**
  18968. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18969. */
  18970. keysLeft: number[];
  18971. /**
  18972. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18973. */
  18974. keysRight: number[];
  18975. private _keys;
  18976. private _onCanvasBlurObserver;
  18977. private _onKeyboardObserver;
  18978. private _engine;
  18979. private _scene;
  18980. /**
  18981. * Attach the input controls to a specific dom element to get the input from.
  18982. * @param element Defines the element the controls should be listened from
  18983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18984. */
  18985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18986. /**
  18987. * Detach the current controls from the specified dom element.
  18988. * @param element Defines the element to stop listening the inputs from
  18989. */
  18990. detachControl(element: Nullable<HTMLElement>): void;
  18991. /**
  18992. * Update the current camera state depending on the inputs that have been used this frame.
  18993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18994. */
  18995. checkInputs(): void;
  18996. /**
  18997. * Gets the class name of the current intput.
  18998. * @returns the class name
  18999. */
  19000. getClassName(): string;
  19001. /** @hidden */
  19002. _onLostFocus(): void;
  19003. /**
  19004. * Get the friendly name associated with the input class.
  19005. * @returns the input friendly name
  19006. */
  19007. getSimpleName(): string;
  19008. }
  19009. }
  19010. declare module "babylonjs/Events/pointerEvents" {
  19011. import { Nullable } from "babylonjs/types";
  19012. import { Vector2 } from "babylonjs/Maths/math.vector";
  19013. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19014. import { Ray } from "babylonjs/Culling/ray";
  19015. /**
  19016. * Gather the list of pointer event types as constants.
  19017. */
  19018. export class PointerEventTypes {
  19019. /**
  19020. * 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.
  19021. */
  19022. static readonly POINTERDOWN: number;
  19023. /**
  19024. * The pointerup event is fired when a pointer is no longer active.
  19025. */
  19026. static readonly POINTERUP: number;
  19027. /**
  19028. * The pointermove event is fired when a pointer changes coordinates.
  19029. */
  19030. static readonly POINTERMOVE: number;
  19031. /**
  19032. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19033. */
  19034. static readonly POINTERWHEEL: number;
  19035. /**
  19036. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19037. */
  19038. static readonly POINTERPICK: number;
  19039. /**
  19040. * The pointertap event is fired when a the object has been touched and released without drag.
  19041. */
  19042. static readonly POINTERTAP: number;
  19043. /**
  19044. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19045. */
  19046. static readonly POINTERDOUBLETAP: number;
  19047. }
  19048. /**
  19049. * Base class of pointer info types.
  19050. */
  19051. export class PointerInfoBase {
  19052. /**
  19053. * Defines the type of event (PointerEventTypes)
  19054. */
  19055. type: number;
  19056. /**
  19057. * Defines the related dom event
  19058. */
  19059. event: PointerEvent | MouseWheelEvent;
  19060. /**
  19061. * Instantiates the base class of pointers info.
  19062. * @param type Defines the type of event (PointerEventTypes)
  19063. * @param event Defines the related dom event
  19064. */
  19065. constructor(
  19066. /**
  19067. * Defines the type of event (PointerEventTypes)
  19068. */
  19069. type: number,
  19070. /**
  19071. * Defines the related dom event
  19072. */
  19073. event: PointerEvent | MouseWheelEvent);
  19074. }
  19075. /**
  19076. * This class is used to store pointer related info for the onPrePointerObservable event.
  19077. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19078. */
  19079. export class PointerInfoPre extends PointerInfoBase {
  19080. /**
  19081. * Ray from a pointer if availible (eg. 6dof controller)
  19082. */
  19083. ray: Nullable<Ray>;
  19084. /**
  19085. * Defines the local position of the pointer on the canvas.
  19086. */
  19087. localPosition: Vector2;
  19088. /**
  19089. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19090. */
  19091. skipOnPointerObservable: boolean;
  19092. /**
  19093. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19094. * @param type Defines the type of event (PointerEventTypes)
  19095. * @param event Defines the related dom event
  19096. * @param localX Defines the local x coordinates of the pointer when the event occured
  19097. * @param localY Defines the local y coordinates of the pointer when the event occured
  19098. */
  19099. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19100. }
  19101. /**
  19102. * This type contains all the data related to a pointer event in Babylon.js.
  19103. * 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.
  19104. */
  19105. export class PointerInfo extends PointerInfoBase {
  19106. /**
  19107. * Defines the picking info associated to the info (if any)\
  19108. */
  19109. pickInfo: Nullable<PickingInfo>;
  19110. /**
  19111. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19112. * @param type Defines the type of event (PointerEventTypes)
  19113. * @param event Defines the related dom event
  19114. * @param pickInfo Defines the picking info associated to the info (if any)\
  19115. */
  19116. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19117. /**
  19118. * Defines the picking info associated to the info (if any)\
  19119. */
  19120. pickInfo: Nullable<PickingInfo>);
  19121. }
  19122. /**
  19123. * Data relating to a touch event on the screen.
  19124. */
  19125. export interface PointerTouch {
  19126. /**
  19127. * X coordinate of touch.
  19128. */
  19129. x: number;
  19130. /**
  19131. * Y coordinate of touch.
  19132. */
  19133. y: number;
  19134. /**
  19135. * Id of touch. Unique for each finger.
  19136. */
  19137. pointerId: number;
  19138. /**
  19139. * Event type passed from DOM.
  19140. */
  19141. type: any;
  19142. }
  19143. }
  19144. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19145. import { Observable } from "babylonjs/Misc/observable";
  19146. import { Nullable } from "babylonjs/types";
  19147. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19148. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19149. /**
  19150. * Manage the mouse inputs to control the movement of a free camera.
  19151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19152. */
  19153. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19154. /**
  19155. * Define if touch is enabled in the mouse input
  19156. */
  19157. touchEnabled: boolean;
  19158. /**
  19159. * Defines the camera the input is attached to.
  19160. */
  19161. camera: FreeCamera;
  19162. /**
  19163. * Defines the buttons associated with the input to handle camera move.
  19164. */
  19165. buttons: number[];
  19166. /**
  19167. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19168. */
  19169. angularSensibility: number;
  19170. private _pointerInput;
  19171. private _onMouseMove;
  19172. private _observer;
  19173. private previousPosition;
  19174. /**
  19175. * Observable for when a pointer move event occurs containing the move offset
  19176. */
  19177. onPointerMovedObservable: Observable<{
  19178. offsetX: number;
  19179. offsetY: number;
  19180. }>;
  19181. /**
  19182. * @hidden
  19183. * If the camera should be rotated automatically based on pointer movement
  19184. */
  19185. _allowCameraRotation: boolean;
  19186. /**
  19187. * Manage the mouse inputs to control the movement of a free camera.
  19188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19189. * @param touchEnabled Defines if touch is enabled or not
  19190. */
  19191. constructor(
  19192. /**
  19193. * Define if touch is enabled in the mouse input
  19194. */
  19195. touchEnabled?: boolean);
  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. * Called on JS contextmenu event.
  19204. * Override this method to provide functionality.
  19205. */
  19206. protected onContextMenu(evt: PointerEvent): void;
  19207. /**
  19208. * Detach the current controls from the specified dom element.
  19209. * @param element Defines the element to stop listening the inputs from
  19210. */
  19211. detachControl(element: Nullable<HTMLElement>): 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/Inputs/freeCameraTouchInput" {
  19225. import { Nullable } from "babylonjs/types";
  19226. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19227. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19228. /**
  19229. * Manage the touch inputs to control the movement of a free camera.
  19230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19231. */
  19232. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19233. /**
  19234. * Defines the camera the input is attached to.
  19235. */
  19236. camera: FreeCamera;
  19237. /**
  19238. * Defines the touch sensibility for rotation.
  19239. * The higher the faster.
  19240. */
  19241. touchAngularSensibility: number;
  19242. /**
  19243. * Defines the touch sensibility for move.
  19244. * The higher the faster.
  19245. */
  19246. touchMoveSensibility: number;
  19247. private _offsetX;
  19248. private _offsetY;
  19249. private _pointerPressed;
  19250. private _pointerInput;
  19251. private _observer;
  19252. private _onLostFocus;
  19253. /**
  19254. * Attach the input controls to a specific dom element to get the input from.
  19255. * @param element Defines the element the controls should be listened from
  19256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19257. */
  19258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19259. /**
  19260. * Detach the current controls from the specified dom element.
  19261. * @param element Defines the element to stop listening the inputs from
  19262. */
  19263. detachControl(element: Nullable<HTMLElement>): void;
  19264. /**
  19265. * Update the current camera state depending on the inputs that have been used this frame.
  19266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19267. */
  19268. checkInputs(): void;
  19269. /**
  19270. * Gets the class name of the current intput.
  19271. * @returns the class name
  19272. */
  19273. getClassName(): string;
  19274. /**
  19275. * Get the friendly name associated with the input class.
  19276. * @returns the input friendly name
  19277. */
  19278. getSimpleName(): string;
  19279. }
  19280. }
  19281. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19283. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19284. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19285. import { Nullable } from "babylonjs/types";
  19286. /**
  19287. * Default Inputs manager for the FreeCamera.
  19288. * It groups all the default supported inputs for ease of use.
  19289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19290. */
  19291. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19292. /**
  19293. * @hidden
  19294. */
  19295. _mouseInput: Nullable<FreeCameraMouseInput>;
  19296. /**
  19297. * Instantiates a new FreeCameraInputsManager.
  19298. * @param camera Defines the camera the inputs belong to
  19299. */
  19300. constructor(camera: FreeCamera);
  19301. /**
  19302. * Add keyboard input support to the input manager.
  19303. * @returns the current input manager
  19304. */
  19305. addKeyboard(): FreeCameraInputsManager;
  19306. /**
  19307. * Add mouse input support to the input manager.
  19308. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19309. * @returns the current input manager
  19310. */
  19311. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19312. /**
  19313. * Removes the mouse input support from the manager
  19314. * @returns the current input manager
  19315. */
  19316. removeMouse(): FreeCameraInputsManager;
  19317. /**
  19318. * Add touch input support to the input manager.
  19319. * @returns the current input manager
  19320. */
  19321. addTouch(): FreeCameraInputsManager;
  19322. /**
  19323. * Remove all attached input methods from a camera
  19324. */
  19325. clear(): void;
  19326. }
  19327. }
  19328. declare module "babylonjs/Cameras/freeCamera" {
  19329. import { Vector3 } from "babylonjs/Maths/math.vector";
  19330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19331. import { Scene } from "babylonjs/scene";
  19332. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19333. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19334. /**
  19335. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19336. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19338. */
  19339. export class FreeCamera extends TargetCamera {
  19340. /**
  19341. * Define the collision ellipsoid of the camera.
  19342. * This is helpful to simulate a camera body like the player body around the camera
  19343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19344. */
  19345. ellipsoid: Vector3;
  19346. /**
  19347. * Define an offset for the position of the ellipsoid around the camera.
  19348. * This can be helpful to determine the center of the body near the gravity center of the body
  19349. * instead of its head.
  19350. */
  19351. ellipsoidOffset: Vector3;
  19352. /**
  19353. * Enable or disable collisions of the camera with the rest of the scene objects.
  19354. */
  19355. checkCollisions: boolean;
  19356. /**
  19357. * Enable or disable gravity on the camera.
  19358. */
  19359. applyGravity: boolean;
  19360. /**
  19361. * Define the input manager associated to the camera.
  19362. */
  19363. inputs: FreeCameraInputsManager;
  19364. /**
  19365. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19366. * Higher values reduce sensitivity.
  19367. */
  19368. get angularSensibility(): number;
  19369. /**
  19370. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19371. * Higher values reduce sensitivity.
  19372. */
  19373. set angularSensibility(value: number);
  19374. /**
  19375. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19376. */
  19377. get keysUp(): number[];
  19378. set keysUp(value: number[]);
  19379. /**
  19380. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19381. */
  19382. get keysUpward(): number[];
  19383. set keysUpward(value: number[]);
  19384. /**
  19385. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19386. */
  19387. get keysDown(): number[];
  19388. set keysDown(value: number[]);
  19389. /**
  19390. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19391. */
  19392. get keysDownward(): number[];
  19393. set keysDownward(value: number[]);
  19394. /**
  19395. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19396. */
  19397. get keysLeft(): number[];
  19398. set keysLeft(value: number[]);
  19399. /**
  19400. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19401. */
  19402. get keysRight(): number[];
  19403. set keysRight(value: number[]);
  19404. /**
  19405. * Event raised when the camera collide with a mesh in the scene.
  19406. */
  19407. onCollide: (collidedMesh: AbstractMesh) => void;
  19408. private _collider;
  19409. private _needMoveForGravity;
  19410. private _oldPosition;
  19411. private _diffPosition;
  19412. private _newPosition;
  19413. /** @hidden */
  19414. _localDirection: Vector3;
  19415. /** @hidden */
  19416. _transformedDirection: Vector3;
  19417. /**
  19418. * Instantiates a Free Camera.
  19419. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19420. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19422. * @param name Define the name of the camera in the scene
  19423. * @param position Define the start position of the camera in the scene
  19424. * @param scene Define the scene the camera belongs to
  19425. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19426. */
  19427. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19428. /**
  19429. * Attached controls to the current camera.
  19430. * @param element Defines the element the controls should be listened from
  19431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19432. */
  19433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19434. /**
  19435. * Detach the current controls from the camera.
  19436. * The camera will stop reacting to inputs.
  19437. * @param element Defines the element to stop listening the inputs from
  19438. */
  19439. detachControl(element: HTMLElement): void;
  19440. private _collisionMask;
  19441. /**
  19442. * Define a collision mask to limit the list of object the camera can collide with
  19443. */
  19444. get collisionMask(): number;
  19445. set collisionMask(mask: number);
  19446. /** @hidden */
  19447. _collideWithWorld(displacement: Vector3): void;
  19448. private _onCollisionPositionChange;
  19449. /** @hidden */
  19450. _checkInputs(): void;
  19451. /** @hidden */
  19452. _decideIfNeedsToMove(): boolean;
  19453. /** @hidden */
  19454. _updatePosition(): void;
  19455. /**
  19456. * Destroy the camera and release the current resources hold by it.
  19457. */
  19458. dispose(): void;
  19459. /**
  19460. * Gets the current object class name.
  19461. * @return the class name
  19462. */
  19463. getClassName(): string;
  19464. }
  19465. }
  19466. declare module "babylonjs/Gamepads/gamepad" {
  19467. import { Observable } from "babylonjs/Misc/observable";
  19468. /**
  19469. * Represents a gamepad control stick position
  19470. */
  19471. export class StickValues {
  19472. /**
  19473. * The x component of the control stick
  19474. */
  19475. x: number;
  19476. /**
  19477. * The y component of the control stick
  19478. */
  19479. y: number;
  19480. /**
  19481. * Initializes the gamepad x and y control stick values
  19482. * @param x The x component of the gamepad control stick value
  19483. * @param y The y component of the gamepad control stick value
  19484. */
  19485. constructor(
  19486. /**
  19487. * The x component of the control stick
  19488. */
  19489. x: number,
  19490. /**
  19491. * The y component of the control stick
  19492. */
  19493. y: number);
  19494. }
  19495. /**
  19496. * An interface which manages callbacks for gamepad button changes
  19497. */
  19498. export interface GamepadButtonChanges {
  19499. /**
  19500. * Called when a gamepad has been changed
  19501. */
  19502. changed: boolean;
  19503. /**
  19504. * Called when a gamepad press event has been triggered
  19505. */
  19506. pressChanged: boolean;
  19507. /**
  19508. * Called when a touch event has been triggered
  19509. */
  19510. touchChanged: boolean;
  19511. /**
  19512. * Called when a value has changed
  19513. */
  19514. valueChanged: boolean;
  19515. }
  19516. /**
  19517. * Represents a gamepad
  19518. */
  19519. export class Gamepad {
  19520. /**
  19521. * The id of the gamepad
  19522. */
  19523. id: string;
  19524. /**
  19525. * The index of the gamepad
  19526. */
  19527. index: number;
  19528. /**
  19529. * The browser gamepad
  19530. */
  19531. browserGamepad: any;
  19532. /**
  19533. * Specifies what type of gamepad this represents
  19534. */
  19535. type: number;
  19536. private _leftStick;
  19537. private _rightStick;
  19538. /** @hidden */
  19539. _isConnected: boolean;
  19540. private _leftStickAxisX;
  19541. private _leftStickAxisY;
  19542. private _rightStickAxisX;
  19543. private _rightStickAxisY;
  19544. /**
  19545. * Triggered when the left control stick has been changed
  19546. */
  19547. private _onleftstickchanged;
  19548. /**
  19549. * Triggered when the right control stick has been changed
  19550. */
  19551. private _onrightstickchanged;
  19552. /**
  19553. * Represents a gamepad controller
  19554. */
  19555. static GAMEPAD: number;
  19556. /**
  19557. * Represents a generic controller
  19558. */
  19559. static GENERIC: number;
  19560. /**
  19561. * Represents an XBox controller
  19562. */
  19563. static XBOX: number;
  19564. /**
  19565. * Represents a pose-enabled controller
  19566. */
  19567. static POSE_ENABLED: number;
  19568. /**
  19569. * Represents an Dual Shock controller
  19570. */
  19571. static DUALSHOCK: number;
  19572. /**
  19573. * Specifies whether the left control stick should be Y-inverted
  19574. */
  19575. protected _invertLeftStickY: boolean;
  19576. /**
  19577. * Specifies if the gamepad has been connected
  19578. */
  19579. get isConnected(): boolean;
  19580. /**
  19581. * Initializes the gamepad
  19582. * @param id The id of the gamepad
  19583. * @param index The index of the gamepad
  19584. * @param browserGamepad The browser gamepad
  19585. * @param leftStickX The x component of the left joystick
  19586. * @param leftStickY The y component of the left joystick
  19587. * @param rightStickX The x component of the right joystick
  19588. * @param rightStickY The y component of the right joystick
  19589. */
  19590. constructor(
  19591. /**
  19592. * The id of the gamepad
  19593. */
  19594. id: string,
  19595. /**
  19596. * The index of the gamepad
  19597. */
  19598. index: number,
  19599. /**
  19600. * The browser gamepad
  19601. */
  19602. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19603. /**
  19604. * Callback triggered when the left joystick has changed
  19605. * @param callback
  19606. */
  19607. onleftstickchanged(callback: (values: StickValues) => void): void;
  19608. /**
  19609. * Callback triggered when the right joystick has changed
  19610. * @param callback
  19611. */
  19612. onrightstickchanged(callback: (values: StickValues) => void): void;
  19613. /**
  19614. * Gets the left joystick
  19615. */
  19616. get leftStick(): StickValues;
  19617. /**
  19618. * Sets the left joystick values
  19619. */
  19620. set leftStick(newValues: StickValues);
  19621. /**
  19622. * Gets the right joystick
  19623. */
  19624. get rightStick(): StickValues;
  19625. /**
  19626. * Sets the right joystick value
  19627. */
  19628. set rightStick(newValues: StickValues);
  19629. /**
  19630. * Updates the gamepad joystick positions
  19631. */
  19632. update(): void;
  19633. /**
  19634. * Disposes the gamepad
  19635. */
  19636. dispose(): void;
  19637. }
  19638. /**
  19639. * Represents a generic gamepad
  19640. */
  19641. export class GenericPad extends Gamepad {
  19642. private _buttons;
  19643. private _onbuttondown;
  19644. private _onbuttonup;
  19645. /**
  19646. * Observable triggered when a button has been pressed
  19647. */
  19648. onButtonDownObservable: Observable<number>;
  19649. /**
  19650. * Observable triggered when a button has been released
  19651. */
  19652. onButtonUpObservable: Observable<number>;
  19653. /**
  19654. * Callback triggered when a button has been pressed
  19655. * @param callback Called when a button has been pressed
  19656. */
  19657. onbuttondown(callback: (buttonPressed: number) => void): void;
  19658. /**
  19659. * Callback triggered when a button has been released
  19660. * @param callback Called when a button has been released
  19661. */
  19662. onbuttonup(callback: (buttonReleased: number) => void): void;
  19663. /**
  19664. * Initializes the generic gamepad
  19665. * @param id The id of the generic gamepad
  19666. * @param index The index of the generic gamepad
  19667. * @param browserGamepad The browser gamepad
  19668. */
  19669. constructor(id: string, index: number, browserGamepad: any);
  19670. private _setButtonValue;
  19671. /**
  19672. * Updates the generic gamepad
  19673. */
  19674. update(): void;
  19675. /**
  19676. * Disposes the generic gamepad
  19677. */
  19678. dispose(): void;
  19679. }
  19680. }
  19681. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19682. import { Observable } from "babylonjs/Misc/observable";
  19683. import { Nullable } from "babylonjs/types";
  19684. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19687. import { Ray } from "babylonjs/Culling/ray";
  19688. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19689. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19690. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19691. /**
  19692. * Defines the types of pose enabled controllers that are supported
  19693. */
  19694. export enum PoseEnabledControllerType {
  19695. /**
  19696. * HTC Vive
  19697. */
  19698. VIVE = 0,
  19699. /**
  19700. * Oculus Rift
  19701. */
  19702. OCULUS = 1,
  19703. /**
  19704. * Windows mixed reality
  19705. */
  19706. WINDOWS = 2,
  19707. /**
  19708. * Samsung gear VR
  19709. */
  19710. GEAR_VR = 3,
  19711. /**
  19712. * Google Daydream
  19713. */
  19714. DAYDREAM = 4,
  19715. /**
  19716. * Generic
  19717. */
  19718. GENERIC = 5
  19719. }
  19720. /**
  19721. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19722. */
  19723. export interface MutableGamepadButton {
  19724. /**
  19725. * Value of the button/trigger
  19726. */
  19727. value: number;
  19728. /**
  19729. * If the button/trigger is currently touched
  19730. */
  19731. touched: boolean;
  19732. /**
  19733. * If the button/trigger is currently pressed
  19734. */
  19735. pressed: boolean;
  19736. }
  19737. /**
  19738. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19739. * @hidden
  19740. */
  19741. export interface ExtendedGamepadButton extends GamepadButton {
  19742. /**
  19743. * If the button/trigger is currently pressed
  19744. */
  19745. readonly pressed: boolean;
  19746. /**
  19747. * If the button/trigger is currently touched
  19748. */
  19749. readonly touched: boolean;
  19750. /**
  19751. * Value of the button/trigger
  19752. */
  19753. readonly value: number;
  19754. }
  19755. /** @hidden */
  19756. export interface _GamePadFactory {
  19757. /**
  19758. * Returns whether or not the current gamepad can be created for this type of controller.
  19759. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19760. * @returns true if it can be created, otherwise false
  19761. */
  19762. canCreate(gamepadInfo: any): boolean;
  19763. /**
  19764. * Creates a new instance of the Gamepad.
  19765. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19766. * @returns the new gamepad instance
  19767. */
  19768. create(gamepadInfo: any): Gamepad;
  19769. }
  19770. /**
  19771. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19772. */
  19773. export class PoseEnabledControllerHelper {
  19774. /** @hidden */
  19775. static _ControllerFactories: _GamePadFactory[];
  19776. /** @hidden */
  19777. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19778. /**
  19779. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19780. * @param vrGamepad the gamepad to initialized
  19781. * @returns a vr controller of the type the gamepad identified as
  19782. */
  19783. static InitiateController(vrGamepad: any): Gamepad;
  19784. }
  19785. /**
  19786. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19787. */
  19788. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19789. /**
  19790. * If the controller is used in a webXR session
  19791. */
  19792. isXR: boolean;
  19793. private _deviceRoomPosition;
  19794. private _deviceRoomRotationQuaternion;
  19795. /**
  19796. * The device position in babylon space
  19797. */
  19798. devicePosition: Vector3;
  19799. /**
  19800. * The device rotation in babylon space
  19801. */
  19802. deviceRotationQuaternion: Quaternion;
  19803. /**
  19804. * The scale factor of the device in babylon space
  19805. */
  19806. deviceScaleFactor: number;
  19807. /**
  19808. * (Likely devicePosition should be used instead) The device position in its room space
  19809. */
  19810. position: Vector3;
  19811. /**
  19812. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19813. */
  19814. rotationQuaternion: Quaternion;
  19815. /**
  19816. * The type of controller (Eg. Windows mixed reality)
  19817. */
  19818. controllerType: PoseEnabledControllerType;
  19819. protected _calculatedPosition: Vector3;
  19820. private _calculatedRotation;
  19821. /**
  19822. * The raw pose from the device
  19823. */
  19824. rawPose: DevicePose;
  19825. private _trackPosition;
  19826. private _maxRotationDistFromHeadset;
  19827. private _draggedRoomRotation;
  19828. /**
  19829. * @hidden
  19830. */
  19831. _disableTrackPosition(fixedPosition: Vector3): void;
  19832. /**
  19833. * Internal, the mesh attached to the controller
  19834. * @hidden
  19835. */
  19836. _mesh: Nullable<AbstractMesh>;
  19837. private _poseControlledCamera;
  19838. private _leftHandSystemQuaternion;
  19839. /**
  19840. * Internal, matrix used to convert room space to babylon space
  19841. * @hidden
  19842. */
  19843. _deviceToWorld: Matrix;
  19844. /**
  19845. * Node to be used when casting a ray from the controller
  19846. * @hidden
  19847. */
  19848. _pointingPoseNode: Nullable<TransformNode>;
  19849. /**
  19850. * Name of the child mesh that can be used to cast a ray from the controller
  19851. */
  19852. static readonly POINTING_POSE: string;
  19853. /**
  19854. * Creates a new PoseEnabledController from a gamepad
  19855. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19856. */
  19857. constructor(browserGamepad: any);
  19858. private _workingMatrix;
  19859. /**
  19860. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19861. */
  19862. update(): void;
  19863. /**
  19864. * Updates only the pose device and mesh without doing any button event checking
  19865. */
  19866. protected _updatePoseAndMesh(): void;
  19867. /**
  19868. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19869. * @param poseData raw pose fromthe device
  19870. */
  19871. updateFromDevice(poseData: DevicePose): void;
  19872. /**
  19873. * @hidden
  19874. */
  19875. _meshAttachedObservable: Observable<AbstractMesh>;
  19876. /**
  19877. * Attaches a mesh to the controller
  19878. * @param mesh the mesh to be attached
  19879. */
  19880. attachToMesh(mesh: AbstractMesh): void;
  19881. /**
  19882. * Attaches the controllers mesh to a camera
  19883. * @param camera the camera the mesh should be attached to
  19884. */
  19885. attachToPoseControlledCamera(camera: TargetCamera): void;
  19886. /**
  19887. * Disposes of the controller
  19888. */
  19889. dispose(): void;
  19890. /**
  19891. * The mesh that is attached to the controller
  19892. */
  19893. get mesh(): Nullable<AbstractMesh>;
  19894. /**
  19895. * Gets the ray of the controller in the direction the controller is pointing
  19896. * @param length the length the resulting ray should be
  19897. * @returns a ray in the direction the controller is pointing
  19898. */
  19899. getForwardRay(length?: number): Ray;
  19900. }
  19901. }
  19902. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19903. import { Observable } from "babylonjs/Misc/observable";
  19904. import { Scene } from "babylonjs/scene";
  19905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19906. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19907. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19908. import { Nullable } from "babylonjs/types";
  19909. /**
  19910. * Defines the WebVRController object that represents controllers tracked in 3D space
  19911. */
  19912. export abstract class WebVRController extends PoseEnabledController {
  19913. /**
  19914. * Internal, the default controller model for the controller
  19915. */
  19916. protected _defaultModel: Nullable<AbstractMesh>;
  19917. /**
  19918. * Fired when the trigger state has changed
  19919. */
  19920. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19921. /**
  19922. * Fired when the main button state has changed
  19923. */
  19924. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19925. /**
  19926. * Fired when the secondary button state has changed
  19927. */
  19928. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19929. /**
  19930. * Fired when the pad state has changed
  19931. */
  19932. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19933. /**
  19934. * Fired when controllers stick values have changed
  19935. */
  19936. onPadValuesChangedObservable: Observable<StickValues>;
  19937. /**
  19938. * Array of button availible on the controller
  19939. */
  19940. protected _buttons: Array<MutableGamepadButton>;
  19941. private _onButtonStateChange;
  19942. /**
  19943. * Fired when a controller button's state has changed
  19944. * @param callback the callback containing the button that was modified
  19945. */
  19946. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19947. /**
  19948. * X and Y axis corresponding to the controllers joystick
  19949. */
  19950. pad: StickValues;
  19951. /**
  19952. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19953. */
  19954. hand: string;
  19955. /**
  19956. * The default controller model for the controller
  19957. */
  19958. get defaultModel(): Nullable<AbstractMesh>;
  19959. /**
  19960. * Creates a new WebVRController from a gamepad
  19961. * @param vrGamepad the gamepad that the WebVRController should be created from
  19962. */
  19963. constructor(vrGamepad: any);
  19964. /**
  19965. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19966. */
  19967. update(): void;
  19968. /**
  19969. * Function to be called when a button is modified
  19970. */
  19971. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19972. /**
  19973. * Loads a mesh and attaches it to the controller
  19974. * @param scene the scene the mesh should be added to
  19975. * @param meshLoaded callback for when the mesh has been loaded
  19976. */
  19977. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19978. private _setButtonValue;
  19979. private _changes;
  19980. private _checkChanges;
  19981. /**
  19982. * Disposes of th webVRCOntroller
  19983. */
  19984. dispose(): void;
  19985. }
  19986. }
  19987. declare module "babylonjs/Lights/hemisphericLight" {
  19988. import { Nullable } from "babylonjs/types";
  19989. import { Scene } from "babylonjs/scene";
  19990. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19991. import { Color3 } from "babylonjs/Maths/math.color";
  19992. import { Effect } from "babylonjs/Materials/effect";
  19993. import { Light } from "babylonjs/Lights/light";
  19994. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19995. /**
  19996. * The HemisphericLight simulates the ambient environment light,
  19997. * so the passed direction is the light reflection direction, not the incoming direction.
  19998. */
  19999. export class HemisphericLight extends Light {
  20000. /**
  20001. * The groundColor is the light in the opposite direction to the one specified during creation.
  20002. * 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.
  20003. */
  20004. groundColor: Color3;
  20005. /**
  20006. * The light reflection direction, not the incoming direction.
  20007. */
  20008. direction: Vector3;
  20009. /**
  20010. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20011. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20012. * The HemisphericLight can't cast shadows.
  20013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20014. * @param name The friendly name of the light
  20015. * @param direction The direction of the light reflection
  20016. * @param scene The scene the light belongs to
  20017. */
  20018. constructor(name: string, direction: Vector3, scene: Scene);
  20019. protected _buildUniformLayout(): void;
  20020. /**
  20021. * Returns the string "HemisphericLight".
  20022. * @return The class name
  20023. */
  20024. getClassName(): string;
  20025. /**
  20026. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20027. * Returns the updated direction.
  20028. * @param target The target the direction should point to
  20029. * @return The computed direction
  20030. */
  20031. setDirectionToTarget(target: Vector3): Vector3;
  20032. /**
  20033. * Returns the shadow generator associated to the light.
  20034. * @returns Always null for hemispheric lights because it does not support shadows.
  20035. */
  20036. getShadowGenerator(): Nullable<IShadowGenerator>;
  20037. /**
  20038. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20039. * @param effect The effect to update
  20040. * @param lightIndex The index of the light in the effect to update
  20041. * @returns The hemispheric light
  20042. */
  20043. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20044. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20045. /**
  20046. * Computes the world matrix of the node
  20047. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20048. * @param useWasUpdatedFlag defines a reserved property
  20049. * @returns the world matrix
  20050. */
  20051. computeWorldMatrix(): Matrix;
  20052. /**
  20053. * Returns the integer 3.
  20054. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20055. */
  20056. getTypeID(): number;
  20057. /**
  20058. * Prepares the list of defines specific to the light type.
  20059. * @param defines the list of defines
  20060. * @param lightIndex defines the index of the light for the effect
  20061. */
  20062. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20063. }
  20064. }
  20065. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20066. /** @hidden */
  20067. export var vrMultiviewToSingleviewPixelShader: {
  20068. name: string;
  20069. shader: string;
  20070. };
  20071. }
  20072. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20074. import { Scene } from "babylonjs/scene";
  20075. /**
  20076. * Renders to multiple views with a single draw call
  20077. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20078. */
  20079. export class MultiviewRenderTarget extends RenderTargetTexture {
  20080. /**
  20081. * Creates a multiview render target
  20082. * @param scene scene used with the render target
  20083. * @param size the size of the render target (used for each view)
  20084. */
  20085. constructor(scene: Scene, size?: number | {
  20086. width: number;
  20087. height: number;
  20088. } | {
  20089. ratio: number;
  20090. });
  20091. /**
  20092. * @hidden
  20093. * @param faceIndex the face index, if its a cube texture
  20094. */
  20095. _bindFrameBuffer(faceIndex?: number): void;
  20096. /**
  20097. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20098. * @returns the view count
  20099. */
  20100. getViewCount(): number;
  20101. }
  20102. }
  20103. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20104. import { Camera } from "babylonjs/Cameras/camera";
  20105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20106. import { Nullable } from "babylonjs/types";
  20107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20108. import { Matrix } from "babylonjs/Maths/math.vector";
  20109. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20110. module "babylonjs/Engines/engine" {
  20111. interface Engine {
  20112. /**
  20113. * Creates a new multiview render target
  20114. * @param width defines the width of the texture
  20115. * @param height defines the height of the texture
  20116. * @returns the created multiview texture
  20117. */
  20118. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20119. /**
  20120. * Binds a multiview framebuffer to be drawn to
  20121. * @param multiviewTexture texture to bind
  20122. */
  20123. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20124. }
  20125. }
  20126. module "babylonjs/Cameras/camera" {
  20127. interface Camera {
  20128. /**
  20129. * @hidden
  20130. * 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)
  20131. */
  20132. _useMultiviewToSingleView: boolean;
  20133. /**
  20134. * @hidden
  20135. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  20136. */
  20137. _multiviewTexture: Nullable<RenderTargetTexture>;
  20138. /**
  20139. * @hidden
  20140. * ensures the multiview texture of the camera exists and has the specified width/height
  20141. * @param width height to set on the multiview texture
  20142. * @param height width to set on the multiview texture
  20143. */
  20144. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20145. }
  20146. }
  20147. module "babylonjs/scene" {
  20148. interface Scene {
  20149. /** @hidden */
  20150. _transformMatrixR: Matrix;
  20151. /** @hidden */
  20152. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20153. /** @hidden */
  20154. _createMultiviewUbo(): void;
  20155. /** @hidden */
  20156. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20157. /** @hidden */
  20158. _renderMultiviewToSingleView(camera: Camera): void;
  20159. }
  20160. }
  20161. }
  20162. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20163. import { Camera } from "babylonjs/Cameras/camera";
  20164. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20165. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20166. import "babylonjs/Engines/Extensions/engine.multiview";
  20167. /**
  20168. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20169. * This will not be used for webXR as it supports displaying texture arrays directly
  20170. */
  20171. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20172. /**
  20173. * Initializes a VRMultiviewToSingleview
  20174. * @param name name of the post process
  20175. * @param camera camera to be applied to
  20176. * @param scaleFactor scaling factor to the size of the output texture
  20177. */
  20178. constructor(name: string, camera: Camera, scaleFactor: number);
  20179. }
  20180. }
  20181. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20182. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20183. import { Nullable } from "babylonjs/types";
  20184. import { Size } from "babylonjs/Maths/math.size";
  20185. import { Observable } from "babylonjs/Misc/observable";
  20186. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20187. /**
  20188. * Interface used to define additional presentation attributes
  20189. */
  20190. export interface IVRPresentationAttributes {
  20191. /**
  20192. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20193. */
  20194. highRefreshRate: boolean;
  20195. /**
  20196. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20197. */
  20198. foveationLevel: number;
  20199. }
  20200. module "babylonjs/Engines/engine" {
  20201. interface Engine {
  20202. /** @hidden */
  20203. _vrDisplay: any;
  20204. /** @hidden */
  20205. _vrSupported: boolean;
  20206. /** @hidden */
  20207. _oldSize: Size;
  20208. /** @hidden */
  20209. _oldHardwareScaleFactor: number;
  20210. /** @hidden */
  20211. _vrExclusivePointerMode: boolean;
  20212. /** @hidden */
  20213. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20214. /** @hidden */
  20215. _onVRDisplayPointerRestricted: () => void;
  20216. /** @hidden */
  20217. _onVRDisplayPointerUnrestricted: () => void;
  20218. /** @hidden */
  20219. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20220. /** @hidden */
  20221. _onVrDisplayDisconnect: Nullable<() => void>;
  20222. /** @hidden */
  20223. _onVrDisplayPresentChange: Nullable<() => void>;
  20224. /**
  20225. * Observable signaled when VR display mode changes
  20226. */
  20227. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20228. /**
  20229. * Observable signaled when VR request present is complete
  20230. */
  20231. onVRRequestPresentComplete: Observable<boolean>;
  20232. /**
  20233. * Observable signaled when VR request present starts
  20234. */
  20235. onVRRequestPresentStart: Observable<Engine>;
  20236. /**
  20237. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20238. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20239. */
  20240. isInVRExclusivePointerMode: boolean;
  20241. /**
  20242. * Gets a boolean indicating if a webVR device was detected
  20243. * @returns true if a webVR device was detected
  20244. */
  20245. isVRDevicePresent(): boolean;
  20246. /**
  20247. * Gets the current webVR device
  20248. * @returns the current webVR device (or null)
  20249. */
  20250. getVRDevice(): any;
  20251. /**
  20252. * Initializes a webVR display and starts listening to display change events
  20253. * The onVRDisplayChangedObservable will be notified upon these changes
  20254. * @returns A promise containing a VRDisplay and if vr is supported
  20255. */
  20256. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20257. /** @hidden */
  20258. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20259. /**
  20260. * Gets or sets the presentation attributes used to configure VR rendering
  20261. */
  20262. vrPresentationAttributes?: IVRPresentationAttributes;
  20263. /**
  20264. * Call this function to switch to webVR mode
  20265. * Will do nothing if webVR is not supported or if there is no webVR device
  20266. * @param options the webvr options provided to the camera. mainly used for multiview
  20267. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20268. */
  20269. enableVR(options: WebVROptions): void;
  20270. /** @hidden */
  20271. _onVRFullScreenTriggered(): void;
  20272. }
  20273. }
  20274. }
  20275. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20276. import { Nullable } from "babylonjs/types";
  20277. import { Observable } from "babylonjs/Misc/observable";
  20278. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20279. import { Scene } from "babylonjs/scene";
  20280. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20281. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20282. import { Node } from "babylonjs/node";
  20283. import { Ray } from "babylonjs/Culling/ray";
  20284. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20285. import "babylonjs/Engines/Extensions/engine.webVR";
  20286. /**
  20287. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20288. * IMPORTANT!! The data is right-hand data.
  20289. * @export
  20290. * @interface DevicePose
  20291. */
  20292. export interface DevicePose {
  20293. /**
  20294. * The position of the device, values in array are [x,y,z].
  20295. */
  20296. readonly position: Nullable<Float32Array>;
  20297. /**
  20298. * The linearVelocity of the device, values in array are [x,y,z].
  20299. */
  20300. readonly linearVelocity: Nullable<Float32Array>;
  20301. /**
  20302. * The linearAcceleration of the device, values in array are [x,y,z].
  20303. */
  20304. readonly linearAcceleration: Nullable<Float32Array>;
  20305. /**
  20306. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20307. */
  20308. readonly orientation: Nullable<Float32Array>;
  20309. /**
  20310. * The angularVelocity of the device, values in array are [x,y,z].
  20311. */
  20312. readonly angularVelocity: Nullable<Float32Array>;
  20313. /**
  20314. * The angularAcceleration of the device, values in array are [x,y,z].
  20315. */
  20316. readonly angularAcceleration: Nullable<Float32Array>;
  20317. }
  20318. /**
  20319. * Interface representing a pose controlled object in Babylon.
  20320. * A pose controlled object has both regular pose values as well as pose values
  20321. * from an external device such as a VR head mounted display
  20322. */
  20323. export interface PoseControlled {
  20324. /**
  20325. * The position of the object in babylon space.
  20326. */
  20327. position: Vector3;
  20328. /**
  20329. * The rotation quaternion of the object in babylon space.
  20330. */
  20331. rotationQuaternion: Quaternion;
  20332. /**
  20333. * The position of the device in babylon space.
  20334. */
  20335. devicePosition?: Vector3;
  20336. /**
  20337. * The rotation quaternion of the device in babylon space.
  20338. */
  20339. deviceRotationQuaternion: Quaternion;
  20340. /**
  20341. * The raw pose coming from the device.
  20342. */
  20343. rawPose: Nullable<DevicePose>;
  20344. /**
  20345. * The scale of the device to be used when translating from device space to babylon space.
  20346. */
  20347. deviceScaleFactor: number;
  20348. /**
  20349. * Updates the poseControlled values based on the input device pose.
  20350. * @param poseData the pose data to update the object with
  20351. */
  20352. updateFromDevice(poseData: DevicePose): void;
  20353. }
  20354. /**
  20355. * Set of options to customize the webVRCamera
  20356. */
  20357. export interface WebVROptions {
  20358. /**
  20359. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20360. */
  20361. trackPosition?: boolean;
  20362. /**
  20363. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20364. */
  20365. positionScale?: number;
  20366. /**
  20367. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20368. */
  20369. displayName?: string;
  20370. /**
  20371. * Should the native controller meshes be initialized. (default: true)
  20372. */
  20373. controllerMeshes?: boolean;
  20374. /**
  20375. * Creating a default HemiLight only on controllers. (default: true)
  20376. */
  20377. defaultLightingOnControllers?: boolean;
  20378. /**
  20379. * If you don't want to use the default VR button of the helper. (default: false)
  20380. */
  20381. useCustomVRButton?: boolean;
  20382. /**
  20383. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20384. */
  20385. customVRButton?: HTMLButtonElement;
  20386. /**
  20387. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20388. */
  20389. rayLength?: number;
  20390. /**
  20391. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20392. */
  20393. defaultHeight?: number;
  20394. /**
  20395. * If multiview should be used if availible (default: false)
  20396. */
  20397. useMultiview?: boolean;
  20398. }
  20399. /**
  20400. * This represents a WebVR camera.
  20401. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20402. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20403. */
  20404. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20405. private webVROptions;
  20406. /**
  20407. * @hidden
  20408. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20409. */
  20410. _vrDevice: any;
  20411. /**
  20412. * The rawPose of the vrDevice.
  20413. */
  20414. rawPose: Nullable<DevicePose>;
  20415. private _onVREnabled;
  20416. private _specsVersion;
  20417. private _attached;
  20418. private _frameData;
  20419. protected _descendants: Array<Node>;
  20420. private _deviceRoomPosition;
  20421. /** @hidden */
  20422. _deviceRoomRotationQuaternion: Quaternion;
  20423. private _standingMatrix;
  20424. /**
  20425. * Represents device position in babylon space.
  20426. */
  20427. devicePosition: Vector3;
  20428. /**
  20429. * Represents device rotation in babylon space.
  20430. */
  20431. deviceRotationQuaternion: Quaternion;
  20432. /**
  20433. * The scale of the device to be used when translating from device space to babylon space.
  20434. */
  20435. deviceScaleFactor: number;
  20436. private _deviceToWorld;
  20437. private _worldToDevice;
  20438. /**
  20439. * References to the webVR controllers for the vrDevice.
  20440. */
  20441. controllers: Array<WebVRController>;
  20442. /**
  20443. * Emits an event when a controller is attached.
  20444. */
  20445. onControllersAttachedObservable: Observable<WebVRController[]>;
  20446. /**
  20447. * Emits an event when a controller's mesh has been loaded;
  20448. */
  20449. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20450. /**
  20451. * Emits an event when the HMD's pose has been updated.
  20452. */
  20453. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20454. private _poseSet;
  20455. /**
  20456. * If the rig cameras be used as parent instead of this camera.
  20457. */
  20458. rigParenting: boolean;
  20459. private _lightOnControllers;
  20460. private _defaultHeight?;
  20461. /**
  20462. * Instantiates a WebVRFreeCamera.
  20463. * @param name The name of the WebVRFreeCamera
  20464. * @param position The starting anchor position for the camera
  20465. * @param scene The scene the camera belongs to
  20466. * @param webVROptions a set of customizable options for the webVRCamera
  20467. */
  20468. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20469. /**
  20470. * Gets the device distance from the ground in meters.
  20471. * @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.
  20472. */
  20473. deviceDistanceToRoomGround(): number;
  20474. /**
  20475. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20476. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20477. */
  20478. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20479. /**
  20480. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20481. * @returns A promise with a boolean set to if the standing matrix is supported.
  20482. */
  20483. useStandingMatrixAsync(): Promise<boolean>;
  20484. /**
  20485. * Disposes the camera
  20486. */
  20487. dispose(): void;
  20488. /**
  20489. * Gets a vrController by name.
  20490. * @param name The name of the controller to retreive
  20491. * @returns the controller matching the name specified or null if not found
  20492. */
  20493. getControllerByName(name: string): Nullable<WebVRController>;
  20494. private _leftController;
  20495. /**
  20496. * The controller corresponding to the users left hand.
  20497. */
  20498. get leftController(): Nullable<WebVRController>;
  20499. private _rightController;
  20500. /**
  20501. * The controller corresponding to the users right hand.
  20502. */
  20503. get rightController(): Nullable<WebVRController>;
  20504. /**
  20505. * Casts a ray forward from the vrCamera's gaze.
  20506. * @param length Length of the ray (default: 100)
  20507. * @returns the ray corresponding to the gaze
  20508. */
  20509. getForwardRay(length?: number): Ray;
  20510. /**
  20511. * @hidden
  20512. * Updates the camera based on device's frame data
  20513. */
  20514. _checkInputs(): void;
  20515. /**
  20516. * Updates the poseControlled values based on the input device pose.
  20517. * @param poseData Pose coming from the device
  20518. */
  20519. updateFromDevice(poseData: DevicePose): void;
  20520. private _htmlElementAttached;
  20521. private _detachIfAttached;
  20522. /**
  20523. * WebVR's attach control will start broadcasting frames to the device.
  20524. * Note that in certain browsers (chrome for example) this function must be called
  20525. * within a user-interaction callback. Example:
  20526. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20527. *
  20528. * @param element html element to attach the vrDevice to
  20529. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20530. */
  20531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20532. /**
  20533. * Detaches the camera from the html element and disables VR
  20534. *
  20535. * @param element html element to detach from
  20536. */
  20537. detachControl(element: HTMLElement): void;
  20538. /**
  20539. * @returns the name of this class
  20540. */
  20541. getClassName(): string;
  20542. /**
  20543. * Calls resetPose on the vrDisplay
  20544. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20545. */
  20546. resetToCurrentRotation(): void;
  20547. /**
  20548. * @hidden
  20549. * Updates the rig cameras (left and right eye)
  20550. */
  20551. _updateRigCameras(): void;
  20552. private _workingVector;
  20553. private _oneVector;
  20554. private _workingMatrix;
  20555. private updateCacheCalled;
  20556. private _correctPositionIfNotTrackPosition;
  20557. /**
  20558. * @hidden
  20559. * Updates the cached values of the camera
  20560. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20561. */
  20562. _updateCache(ignoreParentClass?: boolean): void;
  20563. /**
  20564. * @hidden
  20565. * Get current device position in babylon world
  20566. */
  20567. _computeDevicePosition(): void;
  20568. /**
  20569. * Updates the current device position and rotation in the babylon world
  20570. */
  20571. update(): void;
  20572. /**
  20573. * @hidden
  20574. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20575. * @returns an identity matrix
  20576. */
  20577. _getViewMatrix(): Matrix;
  20578. private _tmpMatrix;
  20579. /**
  20580. * This function is called by the two RIG cameras.
  20581. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20582. * @hidden
  20583. */
  20584. _getWebVRViewMatrix(): Matrix;
  20585. /** @hidden */
  20586. _getWebVRProjectionMatrix(): Matrix;
  20587. private _onGamepadConnectedObserver;
  20588. private _onGamepadDisconnectedObserver;
  20589. private _updateCacheWhenTrackingDisabledObserver;
  20590. /**
  20591. * Initializes the controllers and their meshes
  20592. */
  20593. initControllers(): void;
  20594. }
  20595. }
  20596. declare module "babylonjs/Materials/materialHelper" {
  20597. import { Nullable } from "babylonjs/types";
  20598. import { Scene } from "babylonjs/scene";
  20599. import { Engine } from "babylonjs/Engines/engine";
  20600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20601. import { Light } from "babylonjs/Lights/light";
  20602. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20603. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20605. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20606. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20607. /**
  20608. * "Static Class" containing the most commonly used helper while dealing with material for
  20609. * rendering purpose.
  20610. *
  20611. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20612. *
  20613. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20614. */
  20615. export class MaterialHelper {
  20616. /**
  20617. * Bind the current view position to an effect.
  20618. * @param effect The effect to be bound
  20619. * @param scene The scene the eyes position is used from
  20620. * @param variableName name of the shader variable that will hold the eye position
  20621. */
  20622. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20623. /**
  20624. * Helps preparing the defines values about the UVs in used in the effect.
  20625. * UVs are shared as much as we can accross channels in the shaders.
  20626. * @param texture The texture we are preparing the UVs for
  20627. * @param defines The defines to update
  20628. * @param key The channel key "diffuse", "specular"... used in the shader
  20629. */
  20630. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20631. /**
  20632. * Binds a texture matrix value to its corrsponding uniform
  20633. * @param texture The texture to bind the matrix for
  20634. * @param uniformBuffer The uniform buffer receivin the data
  20635. * @param key The channel key "diffuse", "specular"... used in the shader
  20636. */
  20637. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20638. /**
  20639. * Gets the current status of the fog (should it be enabled?)
  20640. * @param mesh defines the mesh to evaluate for fog support
  20641. * @param scene defines the hosting scene
  20642. * @returns true if fog must be enabled
  20643. */
  20644. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20645. /**
  20646. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20647. * @param mesh defines the current mesh
  20648. * @param scene defines the current scene
  20649. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20650. * @param pointsCloud defines if point cloud rendering has to be turned on
  20651. * @param fogEnabled defines if fog has to be turned on
  20652. * @param alphaTest defines if alpha testing has to be turned on
  20653. * @param defines defines the current list of defines
  20654. */
  20655. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20656. /**
  20657. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20658. * @param scene defines the current scene
  20659. * @param engine defines the current engine
  20660. * @param defines specifies the list of active defines
  20661. * @param useInstances defines if instances have to be turned on
  20662. * @param useClipPlane defines if clip plane have to be turned on
  20663. * @param useInstances defines if instances have to be turned on
  20664. * @param useThinInstances defines if thin instances have to be turned on
  20665. */
  20666. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20667. /**
  20668. * Prepares the defines for bones
  20669. * @param mesh The mesh containing the geometry data we will draw
  20670. * @param defines The defines to update
  20671. */
  20672. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20673. /**
  20674. * Prepares the defines for morph targets
  20675. * @param mesh The mesh containing the geometry data we will draw
  20676. * @param defines The defines to update
  20677. */
  20678. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20679. /**
  20680. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20681. * @param mesh The mesh containing the geometry data we will draw
  20682. * @param defines The defines to update
  20683. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20684. * @param useBones Precise whether bones should be used or not (override mesh info)
  20685. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20686. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20687. * @returns false if defines are considered not dirty and have not been checked
  20688. */
  20689. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20690. /**
  20691. * Prepares the defines related to multiview
  20692. * @param scene The scene we are intending to draw
  20693. * @param defines The defines to update
  20694. */
  20695. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20696. /**
  20697. * Prepares the defines related to the light information passed in parameter
  20698. * @param scene The scene we are intending to draw
  20699. * @param mesh The mesh the effect is compiling for
  20700. * @param light The light the effect is compiling for
  20701. * @param lightIndex The index of the light
  20702. * @param defines The defines to update
  20703. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20704. * @param state Defines the current state regarding what is needed (normals, etc...)
  20705. */
  20706. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20707. needNormals: boolean;
  20708. needRebuild: boolean;
  20709. shadowEnabled: boolean;
  20710. specularEnabled: boolean;
  20711. lightmapMode: boolean;
  20712. }): void;
  20713. /**
  20714. * Prepares the defines related to the light information passed in parameter
  20715. * @param scene The scene we are intending to draw
  20716. * @param mesh The mesh the effect is compiling for
  20717. * @param defines The defines to update
  20718. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20719. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20720. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20721. * @returns true if normals will be required for the rest of the effect
  20722. */
  20723. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20724. /**
  20725. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20726. * @param lightIndex defines the light index
  20727. * @param uniformsList The uniform list
  20728. * @param samplersList The sampler list
  20729. * @param projectedLightTexture defines if projected texture must be used
  20730. * @param uniformBuffersList defines an optional list of uniform buffers
  20731. */
  20732. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20733. /**
  20734. * Prepares the uniforms and samplers list to be used in the effect
  20735. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20736. * @param samplersList The sampler list
  20737. * @param defines The defines helping in the list generation
  20738. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20739. */
  20740. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20741. /**
  20742. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20743. * @param defines The defines to update while falling back
  20744. * @param fallbacks The authorized effect fallbacks
  20745. * @param maxSimultaneousLights The maximum number of lights allowed
  20746. * @param rank the current rank of the Effect
  20747. * @returns The newly affected rank
  20748. */
  20749. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20750. private static _TmpMorphInfluencers;
  20751. /**
  20752. * Prepares the list of attributes required for morph targets according to the effect defines.
  20753. * @param attribs The current list of supported attribs
  20754. * @param mesh The mesh to prepare the morph targets attributes for
  20755. * @param influencers The number of influencers
  20756. */
  20757. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20758. /**
  20759. * Prepares the list of attributes required for morph targets according to the effect defines.
  20760. * @param attribs The current list of supported attribs
  20761. * @param mesh The mesh to prepare the morph targets attributes for
  20762. * @param defines The current Defines of the effect
  20763. */
  20764. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20765. /**
  20766. * Prepares the list of attributes required for bones according to the effect defines.
  20767. * @param attribs The current list of supported attribs
  20768. * @param mesh The mesh to prepare the bones attributes for
  20769. * @param defines The current Defines of the effect
  20770. * @param fallbacks The current efffect fallback strategy
  20771. */
  20772. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20773. /**
  20774. * Check and prepare the list of attributes required for instances according to the effect defines.
  20775. * @param attribs The current list of supported attribs
  20776. * @param defines The current MaterialDefines of the effect
  20777. */
  20778. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20779. /**
  20780. * Add the list of attributes required for instances to the attribs array.
  20781. * @param attribs The current list of supported attribs
  20782. */
  20783. static PushAttributesForInstances(attribs: string[]): void;
  20784. /**
  20785. * Binds the light information to the effect.
  20786. * @param light The light containing the generator
  20787. * @param effect The effect we are binding the data to
  20788. * @param lightIndex The light index in the effect used to render
  20789. */
  20790. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20791. /**
  20792. * Binds the lights information from the scene to the effect for the given mesh.
  20793. * @param light Light to bind
  20794. * @param lightIndex Light index
  20795. * @param scene The scene where the light belongs to
  20796. * @param effect The effect we are binding the data to
  20797. * @param useSpecular Defines if specular is supported
  20798. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20799. */
  20800. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20801. /**
  20802. * Binds the lights information from the scene to the effect for the given mesh.
  20803. * @param scene The scene the lights belongs to
  20804. * @param mesh The mesh we are binding the information to render
  20805. * @param effect The effect we are binding the data to
  20806. * @param defines The generated defines for the effect
  20807. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20808. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20809. */
  20810. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20811. private static _tempFogColor;
  20812. /**
  20813. * Binds the fog information from the scene to the effect for the given mesh.
  20814. * @param scene The scene the lights belongs to
  20815. * @param mesh The mesh we are binding the information to render
  20816. * @param effect The effect we are binding the data to
  20817. * @param linearSpace Defines if the fog effect is applied in linear space
  20818. */
  20819. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20820. /**
  20821. * Binds the bones information from the mesh to the effect.
  20822. * @param mesh The mesh we are binding the information to render
  20823. * @param effect The effect we are binding the data to
  20824. */
  20825. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20826. /**
  20827. * Binds the morph targets information from the mesh to the effect.
  20828. * @param abstractMesh The mesh we are binding the information to render
  20829. * @param effect The effect we are binding the data to
  20830. */
  20831. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20832. /**
  20833. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20834. * @param defines The generated defines used in the effect
  20835. * @param effect The effect we are binding the data to
  20836. * @param scene The scene we are willing to render with logarithmic scale for
  20837. */
  20838. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20839. /**
  20840. * Binds the clip plane information from the scene to the effect.
  20841. * @param scene The scene the clip plane information are extracted from
  20842. * @param effect The effect we are binding the data to
  20843. */
  20844. static BindClipPlane(effect: Effect, scene: Scene): void;
  20845. }
  20846. }
  20847. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20849. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20850. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20851. import { Nullable } from "babylonjs/types";
  20852. import { Effect } from "babylonjs/Materials/effect";
  20853. import { Matrix } from "babylonjs/Maths/math.vector";
  20854. import { Scene } from "babylonjs/scene";
  20855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20857. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20858. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20859. import { Observable } from "babylonjs/Misc/observable";
  20860. /**
  20861. * Block used to expose an input value
  20862. */
  20863. export class InputBlock extends NodeMaterialBlock {
  20864. private _mode;
  20865. private _associatedVariableName;
  20866. private _storedValue;
  20867. private _valueCallback;
  20868. private _type;
  20869. private _animationType;
  20870. /** Gets or set a value used to limit the range of float values */
  20871. min: number;
  20872. /** Gets or set a value used to limit the range of float values */
  20873. max: number;
  20874. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20875. isBoolean: boolean;
  20876. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20877. matrixMode: number;
  20878. /** @hidden */
  20879. _systemValue: Nullable<NodeMaterialSystemValues>;
  20880. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20881. visibleInInspector: boolean;
  20882. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20883. isConstant: boolean;
  20884. /** Gets or sets the group to use to display this block in the Inspector */
  20885. groupInInspector: string;
  20886. /** Gets an observable raised when the value is changed */
  20887. onValueChangedObservable: Observable<InputBlock>;
  20888. /**
  20889. * Gets or sets the connection point type (default is float)
  20890. */
  20891. get type(): NodeMaterialBlockConnectionPointTypes;
  20892. /**
  20893. * Creates a new InputBlock
  20894. * @param name defines the block name
  20895. * @param target defines the target of that block (Vertex by default)
  20896. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20897. */
  20898. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20899. /**
  20900. * Gets the output component
  20901. */
  20902. get output(): NodeMaterialConnectionPoint;
  20903. /**
  20904. * Set the source of this connection point to a vertex attribute
  20905. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20906. * @returns the current connection point
  20907. */
  20908. setAsAttribute(attributeName?: string): InputBlock;
  20909. /**
  20910. * Set the source of this connection point to a system value
  20911. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20912. * @returns the current connection point
  20913. */
  20914. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20915. /**
  20916. * Gets or sets the value of that point.
  20917. * Please note that this value will be ignored if valueCallback is defined
  20918. */
  20919. get value(): any;
  20920. set value(value: any);
  20921. /**
  20922. * Gets or sets a callback used to get the value of that point.
  20923. * Please note that setting this value will force the connection point to ignore the value property
  20924. */
  20925. get valueCallback(): () => any;
  20926. set valueCallback(value: () => any);
  20927. /**
  20928. * Gets or sets the associated variable name in the shader
  20929. */
  20930. get associatedVariableName(): string;
  20931. set associatedVariableName(value: string);
  20932. /** Gets or sets the type of animation applied to the input */
  20933. get animationType(): AnimatedInputBlockTypes;
  20934. set animationType(value: AnimatedInputBlockTypes);
  20935. /**
  20936. * Gets a boolean indicating that this connection point not defined yet
  20937. */
  20938. get isUndefined(): boolean;
  20939. /**
  20940. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20941. * In this case the connection point name must be the name of the uniform to use.
  20942. * Can only be set on inputs
  20943. */
  20944. get isUniform(): boolean;
  20945. set isUniform(value: boolean);
  20946. /**
  20947. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20948. * In this case the connection point name must be the name of the attribute to use
  20949. * Can only be set on inputs
  20950. */
  20951. get isAttribute(): boolean;
  20952. set isAttribute(value: boolean);
  20953. /**
  20954. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20955. * Can only be set on exit points
  20956. */
  20957. get isVarying(): boolean;
  20958. set isVarying(value: boolean);
  20959. /**
  20960. * Gets a boolean indicating that the current connection point is a system value
  20961. */
  20962. get isSystemValue(): boolean;
  20963. /**
  20964. * Gets or sets the current well known value or null if not defined as a system value
  20965. */
  20966. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20967. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20968. /**
  20969. * Gets the current class name
  20970. * @returns the class name
  20971. */
  20972. getClassName(): string;
  20973. /**
  20974. * Animate the input if animationType !== None
  20975. * @param scene defines the rendering scene
  20976. */
  20977. animate(scene: Scene): void;
  20978. private _emitDefine;
  20979. initialize(state: NodeMaterialBuildState): void;
  20980. /**
  20981. * Set the input block to its default value (based on its type)
  20982. */
  20983. setDefaultValue(): void;
  20984. private _emitConstant;
  20985. /** @hidden */
  20986. get _noContextSwitch(): boolean;
  20987. private _emit;
  20988. /** @hidden */
  20989. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20990. /** @hidden */
  20991. _transmit(effect: Effect, scene: Scene): void;
  20992. protected _buildBlock(state: NodeMaterialBuildState): void;
  20993. protected _dumpPropertiesCode(): string;
  20994. dispose(): void;
  20995. serialize(): any;
  20996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20997. }
  20998. }
  20999. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21000. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21001. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21002. import { Nullable } from "babylonjs/types";
  21003. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21004. import { Observable } from "babylonjs/Misc/observable";
  21005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21006. /**
  21007. * Enum used to define the compatibility state between two connection points
  21008. */
  21009. export enum NodeMaterialConnectionPointCompatibilityStates {
  21010. /** Points are compatibles */
  21011. Compatible = 0,
  21012. /** Points are incompatible because of their types */
  21013. TypeIncompatible = 1,
  21014. /** Points are incompatible because of their targets (vertex vs fragment) */
  21015. TargetIncompatible = 2
  21016. }
  21017. /**
  21018. * Defines the direction of a connection point
  21019. */
  21020. export enum NodeMaterialConnectionPointDirection {
  21021. /** Input */
  21022. Input = 0,
  21023. /** Output */
  21024. Output = 1
  21025. }
  21026. /**
  21027. * Defines a connection point for a block
  21028. */
  21029. export class NodeMaterialConnectionPoint {
  21030. /** @hidden */
  21031. _ownerBlock: NodeMaterialBlock;
  21032. /** @hidden */
  21033. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21034. private _endpoints;
  21035. private _associatedVariableName;
  21036. private _direction;
  21037. /** @hidden */
  21038. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21039. /** @hidden */
  21040. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21041. private _type;
  21042. /** @hidden */
  21043. _enforceAssociatedVariableName: boolean;
  21044. /** Gets the direction of the point */
  21045. get direction(): NodeMaterialConnectionPointDirection;
  21046. /** Indicates that this connection point needs dual validation before being connected to another point */
  21047. needDualDirectionValidation: boolean;
  21048. /**
  21049. * Gets or sets the additional types supported by this connection point
  21050. */
  21051. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21052. /**
  21053. * Gets or sets the additional types excluded by this connection point
  21054. */
  21055. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21056. /**
  21057. * Observable triggered when this point is connected
  21058. */
  21059. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21060. /**
  21061. * Gets or sets the associated variable name in the shader
  21062. */
  21063. get associatedVariableName(): string;
  21064. set associatedVariableName(value: string);
  21065. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21066. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21067. /**
  21068. * Gets or sets the connection point type (default is float)
  21069. */
  21070. get type(): NodeMaterialBlockConnectionPointTypes;
  21071. set type(value: NodeMaterialBlockConnectionPointTypes);
  21072. /**
  21073. * Gets or sets the connection point name
  21074. */
  21075. name: string;
  21076. /**
  21077. * Gets or sets the connection point name
  21078. */
  21079. displayName: string;
  21080. /**
  21081. * Gets or sets a boolean indicating that this connection point can be omitted
  21082. */
  21083. isOptional: boolean;
  21084. /**
  21085. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21086. */
  21087. define: string;
  21088. /** @hidden */
  21089. _prioritizeVertex: boolean;
  21090. private _target;
  21091. /** Gets or sets the target of that connection point */
  21092. get target(): NodeMaterialBlockTargets;
  21093. set target(value: NodeMaterialBlockTargets);
  21094. /**
  21095. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21096. */
  21097. get isConnected(): boolean;
  21098. /**
  21099. * Gets a boolean indicating that the current point is connected to an input block
  21100. */
  21101. get isConnectedToInputBlock(): boolean;
  21102. /**
  21103. * Gets a the connected input block (if any)
  21104. */
  21105. get connectInputBlock(): Nullable<InputBlock>;
  21106. /** Get the other side of the connection (if any) */
  21107. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21108. /** Get the block that owns this connection point */
  21109. get ownerBlock(): NodeMaterialBlock;
  21110. /** Get the block connected on the other side of this connection (if any) */
  21111. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21112. /** Get the block connected on the endpoints of this connection (if any) */
  21113. get connectedBlocks(): Array<NodeMaterialBlock>;
  21114. /** Gets the list of connected endpoints */
  21115. get endpoints(): NodeMaterialConnectionPoint[];
  21116. /** Gets a boolean indicating if that output point is connected to at least one input */
  21117. get hasEndpoints(): boolean;
  21118. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21119. get isConnectedInVertexShader(): boolean;
  21120. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21121. get isConnectedInFragmentShader(): boolean;
  21122. /**
  21123. * Creates a block suitable to be used as an input for this input point.
  21124. * If null is returned, a block based on the point type will be created.
  21125. * @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
  21126. */
  21127. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21128. /**
  21129. * Creates a new connection point
  21130. * @param name defines the connection point name
  21131. * @param ownerBlock defines the block hosting this connection point
  21132. * @param direction defines the direction of the connection point
  21133. */
  21134. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21135. /**
  21136. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21137. * @returns the class name
  21138. */
  21139. getClassName(): string;
  21140. /**
  21141. * Gets a boolean indicating if the current point can be connected to another point
  21142. * @param connectionPoint defines the other connection point
  21143. * @returns a boolean
  21144. */
  21145. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21146. /**
  21147. * Gets a number indicating if the current point can be connected to another point
  21148. * @param connectionPoint defines the other connection point
  21149. * @returns a number defining the compatibility state
  21150. */
  21151. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21152. /**
  21153. * Connect this point to another connection point
  21154. * @param connectionPoint defines the other connection point
  21155. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21156. * @returns the current connection point
  21157. */
  21158. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21159. /**
  21160. * Disconnect this point from one of his endpoint
  21161. * @param endpoint defines the other connection point
  21162. * @returns the current connection point
  21163. */
  21164. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21165. /**
  21166. * Serializes this point in a JSON representation
  21167. * @param isInput defines if the connection point is an input (default is true)
  21168. * @returns the serialized point object
  21169. */
  21170. serialize(isInput?: boolean): any;
  21171. /**
  21172. * Release resources
  21173. */
  21174. dispose(): void;
  21175. }
  21176. }
  21177. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21178. /**
  21179. * Enum used to define the material modes
  21180. */
  21181. export enum NodeMaterialModes {
  21182. /** Regular material */
  21183. Material = 0,
  21184. /** For post process */
  21185. PostProcess = 1,
  21186. /** For particle system */
  21187. Particle = 2
  21188. }
  21189. }
  21190. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21193. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21196. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21197. import { Effect } from "babylonjs/Materials/effect";
  21198. import { Mesh } from "babylonjs/Meshes/mesh";
  21199. import { Nullable } from "babylonjs/types";
  21200. import { Texture } from "babylonjs/Materials/Textures/texture";
  21201. import { Scene } from "babylonjs/scene";
  21202. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21203. /**
  21204. * Block used to read a texture from a sampler
  21205. */
  21206. export class TextureBlock extends NodeMaterialBlock {
  21207. private _defineName;
  21208. private _linearDefineName;
  21209. private _gammaDefineName;
  21210. private _tempTextureRead;
  21211. private _samplerName;
  21212. private _transformedUVName;
  21213. private _textureTransformName;
  21214. private _textureInfoName;
  21215. private _mainUVName;
  21216. private _mainUVDefineName;
  21217. private _fragmentOnly;
  21218. /**
  21219. * Gets or sets the texture associated with the node
  21220. */
  21221. texture: Nullable<Texture>;
  21222. /**
  21223. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21224. */
  21225. convertToGammaSpace: boolean;
  21226. /**
  21227. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21228. */
  21229. convertToLinearSpace: boolean;
  21230. /**
  21231. * Create a new TextureBlock
  21232. * @param name defines the block name
  21233. */
  21234. constructor(name: string, fragmentOnly?: boolean);
  21235. /**
  21236. * Gets the current class name
  21237. * @returns the class name
  21238. */
  21239. getClassName(): string;
  21240. /**
  21241. * Gets the uv input component
  21242. */
  21243. get uv(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the rgba output component
  21246. */
  21247. get rgba(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the rgb output component
  21250. */
  21251. get rgb(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the r output component
  21254. */
  21255. get r(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the g output component
  21258. */
  21259. get g(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the b output component
  21262. */
  21263. get b(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Gets the a output component
  21266. */
  21267. get a(): NodeMaterialConnectionPoint;
  21268. get target(): NodeMaterialBlockTargets;
  21269. autoConfigure(material: NodeMaterial): void;
  21270. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21272. isReady(): boolean;
  21273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21274. private get _isMixed();
  21275. private _injectVertexCode;
  21276. private _writeTextureRead;
  21277. private _writeOutput;
  21278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21279. protected _dumpPropertiesCode(): string;
  21280. serialize(): any;
  21281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21282. }
  21283. }
  21284. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21285. /** @hidden */
  21286. export var reflectionFunction: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21297. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21298. import { Effect } from "babylonjs/Materials/effect";
  21299. import { Mesh } from "babylonjs/Meshes/mesh";
  21300. import { Nullable } from "babylonjs/types";
  21301. import { Scene } from "babylonjs/scene";
  21302. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21303. /**
  21304. * Base block used to read a reflection texture from a sampler
  21305. */
  21306. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21307. /** @hidden */
  21308. _define3DName: string;
  21309. /** @hidden */
  21310. _defineCubicName: string;
  21311. /** @hidden */
  21312. _defineExplicitName: string;
  21313. /** @hidden */
  21314. _defineProjectionName: string;
  21315. /** @hidden */
  21316. _defineLocalCubicName: string;
  21317. /** @hidden */
  21318. _defineSphericalName: string;
  21319. /** @hidden */
  21320. _definePlanarName: string;
  21321. /** @hidden */
  21322. _defineEquirectangularName: string;
  21323. /** @hidden */
  21324. _defineMirroredEquirectangularFixedName: string;
  21325. /** @hidden */
  21326. _defineEquirectangularFixedName: string;
  21327. /** @hidden */
  21328. _defineSkyboxName: string;
  21329. /** @hidden */
  21330. _defineOppositeZ: string;
  21331. /** @hidden */
  21332. _cubeSamplerName: string;
  21333. /** @hidden */
  21334. _2DSamplerName: string;
  21335. protected _positionUVWName: string;
  21336. protected _directionWName: string;
  21337. protected _reflectionVectorName: string;
  21338. /** @hidden */
  21339. _reflectionCoordsName: string;
  21340. /** @hidden */
  21341. _reflectionMatrixName: string;
  21342. protected _reflectionColorName: string;
  21343. /**
  21344. * Gets or sets the texture associated with the node
  21345. */
  21346. texture: Nullable<BaseTexture>;
  21347. /**
  21348. * Create a new ReflectionTextureBaseBlock
  21349. * @param name defines the block name
  21350. */
  21351. constructor(name: string);
  21352. /**
  21353. * Gets the current class name
  21354. * @returns the class name
  21355. */
  21356. getClassName(): string;
  21357. /**
  21358. * Gets the world position input component
  21359. */
  21360. abstract get position(): NodeMaterialConnectionPoint;
  21361. /**
  21362. * Gets the world position input component
  21363. */
  21364. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21365. /**
  21366. * Gets the world normal input component
  21367. */
  21368. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21369. /**
  21370. * Gets the world input component
  21371. */
  21372. abstract get world(): NodeMaterialConnectionPoint;
  21373. /**
  21374. * Gets the camera (or eye) position component
  21375. */
  21376. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21377. /**
  21378. * Gets the view input component
  21379. */
  21380. abstract get view(): NodeMaterialConnectionPoint;
  21381. protected _getTexture(): Nullable<BaseTexture>;
  21382. autoConfigure(material: NodeMaterial): void;
  21383. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21384. isReady(): boolean;
  21385. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21386. /**
  21387. * Gets the code to inject in the vertex shader
  21388. * @param state current state of the node material building
  21389. * @returns the shader code
  21390. */
  21391. handleVertexSide(state: NodeMaterialBuildState): string;
  21392. /**
  21393. * Handles the inits for the fragment code path
  21394. * @param state node material build state
  21395. */
  21396. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21397. /**
  21398. * Generates the reflection coords code for the fragment code path
  21399. * @param worldNormalVarName name of the world normal variable
  21400. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21401. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21402. * @returns the shader code
  21403. */
  21404. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21405. /**
  21406. * Generates the reflection color code for the fragment code path
  21407. * @param lodVarName name of the lod variable
  21408. * @param swizzleLookupTexture swizzle to use for the final color variable
  21409. * @returns the shader code
  21410. */
  21411. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21412. /**
  21413. * Generates the code corresponding to the connected output points
  21414. * @param state node material build state
  21415. * @param varName name of the variable to output
  21416. * @returns the shader code
  21417. */
  21418. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21419. protected _buildBlock(state: NodeMaterialBuildState): this;
  21420. protected _dumpPropertiesCode(): string;
  21421. serialize(): any;
  21422. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21423. }
  21424. }
  21425. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21427. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21428. import { Nullable } from "babylonjs/types";
  21429. /**
  21430. * Defines a connection point to be used for points with a custom object type
  21431. */
  21432. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21433. private _blockType;
  21434. private _blockName;
  21435. private _nameForCheking?;
  21436. /**
  21437. * Creates a new connection point
  21438. * @param name defines the connection point name
  21439. * @param ownerBlock defines the block hosting this connection point
  21440. * @param direction defines the direction of the connection point
  21441. */
  21442. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21443. /**
  21444. * Gets a number indicating if the current point can be connected to another point
  21445. * @param connectionPoint defines the other connection point
  21446. * @returns a number defining the compatibility state
  21447. */
  21448. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21449. /**
  21450. * Creates a block suitable to be used as an input for this input point.
  21451. * If null is returned, a block based on the point type will be created.
  21452. * @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
  21453. */
  21454. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21455. }
  21456. }
  21457. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21458. /**
  21459. * Enum defining the type of properties that can be edited in the property pages in the NME
  21460. */
  21461. export enum PropertyTypeForEdition {
  21462. /** property is a boolean */
  21463. Boolean = 0,
  21464. /** property is a float */
  21465. Float = 1,
  21466. /** property is a Vector2 */
  21467. Vector2 = 2,
  21468. /** property is a list of values */
  21469. List = 3
  21470. }
  21471. /**
  21472. * Interface that defines an option in a variable of type list
  21473. */
  21474. export interface IEditablePropertyListOption {
  21475. /** label of the option */
  21476. "label": string;
  21477. /** value of the option */
  21478. "value": number;
  21479. }
  21480. /**
  21481. * Interface that defines the options available for an editable property
  21482. */
  21483. export interface IEditablePropertyOption {
  21484. /** min value */
  21485. "min"?: number;
  21486. /** max value */
  21487. "max"?: number;
  21488. /** notifiers: indicates which actions to take when the property is changed */
  21489. "notifiers"?: {
  21490. /** the material should be rebuilt */
  21491. "rebuild"?: boolean;
  21492. /** the preview should be updated */
  21493. "update"?: boolean;
  21494. };
  21495. /** list of the options for a variable of type list */
  21496. "options"?: IEditablePropertyListOption[];
  21497. }
  21498. /**
  21499. * Interface that describes an editable property
  21500. */
  21501. export interface IPropertyDescriptionForEdition {
  21502. /** name of the property */
  21503. "propertyName": string;
  21504. /** display name of the property */
  21505. "displayName": string;
  21506. /** type of the property */
  21507. "type": PropertyTypeForEdition;
  21508. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21509. "groupName": string;
  21510. /** options for the property */
  21511. "options": IEditablePropertyOption;
  21512. }
  21513. /**
  21514. * Decorator that flags a property in a node material block as being editable
  21515. */
  21516. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21517. }
  21518. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21521. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21523. import { Nullable } from "babylonjs/types";
  21524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21525. import { Mesh } from "babylonjs/Meshes/mesh";
  21526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21527. import { Effect } from "babylonjs/Materials/effect";
  21528. import { Scene } from "babylonjs/scene";
  21529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21530. /**
  21531. * Block used to implement the refraction part of the sub surface module of the PBR material
  21532. */
  21533. export class RefractionBlock extends NodeMaterialBlock {
  21534. /** @hidden */
  21535. _define3DName: string;
  21536. /** @hidden */
  21537. _refractionMatrixName: string;
  21538. /** @hidden */
  21539. _defineLODRefractionAlpha: string;
  21540. /** @hidden */
  21541. _defineLinearSpecularRefraction: string;
  21542. /** @hidden */
  21543. _defineOppositeZ: string;
  21544. /** @hidden */
  21545. _cubeSamplerName: string;
  21546. /** @hidden */
  21547. _2DSamplerName: string;
  21548. /** @hidden */
  21549. _vRefractionMicrosurfaceInfosName: string;
  21550. /** @hidden */
  21551. _vRefractionInfosName: string;
  21552. private _scene;
  21553. /**
  21554. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21555. * Materials half opaque for instance using refraction could benefit from this control.
  21556. */
  21557. linkRefractionWithTransparency: boolean;
  21558. /**
  21559. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21560. */
  21561. invertRefractionY: boolean;
  21562. /**
  21563. * Gets or sets the texture associated with the node
  21564. */
  21565. texture: Nullable<BaseTexture>;
  21566. /**
  21567. * Create a new RefractionBlock
  21568. * @param name defines the block name
  21569. */
  21570. constructor(name: string);
  21571. /**
  21572. * Gets the current class name
  21573. * @returns the class name
  21574. */
  21575. getClassName(): string;
  21576. /**
  21577. * Gets the intensity input component
  21578. */
  21579. get intensity(): NodeMaterialConnectionPoint;
  21580. /**
  21581. * Gets the index of refraction input component
  21582. */
  21583. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21584. /**
  21585. * Gets the tint at distance input component
  21586. */
  21587. get tintAtDistance(): NodeMaterialConnectionPoint;
  21588. /**
  21589. * Gets the view input component
  21590. */
  21591. get view(): NodeMaterialConnectionPoint;
  21592. /**
  21593. * Gets the refraction object output component
  21594. */
  21595. get refraction(): NodeMaterialConnectionPoint;
  21596. /**
  21597. * Returns true if the block has a texture
  21598. */
  21599. get hasTexture(): boolean;
  21600. protected _getTexture(): Nullable<BaseTexture>;
  21601. autoConfigure(material: NodeMaterial): void;
  21602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21603. isReady(): boolean;
  21604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21605. /**
  21606. * Gets the main code of the block (fragment side)
  21607. * @param state current state of the node material building
  21608. * @returns the shader code
  21609. */
  21610. getCode(state: NodeMaterialBuildState): string;
  21611. protected _buildBlock(state: NodeMaterialBuildState): this;
  21612. protected _dumpPropertiesCode(): string;
  21613. serialize(): any;
  21614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21615. }
  21616. }
  21617. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21620. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21623. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21624. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21625. import { Nullable } from "babylonjs/types";
  21626. import { Scene } from "babylonjs/scene";
  21627. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21628. /**
  21629. * Base block used as input for post process
  21630. */
  21631. export class CurrentScreenBlock extends NodeMaterialBlock {
  21632. private _samplerName;
  21633. private _linearDefineName;
  21634. private _gammaDefineName;
  21635. private _mainUVName;
  21636. private _tempTextureRead;
  21637. /**
  21638. * Gets or sets the texture associated with the node
  21639. */
  21640. texture: Nullable<BaseTexture>;
  21641. /**
  21642. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21643. */
  21644. convertToGammaSpace: boolean;
  21645. /**
  21646. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21647. */
  21648. convertToLinearSpace: boolean;
  21649. /**
  21650. * Create a new CurrentScreenBlock
  21651. * @param name defines the block name
  21652. */
  21653. constructor(name: string);
  21654. /**
  21655. * Gets the current class name
  21656. * @returns the class name
  21657. */
  21658. getClassName(): string;
  21659. /**
  21660. * Gets the uv input component
  21661. */
  21662. get uv(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Gets the rgba output component
  21665. */
  21666. get rgba(): NodeMaterialConnectionPoint;
  21667. /**
  21668. * Gets the rgb output component
  21669. */
  21670. get rgb(): NodeMaterialConnectionPoint;
  21671. /**
  21672. * Gets the r output component
  21673. */
  21674. get r(): NodeMaterialConnectionPoint;
  21675. /**
  21676. * Gets the g output component
  21677. */
  21678. get g(): NodeMaterialConnectionPoint;
  21679. /**
  21680. * Gets the b output component
  21681. */
  21682. get b(): NodeMaterialConnectionPoint;
  21683. /**
  21684. * Gets the a output component
  21685. */
  21686. get a(): NodeMaterialConnectionPoint;
  21687. /**
  21688. * Initialize the block and prepare the context for build
  21689. * @param state defines the state that will be used for the build
  21690. */
  21691. initialize(state: NodeMaterialBuildState): void;
  21692. get target(): NodeMaterialBlockTargets;
  21693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21694. isReady(): boolean;
  21695. private _injectVertexCode;
  21696. private _writeTextureRead;
  21697. private _writeOutput;
  21698. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21699. serialize(): any;
  21700. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21701. }
  21702. }
  21703. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21708. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21710. import { Nullable } from "babylonjs/types";
  21711. import { Scene } from "babylonjs/scene";
  21712. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21713. /**
  21714. * Base block used for the particle texture
  21715. */
  21716. export class ParticleTextureBlock extends NodeMaterialBlock {
  21717. private _samplerName;
  21718. private _linearDefineName;
  21719. private _gammaDefineName;
  21720. private _tempTextureRead;
  21721. /**
  21722. * Gets or sets the texture associated with the node
  21723. */
  21724. texture: Nullable<BaseTexture>;
  21725. /**
  21726. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21727. */
  21728. convertToGammaSpace: boolean;
  21729. /**
  21730. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21731. */
  21732. convertToLinearSpace: boolean;
  21733. /**
  21734. * Create a new ParticleTextureBlock
  21735. * @param name defines the block name
  21736. */
  21737. constructor(name: string);
  21738. /**
  21739. * Gets the current class name
  21740. * @returns the class name
  21741. */
  21742. getClassName(): string;
  21743. /**
  21744. * Gets the uv input component
  21745. */
  21746. get uv(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Gets the rgba output component
  21749. */
  21750. get rgba(): NodeMaterialConnectionPoint;
  21751. /**
  21752. * Gets the rgb output component
  21753. */
  21754. get rgb(): NodeMaterialConnectionPoint;
  21755. /**
  21756. * Gets the r output component
  21757. */
  21758. get r(): NodeMaterialConnectionPoint;
  21759. /**
  21760. * Gets the g output component
  21761. */
  21762. get g(): NodeMaterialConnectionPoint;
  21763. /**
  21764. * Gets the b output component
  21765. */
  21766. get b(): NodeMaterialConnectionPoint;
  21767. /**
  21768. * Gets the a output component
  21769. */
  21770. get a(): NodeMaterialConnectionPoint;
  21771. /**
  21772. * Initialize the block and prepare the context for build
  21773. * @param state defines the state that will be used for the build
  21774. */
  21775. initialize(state: NodeMaterialBuildState): void;
  21776. autoConfigure(material: NodeMaterial): void;
  21777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21778. isReady(): boolean;
  21779. private _writeOutput;
  21780. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21781. serialize(): any;
  21782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21783. }
  21784. }
  21785. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21786. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21788. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21789. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21790. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21791. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21792. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21793. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21794. import { Scene } from "babylonjs/scene";
  21795. /**
  21796. * Class used to store shared data between 2 NodeMaterialBuildState
  21797. */
  21798. export class NodeMaterialBuildStateSharedData {
  21799. /**
  21800. * Gets the list of emitted varyings
  21801. */
  21802. temps: string[];
  21803. /**
  21804. * Gets the list of emitted varyings
  21805. */
  21806. varyings: string[];
  21807. /**
  21808. * Gets the varying declaration string
  21809. */
  21810. varyingDeclaration: string;
  21811. /**
  21812. * Input blocks
  21813. */
  21814. inputBlocks: InputBlock[];
  21815. /**
  21816. * Input blocks
  21817. */
  21818. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21819. /**
  21820. * Bindable blocks (Blocks that need to set data to the effect)
  21821. */
  21822. bindableBlocks: NodeMaterialBlock[];
  21823. /**
  21824. * List of blocks that can provide a compilation fallback
  21825. */
  21826. blocksWithFallbacks: NodeMaterialBlock[];
  21827. /**
  21828. * List of blocks that can provide a define update
  21829. */
  21830. blocksWithDefines: NodeMaterialBlock[];
  21831. /**
  21832. * List of blocks that can provide a repeatable content
  21833. */
  21834. repeatableContentBlocks: NodeMaterialBlock[];
  21835. /**
  21836. * List of blocks that can provide a dynamic list of uniforms
  21837. */
  21838. dynamicUniformBlocks: NodeMaterialBlock[];
  21839. /**
  21840. * List of blocks that can block the isReady function for the material
  21841. */
  21842. blockingBlocks: NodeMaterialBlock[];
  21843. /**
  21844. * Gets the list of animated inputs
  21845. */
  21846. animatedInputs: InputBlock[];
  21847. /**
  21848. * Build Id used to avoid multiple recompilations
  21849. */
  21850. buildId: number;
  21851. /** List of emitted variables */
  21852. variableNames: {
  21853. [key: string]: number;
  21854. };
  21855. /** List of emitted defines */
  21856. defineNames: {
  21857. [key: string]: number;
  21858. };
  21859. /** Should emit comments? */
  21860. emitComments: boolean;
  21861. /** Emit build activity */
  21862. verbose: boolean;
  21863. /** Gets or sets the hosting scene */
  21864. scene: Scene;
  21865. /**
  21866. * Gets the compilation hints emitted at compilation time
  21867. */
  21868. hints: {
  21869. needWorldViewMatrix: boolean;
  21870. needWorldViewProjectionMatrix: boolean;
  21871. needAlphaBlending: boolean;
  21872. needAlphaTesting: boolean;
  21873. };
  21874. /**
  21875. * List of compilation checks
  21876. */
  21877. checks: {
  21878. emitVertex: boolean;
  21879. emitFragment: boolean;
  21880. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21881. };
  21882. /**
  21883. * Is vertex program allowed to be empty?
  21884. */
  21885. allowEmptyVertexProgram: boolean;
  21886. /** Creates a new shared data */
  21887. constructor();
  21888. /**
  21889. * Emits console errors and exceptions if there is a failing check
  21890. */
  21891. emitErrors(): void;
  21892. }
  21893. }
  21894. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21895. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21896. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21897. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21898. /**
  21899. * Class used to store node based material build state
  21900. */
  21901. export class NodeMaterialBuildState {
  21902. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21903. supportUniformBuffers: boolean;
  21904. /**
  21905. * Gets the list of emitted attributes
  21906. */
  21907. attributes: string[];
  21908. /**
  21909. * Gets the list of emitted uniforms
  21910. */
  21911. uniforms: string[];
  21912. /**
  21913. * Gets the list of emitted constants
  21914. */
  21915. constants: string[];
  21916. /**
  21917. * Gets the list of emitted samplers
  21918. */
  21919. samplers: string[];
  21920. /**
  21921. * Gets the list of emitted functions
  21922. */
  21923. functions: {
  21924. [key: string]: string;
  21925. };
  21926. /**
  21927. * Gets the list of emitted extensions
  21928. */
  21929. extensions: {
  21930. [key: string]: string;
  21931. };
  21932. /**
  21933. * Gets the target of the compilation state
  21934. */
  21935. target: NodeMaterialBlockTargets;
  21936. /**
  21937. * Gets the list of emitted counters
  21938. */
  21939. counters: {
  21940. [key: string]: number;
  21941. };
  21942. /**
  21943. * Shared data between multiple NodeMaterialBuildState instances
  21944. */
  21945. sharedData: NodeMaterialBuildStateSharedData;
  21946. /** @hidden */
  21947. _vertexState: NodeMaterialBuildState;
  21948. /** @hidden */
  21949. _attributeDeclaration: string;
  21950. /** @hidden */
  21951. _uniformDeclaration: string;
  21952. /** @hidden */
  21953. _constantDeclaration: string;
  21954. /** @hidden */
  21955. _samplerDeclaration: string;
  21956. /** @hidden */
  21957. _varyingTransfer: string;
  21958. /** @hidden */
  21959. _injectAtEnd: string;
  21960. private _repeatableContentAnchorIndex;
  21961. /** @hidden */
  21962. _builtCompilationString: string;
  21963. /**
  21964. * Gets the emitted compilation strings
  21965. */
  21966. compilationString: string;
  21967. /**
  21968. * Finalize the compilation strings
  21969. * @param state defines the current compilation state
  21970. */
  21971. finalize(state: NodeMaterialBuildState): void;
  21972. /** @hidden */
  21973. get _repeatableContentAnchor(): string;
  21974. /** @hidden */
  21975. _getFreeVariableName(prefix: string): string;
  21976. /** @hidden */
  21977. _getFreeDefineName(prefix: string): string;
  21978. /** @hidden */
  21979. _excludeVariableName(name: string): void;
  21980. /** @hidden */
  21981. _emit2DSampler(name: string): void;
  21982. /** @hidden */
  21983. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21984. /** @hidden */
  21985. _emitExtension(name: string, extension: string, define?: string): void;
  21986. /** @hidden */
  21987. _emitFunction(name: string, code: string, comments: string): void;
  21988. /** @hidden */
  21989. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21990. replaceStrings?: {
  21991. search: RegExp;
  21992. replace: string;
  21993. }[];
  21994. repeatKey?: string;
  21995. }): string;
  21996. /** @hidden */
  21997. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21998. repeatKey?: string;
  21999. removeAttributes?: boolean;
  22000. removeUniforms?: boolean;
  22001. removeVaryings?: boolean;
  22002. removeIfDef?: boolean;
  22003. replaceStrings?: {
  22004. search: RegExp;
  22005. replace: string;
  22006. }[];
  22007. }, storeKey?: string): void;
  22008. /** @hidden */
  22009. _registerTempVariable(name: string): boolean;
  22010. /** @hidden */
  22011. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22012. /** @hidden */
  22013. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22014. /** @hidden */
  22015. _emitFloat(value: number): string;
  22016. }
  22017. }
  22018. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22019. /**
  22020. * Helper class used to generate session unique ID
  22021. */
  22022. export class UniqueIdGenerator {
  22023. private static _UniqueIdCounter;
  22024. /**
  22025. * Gets an unique (relatively to the current scene) Id
  22026. */
  22027. static get UniqueId(): number;
  22028. }
  22029. }
  22030. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22031. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22033. import { Nullable } from "babylonjs/types";
  22034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22035. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22036. import { Effect } from "babylonjs/Materials/effect";
  22037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22038. import { Mesh } from "babylonjs/Meshes/mesh";
  22039. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22040. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22041. import { Scene } from "babylonjs/scene";
  22042. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22043. /**
  22044. * Defines a block that can be used inside a node based material
  22045. */
  22046. export class NodeMaterialBlock {
  22047. private _buildId;
  22048. private _buildTarget;
  22049. private _target;
  22050. private _isFinalMerger;
  22051. private _isInput;
  22052. protected _isUnique: boolean;
  22053. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22054. inputsAreExclusive: boolean;
  22055. /** @hidden */
  22056. _codeVariableName: string;
  22057. /** @hidden */
  22058. _inputs: NodeMaterialConnectionPoint[];
  22059. /** @hidden */
  22060. _outputs: NodeMaterialConnectionPoint[];
  22061. /** @hidden */
  22062. _preparationId: number;
  22063. /**
  22064. * Gets or sets the name of the block
  22065. */
  22066. name: string;
  22067. /**
  22068. * Gets or sets the unique id of the node
  22069. */
  22070. uniqueId: number;
  22071. /**
  22072. * Gets or sets the comments associated with this block
  22073. */
  22074. comments: string;
  22075. /**
  22076. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22077. */
  22078. get isUnique(): boolean;
  22079. /**
  22080. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22081. */
  22082. get isFinalMerger(): boolean;
  22083. /**
  22084. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22085. */
  22086. get isInput(): boolean;
  22087. /**
  22088. * Gets or sets the build Id
  22089. */
  22090. get buildId(): number;
  22091. set buildId(value: number);
  22092. /**
  22093. * Gets or sets the target of the block
  22094. */
  22095. get target(): NodeMaterialBlockTargets;
  22096. set target(value: NodeMaterialBlockTargets);
  22097. /**
  22098. * Gets the list of input points
  22099. */
  22100. get inputs(): NodeMaterialConnectionPoint[];
  22101. /** Gets the list of output points */
  22102. get outputs(): NodeMaterialConnectionPoint[];
  22103. /**
  22104. * Find an input by its name
  22105. * @param name defines the name of the input to look for
  22106. * @returns the input or null if not found
  22107. */
  22108. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22109. /**
  22110. * Find an output by its name
  22111. * @param name defines the name of the outputto look for
  22112. * @returns the output or null if not found
  22113. */
  22114. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22115. /**
  22116. * Creates a new NodeMaterialBlock
  22117. * @param name defines the block name
  22118. * @param target defines the target of that block (Vertex by default)
  22119. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22120. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22121. */
  22122. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22123. /**
  22124. * Initialize the block and prepare the context for build
  22125. * @param state defines the state that will be used for the build
  22126. */
  22127. initialize(state: NodeMaterialBuildState): void;
  22128. /**
  22129. * Bind data to effect. Will only be called for blocks with isBindable === true
  22130. * @param effect defines the effect to bind data to
  22131. * @param nodeMaterial defines the hosting NodeMaterial
  22132. * @param mesh defines the mesh that will be rendered
  22133. * @param subMesh defines the submesh that will be rendered
  22134. */
  22135. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22136. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22137. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22138. protected _writeFloat(value: number): string;
  22139. /**
  22140. * Gets the current class name e.g. "NodeMaterialBlock"
  22141. * @returns the class name
  22142. */
  22143. getClassName(): string;
  22144. /**
  22145. * Register a new input. Must be called inside a block constructor
  22146. * @param name defines the connection point name
  22147. * @param type defines the connection point type
  22148. * @param isOptional defines a boolean indicating that this input can be omitted
  22149. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22150. * @param point an already created connection point. If not provided, create a new one
  22151. * @returns the current block
  22152. */
  22153. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22154. /**
  22155. * Register a new output. Must be called inside a block constructor
  22156. * @param name defines the connection point name
  22157. * @param type defines the connection point type
  22158. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22159. * @param point an already created connection point. If not provided, create a new one
  22160. * @returns the current block
  22161. */
  22162. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22163. /**
  22164. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22165. * @param forOutput defines an optional connection point to check compatibility with
  22166. * @returns the first available input or null
  22167. */
  22168. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22169. /**
  22170. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22171. * @param forBlock defines an optional block to check compatibility with
  22172. * @returns the first available input or null
  22173. */
  22174. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22175. /**
  22176. * Gets the sibling of the given output
  22177. * @param current defines the current output
  22178. * @returns the next output in the list or null
  22179. */
  22180. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22181. /**
  22182. * Connect current block with another block
  22183. * @param other defines the block to connect with
  22184. * @param options define the various options to help pick the right connections
  22185. * @returns the current block
  22186. */
  22187. connectTo(other: NodeMaterialBlock, options?: {
  22188. input?: string;
  22189. output?: string;
  22190. outputSwizzle?: string;
  22191. }): this | undefined;
  22192. protected _buildBlock(state: NodeMaterialBuildState): void;
  22193. /**
  22194. * Add uniforms, samplers and uniform buffers at compilation time
  22195. * @param state defines the state to update
  22196. * @param nodeMaterial defines the node material requesting the update
  22197. * @param defines defines the material defines to update
  22198. * @param uniformBuffers defines the list of uniform buffer names
  22199. */
  22200. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22201. /**
  22202. * Add potential fallbacks if shader compilation fails
  22203. * @param mesh defines the mesh to be rendered
  22204. * @param fallbacks defines the current prioritized list of fallbacks
  22205. */
  22206. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22207. /**
  22208. * Initialize defines for shader compilation
  22209. * @param mesh defines the mesh to be rendered
  22210. * @param nodeMaterial defines the node material requesting the update
  22211. * @param defines defines the material defines to update
  22212. * @param useInstances specifies that instances should be used
  22213. */
  22214. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22215. /**
  22216. * Update defines for shader compilation
  22217. * @param mesh defines the mesh to be rendered
  22218. * @param nodeMaterial defines the node material requesting the update
  22219. * @param defines defines the material defines to update
  22220. * @param useInstances specifies that instances should be used
  22221. * @param subMesh defines which submesh to render
  22222. */
  22223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22224. /**
  22225. * Lets the block try to connect some inputs automatically
  22226. * @param material defines the hosting NodeMaterial
  22227. */
  22228. autoConfigure(material: NodeMaterial): void;
  22229. /**
  22230. * Function called when a block is declared as repeatable content generator
  22231. * @param vertexShaderState defines the current compilation state for the vertex shader
  22232. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22233. * @param mesh defines the mesh to be rendered
  22234. * @param defines defines the material defines to update
  22235. */
  22236. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22237. /**
  22238. * Checks if the block is ready
  22239. * @param mesh defines the mesh to be rendered
  22240. * @param nodeMaterial defines the node material requesting the update
  22241. * @param defines defines the material defines to update
  22242. * @param useInstances specifies that instances should be used
  22243. * @returns true if the block is ready
  22244. */
  22245. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22246. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22247. private _processBuild;
  22248. /**
  22249. * Compile the current node and generate the shader code
  22250. * @param state defines the current compilation state (uniforms, samplers, current string)
  22251. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22252. * @returns true if already built
  22253. */
  22254. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22255. protected _inputRename(name: string): string;
  22256. protected _outputRename(name: string): string;
  22257. protected _dumpPropertiesCode(): string;
  22258. /** @hidden */
  22259. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22260. /** @hidden */
  22261. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22262. /**
  22263. * Clone the current block to a new identical block
  22264. * @param scene defines the hosting scene
  22265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22266. * @returns a copy of the current block
  22267. */
  22268. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22269. /**
  22270. * Serializes this block in a JSON representation
  22271. * @returns the serialized block object
  22272. */
  22273. serialize(): any;
  22274. /** @hidden */
  22275. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22276. private _deserializePortDisplayNames;
  22277. /**
  22278. * Release resources
  22279. */
  22280. dispose(): void;
  22281. }
  22282. }
  22283. declare module "babylonjs/Materials/pushMaterial" {
  22284. import { Nullable } from "babylonjs/types";
  22285. import { Scene } from "babylonjs/scene";
  22286. import { Matrix } from "babylonjs/Maths/math.vector";
  22287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22288. import { Mesh } from "babylonjs/Meshes/mesh";
  22289. import { Material } from "babylonjs/Materials/material";
  22290. import { Effect } from "babylonjs/Materials/effect";
  22291. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22292. /**
  22293. * Base class of materials working in push mode in babylon JS
  22294. * @hidden
  22295. */
  22296. export class PushMaterial extends Material {
  22297. protected _activeEffect: Effect;
  22298. protected _normalMatrix: Matrix;
  22299. constructor(name: string, scene: Scene);
  22300. getEffect(): Effect;
  22301. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22302. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22303. /**
  22304. * Binds the given world matrix to the active effect
  22305. *
  22306. * @param world the matrix to bind
  22307. */
  22308. bindOnlyWorldMatrix(world: Matrix): void;
  22309. /**
  22310. * Binds the given normal matrix to the active effect
  22311. *
  22312. * @param normalMatrix the matrix to bind
  22313. */
  22314. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22315. bind(world: Matrix, mesh?: Mesh): void;
  22316. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22317. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22318. }
  22319. }
  22320. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22322. /**
  22323. * Root class for all node material optimizers
  22324. */
  22325. export class NodeMaterialOptimizer {
  22326. /**
  22327. * Function used to optimize a NodeMaterial graph
  22328. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22329. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22330. */
  22331. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22332. }
  22333. }
  22334. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22338. import { Scene } from "babylonjs/scene";
  22339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22340. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22341. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22342. /**
  22343. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22344. */
  22345. export class TransformBlock extends NodeMaterialBlock {
  22346. /**
  22347. * Defines the value to use to complement W value to transform it to a Vector4
  22348. */
  22349. complementW: number;
  22350. /**
  22351. * Defines the value to use to complement z value to transform it to a Vector4
  22352. */
  22353. complementZ: number;
  22354. /**
  22355. * Creates a new TransformBlock
  22356. * @param name defines the block name
  22357. */
  22358. constructor(name: string);
  22359. /**
  22360. * Gets the current class name
  22361. * @returns the class name
  22362. */
  22363. getClassName(): string;
  22364. /**
  22365. * Gets the vector input
  22366. */
  22367. get vector(): NodeMaterialConnectionPoint;
  22368. /**
  22369. * Gets the output component
  22370. */
  22371. get output(): NodeMaterialConnectionPoint;
  22372. /**
  22373. * Gets the xyz output component
  22374. */
  22375. get xyz(): NodeMaterialConnectionPoint;
  22376. /**
  22377. * Gets the matrix transform input
  22378. */
  22379. get transform(): NodeMaterialConnectionPoint;
  22380. protected _buildBlock(state: NodeMaterialBuildState): this;
  22381. /**
  22382. * Update defines for shader compilation
  22383. * @param mesh defines the mesh to be rendered
  22384. * @param nodeMaterial defines the node material requesting the update
  22385. * @param defines defines the material defines to update
  22386. * @param useInstances specifies that instances should be used
  22387. * @param subMesh defines which submesh to render
  22388. */
  22389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22390. serialize(): any;
  22391. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22392. protected _dumpPropertiesCode(): string;
  22393. }
  22394. }
  22395. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22399. /**
  22400. * Block used to output the vertex position
  22401. */
  22402. export class VertexOutputBlock extends NodeMaterialBlock {
  22403. /**
  22404. * Creates a new VertexOutputBlock
  22405. * @param name defines the block name
  22406. */
  22407. constructor(name: string);
  22408. /**
  22409. * Gets the current class name
  22410. * @returns the class name
  22411. */
  22412. getClassName(): string;
  22413. /**
  22414. * Gets the vector input component
  22415. */
  22416. get vector(): NodeMaterialConnectionPoint;
  22417. protected _buildBlock(state: NodeMaterialBuildState): this;
  22418. }
  22419. }
  22420. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22424. /**
  22425. * Block used to output the final color
  22426. */
  22427. export class FragmentOutputBlock extends NodeMaterialBlock {
  22428. /**
  22429. * Create a new FragmentOutputBlock
  22430. * @param name defines the block name
  22431. */
  22432. constructor(name: string);
  22433. /**
  22434. * Gets the current class name
  22435. * @returns the class name
  22436. */
  22437. getClassName(): string;
  22438. /**
  22439. * Gets the rgba input component
  22440. */
  22441. get rgba(): NodeMaterialConnectionPoint;
  22442. /**
  22443. * Gets the rgb input component
  22444. */
  22445. get rgb(): NodeMaterialConnectionPoint;
  22446. /**
  22447. * Gets the a input component
  22448. */
  22449. get a(): NodeMaterialConnectionPoint;
  22450. protected _buildBlock(state: NodeMaterialBuildState): this;
  22451. }
  22452. }
  22453. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22454. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22455. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22457. /**
  22458. * Block used for the particle ramp gradient section
  22459. */
  22460. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22461. /**
  22462. * Create a new ParticleRampGradientBlock
  22463. * @param name defines the block name
  22464. */
  22465. constructor(name: string);
  22466. /**
  22467. * Gets the current class name
  22468. * @returns the class name
  22469. */
  22470. getClassName(): string;
  22471. /**
  22472. * Gets the color input component
  22473. */
  22474. get color(): NodeMaterialConnectionPoint;
  22475. /**
  22476. * Gets the rampColor output component
  22477. */
  22478. get rampColor(): NodeMaterialConnectionPoint;
  22479. /**
  22480. * Initialize the block and prepare the context for build
  22481. * @param state defines the state that will be used for the build
  22482. */
  22483. initialize(state: NodeMaterialBuildState): void;
  22484. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22485. }
  22486. }
  22487. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22491. /**
  22492. * Block used for the particle blend multiply section
  22493. */
  22494. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22495. /**
  22496. * Create a new ParticleBlendMultiplyBlock
  22497. * @param name defines the block name
  22498. */
  22499. constructor(name: string);
  22500. /**
  22501. * Gets the current class name
  22502. * @returns the class name
  22503. */
  22504. getClassName(): string;
  22505. /**
  22506. * Gets the color input component
  22507. */
  22508. get color(): NodeMaterialConnectionPoint;
  22509. /**
  22510. * Gets the alphaTexture input component
  22511. */
  22512. get alphaTexture(): NodeMaterialConnectionPoint;
  22513. /**
  22514. * Gets the alphaColor input component
  22515. */
  22516. get alphaColor(): NodeMaterialConnectionPoint;
  22517. /**
  22518. * Gets the blendColor output component
  22519. */
  22520. get blendColor(): NodeMaterialConnectionPoint;
  22521. /**
  22522. * Initialize the block and prepare the context for build
  22523. * @param state defines the state that will be used for the build
  22524. */
  22525. initialize(state: NodeMaterialBuildState): void;
  22526. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22527. }
  22528. }
  22529. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22533. /**
  22534. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22535. */
  22536. export class VectorMergerBlock extends NodeMaterialBlock {
  22537. /**
  22538. * Create a new VectorMergerBlock
  22539. * @param name defines the block name
  22540. */
  22541. constructor(name: string);
  22542. /**
  22543. * Gets the current class name
  22544. * @returns the class name
  22545. */
  22546. getClassName(): string;
  22547. /**
  22548. * Gets the xyz component (input)
  22549. */
  22550. get xyzIn(): NodeMaterialConnectionPoint;
  22551. /**
  22552. * Gets the xy component (input)
  22553. */
  22554. get xyIn(): NodeMaterialConnectionPoint;
  22555. /**
  22556. * Gets the x component (input)
  22557. */
  22558. get x(): NodeMaterialConnectionPoint;
  22559. /**
  22560. * Gets the y component (input)
  22561. */
  22562. get y(): NodeMaterialConnectionPoint;
  22563. /**
  22564. * Gets the z component (input)
  22565. */
  22566. get z(): NodeMaterialConnectionPoint;
  22567. /**
  22568. * Gets the w component (input)
  22569. */
  22570. get w(): NodeMaterialConnectionPoint;
  22571. /**
  22572. * Gets the xyzw component (output)
  22573. */
  22574. get xyzw(): NodeMaterialConnectionPoint;
  22575. /**
  22576. * Gets the xyz component (output)
  22577. */
  22578. get xyzOut(): NodeMaterialConnectionPoint;
  22579. /**
  22580. * Gets the xy component (output)
  22581. */
  22582. get xyOut(): NodeMaterialConnectionPoint;
  22583. /**
  22584. * Gets the xy component (output)
  22585. * @deprecated Please use xyOut instead.
  22586. */
  22587. get xy(): NodeMaterialConnectionPoint;
  22588. /**
  22589. * Gets the xyz component (output)
  22590. * @deprecated Please use xyzOut instead.
  22591. */
  22592. get xyz(): NodeMaterialConnectionPoint;
  22593. protected _buildBlock(state: NodeMaterialBuildState): this;
  22594. }
  22595. }
  22596. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22598. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22599. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22600. import { Vector2 } from "babylonjs/Maths/math.vector";
  22601. import { Scene } from "babylonjs/scene";
  22602. /**
  22603. * Block used to remap a float from a range to a new one
  22604. */
  22605. export class RemapBlock extends NodeMaterialBlock {
  22606. /**
  22607. * Gets or sets the source range
  22608. */
  22609. sourceRange: Vector2;
  22610. /**
  22611. * Gets or sets the target range
  22612. */
  22613. targetRange: Vector2;
  22614. /**
  22615. * Creates a new RemapBlock
  22616. * @param name defines the block name
  22617. */
  22618. constructor(name: string);
  22619. /**
  22620. * Gets the current class name
  22621. * @returns the class name
  22622. */
  22623. getClassName(): string;
  22624. /**
  22625. * Gets the input component
  22626. */
  22627. get input(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the source min input component
  22630. */
  22631. get sourceMin(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the source max input component
  22634. */
  22635. get sourceMax(): NodeMaterialConnectionPoint;
  22636. /**
  22637. * Gets the target min input component
  22638. */
  22639. get targetMin(): NodeMaterialConnectionPoint;
  22640. /**
  22641. * Gets the target max input component
  22642. */
  22643. get targetMax(): NodeMaterialConnectionPoint;
  22644. /**
  22645. * Gets the output component
  22646. */
  22647. get output(): NodeMaterialConnectionPoint;
  22648. protected _buildBlock(state: NodeMaterialBuildState): this;
  22649. protected _dumpPropertiesCode(): string;
  22650. serialize(): any;
  22651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22652. }
  22653. }
  22654. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22658. /**
  22659. * Block used to multiply 2 values
  22660. */
  22661. export class MultiplyBlock extends NodeMaterialBlock {
  22662. /**
  22663. * Creates a new MultiplyBlock
  22664. * @param name defines the block name
  22665. */
  22666. constructor(name: string);
  22667. /**
  22668. * Gets the current class name
  22669. * @returns the class name
  22670. */
  22671. getClassName(): string;
  22672. /**
  22673. * Gets the left operand input component
  22674. */
  22675. get left(): NodeMaterialConnectionPoint;
  22676. /**
  22677. * Gets the right operand input component
  22678. */
  22679. get right(): NodeMaterialConnectionPoint;
  22680. /**
  22681. * Gets the output component
  22682. */
  22683. get output(): NodeMaterialConnectionPoint;
  22684. protected _buildBlock(state: NodeMaterialBuildState): this;
  22685. }
  22686. }
  22687. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22691. /**
  22692. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22693. */
  22694. export class ColorSplitterBlock extends NodeMaterialBlock {
  22695. /**
  22696. * Create a new ColorSplitterBlock
  22697. * @param name defines the block name
  22698. */
  22699. constructor(name: string);
  22700. /**
  22701. * Gets the current class name
  22702. * @returns the class name
  22703. */
  22704. getClassName(): string;
  22705. /**
  22706. * Gets the rgba component (input)
  22707. */
  22708. get rgba(): NodeMaterialConnectionPoint;
  22709. /**
  22710. * Gets the rgb component (input)
  22711. */
  22712. get rgbIn(): NodeMaterialConnectionPoint;
  22713. /**
  22714. * Gets the rgb component (output)
  22715. */
  22716. get rgbOut(): NodeMaterialConnectionPoint;
  22717. /**
  22718. * Gets the r component (output)
  22719. */
  22720. get r(): NodeMaterialConnectionPoint;
  22721. /**
  22722. * Gets the g component (output)
  22723. */
  22724. get g(): NodeMaterialConnectionPoint;
  22725. /**
  22726. * Gets the b component (output)
  22727. */
  22728. get b(): NodeMaterialConnectionPoint;
  22729. /**
  22730. * Gets the a component (output)
  22731. */
  22732. get a(): NodeMaterialConnectionPoint;
  22733. protected _inputRename(name: string): string;
  22734. protected _outputRename(name: string): string;
  22735. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22736. }
  22737. }
  22738. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22740. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22741. import { Scene } from "babylonjs/scene";
  22742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22743. import { Matrix } from "babylonjs/Maths/math.vector";
  22744. import { Mesh } from "babylonjs/Meshes/mesh";
  22745. import { Engine } from "babylonjs/Engines/engine";
  22746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22747. import { Observable } from "babylonjs/Misc/observable";
  22748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22749. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22750. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22751. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22752. import { Nullable } from "babylonjs/types";
  22753. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22754. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22755. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22756. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22757. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22758. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22759. import { Effect } from "babylonjs/Materials/effect";
  22760. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22761. import { Camera } from "babylonjs/Cameras/camera";
  22762. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22763. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22764. /**
  22765. * Interface used to configure the node material editor
  22766. */
  22767. export interface INodeMaterialEditorOptions {
  22768. /** Define the URl to load node editor script */
  22769. editorURL?: string;
  22770. }
  22771. /** @hidden */
  22772. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22773. NORMAL: boolean;
  22774. TANGENT: boolean;
  22775. UV1: boolean;
  22776. /** BONES */
  22777. NUM_BONE_INFLUENCERS: number;
  22778. BonesPerMesh: number;
  22779. BONETEXTURE: boolean;
  22780. /** MORPH TARGETS */
  22781. MORPHTARGETS: boolean;
  22782. MORPHTARGETS_NORMAL: boolean;
  22783. MORPHTARGETS_TANGENT: boolean;
  22784. MORPHTARGETS_UV: boolean;
  22785. NUM_MORPH_INFLUENCERS: number;
  22786. /** IMAGE PROCESSING */
  22787. IMAGEPROCESSING: boolean;
  22788. VIGNETTE: boolean;
  22789. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22790. VIGNETTEBLENDMODEOPAQUE: boolean;
  22791. TONEMAPPING: boolean;
  22792. TONEMAPPING_ACES: boolean;
  22793. CONTRAST: boolean;
  22794. EXPOSURE: boolean;
  22795. COLORCURVES: boolean;
  22796. COLORGRADING: boolean;
  22797. COLORGRADING3D: boolean;
  22798. SAMPLER3DGREENDEPTH: boolean;
  22799. SAMPLER3DBGRMAP: boolean;
  22800. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22801. /** MISC. */
  22802. BUMPDIRECTUV: number;
  22803. constructor();
  22804. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22805. }
  22806. /**
  22807. * Class used to configure NodeMaterial
  22808. */
  22809. export interface INodeMaterialOptions {
  22810. /**
  22811. * Defines if blocks should emit comments
  22812. */
  22813. emitComments: boolean;
  22814. }
  22815. /**
  22816. * Class used to create a node based material built by assembling shader blocks
  22817. */
  22818. export class NodeMaterial extends PushMaterial {
  22819. private static _BuildIdGenerator;
  22820. private _options;
  22821. private _vertexCompilationState;
  22822. private _fragmentCompilationState;
  22823. private _sharedData;
  22824. private _buildId;
  22825. private _buildWasSuccessful;
  22826. private _cachedWorldViewMatrix;
  22827. private _cachedWorldViewProjectionMatrix;
  22828. private _optimizers;
  22829. private _animationFrame;
  22830. /** Define the Url to load node editor script */
  22831. static EditorURL: string;
  22832. /** Define the Url to load snippets */
  22833. static SnippetUrl: string;
  22834. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22835. static IgnoreTexturesAtLoadTime: boolean;
  22836. private BJSNODEMATERIALEDITOR;
  22837. /** Get the inspector from bundle or global */
  22838. private _getGlobalNodeMaterialEditor;
  22839. /**
  22840. * Snippet ID if the material was created from the snippet server
  22841. */
  22842. snippetId: string;
  22843. /**
  22844. * Gets or sets data used by visual editor
  22845. * @see https://nme.babylonjs.com
  22846. */
  22847. editorData: any;
  22848. /**
  22849. * 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)
  22850. */
  22851. ignoreAlpha: boolean;
  22852. /**
  22853. * Defines the maximum number of lights that can be used in the material
  22854. */
  22855. maxSimultaneousLights: number;
  22856. /**
  22857. * Observable raised when the material is built
  22858. */
  22859. onBuildObservable: Observable<NodeMaterial>;
  22860. /**
  22861. * Gets or sets the root nodes of the material vertex shader
  22862. */
  22863. _vertexOutputNodes: NodeMaterialBlock[];
  22864. /**
  22865. * Gets or sets the root nodes of the material fragment (pixel) shader
  22866. */
  22867. _fragmentOutputNodes: NodeMaterialBlock[];
  22868. /** Gets or sets options to control the node material overall behavior */
  22869. get options(): INodeMaterialOptions;
  22870. set options(options: INodeMaterialOptions);
  22871. /**
  22872. * Default configuration related to image processing available in the standard Material.
  22873. */
  22874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22875. /**
  22876. * Gets the image processing configuration used either in this material.
  22877. */
  22878. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22879. /**
  22880. * Sets the Default image processing configuration used either in the this material.
  22881. *
  22882. * If sets to null, the scene one is in use.
  22883. */
  22884. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22885. /**
  22886. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22887. */
  22888. attachedBlocks: NodeMaterialBlock[];
  22889. /**
  22890. * Specifies the mode of the node material
  22891. * @hidden
  22892. */
  22893. _mode: NodeMaterialModes;
  22894. /**
  22895. * Gets the mode property
  22896. */
  22897. get mode(): NodeMaterialModes;
  22898. /**
  22899. * Create a new node based material
  22900. * @param name defines the material name
  22901. * @param scene defines the hosting scene
  22902. * @param options defines creation option
  22903. */
  22904. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22905. /**
  22906. * Gets the current class name of the material e.g. "NodeMaterial"
  22907. * @returns the class name
  22908. */
  22909. getClassName(): string;
  22910. /**
  22911. * Keep track of the image processing observer to allow dispose and replace.
  22912. */
  22913. private _imageProcessingObserver;
  22914. /**
  22915. * Attaches a new image processing configuration to the Standard Material.
  22916. * @param configuration
  22917. */
  22918. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22919. /**
  22920. * Get a block by its name
  22921. * @param name defines the name of the block to retrieve
  22922. * @returns the required block or null if not found
  22923. */
  22924. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22925. /**
  22926. * Get a block by its name
  22927. * @param predicate defines the predicate used to find the good candidate
  22928. * @returns the required block or null if not found
  22929. */
  22930. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22931. /**
  22932. * Get an input block by its name
  22933. * @param predicate defines the predicate used to find the good candidate
  22934. * @returns the required input block or null if not found
  22935. */
  22936. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22937. /**
  22938. * Gets the list of input blocks attached to this material
  22939. * @returns an array of InputBlocks
  22940. */
  22941. getInputBlocks(): InputBlock[];
  22942. /**
  22943. * Adds a new optimizer to the list of optimizers
  22944. * @param optimizer defines the optimizers to add
  22945. * @returns the current material
  22946. */
  22947. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22948. /**
  22949. * Remove an optimizer from the list of optimizers
  22950. * @param optimizer defines the optimizers to remove
  22951. * @returns the current material
  22952. */
  22953. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22954. /**
  22955. * Add a new block to the list of output nodes
  22956. * @param node defines the node to add
  22957. * @returns the current material
  22958. */
  22959. addOutputNode(node: NodeMaterialBlock): this;
  22960. /**
  22961. * Remove a block from the list of root nodes
  22962. * @param node defines the node to remove
  22963. * @returns the current material
  22964. */
  22965. removeOutputNode(node: NodeMaterialBlock): this;
  22966. private _addVertexOutputNode;
  22967. private _removeVertexOutputNode;
  22968. private _addFragmentOutputNode;
  22969. private _removeFragmentOutputNode;
  22970. /**
  22971. * Specifies if the material will require alpha blending
  22972. * @returns a boolean specifying if alpha blending is needed
  22973. */
  22974. needAlphaBlending(): boolean;
  22975. /**
  22976. * Specifies if this material should be rendered in alpha test mode
  22977. * @returns a boolean specifying if an alpha test is needed.
  22978. */
  22979. needAlphaTesting(): boolean;
  22980. private _initializeBlock;
  22981. private _resetDualBlocks;
  22982. /**
  22983. * Remove a block from the current node material
  22984. * @param block defines the block to remove
  22985. */
  22986. removeBlock(block: NodeMaterialBlock): void;
  22987. /**
  22988. * Build the material and generates the inner effect
  22989. * @param verbose defines if the build should log activity
  22990. */
  22991. build(verbose?: boolean): void;
  22992. /**
  22993. * Runs an otpimization phase to try to improve the shader code
  22994. */
  22995. optimize(): void;
  22996. private _prepareDefinesForAttributes;
  22997. /**
  22998. * Create a post process from the material
  22999. * @param camera The camera to apply the render pass to.
  23000. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23002. * @param engine The engine which the post process will be applied. (default: current engine)
  23003. * @param reusable If the post process can be reused on the same frame. (default: false)
  23004. * @param textureType Type of textures used when performing the post process. (default: 0)
  23005. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23006. * @returns the post process created
  23007. */
  23008. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23009. /**
  23010. * Create the post process effect from the material
  23011. * @param postProcess The post process to create the effect for
  23012. */
  23013. createEffectForPostProcess(postProcess: PostProcess): void;
  23014. private _createEffectOrPostProcess;
  23015. private _createEffectForParticles;
  23016. /**
  23017. * Create the effect to be used as the custom effect for a particle system
  23018. * @param particleSystem Particle system to create the effect for
  23019. * @param onCompiled defines a function to call when the effect creation is successful
  23020. * @param onError defines a function to call when the effect creation has failed
  23021. */
  23022. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23023. private _processDefines;
  23024. /**
  23025. * Get if the submesh is ready to be used and all its information available.
  23026. * Child classes can use it to update shaders
  23027. * @param mesh defines the mesh to check
  23028. * @param subMesh defines which submesh to check
  23029. * @param useInstances specifies that instances should be used
  23030. * @returns a boolean indicating that the submesh is ready or not
  23031. */
  23032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23033. /**
  23034. * Get a string representing the shaders built by the current node graph
  23035. */
  23036. get compiledShaders(): string;
  23037. /**
  23038. * Binds the world matrix to the material
  23039. * @param world defines the world transformation matrix
  23040. */
  23041. bindOnlyWorldMatrix(world: Matrix): void;
  23042. /**
  23043. * Binds the submesh to this material by preparing the effect and shader to draw
  23044. * @param world defines the world transformation matrix
  23045. * @param mesh defines the mesh containing the submesh
  23046. * @param subMesh defines the submesh to bind the material to
  23047. */
  23048. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23049. /**
  23050. * Gets the active textures from the material
  23051. * @returns an array of textures
  23052. */
  23053. getActiveTextures(): BaseTexture[];
  23054. /**
  23055. * Gets the list of texture blocks
  23056. * @returns an array of texture blocks
  23057. */
  23058. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23059. /**
  23060. * Specifies if the material uses a texture
  23061. * @param texture defines the texture to check against the material
  23062. * @returns a boolean specifying if the material uses the texture
  23063. */
  23064. hasTexture(texture: BaseTexture): boolean;
  23065. /**
  23066. * Disposes the material
  23067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23070. */
  23071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23072. /** Creates the node editor window. */
  23073. private _createNodeEditor;
  23074. /**
  23075. * Launch the node material editor
  23076. * @param config Define the configuration of the editor
  23077. * @return a promise fulfilled when the node editor is visible
  23078. */
  23079. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23080. /**
  23081. * Clear the current material
  23082. */
  23083. clear(): void;
  23084. /**
  23085. * Clear the current material and set it to a default state
  23086. */
  23087. setToDefault(): void;
  23088. /**
  23089. * Clear the current material and set it to a default state for post process
  23090. */
  23091. setToDefaultPostProcess(): void;
  23092. /**
  23093. * Clear the current material and set it to a default state for particle
  23094. */
  23095. setToDefaultParticle(): void;
  23096. /**
  23097. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23098. * @param url defines the url to load from
  23099. * @returns a promise that will fullfil when the material is fully loaded
  23100. */
  23101. loadAsync(url: string): Promise<void>;
  23102. private _gatherBlocks;
  23103. /**
  23104. * Generate a string containing the code declaration required to create an equivalent of this material
  23105. * @returns a string
  23106. */
  23107. generateCode(): string;
  23108. /**
  23109. * Serializes this material in a JSON representation
  23110. * @returns the serialized material object
  23111. */
  23112. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23113. private _restoreConnections;
  23114. /**
  23115. * Clear the current graph and load a new one from a serialization object
  23116. * @param source defines the JSON representation of the material
  23117. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23118. */
  23119. loadFromSerialization(source: any, rootUrl?: string): void;
  23120. /**
  23121. * Makes a duplicate of the current material.
  23122. * @param name - name to use for the new material.
  23123. */
  23124. clone(name: string): NodeMaterial;
  23125. /**
  23126. * Creates a node material from parsed material data
  23127. * @param source defines the JSON representation of the material
  23128. * @param scene defines the hosting scene
  23129. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23130. * @returns a new node material
  23131. */
  23132. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23133. /**
  23134. * Creates a node material from a snippet saved in a remote file
  23135. * @param name defines the name of the material to create
  23136. * @param url defines the url to load from
  23137. * @param scene defines the hosting scene
  23138. * @returns a promise that will resolve to the new node material
  23139. */
  23140. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23141. /**
  23142. * Creates a node material from a snippet saved by the node material editor
  23143. * @param snippetId defines the snippet to load
  23144. * @param scene defines the hosting scene
  23145. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23146. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23147. * @returns a promise that will resolve to the new node material
  23148. */
  23149. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23150. /**
  23151. * Creates a new node material set to default basic configuration
  23152. * @param name defines the name of the material
  23153. * @param scene defines the hosting scene
  23154. * @returns a new NodeMaterial
  23155. */
  23156. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23157. }
  23158. }
  23159. declare module "babylonjs/PostProcesses/postProcess" {
  23160. import { Nullable } from "babylonjs/types";
  23161. import { SmartArray } from "babylonjs/Misc/smartArray";
  23162. import { Observable } from "babylonjs/Misc/observable";
  23163. import { Vector2 } from "babylonjs/Maths/math.vector";
  23164. import { Camera } from "babylonjs/Cameras/camera";
  23165. import { Effect } from "babylonjs/Materials/effect";
  23166. import "babylonjs/Shaders/postprocess.vertex";
  23167. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23168. import { Engine } from "babylonjs/Engines/engine";
  23169. import { Color4 } from "babylonjs/Maths/math.color";
  23170. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23171. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23172. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23173. /**
  23174. * Size options for a post process
  23175. */
  23176. export type PostProcessOptions = {
  23177. width: number;
  23178. height: number;
  23179. };
  23180. /**
  23181. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23182. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23183. */
  23184. export class PostProcess {
  23185. /** Name of the PostProcess. */
  23186. name: string;
  23187. /**
  23188. * Gets or sets the unique id of the post process
  23189. */
  23190. uniqueId: number;
  23191. /**
  23192. * Width of the texture to apply the post process on
  23193. */
  23194. width: number;
  23195. /**
  23196. * Height of the texture to apply the post process on
  23197. */
  23198. height: number;
  23199. /**
  23200. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23201. */
  23202. nodeMaterialSource: Nullable<NodeMaterial>;
  23203. /**
  23204. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23205. * @hidden
  23206. */
  23207. _outputTexture: Nullable<InternalTexture>;
  23208. /**
  23209. * Sampling mode used by the shader
  23210. * See https://doc.babylonjs.com/classes/3.1/texture
  23211. */
  23212. renderTargetSamplingMode: number;
  23213. /**
  23214. * Clear color to use when screen clearing
  23215. */
  23216. clearColor: Color4;
  23217. /**
  23218. * If the buffer needs to be cleared before applying the post process. (default: true)
  23219. * Should be set to false if shader will overwrite all previous pixels.
  23220. */
  23221. autoClear: boolean;
  23222. /**
  23223. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23224. */
  23225. alphaMode: number;
  23226. /**
  23227. * Sets the setAlphaBlendConstants of the babylon engine
  23228. */
  23229. alphaConstants: Color4;
  23230. /**
  23231. * Animations to be used for the post processing
  23232. */
  23233. animations: import("babylonjs/Animations/animation").Animation[];
  23234. /**
  23235. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23236. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23237. */
  23238. enablePixelPerfectMode: boolean;
  23239. /**
  23240. * Force the postprocess to be applied without taking in account viewport
  23241. */
  23242. forceFullscreenViewport: boolean;
  23243. /**
  23244. * List of inspectable custom properties (used by the Inspector)
  23245. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23246. */
  23247. inspectableCustomProperties: IInspectable[];
  23248. /**
  23249. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23250. *
  23251. * | Value | Type | Description |
  23252. * | ----- | ----------------------------------- | ----------- |
  23253. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23254. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23255. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23256. *
  23257. */
  23258. scaleMode: number;
  23259. /**
  23260. * Force textures to be a power of two (default: false)
  23261. */
  23262. alwaysForcePOT: boolean;
  23263. private _samples;
  23264. /**
  23265. * Number of sample textures (default: 1)
  23266. */
  23267. get samples(): number;
  23268. set samples(n: number);
  23269. /**
  23270. * Modify the scale of the post process to be the same as the viewport (default: false)
  23271. */
  23272. adaptScaleToCurrentViewport: boolean;
  23273. private _camera;
  23274. private _scene;
  23275. private _engine;
  23276. private _options;
  23277. private _reusable;
  23278. private _textureType;
  23279. private _textureFormat;
  23280. /**
  23281. * Smart array of input and output textures for the post process.
  23282. * @hidden
  23283. */
  23284. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23285. /**
  23286. * The index in _textures that corresponds to the output texture.
  23287. * @hidden
  23288. */
  23289. _currentRenderTextureInd: number;
  23290. private _effect;
  23291. private _samplers;
  23292. private _fragmentUrl;
  23293. private _vertexUrl;
  23294. private _parameters;
  23295. private _scaleRatio;
  23296. protected _indexParameters: any;
  23297. private _shareOutputWithPostProcess;
  23298. private _texelSize;
  23299. private _forcedOutputTexture;
  23300. /**
  23301. * Returns the fragment url or shader name used in the post process.
  23302. * @returns the fragment url or name in the shader store.
  23303. */
  23304. getEffectName(): string;
  23305. /**
  23306. * An event triggered when the postprocess is activated.
  23307. */
  23308. onActivateObservable: Observable<Camera>;
  23309. private _onActivateObserver;
  23310. /**
  23311. * A function that is added to the onActivateObservable
  23312. */
  23313. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23314. /**
  23315. * An event triggered when the postprocess changes its size.
  23316. */
  23317. onSizeChangedObservable: Observable<PostProcess>;
  23318. private _onSizeChangedObserver;
  23319. /**
  23320. * A function that is added to the onSizeChangedObservable
  23321. */
  23322. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23323. /**
  23324. * An event triggered when the postprocess applies its effect.
  23325. */
  23326. onApplyObservable: Observable<Effect>;
  23327. private _onApplyObserver;
  23328. /**
  23329. * A function that is added to the onApplyObservable
  23330. */
  23331. set onApply(callback: (effect: Effect) => void);
  23332. /**
  23333. * An event triggered before rendering the postprocess
  23334. */
  23335. onBeforeRenderObservable: Observable<Effect>;
  23336. private _onBeforeRenderObserver;
  23337. /**
  23338. * A function that is added to the onBeforeRenderObservable
  23339. */
  23340. set onBeforeRender(callback: (effect: Effect) => void);
  23341. /**
  23342. * An event triggered after rendering the postprocess
  23343. */
  23344. onAfterRenderObservable: Observable<Effect>;
  23345. private _onAfterRenderObserver;
  23346. /**
  23347. * A function that is added to the onAfterRenderObservable
  23348. */
  23349. set onAfterRender(callback: (efect: Effect) => void);
  23350. /**
  23351. * 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
  23352. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23353. */
  23354. get inputTexture(): InternalTexture;
  23355. set inputTexture(value: InternalTexture);
  23356. /**
  23357. * Gets the camera which post process is applied to.
  23358. * @returns The camera the post process is applied to.
  23359. */
  23360. getCamera(): Camera;
  23361. /**
  23362. * Gets the texel size of the postprocess.
  23363. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23364. */
  23365. get texelSize(): Vector2;
  23366. /**
  23367. * Creates a new instance PostProcess
  23368. * @param name The name of the PostProcess.
  23369. * @param fragmentUrl The url of the fragment shader to be used.
  23370. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23371. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23372. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23373. * @param camera The camera to apply the render pass to.
  23374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23375. * @param engine The engine which the post process will be applied. (default: current engine)
  23376. * @param reusable If the post process can be reused on the same frame. (default: false)
  23377. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23378. * @param textureType Type of textures used when performing the post process. (default: 0)
  23379. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23380. * @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
  23381. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23382. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23383. */
  23384. constructor(
  23385. /** Name of the PostProcess. */
  23386. 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);
  23387. /**
  23388. * Gets a string idenfifying the name of the class
  23389. * @returns "PostProcess" string
  23390. */
  23391. getClassName(): string;
  23392. /**
  23393. * Gets the engine which this post process belongs to.
  23394. * @returns The engine the post process was enabled with.
  23395. */
  23396. getEngine(): Engine;
  23397. /**
  23398. * The effect that is created when initializing the post process.
  23399. * @returns The created effect corresponding the the postprocess.
  23400. */
  23401. getEffect(): Effect;
  23402. /**
  23403. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23404. * @param postProcess The post process to share the output with.
  23405. * @returns This post process.
  23406. */
  23407. shareOutputWith(postProcess: PostProcess): PostProcess;
  23408. /**
  23409. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23410. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23411. */
  23412. useOwnOutput(): void;
  23413. /**
  23414. * Updates the effect with the current post process compile time values and recompiles the shader.
  23415. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23416. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23417. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23418. * @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
  23419. * @param onCompiled Called when the shader has been compiled.
  23420. * @param onError Called if there is an error when compiling a shader.
  23421. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23422. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23423. */
  23424. 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;
  23425. /**
  23426. * The post process is reusable if it can be used multiple times within one frame.
  23427. * @returns If the post process is reusable
  23428. */
  23429. isReusable(): boolean;
  23430. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23431. markTextureDirty(): void;
  23432. /**
  23433. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23434. * 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.
  23435. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23436. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23437. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23438. * @returns The target texture that was bound to be written to.
  23439. */
  23440. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23441. /**
  23442. * If the post process is supported.
  23443. */
  23444. get isSupported(): boolean;
  23445. /**
  23446. * The aspect ratio of the output texture.
  23447. */
  23448. get aspectRatio(): number;
  23449. /**
  23450. * Get a value indicating if the post-process is ready to be used
  23451. * @returns true if the post-process is ready (shader is compiled)
  23452. */
  23453. isReady(): boolean;
  23454. /**
  23455. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23456. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23457. */
  23458. apply(): Nullable<Effect>;
  23459. private _disposeTextures;
  23460. /**
  23461. * Disposes the post process.
  23462. * @param camera The camera to dispose the post process on.
  23463. */
  23464. dispose(camera?: Camera): void;
  23465. }
  23466. }
  23467. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23468. /** @hidden */
  23469. export var kernelBlurVaryingDeclaration: {
  23470. name: string;
  23471. shader: string;
  23472. };
  23473. }
  23474. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23475. /** @hidden */
  23476. export var kernelBlurFragment: {
  23477. name: string;
  23478. shader: string;
  23479. };
  23480. }
  23481. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23482. /** @hidden */
  23483. export var kernelBlurFragment2: {
  23484. name: string;
  23485. shader: string;
  23486. };
  23487. }
  23488. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23489. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23490. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23491. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23492. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23493. /** @hidden */
  23494. export var kernelBlurPixelShader: {
  23495. name: string;
  23496. shader: string;
  23497. };
  23498. }
  23499. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23500. /** @hidden */
  23501. export var kernelBlurVertex: {
  23502. name: string;
  23503. shader: string;
  23504. };
  23505. }
  23506. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23507. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23508. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23509. /** @hidden */
  23510. export var kernelBlurVertexShader: {
  23511. name: string;
  23512. shader: string;
  23513. };
  23514. }
  23515. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23516. import { Vector2 } from "babylonjs/Maths/math.vector";
  23517. import { Nullable } from "babylonjs/types";
  23518. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23519. import { Camera } from "babylonjs/Cameras/camera";
  23520. import { Effect } from "babylonjs/Materials/effect";
  23521. import { Engine } from "babylonjs/Engines/engine";
  23522. import "babylonjs/Shaders/kernelBlur.fragment";
  23523. import "babylonjs/Shaders/kernelBlur.vertex";
  23524. /**
  23525. * The Blur Post Process which blurs an image based on a kernel and direction.
  23526. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23527. */
  23528. export class BlurPostProcess extends PostProcess {
  23529. /** The direction in which to blur the image. */
  23530. direction: Vector2;
  23531. private blockCompilation;
  23532. protected _kernel: number;
  23533. protected _idealKernel: number;
  23534. protected _packedFloat: boolean;
  23535. private _staticDefines;
  23536. /**
  23537. * Sets the length in pixels of the blur sample region
  23538. */
  23539. set kernel(v: number);
  23540. /**
  23541. * Gets the length in pixels of the blur sample region
  23542. */
  23543. get kernel(): number;
  23544. /**
  23545. * Sets wether or not the blur needs to unpack/repack floats
  23546. */
  23547. set packedFloat(v: boolean);
  23548. /**
  23549. * Gets wether or not the blur is unpacking/repacking floats
  23550. */
  23551. get packedFloat(): boolean;
  23552. /**
  23553. * Creates a new instance BlurPostProcess
  23554. * @param name The name of the effect.
  23555. * @param direction The direction in which to blur the image.
  23556. * @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.
  23557. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23558. * @param camera The camera to apply the render pass to.
  23559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23560. * @param engine The engine which the post process will be applied. (default: current engine)
  23561. * @param reusable If the post process can be reused on the same frame. (default: false)
  23562. * @param textureType Type of textures used when performing the post process. (default: 0)
  23563. * @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)
  23564. */
  23565. constructor(name: string,
  23566. /** The direction in which to blur the image. */
  23567. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23568. /**
  23569. * Updates the effect with the current post process compile time values and recompiles the shader.
  23570. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23571. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23572. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23573. * @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
  23574. * @param onCompiled Called when the shader has been compiled.
  23575. * @param onError Called if there is an error when compiling a shader.
  23576. */
  23577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23578. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23579. /**
  23580. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23581. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23582. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23583. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23584. * The gaps between physical kernels are compensated for in the weighting of the samples
  23585. * @param idealKernel Ideal blur kernel.
  23586. * @return Nearest best kernel.
  23587. */
  23588. protected _nearestBestKernel(idealKernel: number): number;
  23589. /**
  23590. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23591. * @param x The point on the Gaussian distribution to sample.
  23592. * @return the value of the Gaussian function at x.
  23593. */
  23594. protected _gaussianWeight(x: number): number;
  23595. /**
  23596. * Generates a string that can be used as a floating point number in GLSL.
  23597. * @param x Value to print.
  23598. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23599. * @return GLSL float string.
  23600. */
  23601. protected _glslFloat(x: number, decimalFigures?: number): string;
  23602. }
  23603. }
  23604. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23605. import { Scene } from "babylonjs/scene";
  23606. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23607. import { Plane } from "babylonjs/Maths/math.plane";
  23608. /**
  23609. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23610. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23611. * You can then easily use it as a reflectionTexture on a flat surface.
  23612. * In case the surface is not a plane, please consider relying on reflection probes.
  23613. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23614. */
  23615. export class MirrorTexture extends RenderTargetTexture {
  23616. private scene;
  23617. /**
  23618. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23619. * 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.
  23620. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23621. */
  23622. mirrorPlane: Plane;
  23623. /**
  23624. * Define the blur ratio used to blur the reflection if needed.
  23625. */
  23626. set blurRatio(value: number);
  23627. get blurRatio(): number;
  23628. /**
  23629. * Define the adaptive blur kernel used to blur the reflection if needed.
  23630. * This will autocompute the closest best match for the `blurKernel`
  23631. */
  23632. set adaptiveBlurKernel(value: number);
  23633. /**
  23634. * Define the blur kernel used to blur the reflection if needed.
  23635. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23636. */
  23637. set blurKernel(value: number);
  23638. /**
  23639. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23640. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23641. */
  23642. set blurKernelX(value: number);
  23643. get blurKernelX(): number;
  23644. /**
  23645. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23646. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23647. */
  23648. set blurKernelY(value: number);
  23649. get blurKernelY(): number;
  23650. private _autoComputeBlurKernel;
  23651. protected _onRatioRescale(): void;
  23652. private _updateGammaSpace;
  23653. private _imageProcessingConfigChangeObserver;
  23654. private _transformMatrix;
  23655. private _mirrorMatrix;
  23656. private _savedViewMatrix;
  23657. private _blurX;
  23658. private _blurY;
  23659. private _adaptiveBlurKernel;
  23660. private _blurKernelX;
  23661. private _blurKernelY;
  23662. private _blurRatio;
  23663. /**
  23664. * Instantiates a Mirror Texture.
  23665. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23666. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23667. * You can then easily use it as a reflectionTexture on a flat surface.
  23668. * In case the surface is not a plane, please consider relying on reflection probes.
  23669. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23670. * @param name
  23671. * @param size
  23672. * @param scene
  23673. * @param generateMipMaps
  23674. * @param type
  23675. * @param samplingMode
  23676. * @param generateDepthBuffer
  23677. */
  23678. constructor(name: string, size: number | {
  23679. width: number;
  23680. height: number;
  23681. } | {
  23682. ratio: number;
  23683. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23684. private _preparePostProcesses;
  23685. /**
  23686. * Clone the mirror texture.
  23687. * @returns the cloned texture
  23688. */
  23689. clone(): MirrorTexture;
  23690. /**
  23691. * Serialize the texture to a JSON representation you could use in Parse later on
  23692. * @returns the serialized JSON representation
  23693. */
  23694. serialize(): any;
  23695. /**
  23696. * Dispose the texture and release its associated resources.
  23697. */
  23698. dispose(): void;
  23699. }
  23700. }
  23701. declare module "babylonjs/Materials/Textures/texture" {
  23702. import { Observable } from "babylonjs/Misc/observable";
  23703. import { Nullable } from "babylonjs/types";
  23704. import { Matrix } from "babylonjs/Maths/math.vector";
  23705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23706. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23707. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23708. import { Scene } from "babylonjs/scene";
  23709. /**
  23710. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23711. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23712. */
  23713. export class Texture extends BaseTexture {
  23714. /**
  23715. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23716. */
  23717. static SerializeBuffers: boolean;
  23718. /** @hidden */
  23719. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23720. /** @hidden */
  23721. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23722. /** @hidden */
  23723. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23724. /** nearest is mag = nearest and min = nearest and mip = linear */
  23725. static readonly NEAREST_SAMPLINGMODE: number;
  23726. /** nearest is mag = nearest and min = nearest and mip = linear */
  23727. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23729. static readonly BILINEAR_SAMPLINGMODE: number;
  23730. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23731. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23732. /** Trilinear is mag = linear and min = linear and mip = linear */
  23733. static readonly TRILINEAR_SAMPLINGMODE: number;
  23734. /** Trilinear is mag = linear and min = linear and mip = linear */
  23735. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23736. /** mag = nearest and min = nearest and mip = nearest */
  23737. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23738. /** mag = nearest and min = linear and mip = nearest */
  23739. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23740. /** mag = nearest and min = linear and mip = linear */
  23741. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23742. /** mag = nearest and min = linear and mip = none */
  23743. static readonly NEAREST_LINEAR: number;
  23744. /** mag = nearest and min = nearest and mip = none */
  23745. static readonly NEAREST_NEAREST: number;
  23746. /** mag = linear and min = nearest and mip = nearest */
  23747. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23748. /** mag = linear and min = nearest and mip = linear */
  23749. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23750. /** mag = linear and min = linear and mip = none */
  23751. static readonly LINEAR_LINEAR: number;
  23752. /** mag = linear and min = nearest and mip = none */
  23753. static readonly LINEAR_NEAREST: number;
  23754. /** Explicit coordinates mode */
  23755. static readonly EXPLICIT_MODE: number;
  23756. /** Spherical coordinates mode */
  23757. static readonly SPHERICAL_MODE: number;
  23758. /** Planar coordinates mode */
  23759. static readonly PLANAR_MODE: number;
  23760. /** Cubic coordinates mode */
  23761. static readonly CUBIC_MODE: number;
  23762. /** Projection coordinates mode */
  23763. static readonly PROJECTION_MODE: number;
  23764. /** Inverse Cubic coordinates mode */
  23765. static readonly SKYBOX_MODE: number;
  23766. /** Inverse Cubic coordinates mode */
  23767. static readonly INVCUBIC_MODE: number;
  23768. /** Equirectangular coordinates mode */
  23769. static readonly EQUIRECTANGULAR_MODE: number;
  23770. /** Equirectangular Fixed coordinates mode */
  23771. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23772. /** Equirectangular Fixed Mirrored coordinates mode */
  23773. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23774. /** Texture is not repeating outside of 0..1 UVs */
  23775. static readonly CLAMP_ADDRESSMODE: number;
  23776. /** Texture is repeating outside of 0..1 UVs */
  23777. static readonly WRAP_ADDRESSMODE: number;
  23778. /** Texture is repeating and mirrored */
  23779. static readonly MIRROR_ADDRESSMODE: number;
  23780. /**
  23781. * 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
  23782. */
  23783. static UseSerializedUrlIfAny: boolean;
  23784. /**
  23785. * Define the url of the texture.
  23786. */
  23787. url: Nullable<string>;
  23788. /**
  23789. * Define an offset on the texture to offset the u coordinates of the UVs
  23790. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23791. */
  23792. uOffset: number;
  23793. /**
  23794. * Define an offset on the texture to offset the v coordinates of the UVs
  23795. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23796. */
  23797. vOffset: number;
  23798. /**
  23799. * Define an offset on the texture to scale the u coordinates of the UVs
  23800. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23801. */
  23802. uScale: number;
  23803. /**
  23804. * Define an offset on the texture to scale the v coordinates of the UVs
  23805. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23806. */
  23807. vScale: number;
  23808. /**
  23809. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23810. * @see http://doc.babylonjs.com/how_to/more_materials
  23811. */
  23812. uAng: number;
  23813. /**
  23814. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23815. * @see http://doc.babylonjs.com/how_to/more_materials
  23816. */
  23817. vAng: number;
  23818. /**
  23819. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23820. * @see http://doc.babylonjs.com/how_to/more_materials
  23821. */
  23822. wAng: number;
  23823. /**
  23824. * Defines the center of rotation (U)
  23825. */
  23826. uRotationCenter: number;
  23827. /**
  23828. * Defines the center of rotation (V)
  23829. */
  23830. vRotationCenter: number;
  23831. /**
  23832. * Defines the center of rotation (W)
  23833. */
  23834. wRotationCenter: number;
  23835. /**
  23836. * Are mip maps generated for this texture or not.
  23837. */
  23838. get noMipmap(): boolean;
  23839. /**
  23840. * List of inspectable custom properties (used by the Inspector)
  23841. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23842. */
  23843. inspectableCustomProperties: Nullable<IInspectable[]>;
  23844. private _noMipmap;
  23845. /** @hidden */
  23846. _invertY: boolean;
  23847. private _rowGenerationMatrix;
  23848. private _cachedTextureMatrix;
  23849. private _projectionModeMatrix;
  23850. private _t0;
  23851. private _t1;
  23852. private _t2;
  23853. private _cachedUOffset;
  23854. private _cachedVOffset;
  23855. private _cachedUScale;
  23856. private _cachedVScale;
  23857. private _cachedUAng;
  23858. private _cachedVAng;
  23859. private _cachedWAng;
  23860. private _cachedProjectionMatrixId;
  23861. private _cachedCoordinatesMode;
  23862. /** @hidden */
  23863. protected _initialSamplingMode: number;
  23864. /** @hidden */
  23865. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23866. private _deleteBuffer;
  23867. protected _format: Nullable<number>;
  23868. private _delayedOnLoad;
  23869. private _delayedOnError;
  23870. private _mimeType?;
  23871. /**
  23872. * Observable triggered once the texture has been loaded.
  23873. */
  23874. onLoadObservable: Observable<Texture>;
  23875. protected _isBlocking: boolean;
  23876. /**
  23877. * Is the texture preventing material to render while loading.
  23878. * If false, a default texture will be used instead of the loading one during the preparation step.
  23879. */
  23880. set isBlocking(value: boolean);
  23881. get isBlocking(): boolean;
  23882. /**
  23883. * Get the current sampling mode associated with the texture.
  23884. */
  23885. get samplingMode(): number;
  23886. /**
  23887. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23888. */
  23889. get invertY(): boolean;
  23890. /**
  23891. * Instantiates a new texture.
  23892. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23893. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23894. * @param url defines the url of the picture to load as a texture
  23895. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23896. * @param noMipmap defines if the texture will require mip maps or not
  23897. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23898. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23899. * @param onLoad defines a callback triggered when the texture has been loaded
  23900. * @param onError defines a callback triggered when an error occurred during the loading session
  23901. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23902. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23903. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23904. * @param mimeType defines an optional mime type information
  23905. */
  23906. 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);
  23907. /**
  23908. * Update the url (and optional buffer) of this texture if url was null during construction.
  23909. * @param url the url of the texture
  23910. * @param buffer the buffer of the texture (defaults to null)
  23911. * @param onLoad callback called when the texture is loaded (defaults to null)
  23912. */
  23913. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23914. /**
  23915. * Finish the loading sequence of a texture flagged as delayed load.
  23916. * @hidden
  23917. */
  23918. delayLoad(): void;
  23919. private _prepareRowForTextureGeneration;
  23920. /**
  23921. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23922. * @returns the transform matrix of the texture.
  23923. */
  23924. getTextureMatrix(uBase?: number): Matrix;
  23925. /**
  23926. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23927. * @returns The reflection texture transform
  23928. */
  23929. getReflectionTextureMatrix(): Matrix;
  23930. /**
  23931. * Clones the texture.
  23932. * @returns the cloned texture
  23933. */
  23934. clone(): Texture;
  23935. /**
  23936. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23937. * @returns The JSON representation of the texture
  23938. */
  23939. serialize(): any;
  23940. /**
  23941. * Get the current class name of the texture useful for serialization or dynamic coding.
  23942. * @returns "Texture"
  23943. */
  23944. getClassName(): string;
  23945. /**
  23946. * Dispose the texture and release its associated resources.
  23947. */
  23948. dispose(): void;
  23949. /**
  23950. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23951. * @param parsedTexture Define the JSON representation of the texture
  23952. * @param scene Define the scene the parsed texture should be instantiated in
  23953. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23954. * @returns The parsed texture if successful
  23955. */
  23956. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23957. /**
  23958. * Creates a texture from its base 64 representation.
  23959. * @param data Define the base64 payload without the data: prefix
  23960. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23961. * @param scene Define the scene the texture should belong to
  23962. * @param noMipmap Forces the texture to not create mip map information if true
  23963. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23964. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23965. * @param onLoad define a callback triggered when the texture has been loaded
  23966. * @param onError define a callback triggered when an error occurred during the loading session
  23967. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23968. * @returns the created texture
  23969. */
  23970. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23971. /**
  23972. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23973. * @param data Define the base64 payload without the data: prefix
  23974. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23975. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23976. * @param scene Define the scene the texture should belong to
  23977. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23978. * @param noMipmap Forces the texture to not create mip map information if true
  23979. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23980. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23981. * @param onLoad define a callback triggered when the texture has been loaded
  23982. * @param onError define a callback triggered when an error occurred during the loading session
  23983. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23984. * @returns the created texture
  23985. */
  23986. 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;
  23987. }
  23988. }
  23989. declare module "babylonjs/PostProcesses/postProcessManager" {
  23990. import { Nullable } from "babylonjs/types";
  23991. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23993. import { Scene } from "babylonjs/scene";
  23994. /**
  23995. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23996. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23997. */
  23998. export class PostProcessManager {
  23999. private _scene;
  24000. private _indexBuffer;
  24001. private _vertexBuffers;
  24002. /**
  24003. * Creates a new instance PostProcess
  24004. * @param scene The scene that the post process is associated with.
  24005. */
  24006. constructor(scene: Scene);
  24007. private _prepareBuffers;
  24008. private _buildIndexBuffer;
  24009. /**
  24010. * Rebuilds the vertex buffers of the manager.
  24011. * @hidden
  24012. */
  24013. _rebuild(): void;
  24014. /**
  24015. * Prepares a frame to be run through a post process.
  24016. * @param sourceTexture The input texture to the post procesess. (default: null)
  24017. * @param postProcesses An array of post processes to be run. (default: null)
  24018. * @returns True if the post processes were able to be run.
  24019. * @hidden
  24020. */
  24021. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24022. /**
  24023. * Manually render a set of post processes to a texture.
  24024. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24025. * @param postProcesses An array of post processes to be run.
  24026. * @param targetTexture The target texture to render to.
  24027. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24028. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24029. * @param lodLevel defines which lod of the texture to render to
  24030. */
  24031. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  24032. /**
  24033. * Finalize the result of the output of the postprocesses.
  24034. * @param doNotPresent If true the result will not be displayed to the screen.
  24035. * @param targetTexture The target texture to render to.
  24036. * @param faceIndex The index of the face to bind the target texture to.
  24037. * @param postProcesses The array of post processes to render.
  24038. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24039. * @hidden
  24040. */
  24041. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24042. /**
  24043. * Disposes of the post process manager.
  24044. */
  24045. dispose(): void;
  24046. }
  24047. }
  24048. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24049. import { Observable } from "babylonjs/Misc/observable";
  24050. import { SmartArray } from "babylonjs/Misc/smartArray";
  24051. import { Nullable, Immutable } from "babylonjs/types";
  24052. import { Camera } from "babylonjs/Cameras/camera";
  24053. import { Scene } from "babylonjs/scene";
  24054. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24055. import { Color4 } from "babylonjs/Maths/math.color";
  24056. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24058. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24059. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24060. import { Texture } from "babylonjs/Materials/Textures/texture";
  24061. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24062. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24063. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24064. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24065. import { Engine } from "babylonjs/Engines/engine";
  24066. /**
  24067. * This Helps creating a texture that will be created from a camera in your scene.
  24068. * It is basically a dynamic texture that could be used to create special effects for instance.
  24069. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24070. */
  24071. export class RenderTargetTexture extends Texture {
  24072. isCube: boolean;
  24073. /**
  24074. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24075. */
  24076. static readonly REFRESHRATE_RENDER_ONCE: number;
  24077. /**
  24078. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24079. */
  24080. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24081. /**
  24082. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24083. * the central point of your effect and can save a lot of performances.
  24084. */
  24085. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24086. /**
  24087. * Use this predicate to dynamically define the list of mesh you want to render.
  24088. * If set, the renderList property will be overwritten.
  24089. */
  24090. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24091. private _renderList;
  24092. /**
  24093. * Use this list to define the list of mesh you want to render.
  24094. */
  24095. get renderList(): Nullable<Array<AbstractMesh>>;
  24096. set renderList(value: Nullable<Array<AbstractMesh>>);
  24097. /**
  24098. * Use this function to overload the renderList array at rendering time.
  24099. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24100. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24101. * the cube (if the RTT is a cube, else layerOrFace=0).
  24102. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24103. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24104. * hold dummy elements!
  24105. */
  24106. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24107. private _hookArray;
  24108. /**
  24109. * Define if particles should be rendered in your texture.
  24110. */
  24111. renderParticles: boolean;
  24112. /**
  24113. * Define if sprites should be rendered in your texture.
  24114. */
  24115. renderSprites: boolean;
  24116. /**
  24117. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24118. */
  24119. coordinatesMode: number;
  24120. /**
  24121. * Define the camera used to render the texture.
  24122. */
  24123. activeCamera: Nullable<Camera>;
  24124. /**
  24125. * Override the mesh isReady function with your own one.
  24126. */
  24127. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24128. /**
  24129. * Override the render function of the texture with your own one.
  24130. */
  24131. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24132. /**
  24133. * Define if camera post processes should be use while rendering the texture.
  24134. */
  24135. useCameraPostProcesses: boolean;
  24136. /**
  24137. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24138. */
  24139. ignoreCameraViewport: boolean;
  24140. private _postProcessManager;
  24141. private _postProcesses;
  24142. private _resizeObserver;
  24143. /**
  24144. * An event triggered when the texture is unbind.
  24145. */
  24146. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24147. /**
  24148. * An event triggered when the texture is unbind.
  24149. */
  24150. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24151. private _onAfterUnbindObserver;
  24152. /**
  24153. * Set a after unbind callback in the texture.
  24154. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24155. */
  24156. set onAfterUnbind(callback: () => void);
  24157. /**
  24158. * An event triggered before rendering the texture
  24159. */
  24160. onBeforeRenderObservable: Observable<number>;
  24161. private _onBeforeRenderObserver;
  24162. /**
  24163. * Set a before render callback in the texture.
  24164. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24165. */
  24166. set onBeforeRender(callback: (faceIndex: number) => void);
  24167. /**
  24168. * An event triggered after rendering the texture
  24169. */
  24170. onAfterRenderObservable: Observable<number>;
  24171. private _onAfterRenderObserver;
  24172. /**
  24173. * Set a after render callback in the texture.
  24174. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24175. */
  24176. set onAfterRender(callback: (faceIndex: number) => void);
  24177. /**
  24178. * An event triggered after the texture clear
  24179. */
  24180. onClearObservable: Observable<Engine>;
  24181. private _onClearObserver;
  24182. /**
  24183. * Set a clear callback in the texture.
  24184. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24185. */
  24186. set onClear(callback: (Engine: Engine) => void);
  24187. /**
  24188. * An event triggered when the texture is resized.
  24189. */
  24190. onResizeObservable: Observable<RenderTargetTexture>;
  24191. /**
  24192. * Define the clear color of the Render Target if it should be different from the scene.
  24193. */
  24194. clearColor: Color4;
  24195. protected _size: number | {
  24196. width: number;
  24197. height: number;
  24198. layers?: number;
  24199. };
  24200. protected _initialSizeParameter: number | {
  24201. width: number;
  24202. height: number;
  24203. } | {
  24204. ratio: number;
  24205. };
  24206. protected _sizeRatio: Nullable<number>;
  24207. /** @hidden */
  24208. _generateMipMaps: boolean;
  24209. protected _renderingManager: RenderingManager;
  24210. /** @hidden */
  24211. _waitingRenderList: string[];
  24212. protected _doNotChangeAspectRatio: boolean;
  24213. protected _currentRefreshId: number;
  24214. protected _refreshRate: number;
  24215. protected _textureMatrix: Matrix;
  24216. protected _samples: number;
  24217. protected _renderTargetOptions: RenderTargetCreationOptions;
  24218. /**
  24219. * Gets render target creation options that were used.
  24220. */
  24221. get renderTargetOptions(): RenderTargetCreationOptions;
  24222. protected _onRatioRescale(): void;
  24223. /**
  24224. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24225. * It must define where the camera used to render the texture is set
  24226. */
  24227. boundingBoxPosition: Vector3;
  24228. private _boundingBoxSize;
  24229. /**
  24230. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24231. * When defined, the cubemap will switch to local mode
  24232. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24233. * @example https://www.babylonjs-playground.com/#RNASML
  24234. */
  24235. set boundingBoxSize(value: Vector3);
  24236. get boundingBoxSize(): Vector3;
  24237. /**
  24238. * In case the RTT has been created with a depth texture, get the associated
  24239. * depth texture.
  24240. * Otherwise, return null.
  24241. */
  24242. get depthStencilTexture(): Nullable<InternalTexture>;
  24243. /**
  24244. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24245. * or used a shadow, depth texture...
  24246. * @param name The friendly name of the texture
  24247. * @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)
  24248. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24249. * @param generateMipMaps True if mip maps need to be generated after render.
  24250. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24251. * @param type The type of the buffer in the RTT (int, half float, float...)
  24252. * @param isCube True if a cube texture needs to be created
  24253. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24254. * @param generateDepthBuffer True to generate a depth buffer
  24255. * @param generateStencilBuffer True to generate a stencil buffer
  24256. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24257. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24258. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24259. */
  24260. constructor(name: string, size: number | {
  24261. width: number;
  24262. height: number;
  24263. layers?: number;
  24264. } | {
  24265. ratio: number;
  24266. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24267. /**
  24268. * Creates a depth stencil texture.
  24269. * This is only available in WebGL 2 or with the depth texture extension available.
  24270. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24271. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24272. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24273. */
  24274. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24275. private _processSizeParameter;
  24276. /**
  24277. * Define the number of samples to use in case of MSAA.
  24278. * It defaults to one meaning no MSAA has been enabled.
  24279. */
  24280. get samples(): number;
  24281. set samples(value: number);
  24282. /**
  24283. * Resets the refresh counter of the texture and start bak from scratch.
  24284. * Could be useful to regenerate the texture if it is setup to render only once.
  24285. */
  24286. resetRefreshCounter(): void;
  24287. /**
  24288. * Define the refresh rate of the texture or the rendering frequency.
  24289. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24290. */
  24291. get refreshRate(): number;
  24292. set refreshRate(value: number);
  24293. /**
  24294. * Adds a post process to the render target rendering passes.
  24295. * @param postProcess define the post process to add
  24296. */
  24297. addPostProcess(postProcess: PostProcess): void;
  24298. /**
  24299. * Clear all the post processes attached to the render target
  24300. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24301. */
  24302. clearPostProcesses(dispose?: boolean): void;
  24303. /**
  24304. * Remove one of the post process from the list of attached post processes to the texture
  24305. * @param postProcess define the post process to remove from the list
  24306. */
  24307. removePostProcess(postProcess: PostProcess): void;
  24308. /** @hidden */
  24309. _shouldRender(): boolean;
  24310. /**
  24311. * Gets the actual render size of the texture.
  24312. * @returns the width of the render size
  24313. */
  24314. getRenderSize(): number;
  24315. /**
  24316. * Gets the actual render width of the texture.
  24317. * @returns the width of the render size
  24318. */
  24319. getRenderWidth(): number;
  24320. /**
  24321. * Gets the actual render height of the texture.
  24322. * @returns the height of the render size
  24323. */
  24324. getRenderHeight(): number;
  24325. /**
  24326. * Gets the actual number of layers of the texture.
  24327. * @returns the number of layers
  24328. */
  24329. getRenderLayers(): number;
  24330. /**
  24331. * Get if the texture can be rescaled or not.
  24332. */
  24333. get canRescale(): boolean;
  24334. /**
  24335. * Resize the texture using a ratio.
  24336. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24337. */
  24338. scale(ratio: number): void;
  24339. /**
  24340. * Get the texture reflection matrix used to rotate/transform the reflection.
  24341. * @returns the reflection matrix
  24342. */
  24343. getReflectionTextureMatrix(): Matrix;
  24344. /**
  24345. * Resize the texture to a new desired size.
  24346. * Be carrefull as it will recreate all the data in the new texture.
  24347. * @param size Define the new size. It can be:
  24348. * - a number for squared texture,
  24349. * - an object containing { width: number, height: number }
  24350. * - or an object containing a ratio { ratio: number }
  24351. */
  24352. resize(size: number | {
  24353. width: number;
  24354. height: number;
  24355. } | {
  24356. ratio: number;
  24357. }): void;
  24358. private _defaultRenderListPrepared;
  24359. /**
  24360. * Renders all the objects from the render list into the texture.
  24361. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24362. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24363. */
  24364. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24365. private _bestReflectionRenderTargetDimension;
  24366. private _prepareRenderingManager;
  24367. /**
  24368. * @hidden
  24369. * @param faceIndex face index to bind to if this is a cubetexture
  24370. * @param layer defines the index of the texture to bind in the array
  24371. */
  24372. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24373. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24374. private renderToTarget;
  24375. /**
  24376. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24377. * This allowed control for front to back rendering or reversly depending of the special needs.
  24378. *
  24379. * @param renderingGroupId The rendering group id corresponding to its index
  24380. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24381. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24382. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24383. */
  24384. 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;
  24385. /**
  24386. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24387. *
  24388. * @param renderingGroupId The rendering group id corresponding to its index
  24389. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24390. */
  24391. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24392. /**
  24393. * Clones the texture.
  24394. * @returns the cloned texture
  24395. */
  24396. clone(): RenderTargetTexture;
  24397. /**
  24398. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24399. * @returns The JSON representation of the texture
  24400. */
  24401. serialize(): any;
  24402. /**
  24403. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24404. */
  24405. disposeFramebufferObjects(): void;
  24406. /**
  24407. * Dispose the texture and release its associated resources.
  24408. */
  24409. dispose(): void;
  24410. /** @hidden */
  24411. _rebuild(): void;
  24412. /**
  24413. * Clear the info related to rendering groups preventing retention point in material dispose.
  24414. */
  24415. freeRenderingGroups(): void;
  24416. /**
  24417. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24418. * @returns the view count
  24419. */
  24420. getViewCount(): number;
  24421. }
  24422. }
  24423. declare module "babylonjs/Misc/guid" {
  24424. /**
  24425. * Class used to manipulate GUIDs
  24426. */
  24427. export class GUID {
  24428. /**
  24429. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24430. * Be aware Math.random() could cause collisions, but:
  24431. * "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"
  24432. * @returns a pseudo random id
  24433. */
  24434. static RandomId(): string;
  24435. }
  24436. }
  24437. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24438. import { Nullable } from "babylonjs/types";
  24439. import { Scene } from "babylonjs/scene";
  24440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24441. import { Material } from "babylonjs/Materials/material";
  24442. import { Effect } from "babylonjs/Materials/effect";
  24443. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24444. /**
  24445. * Options to be used when creating a shadow depth material
  24446. */
  24447. export interface IIOptionShadowDepthMaterial {
  24448. /** Variables in the vertex shader code that need to have their names remapped.
  24449. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24450. * "var_name" should be either: worldPos or vNormalW
  24451. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24452. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24453. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24454. */
  24455. remappedVariables?: string[];
  24456. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24457. standalone?: boolean;
  24458. }
  24459. /**
  24460. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24461. */
  24462. export class ShadowDepthWrapper {
  24463. private _scene;
  24464. private _options?;
  24465. private _baseMaterial;
  24466. private _onEffectCreatedObserver;
  24467. private _subMeshToEffect;
  24468. private _subMeshToDepthEffect;
  24469. private _meshes;
  24470. /** @hidden */
  24471. _matriceNames: any;
  24472. /** Gets the standalone status of the wrapper */
  24473. get standalone(): boolean;
  24474. /** Gets the base material the wrapper is built upon */
  24475. get baseMaterial(): Material;
  24476. /**
  24477. * Instantiate a new shadow depth wrapper.
  24478. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24479. * generate the shadow depth map. For more information, please refer to the documentation:
  24480. * https://doc.babylonjs.com/babylon101/shadows
  24481. * @param baseMaterial Material to wrap
  24482. * @param scene Define the scene the material belongs to
  24483. * @param options Options used to create the wrapper
  24484. */
  24485. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24486. /**
  24487. * Gets the effect to use to generate the depth map
  24488. * @param subMesh subMesh to get the effect for
  24489. * @param shadowGenerator shadow generator to get the effect for
  24490. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24491. */
  24492. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24493. /**
  24494. * Specifies that the submesh is ready to be used for depth rendering
  24495. * @param subMesh submesh to check
  24496. * @param defines the list of defines to take into account when checking the effect
  24497. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24498. * @param useInstances specifies that instances should be used
  24499. * @returns a boolean indicating that the submesh is ready or not
  24500. */
  24501. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24502. /**
  24503. * Disposes the resources
  24504. */
  24505. dispose(): void;
  24506. private _makeEffect;
  24507. }
  24508. }
  24509. declare module "babylonjs/Materials/material" {
  24510. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24511. import { SmartArray } from "babylonjs/Misc/smartArray";
  24512. import { Observable } from "babylonjs/Misc/observable";
  24513. import { Nullable } from "babylonjs/types";
  24514. import { Scene } from "babylonjs/scene";
  24515. import { Matrix } from "babylonjs/Maths/math.vector";
  24516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24518. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24519. import { Effect } from "babylonjs/Materials/effect";
  24520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24522. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24523. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24524. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24525. import { Mesh } from "babylonjs/Meshes/mesh";
  24526. import { Animation } from "babylonjs/Animations/animation";
  24527. /**
  24528. * Options for compiling materials.
  24529. */
  24530. export interface IMaterialCompilationOptions {
  24531. /**
  24532. * Defines whether clip planes are enabled.
  24533. */
  24534. clipPlane: boolean;
  24535. /**
  24536. * Defines whether instances are enabled.
  24537. */
  24538. useInstances: boolean;
  24539. }
  24540. /**
  24541. * Options passed when calling customShaderNameResolve
  24542. */
  24543. export interface ICustomShaderNameResolveOptions {
  24544. /**
  24545. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  24546. */
  24547. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24548. }
  24549. /**
  24550. * Base class for the main features of a material in Babylon.js
  24551. */
  24552. export class Material implements IAnimatable {
  24553. /**
  24554. * Returns the triangle fill mode
  24555. */
  24556. static readonly TriangleFillMode: number;
  24557. /**
  24558. * Returns the wireframe mode
  24559. */
  24560. static readonly WireFrameFillMode: number;
  24561. /**
  24562. * Returns the point fill mode
  24563. */
  24564. static readonly PointFillMode: number;
  24565. /**
  24566. * Returns the point list draw mode
  24567. */
  24568. static readonly PointListDrawMode: number;
  24569. /**
  24570. * Returns the line list draw mode
  24571. */
  24572. static readonly LineListDrawMode: number;
  24573. /**
  24574. * Returns the line loop draw mode
  24575. */
  24576. static readonly LineLoopDrawMode: number;
  24577. /**
  24578. * Returns the line strip draw mode
  24579. */
  24580. static readonly LineStripDrawMode: number;
  24581. /**
  24582. * Returns the triangle strip draw mode
  24583. */
  24584. static readonly TriangleStripDrawMode: number;
  24585. /**
  24586. * Returns the triangle fan draw mode
  24587. */
  24588. static readonly TriangleFanDrawMode: number;
  24589. /**
  24590. * Stores the clock-wise side orientation
  24591. */
  24592. static readonly ClockWiseSideOrientation: number;
  24593. /**
  24594. * Stores the counter clock-wise side orientation
  24595. */
  24596. static readonly CounterClockWiseSideOrientation: number;
  24597. /**
  24598. * The dirty texture flag value
  24599. */
  24600. static readonly TextureDirtyFlag: number;
  24601. /**
  24602. * The dirty light flag value
  24603. */
  24604. static readonly LightDirtyFlag: number;
  24605. /**
  24606. * The dirty fresnel flag value
  24607. */
  24608. static readonly FresnelDirtyFlag: number;
  24609. /**
  24610. * The dirty attribute flag value
  24611. */
  24612. static readonly AttributesDirtyFlag: number;
  24613. /**
  24614. * The dirty misc flag value
  24615. */
  24616. static readonly MiscDirtyFlag: number;
  24617. /**
  24618. * The all dirty flag value
  24619. */
  24620. static readonly AllDirtyFlag: number;
  24621. /**
  24622. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24623. */
  24624. static readonly MATERIAL_OPAQUE: number;
  24625. /**
  24626. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24627. */
  24628. static readonly MATERIAL_ALPHATEST: number;
  24629. /**
  24630. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24631. */
  24632. static readonly MATERIAL_ALPHABLEND: number;
  24633. /**
  24634. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24635. * They are also discarded below the alpha cutoff threshold to improve performances.
  24636. */
  24637. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24638. /**
  24639. * Custom callback helping to override the default shader used in the material.
  24640. */
  24641. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24642. /**
  24643. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24644. */
  24645. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24646. /**
  24647. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24648. * This means that the material can keep using a previous shader while a new one is being compiled.
  24649. * This is mostly used when shader parallel compilation is supported (true by default)
  24650. */
  24651. allowShaderHotSwapping: boolean;
  24652. /**
  24653. * The ID of the material
  24654. */
  24655. id: string;
  24656. /**
  24657. * Gets or sets the unique id of the material
  24658. */
  24659. uniqueId: number;
  24660. /**
  24661. * The name of the material
  24662. */
  24663. name: string;
  24664. /**
  24665. * Gets or sets user defined metadata
  24666. */
  24667. metadata: any;
  24668. /**
  24669. * For internal use only. Please do not use.
  24670. */
  24671. reservedDataStore: any;
  24672. /**
  24673. * Specifies if the ready state should be checked on each call
  24674. */
  24675. checkReadyOnEveryCall: boolean;
  24676. /**
  24677. * Specifies if the ready state should be checked once
  24678. */
  24679. checkReadyOnlyOnce: boolean;
  24680. /**
  24681. * The state of the material
  24682. */
  24683. state: string;
  24684. /**
  24685. * The alpha value of the material
  24686. */
  24687. protected _alpha: number;
  24688. /**
  24689. * List of inspectable custom properties (used by the Inspector)
  24690. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24691. */
  24692. inspectableCustomProperties: IInspectable[];
  24693. /**
  24694. * Sets the alpha value of the material
  24695. */
  24696. set alpha(value: number);
  24697. /**
  24698. * Gets the alpha value of the material
  24699. */
  24700. get alpha(): number;
  24701. /**
  24702. * Specifies if back face culling is enabled
  24703. */
  24704. protected _backFaceCulling: boolean;
  24705. /**
  24706. * Sets the back-face culling state
  24707. */
  24708. set backFaceCulling(value: boolean);
  24709. /**
  24710. * Gets the back-face culling state
  24711. */
  24712. get backFaceCulling(): boolean;
  24713. /**
  24714. * Stores the value for side orientation
  24715. */
  24716. sideOrientation: number;
  24717. /**
  24718. * Callback triggered when the material is compiled
  24719. */
  24720. onCompiled: Nullable<(effect: Effect) => void>;
  24721. /**
  24722. * Callback triggered when an error occurs
  24723. */
  24724. onError: Nullable<(effect: Effect, errors: string) => void>;
  24725. /**
  24726. * Callback triggered to get the render target textures
  24727. */
  24728. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24729. /**
  24730. * Gets a boolean indicating that current material needs to register RTT
  24731. */
  24732. get hasRenderTargetTextures(): boolean;
  24733. /**
  24734. * Specifies if the material should be serialized
  24735. */
  24736. doNotSerialize: boolean;
  24737. /**
  24738. * @hidden
  24739. */
  24740. _storeEffectOnSubMeshes: boolean;
  24741. /**
  24742. * Stores the animations for the material
  24743. */
  24744. animations: Nullable<Array<Animation>>;
  24745. /**
  24746. * An event triggered when the material is disposed
  24747. */
  24748. onDisposeObservable: Observable<Material>;
  24749. /**
  24750. * An observer which watches for dispose events
  24751. */
  24752. private _onDisposeObserver;
  24753. private _onUnBindObservable;
  24754. /**
  24755. * Called during a dispose event
  24756. */
  24757. set onDispose(callback: () => void);
  24758. private _onBindObservable;
  24759. /**
  24760. * An event triggered when the material is bound
  24761. */
  24762. get onBindObservable(): Observable<AbstractMesh>;
  24763. /**
  24764. * An observer which watches for bind events
  24765. */
  24766. private _onBindObserver;
  24767. /**
  24768. * Called during a bind event
  24769. */
  24770. set onBind(callback: (Mesh: AbstractMesh) => void);
  24771. /**
  24772. * An event triggered when the material is unbound
  24773. */
  24774. get onUnBindObservable(): Observable<Material>;
  24775. protected _onEffectCreatedObservable: Nullable<Observable<{
  24776. effect: Effect;
  24777. subMesh: Nullable<SubMesh>;
  24778. }>>;
  24779. /**
  24780. * An event triggered when the effect is (re)created
  24781. */
  24782. get onEffectCreatedObservable(): Observable<{
  24783. effect: Effect;
  24784. subMesh: Nullable<SubMesh>;
  24785. }>;
  24786. /**
  24787. * Stores the value of the alpha mode
  24788. */
  24789. private _alphaMode;
  24790. /**
  24791. * Sets the value of the alpha mode.
  24792. *
  24793. * | Value | Type | Description |
  24794. * | --- | --- | --- |
  24795. * | 0 | ALPHA_DISABLE | |
  24796. * | 1 | ALPHA_ADD | |
  24797. * | 2 | ALPHA_COMBINE | |
  24798. * | 3 | ALPHA_SUBTRACT | |
  24799. * | 4 | ALPHA_MULTIPLY | |
  24800. * | 5 | ALPHA_MAXIMIZED | |
  24801. * | 6 | ALPHA_ONEONE | |
  24802. * | 7 | ALPHA_PREMULTIPLIED | |
  24803. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24804. * | 9 | ALPHA_INTERPOLATE | |
  24805. * | 10 | ALPHA_SCREENMODE | |
  24806. *
  24807. */
  24808. set alphaMode(value: number);
  24809. /**
  24810. * Gets the value of the alpha mode
  24811. */
  24812. get alphaMode(): number;
  24813. /**
  24814. * Stores the state of the need depth pre-pass value
  24815. */
  24816. private _needDepthPrePass;
  24817. /**
  24818. * Sets the need depth pre-pass value
  24819. */
  24820. set needDepthPrePass(value: boolean);
  24821. /**
  24822. * Gets the depth pre-pass value
  24823. */
  24824. get needDepthPrePass(): boolean;
  24825. /**
  24826. * Specifies if depth writing should be disabled
  24827. */
  24828. disableDepthWrite: boolean;
  24829. /**
  24830. * Specifies if color writing should be disabled
  24831. */
  24832. disableColorWrite: boolean;
  24833. /**
  24834. * Specifies if depth writing should be forced
  24835. */
  24836. forceDepthWrite: boolean;
  24837. /**
  24838. * Specifies the depth function that should be used. 0 means the default engine function
  24839. */
  24840. depthFunction: number;
  24841. /**
  24842. * Specifies if there should be a separate pass for culling
  24843. */
  24844. separateCullingPass: boolean;
  24845. /**
  24846. * Stores the state specifing if fog should be enabled
  24847. */
  24848. private _fogEnabled;
  24849. /**
  24850. * Sets the state for enabling fog
  24851. */
  24852. set fogEnabled(value: boolean);
  24853. /**
  24854. * Gets the value of the fog enabled state
  24855. */
  24856. get fogEnabled(): boolean;
  24857. /**
  24858. * Stores the size of points
  24859. */
  24860. pointSize: number;
  24861. /**
  24862. * Stores the z offset value
  24863. */
  24864. zOffset: number;
  24865. get wireframe(): boolean;
  24866. /**
  24867. * Sets the state of wireframe mode
  24868. */
  24869. set wireframe(value: boolean);
  24870. /**
  24871. * Gets the value specifying if point clouds are enabled
  24872. */
  24873. get pointsCloud(): boolean;
  24874. /**
  24875. * Sets the state of point cloud mode
  24876. */
  24877. set pointsCloud(value: boolean);
  24878. /**
  24879. * Gets the material fill mode
  24880. */
  24881. get fillMode(): number;
  24882. /**
  24883. * Sets the material fill mode
  24884. */
  24885. set fillMode(value: number);
  24886. /**
  24887. * @hidden
  24888. * Stores the effects for the material
  24889. */
  24890. _effect: Nullable<Effect>;
  24891. /**
  24892. * Specifies if uniform buffers should be used
  24893. */
  24894. private _useUBO;
  24895. /**
  24896. * Stores a reference to the scene
  24897. */
  24898. private _scene;
  24899. /**
  24900. * Stores the fill mode state
  24901. */
  24902. private _fillMode;
  24903. /**
  24904. * Specifies if the depth write state should be cached
  24905. */
  24906. private _cachedDepthWriteState;
  24907. /**
  24908. * Specifies if the color write state should be cached
  24909. */
  24910. private _cachedColorWriteState;
  24911. /**
  24912. * Specifies if the depth function state should be cached
  24913. */
  24914. private _cachedDepthFunctionState;
  24915. /**
  24916. * Stores the uniform buffer
  24917. */
  24918. protected _uniformBuffer: UniformBuffer;
  24919. /** @hidden */
  24920. _indexInSceneMaterialArray: number;
  24921. /** @hidden */
  24922. meshMap: Nullable<{
  24923. [id: string]: AbstractMesh | undefined;
  24924. }>;
  24925. /**
  24926. * Creates a material instance
  24927. * @param name defines the name of the material
  24928. * @param scene defines the scene to reference
  24929. * @param doNotAdd specifies if the material should be added to the scene
  24930. */
  24931. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24932. /**
  24933. * Returns a string representation of the current material
  24934. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24935. * @returns a string with material information
  24936. */
  24937. toString(fullDetails?: boolean): string;
  24938. /**
  24939. * Gets the class name of the material
  24940. * @returns a string with the class name of the material
  24941. */
  24942. getClassName(): string;
  24943. /**
  24944. * Specifies if updates for the material been locked
  24945. */
  24946. get isFrozen(): boolean;
  24947. /**
  24948. * Locks updates for the material
  24949. */
  24950. freeze(): void;
  24951. /**
  24952. * Unlocks updates for the material
  24953. */
  24954. unfreeze(): void;
  24955. /**
  24956. * Specifies if the material is ready to be used
  24957. * @param mesh defines the mesh to check
  24958. * @param useInstances specifies if instances should be used
  24959. * @returns a boolean indicating if the material is ready to be used
  24960. */
  24961. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24962. /**
  24963. * Specifies that the submesh is ready to be used
  24964. * @param mesh defines the mesh to check
  24965. * @param subMesh defines which submesh to check
  24966. * @param useInstances specifies that instances should be used
  24967. * @returns a boolean indicating that the submesh is ready or not
  24968. */
  24969. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24970. /**
  24971. * Returns the material effect
  24972. * @returns the effect associated with the material
  24973. */
  24974. getEffect(): Nullable<Effect>;
  24975. /**
  24976. * Returns the current scene
  24977. * @returns a Scene
  24978. */
  24979. getScene(): Scene;
  24980. /**
  24981. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24982. */
  24983. protected _forceAlphaTest: boolean;
  24984. /**
  24985. * The transparency mode of the material.
  24986. */
  24987. protected _transparencyMode: Nullable<number>;
  24988. /**
  24989. * Gets the current transparency mode.
  24990. */
  24991. get transparencyMode(): Nullable<number>;
  24992. /**
  24993. * Sets the transparency mode of the material.
  24994. *
  24995. * | Value | Type | Description |
  24996. * | ----- | ----------------------------------- | ----------- |
  24997. * | 0 | OPAQUE | |
  24998. * | 1 | ALPHATEST | |
  24999. * | 2 | ALPHABLEND | |
  25000. * | 3 | ALPHATESTANDBLEND | |
  25001. *
  25002. */
  25003. set transparencyMode(value: Nullable<number>);
  25004. /**
  25005. * Returns true if alpha blending should be disabled.
  25006. */
  25007. protected get _disableAlphaBlending(): boolean;
  25008. /**
  25009. * Specifies whether or not this material should be rendered in alpha blend mode.
  25010. * @returns a boolean specifying if alpha blending is needed
  25011. */
  25012. needAlphaBlending(): boolean;
  25013. /**
  25014. * Specifies if the mesh will require alpha blending
  25015. * @param mesh defines the mesh to check
  25016. * @returns a boolean specifying if alpha blending is needed for the mesh
  25017. */
  25018. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25019. /**
  25020. * Specifies whether or not this material should be rendered in alpha test mode.
  25021. * @returns a boolean specifying if an alpha test is needed.
  25022. */
  25023. needAlphaTesting(): boolean;
  25024. /**
  25025. * Specifies if material alpha testing should be turned on for the mesh
  25026. * @param mesh defines the mesh to check
  25027. */
  25028. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25029. /**
  25030. * Gets the texture used for the alpha test
  25031. * @returns the texture to use for alpha testing
  25032. */
  25033. getAlphaTestTexture(): Nullable<BaseTexture>;
  25034. /**
  25035. * Marks the material to indicate that it needs to be re-calculated
  25036. */
  25037. markDirty(): void;
  25038. /** @hidden */
  25039. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25040. /**
  25041. * Binds the material to the mesh
  25042. * @param world defines the world transformation matrix
  25043. * @param mesh defines the mesh to bind the material to
  25044. */
  25045. bind(world: Matrix, mesh?: Mesh): void;
  25046. /**
  25047. * Binds the submesh to the material
  25048. * @param world defines the world transformation matrix
  25049. * @param mesh defines the mesh containing the submesh
  25050. * @param subMesh defines the submesh to bind the material to
  25051. */
  25052. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25053. /**
  25054. * Binds the world matrix to the material
  25055. * @param world defines the world transformation matrix
  25056. */
  25057. bindOnlyWorldMatrix(world: Matrix): void;
  25058. /**
  25059. * Binds the scene's uniform buffer to the effect.
  25060. * @param effect defines the effect to bind to the scene uniform buffer
  25061. * @param sceneUbo defines the uniform buffer storing scene data
  25062. */
  25063. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25064. /**
  25065. * Binds the view matrix to the effect
  25066. * @param effect defines the effect to bind the view matrix to
  25067. */
  25068. bindView(effect: Effect): void;
  25069. /**
  25070. * Binds the view projection matrix to the effect
  25071. * @param effect defines the effect to bind the view projection matrix to
  25072. */
  25073. bindViewProjection(effect: Effect): void;
  25074. /**
  25075. * Processes to execute after binding the material to a mesh
  25076. * @param mesh defines the rendered mesh
  25077. */
  25078. protected _afterBind(mesh?: Mesh): void;
  25079. /**
  25080. * Unbinds the material from the mesh
  25081. */
  25082. unbind(): void;
  25083. /**
  25084. * Gets the active textures from the material
  25085. * @returns an array of textures
  25086. */
  25087. getActiveTextures(): BaseTexture[];
  25088. /**
  25089. * Specifies if the material uses a texture
  25090. * @param texture defines the texture to check against the material
  25091. * @returns a boolean specifying if the material uses the texture
  25092. */
  25093. hasTexture(texture: BaseTexture): boolean;
  25094. /**
  25095. * Makes a duplicate of the material, and gives it a new name
  25096. * @param name defines the new name for the duplicated material
  25097. * @returns the cloned material
  25098. */
  25099. clone(name: string): Nullable<Material>;
  25100. /**
  25101. * Gets the meshes bound to the material
  25102. * @returns an array of meshes bound to the material
  25103. */
  25104. getBindedMeshes(): AbstractMesh[];
  25105. /**
  25106. * Force shader compilation
  25107. * @param mesh defines the mesh associated with this material
  25108. * @param onCompiled defines a function to execute once the material is compiled
  25109. * @param options defines the options to configure the compilation
  25110. * @param onError defines a function to execute if the material fails compiling
  25111. */
  25112. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25113. /**
  25114. * Force shader compilation
  25115. * @param mesh defines the mesh that will use this material
  25116. * @param options defines additional options for compiling the shaders
  25117. * @returns a promise that resolves when the compilation completes
  25118. */
  25119. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25120. private static readonly _AllDirtyCallBack;
  25121. private static readonly _ImageProcessingDirtyCallBack;
  25122. private static readonly _TextureDirtyCallBack;
  25123. private static readonly _FresnelDirtyCallBack;
  25124. private static readonly _MiscDirtyCallBack;
  25125. private static readonly _LightsDirtyCallBack;
  25126. private static readonly _AttributeDirtyCallBack;
  25127. private static _FresnelAndMiscDirtyCallBack;
  25128. private static _TextureAndMiscDirtyCallBack;
  25129. private static readonly _DirtyCallbackArray;
  25130. private static readonly _RunDirtyCallBacks;
  25131. /**
  25132. * Marks a define in the material to indicate that it needs to be re-computed
  25133. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25134. */
  25135. markAsDirty(flag: number): void;
  25136. /**
  25137. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25138. * @param func defines a function which checks material defines against the submeshes
  25139. */
  25140. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25141. /**
  25142. * Indicates that we need to re-calculated for all submeshes
  25143. */
  25144. protected _markAllSubMeshesAsAllDirty(): void;
  25145. /**
  25146. * Indicates that image processing needs to be re-calculated for all submeshes
  25147. */
  25148. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25149. /**
  25150. * Indicates that textures need to be re-calculated for all submeshes
  25151. */
  25152. protected _markAllSubMeshesAsTexturesDirty(): void;
  25153. /**
  25154. * Indicates that fresnel needs to be re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsFresnelDirty(): void;
  25157. /**
  25158. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25159. */
  25160. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25161. /**
  25162. * Indicates that lights need to be re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsLightsDirty(): void;
  25165. /**
  25166. * Indicates that attributes need to be re-calculated for all submeshes
  25167. */
  25168. protected _markAllSubMeshesAsAttributesDirty(): void;
  25169. /**
  25170. * Indicates that misc needs to be re-calculated for all submeshes
  25171. */
  25172. protected _markAllSubMeshesAsMiscDirty(): void;
  25173. /**
  25174. * Indicates that textures and misc need to be re-calculated for all submeshes
  25175. */
  25176. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25177. /**
  25178. * Disposes the material
  25179. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25180. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25181. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25182. */
  25183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25184. /** @hidden */
  25185. private releaseVertexArrayObject;
  25186. /**
  25187. * Serializes this material
  25188. * @returns the serialized material object
  25189. */
  25190. serialize(): any;
  25191. /**
  25192. * Creates a material from parsed material data
  25193. * @param parsedMaterial defines parsed material data
  25194. * @param scene defines the hosting scene
  25195. * @param rootUrl defines the root URL to use to load textures
  25196. * @returns a new material
  25197. */
  25198. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25199. }
  25200. }
  25201. declare module "babylonjs/Materials/multiMaterial" {
  25202. import { Nullable } from "babylonjs/types";
  25203. import { Scene } from "babylonjs/scene";
  25204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25205. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25207. import { Material } from "babylonjs/Materials/material";
  25208. /**
  25209. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25210. * separate meshes. This can be use to improve performances.
  25211. * @see http://doc.babylonjs.com/how_to/multi_materials
  25212. */
  25213. export class MultiMaterial extends Material {
  25214. private _subMaterials;
  25215. /**
  25216. * Gets or Sets the list of Materials used within the multi material.
  25217. * They need to be ordered according to the submeshes order in the associated mesh
  25218. */
  25219. get subMaterials(): Nullable<Material>[];
  25220. set subMaterials(value: Nullable<Material>[]);
  25221. /**
  25222. * Function used to align with Node.getChildren()
  25223. * @returns the list of Materials used within the multi material
  25224. */
  25225. getChildren(): Nullable<Material>[];
  25226. /**
  25227. * Instantiates a new Multi Material
  25228. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25229. * separate meshes. This can be use to improve performances.
  25230. * @see http://doc.babylonjs.com/how_to/multi_materials
  25231. * @param name Define the name in the scene
  25232. * @param scene Define the scene the material belongs to
  25233. */
  25234. constructor(name: string, scene: Scene);
  25235. private _hookArray;
  25236. /**
  25237. * Get one of the submaterial by its index in the submaterials array
  25238. * @param index The index to look the sub material at
  25239. * @returns The Material if the index has been defined
  25240. */
  25241. getSubMaterial(index: number): Nullable<Material>;
  25242. /**
  25243. * Get the list of active textures for the whole sub materials list.
  25244. * @returns All the textures that will be used during the rendering
  25245. */
  25246. getActiveTextures(): BaseTexture[];
  25247. /**
  25248. * Gets the current class name of the material e.g. "MultiMaterial"
  25249. * Mainly use in serialization.
  25250. * @returns the class name
  25251. */
  25252. getClassName(): string;
  25253. /**
  25254. * Checks if the material is ready to render the requested sub mesh
  25255. * @param mesh Define the mesh the submesh belongs to
  25256. * @param subMesh Define the sub mesh to look readyness for
  25257. * @param useInstances Define whether or not the material is used with instances
  25258. * @returns true if ready, otherwise false
  25259. */
  25260. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25261. /**
  25262. * Clones the current material and its related sub materials
  25263. * @param name Define the name of the newly cloned material
  25264. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25265. * @returns the cloned material
  25266. */
  25267. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25268. /**
  25269. * Serializes the materials into a JSON representation.
  25270. * @returns the JSON representation
  25271. */
  25272. serialize(): any;
  25273. /**
  25274. * Dispose the material and release its associated resources
  25275. * @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)
  25276. * @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)
  25277. * @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)
  25278. */
  25279. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25280. /**
  25281. * Creates a MultiMaterial from parsed MultiMaterial data.
  25282. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25283. * @param scene defines the hosting scene
  25284. * @returns a new MultiMaterial
  25285. */
  25286. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25287. }
  25288. }
  25289. declare module "babylonjs/Meshes/subMesh" {
  25290. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25291. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25292. import { Engine } from "babylonjs/Engines/engine";
  25293. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25294. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25295. import { Effect } from "babylonjs/Materials/effect";
  25296. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25297. import { Plane } from "babylonjs/Maths/math.plane";
  25298. import { Collider } from "babylonjs/Collisions/collider";
  25299. import { Material } from "babylonjs/Materials/material";
  25300. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25302. import { Mesh } from "babylonjs/Meshes/mesh";
  25303. import { Ray } from "babylonjs/Culling/ray";
  25304. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25305. /**
  25306. * Defines a subdivision inside a mesh
  25307. */
  25308. export class SubMesh implements ICullable {
  25309. /** the material index to use */
  25310. materialIndex: number;
  25311. /** vertex index start */
  25312. verticesStart: number;
  25313. /** vertices count */
  25314. verticesCount: number;
  25315. /** index start */
  25316. indexStart: number;
  25317. /** indices count */
  25318. indexCount: number;
  25319. /** @hidden */
  25320. _materialDefines: Nullable<MaterialDefines>;
  25321. /** @hidden */
  25322. _materialEffect: Nullable<Effect>;
  25323. /** @hidden */
  25324. _effectOverride: Nullable<Effect>;
  25325. /**
  25326. * Gets material defines used by the effect associated to the sub mesh
  25327. */
  25328. get materialDefines(): Nullable<MaterialDefines>;
  25329. /**
  25330. * Sets material defines used by the effect associated to the sub mesh
  25331. */
  25332. set materialDefines(defines: Nullable<MaterialDefines>);
  25333. /**
  25334. * Gets associated effect
  25335. */
  25336. get effect(): Nullable<Effect>;
  25337. /**
  25338. * Sets associated effect (effect used to render this submesh)
  25339. * @param effect defines the effect to associate with
  25340. * @param defines defines the set of defines used to compile this effect
  25341. */
  25342. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25343. /** @hidden */
  25344. _linesIndexCount: number;
  25345. private _mesh;
  25346. private _renderingMesh;
  25347. private _boundingInfo;
  25348. private _linesIndexBuffer;
  25349. /** @hidden */
  25350. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25351. /** @hidden */
  25352. _trianglePlanes: Plane[];
  25353. /** @hidden */
  25354. _lastColliderTransformMatrix: Nullable<Matrix>;
  25355. /** @hidden */
  25356. _renderId: number;
  25357. /** @hidden */
  25358. _alphaIndex: number;
  25359. /** @hidden */
  25360. _distanceToCamera: number;
  25361. /** @hidden */
  25362. _id: number;
  25363. private _currentMaterial;
  25364. /**
  25365. * Add a new submesh to a mesh
  25366. * @param materialIndex defines the material index to use
  25367. * @param verticesStart defines vertex index start
  25368. * @param verticesCount defines vertices count
  25369. * @param indexStart defines index start
  25370. * @param indexCount defines indices count
  25371. * @param mesh defines the parent mesh
  25372. * @param renderingMesh defines an optional rendering mesh
  25373. * @param createBoundingBox defines if bounding box should be created for this submesh
  25374. * @returns the new submesh
  25375. */
  25376. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25377. /**
  25378. * Creates a new submesh
  25379. * @param materialIndex defines the material index to use
  25380. * @param verticesStart defines vertex index start
  25381. * @param verticesCount defines vertices count
  25382. * @param indexStart defines index start
  25383. * @param indexCount defines indices count
  25384. * @param mesh defines the parent mesh
  25385. * @param renderingMesh defines an optional rendering mesh
  25386. * @param createBoundingBox defines if bounding box should be created for this submesh
  25387. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25388. */
  25389. constructor(
  25390. /** the material index to use */
  25391. materialIndex: number,
  25392. /** vertex index start */
  25393. verticesStart: number,
  25394. /** vertices count */
  25395. verticesCount: number,
  25396. /** index start */
  25397. indexStart: number,
  25398. /** indices count */
  25399. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25400. /**
  25401. * Returns true if this submesh covers the entire parent mesh
  25402. * @ignorenaming
  25403. */
  25404. get IsGlobal(): boolean;
  25405. /**
  25406. * Returns the submesh BoudingInfo object
  25407. * @returns current bounding info (or mesh's one if the submesh is global)
  25408. */
  25409. getBoundingInfo(): BoundingInfo;
  25410. /**
  25411. * Sets the submesh BoundingInfo
  25412. * @param boundingInfo defines the new bounding info to use
  25413. * @returns the SubMesh
  25414. */
  25415. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25416. /**
  25417. * Returns the mesh of the current submesh
  25418. * @return the parent mesh
  25419. */
  25420. getMesh(): AbstractMesh;
  25421. /**
  25422. * Returns the rendering mesh of the submesh
  25423. * @returns the rendering mesh (could be different from parent mesh)
  25424. */
  25425. getRenderingMesh(): Mesh;
  25426. /**
  25427. * Returns the replacement mesh of the submesh
  25428. * @returns the replacement mesh (could be different from parent mesh)
  25429. */
  25430. getReplacementMesh(): Nullable<AbstractMesh>;
  25431. /**
  25432. * Returns the effective mesh of the submesh
  25433. * @returns the effective mesh (could be different from parent mesh)
  25434. */
  25435. getEffectiveMesh(): AbstractMesh;
  25436. /**
  25437. * Returns the submesh material
  25438. * @returns null or the current material
  25439. */
  25440. getMaterial(): Nullable<Material>;
  25441. /**
  25442. * Sets a new updated BoundingInfo object to the submesh
  25443. * @param data defines an optional position array to use to determine the bounding info
  25444. * @returns the SubMesh
  25445. */
  25446. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25447. /** @hidden */
  25448. _checkCollision(collider: Collider): boolean;
  25449. /**
  25450. * Updates the submesh BoundingInfo
  25451. * @param world defines the world matrix to use to update the bounding info
  25452. * @returns the submesh
  25453. */
  25454. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25455. /**
  25456. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25457. * @param frustumPlanes defines the frustum planes
  25458. * @returns true if the submesh is intersecting with the frustum
  25459. */
  25460. isInFrustum(frustumPlanes: Plane[]): boolean;
  25461. /**
  25462. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25463. * @param frustumPlanes defines the frustum planes
  25464. * @returns true if the submesh is inside the frustum
  25465. */
  25466. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25467. /**
  25468. * Renders the submesh
  25469. * @param enableAlphaMode defines if alpha needs to be used
  25470. * @returns the submesh
  25471. */
  25472. render(enableAlphaMode: boolean): SubMesh;
  25473. /**
  25474. * @hidden
  25475. */
  25476. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25477. /**
  25478. * Checks if the submesh intersects with a ray
  25479. * @param ray defines the ray to test
  25480. * @returns true is the passed ray intersects the submesh bounding box
  25481. */
  25482. canIntersects(ray: Ray): boolean;
  25483. /**
  25484. * Intersects current submesh with a ray
  25485. * @param ray defines the ray to test
  25486. * @param positions defines mesh's positions array
  25487. * @param indices defines mesh's indices array
  25488. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25489. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25490. * @returns intersection info or null if no intersection
  25491. */
  25492. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25493. /** @hidden */
  25494. private _intersectLines;
  25495. /** @hidden */
  25496. private _intersectUnIndexedLines;
  25497. /** @hidden */
  25498. private _intersectTriangles;
  25499. /** @hidden */
  25500. private _intersectUnIndexedTriangles;
  25501. /** @hidden */
  25502. _rebuild(): void;
  25503. /**
  25504. * Creates a new submesh from the passed mesh
  25505. * @param newMesh defines the new hosting mesh
  25506. * @param newRenderingMesh defines an optional rendering mesh
  25507. * @returns the new submesh
  25508. */
  25509. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25510. /**
  25511. * Release associated resources
  25512. */
  25513. dispose(): void;
  25514. /**
  25515. * Gets the class name
  25516. * @returns the string "SubMesh".
  25517. */
  25518. getClassName(): string;
  25519. /**
  25520. * Creates a new submesh from indices data
  25521. * @param materialIndex the index of the main mesh material
  25522. * @param startIndex the index where to start the copy in the mesh indices array
  25523. * @param indexCount the number of indices to copy then from the startIndex
  25524. * @param mesh the main mesh to create the submesh from
  25525. * @param renderingMesh the optional rendering mesh
  25526. * @returns a new submesh
  25527. */
  25528. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25529. }
  25530. }
  25531. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25532. /**
  25533. * Class used to represent data loading progression
  25534. */
  25535. export class SceneLoaderFlags {
  25536. private static _ForceFullSceneLoadingForIncremental;
  25537. private static _ShowLoadingScreen;
  25538. private static _CleanBoneMatrixWeights;
  25539. private static _loggingLevel;
  25540. /**
  25541. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25542. */
  25543. static get ForceFullSceneLoadingForIncremental(): boolean;
  25544. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25545. /**
  25546. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25547. */
  25548. static get ShowLoadingScreen(): boolean;
  25549. static set ShowLoadingScreen(value: boolean);
  25550. /**
  25551. * Defines the current logging level (while loading the scene)
  25552. * @ignorenaming
  25553. */
  25554. static get loggingLevel(): number;
  25555. static set loggingLevel(value: number);
  25556. /**
  25557. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25558. */
  25559. static get CleanBoneMatrixWeights(): boolean;
  25560. static set CleanBoneMatrixWeights(value: boolean);
  25561. }
  25562. }
  25563. declare module "babylonjs/Meshes/geometry" {
  25564. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25565. import { Scene } from "babylonjs/scene";
  25566. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25567. import { Engine } from "babylonjs/Engines/engine";
  25568. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25569. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25570. import { Effect } from "babylonjs/Materials/effect";
  25571. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25572. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25573. import { Mesh } from "babylonjs/Meshes/mesh";
  25574. /**
  25575. * Class used to store geometry data (vertex buffers + index buffer)
  25576. */
  25577. export class Geometry implements IGetSetVerticesData {
  25578. /**
  25579. * Gets or sets the ID of the geometry
  25580. */
  25581. id: string;
  25582. /**
  25583. * Gets or sets the unique ID of the geometry
  25584. */
  25585. uniqueId: number;
  25586. /**
  25587. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25588. */
  25589. delayLoadState: number;
  25590. /**
  25591. * Gets the file containing the data to load when running in delay load state
  25592. */
  25593. delayLoadingFile: Nullable<string>;
  25594. /**
  25595. * Callback called when the geometry is updated
  25596. */
  25597. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25598. private _scene;
  25599. private _engine;
  25600. private _meshes;
  25601. private _totalVertices;
  25602. /** @hidden */
  25603. _indices: IndicesArray;
  25604. /** @hidden */
  25605. _vertexBuffers: {
  25606. [key: string]: VertexBuffer;
  25607. };
  25608. private _isDisposed;
  25609. private _extend;
  25610. private _boundingBias;
  25611. /** @hidden */
  25612. _delayInfo: Array<string>;
  25613. private _indexBuffer;
  25614. private _indexBufferIsUpdatable;
  25615. /** @hidden */
  25616. _boundingInfo: Nullable<BoundingInfo>;
  25617. /** @hidden */
  25618. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25619. /** @hidden */
  25620. _softwareSkinningFrameId: number;
  25621. private _vertexArrayObjects;
  25622. private _updatable;
  25623. /** @hidden */
  25624. _positions: Nullable<Vector3[]>;
  25625. /**
  25626. * 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
  25627. */
  25628. get boundingBias(): Vector2;
  25629. /**
  25630. * 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
  25631. */
  25632. set boundingBias(value: Vector2);
  25633. /**
  25634. * Static function used to attach a new empty geometry to a mesh
  25635. * @param mesh defines the mesh to attach the geometry to
  25636. * @returns the new Geometry
  25637. */
  25638. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25639. /** Get the list of meshes using this geometry */
  25640. get meshes(): Mesh[];
  25641. /**
  25642. * Creates a new geometry
  25643. * @param id defines the unique ID
  25644. * @param scene defines the hosting scene
  25645. * @param vertexData defines the VertexData used to get geometry data
  25646. * @param updatable defines if geometry must be updatable (false by default)
  25647. * @param mesh defines the mesh that will be associated with the geometry
  25648. */
  25649. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25650. /**
  25651. * Gets the current extend of the geometry
  25652. */
  25653. get extend(): {
  25654. minimum: Vector3;
  25655. maximum: Vector3;
  25656. };
  25657. /**
  25658. * Gets the hosting scene
  25659. * @returns the hosting Scene
  25660. */
  25661. getScene(): Scene;
  25662. /**
  25663. * Gets the hosting engine
  25664. * @returns the hosting Engine
  25665. */
  25666. getEngine(): Engine;
  25667. /**
  25668. * Defines if the geometry is ready to use
  25669. * @returns true if the geometry is ready to be used
  25670. */
  25671. isReady(): boolean;
  25672. /**
  25673. * Gets a value indicating that the geometry should not be serialized
  25674. */
  25675. get doNotSerialize(): boolean;
  25676. /** @hidden */
  25677. _rebuild(): void;
  25678. /**
  25679. * Affects all geometry data in one call
  25680. * @param vertexData defines the geometry data
  25681. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25682. */
  25683. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25684. /**
  25685. * Set specific vertex data
  25686. * @param kind defines the data kind (Position, normal, etc...)
  25687. * @param data defines the vertex data to use
  25688. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25689. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25690. */
  25691. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25692. /**
  25693. * Removes a specific vertex data
  25694. * @param kind defines the data kind (Position, normal, etc...)
  25695. */
  25696. removeVerticesData(kind: string): void;
  25697. /**
  25698. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25699. * @param buffer defines the vertex buffer to use
  25700. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25701. */
  25702. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25703. /**
  25704. * Update a specific vertex buffer
  25705. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25706. * It will do nothing if the buffer is not updatable
  25707. * @param kind defines the data kind (Position, normal, etc...)
  25708. * @param data defines the data to use
  25709. * @param offset defines the offset in the target buffer where to store the data
  25710. * @param useBytes set to true if the offset is in bytes
  25711. */
  25712. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25713. /**
  25714. * Update a specific vertex buffer
  25715. * This function will create a new buffer if the current one is not updatable
  25716. * @param kind defines the data kind (Position, normal, etc...)
  25717. * @param data defines the data to use
  25718. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25719. */
  25720. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25721. private _updateBoundingInfo;
  25722. /** @hidden */
  25723. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25724. /**
  25725. * Gets total number of vertices
  25726. * @returns the total number of vertices
  25727. */
  25728. getTotalVertices(): number;
  25729. /**
  25730. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25731. * @param kind defines the data kind (Position, normal, etc...)
  25732. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25733. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25734. * @returns a float array containing vertex data
  25735. */
  25736. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25737. /**
  25738. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25739. * @param kind defines the data kind (Position, normal, etc...)
  25740. * @returns true if the vertex buffer with the specified kind is updatable
  25741. */
  25742. isVertexBufferUpdatable(kind: string): boolean;
  25743. /**
  25744. * Gets a specific vertex buffer
  25745. * @param kind defines the data kind (Position, normal, etc...)
  25746. * @returns a VertexBuffer
  25747. */
  25748. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25749. /**
  25750. * Returns all vertex buffers
  25751. * @return an object holding all vertex buffers indexed by kind
  25752. */
  25753. getVertexBuffers(): Nullable<{
  25754. [key: string]: VertexBuffer;
  25755. }>;
  25756. /**
  25757. * Gets a boolean indicating if specific vertex buffer is present
  25758. * @param kind defines the data kind (Position, normal, etc...)
  25759. * @returns true if data is present
  25760. */
  25761. isVerticesDataPresent(kind: string): boolean;
  25762. /**
  25763. * Gets a list of all attached data kinds (Position, normal, etc...)
  25764. * @returns a list of string containing all kinds
  25765. */
  25766. getVerticesDataKinds(): string[];
  25767. /**
  25768. * Update index buffer
  25769. * @param indices defines the indices to store in the index buffer
  25770. * @param offset defines the offset in the target buffer where to store the data
  25771. * @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)
  25772. */
  25773. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25774. /**
  25775. * Creates a new index buffer
  25776. * @param indices defines the indices to store in the index buffer
  25777. * @param totalVertices defines the total number of vertices (could be null)
  25778. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25779. */
  25780. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25781. /**
  25782. * Return the total number of indices
  25783. * @returns the total number of indices
  25784. */
  25785. getTotalIndices(): number;
  25786. /**
  25787. * Gets the index buffer array
  25788. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25789. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25790. * @returns the index buffer array
  25791. */
  25792. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25793. /**
  25794. * Gets the index buffer
  25795. * @return the index buffer
  25796. */
  25797. getIndexBuffer(): Nullable<DataBuffer>;
  25798. /** @hidden */
  25799. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25800. /**
  25801. * Release the associated resources for a specific mesh
  25802. * @param mesh defines the source mesh
  25803. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25804. */
  25805. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25806. /**
  25807. * Apply current geometry to a given mesh
  25808. * @param mesh defines the mesh to apply geometry to
  25809. */
  25810. applyToMesh(mesh: Mesh): void;
  25811. private _updateExtend;
  25812. private _applyToMesh;
  25813. private notifyUpdate;
  25814. /**
  25815. * Load the geometry if it was flagged as delay loaded
  25816. * @param scene defines the hosting scene
  25817. * @param onLoaded defines a callback called when the geometry is loaded
  25818. */
  25819. load(scene: Scene, onLoaded?: () => void): void;
  25820. private _queueLoad;
  25821. /**
  25822. * Invert the geometry to move from a right handed system to a left handed one.
  25823. */
  25824. toLeftHanded(): void;
  25825. /** @hidden */
  25826. _resetPointsArrayCache(): void;
  25827. /** @hidden */
  25828. _generatePointsArray(): boolean;
  25829. /**
  25830. * Gets a value indicating if the geometry is disposed
  25831. * @returns true if the geometry was disposed
  25832. */
  25833. isDisposed(): boolean;
  25834. private _disposeVertexArrayObjects;
  25835. /**
  25836. * Free all associated resources
  25837. */
  25838. dispose(): void;
  25839. /**
  25840. * Clone the current geometry into a new geometry
  25841. * @param id defines the unique ID of the new geometry
  25842. * @returns a new geometry object
  25843. */
  25844. copy(id: string): Geometry;
  25845. /**
  25846. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25847. * @return a JSON representation of the current geometry data (without the vertices data)
  25848. */
  25849. serialize(): any;
  25850. private toNumberArray;
  25851. /**
  25852. * Serialize all vertices data into a JSON oject
  25853. * @returns a JSON representation of the current geometry data
  25854. */
  25855. serializeVerticeData(): any;
  25856. /**
  25857. * Extracts a clone of a mesh geometry
  25858. * @param mesh defines the source mesh
  25859. * @param id defines the unique ID of the new geometry object
  25860. * @returns the new geometry object
  25861. */
  25862. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25863. /**
  25864. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25865. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25866. * Be aware Math.random() could cause collisions, but:
  25867. * "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"
  25868. * @returns a string containing a new GUID
  25869. */
  25870. static RandomId(): string;
  25871. /** @hidden */
  25872. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25873. private static _CleanMatricesWeights;
  25874. /**
  25875. * Create a new geometry from persisted data (Using .babylon file format)
  25876. * @param parsedVertexData defines the persisted data
  25877. * @param scene defines the hosting scene
  25878. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25879. * @returns the new geometry object
  25880. */
  25881. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25882. }
  25883. }
  25884. declare module "babylonjs/Meshes/mesh.vertexData" {
  25885. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25886. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25887. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25888. import { Geometry } from "babylonjs/Meshes/geometry";
  25889. import { Mesh } from "babylonjs/Meshes/mesh";
  25890. /**
  25891. * Define an interface for all classes that will get and set the data on vertices
  25892. */
  25893. export interface IGetSetVerticesData {
  25894. /**
  25895. * Gets a boolean indicating if specific vertex data is present
  25896. * @param kind defines the vertex data kind to use
  25897. * @returns true is data kind is present
  25898. */
  25899. isVerticesDataPresent(kind: string): boolean;
  25900. /**
  25901. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25902. * @param kind defines the data kind (Position, normal, etc...)
  25903. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25905. * @returns a float array containing vertex data
  25906. */
  25907. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25908. /**
  25909. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25910. * @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.
  25911. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25912. * @returns the indices array or an empty array if the mesh has no geometry
  25913. */
  25914. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25915. /**
  25916. * Set specific vertex data
  25917. * @param kind defines the data kind (Position, normal, etc...)
  25918. * @param data defines the vertex data to use
  25919. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25920. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25921. */
  25922. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25923. /**
  25924. * Update a specific associated vertex buffer
  25925. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25926. * - VertexBuffer.PositionKind
  25927. * - VertexBuffer.UVKind
  25928. * - VertexBuffer.UV2Kind
  25929. * - VertexBuffer.UV3Kind
  25930. * - VertexBuffer.UV4Kind
  25931. * - VertexBuffer.UV5Kind
  25932. * - VertexBuffer.UV6Kind
  25933. * - VertexBuffer.ColorKind
  25934. * - VertexBuffer.MatricesIndicesKind
  25935. * - VertexBuffer.MatricesIndicesExtraKind
  25936. * - VertexBuffer.MatricesWeightsKind
  25937. * - VertexBuffer.MatricesWeightsExtraKind
  25938. * @param data defines the data source
  25939. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25940. * @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)
  25941. */
  25942. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25943. /**
  25944. * Creates a new index buffer
  25945. * @param indices defines the indices to store in the index buffer
  25946. * @param totalVertices defines the total number of vertices (could be null)
  25947. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25948. */
  25949. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25950. }
  25951. /**
  25952. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25953. */
  25954. export class VertexData {
  25955. /**
  25956. * Mesh side orientation : usually the external or front surface
  25957. */
  25958. static readonly FRONTSIDE: number;
  25959. /**
  25960. * Mesh side orientation : usually the internal or back surface
  25961. */
  25962. static readonly BACKSIDE: number;
  25963. /**
  25964. * Mesh side orientation : both internal and external or front and back surfaces
  25965. */
  25966. static readonly DOUBLESIDE: number;
  25967. /**
  25968. * Mesh side orientation : by default, `FRONTSIDE`
  25969. */
  25970. static readonly DEFAULTSIDE: number;
  25971. /**
  25972. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25973. */
  25974. positions: Nullable<FloatArray>;
  25975. /**
  25976. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25977. */
  25978. normals: Nullable<FloatArray>;
  25979. /**
  25980. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25981. */
  25982. tangents: Nullable<FloatArray>;
  25983. /**
  25984. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25985. */
  25986. uvs: Nullable<FloatArray>;
  25987. /**
  25988. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25989. */
  25990. uvs2: Nullable<FloatArray>;
  25991. /**
  25992. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25993. */
  25994. uvs3: Nullable<FloatArray>;
  25995. /**
  25996. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25997. */
  25998. uvs4: Nullable<FloatArray>;
  25999. /**
  26000. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26001. */
  26002. uvs5: Nullable<FloatArray>;
  26003. /**
  26004. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26005. */
  26006. uvs6: Nullable<FloatArray>;
  26007. /**
  26008. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26009. */
  26010. colors: Nullable<FloatArray>;
  26011. /**
  26012. * 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).
  26013. */
  26014. matricesIndices: Nullable<FloatArray>;
  26015. /**
  26016. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26017. */
  26018. matricesWeights: Nullable<FloatArray>;
  26019. /**
  26020. * An array extending the number of possible indices
  26021. */
  26022. matricesIndicesExtra: Nullable<FloatArray>;
  26023. /**
  26024. * An array extending the number of possible weights when the number of indices is extended
  26025. */
  26026. matricesWeightsExtra: Nullable<FloatArray>;
  26027. /**
  26028. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26029. */
  26030. indices: Nullable<IndicesArray>;
  26031. /**
  26032. * Uses the passed data array to set the set the values for the specified kind of data
  26033. * @param data a linear array of floating numbers
  26034. * @param kind the type of data that is being set, eg positions, colors etc
  26035. */
  26036. set(data: FloatArray, kind: string): void;
  26037. /**
  26038. * Associates the vertexData to the passed Mesh.
  26039. * Sets it as updatable or not (default `false`)
  26040. * @param mesh the mesh the vertexData is applied to
  26041. * @param updatable when used and having the value true allows new data to update the vertexData
  26042. * @returns the VertexData
  26043. */
  26044. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26045. /**
  26046. * Associates the vertexData to the passed Geometry.
  26047. * Sets it as updatable or not (default `false`)
  26048. * @param geometry the geometry the vertexData is applied to
  26049. * @param updatable when used and having the value true allows new data to update the vertexData
  26050. * @returns VertexData
  26051. */
  26052. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26053. /**
  26054. * Updates the associated mesh
  26055. * @param mesh the mesh to be updated
  26056. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26057. * @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
  26058. * @returns VertexData
  26059. */
  26060. updateMesh(mesh: Mesh): VertexData;
  26061. /**
  26062. * Updates the associated geometry
  26063. * @param geometry the geometry to be updated
  26064. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26065. * @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
  26066. * @returns VertexData.
  26067. */
  26068. updateGeometry(geometry: Geometry): VertexData;
  26069. private _applyTo;
  26070. private _update;
  26071. /**
  26072. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26073. * @param matrix the transforming matrix
  26074. * @returns the VertexData
  26075. */
  26076. transform(matrix: Matrix): VertexData;
  26077. /**
  26078. * Merges the passed VertexData into the current one
  26079. * @param other the VertexData to be merged into the current one
  26080. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26081. * @returns the modified VertexData
  26082. */
  26083. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26084. private _mergeElement;
  26085. private _validate;
  26086. /**
  26087. * Serializes the VertexData
  26088. * @returns a serialized object
  26089. */
  26090. serialize(): any;
  26091. /**
  26092. * Extracts the vertexData from a mesh
  26093. * @param mesh the mesh from which to extract the VertexData
  26094. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26095. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26096. * @returns the object VertexData associated to the passed mesh
  26097. */
  26098. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26099. /**
  26100. * Extracts the vertexData from the geometry
  26101. * @param geometry the geometry from which to extract the VertexData
  26102. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26103. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26104. * @returns the object VertexData associated to the passed mesh
  26105. */
  26106. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26107. private static _ExtractFrom;
  26108. /**
  26109. * Creates the VertexData for a Ribbon
  26110. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26111. * * pathArray array of paths, each of which an array of successive Vector3
  26112. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26113. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26114. * * 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
  26115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26116. * * 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)
  26117. * * 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)
  26118. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26119. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26120. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26121. * @returns the VertexData of the ribbon
  26122. */
  26123. static CreateRibbon(options: {
  26124. pathArray: Vector3[][];
  26125. closeArray?: boolean;
  26126. closePath?: boolean;
  26127. offset?: number;
  26128. sideOrientation?: number;
  26129. frontUVs?: Vector4;
  26130. backUVs?: Vector4;
  26131. invertUV?: boolean;
  26132. uvs?: Vector2[];
  26133. colors?: Color4[];
  26134. }): VertexData;
  26135. /**
  26136. * Creates the VertexData for a box
  26137. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26138. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26139. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26140. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26141. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26142. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26143. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26145. * * 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)
  26146. * * 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)
  26147. * @returns the VertexData of the box
  26148. */
  26149. static CreateBox(options: {
  26150. size?: number;
  26151. width?: number;
  26152. height?: number;
  26153. depth?: number;
  26154. faceUV?: Vector4[];
  26155. faceColors?: Color4[];
  26156. sideOrientation?: number;
  26157. frontUVs?: Vector4;
  26158. backUVs?: Vector4;
  26159. }): VertexData;
  26160. /**
  26161. * Creates the VertexData for a tiled box
  26162. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26163. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26164. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26165. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26167. * @returns the VertexData of the box
  26168. */
  26169. static CreateTiledBox(options: {
  26170. pattern?: number;
  26171. width?: number;
  26172. height?: number;
  26173. depth?: number;
  26174. tileSize?: number;
  26175. tileWidth?: number;
  26176. tileHeight?: number;
  26177. alignHorizontal?: number;
  26178. alignVertical?: number;
  26179. faceUV?: Vector4[];
  26180. faceColors?: Color4[];
  26181. sideOrientation?: number;
  26182. }): VertexData;
  26183. /**
  26184. * Creates the VertexData for a tiled plane
  26185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26186. * * pattern a limited pattern arrangement depending on the number
  26187. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26188. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26189. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  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 tiled plane
  26194. */
  26195. static CreateTiledPlane(options: {
  26196. pattern?: number;
  26197. tileSize?: number;
  26198. tileWidth?: number;
  26199. tileHeight?: number;
  26200. size?: number;
  26201. width?: number;
  26202. height?: number;
  26203. alignHorizontal?: number;
  26204. alignVertical?: number;
  26205. sideOrientation?: number;
  26206. frontUVs?: Vector4;
  26207. backUVs?: Vector4;
  26208. }): VertexData;
  26209. /**
  26210. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26211. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26212. * * segments sets the number of horizontal strips optional, default 32
  26213. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26214. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26215. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26216. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26217. * * 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
  26218. * * 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
  26219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26220. * * 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)
  26221. * * 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)
  26222. * @returns the VertexData of the ellipsoid
  26223. */
  26224. static CreateSphere(options: {
  26225. segments?: number;
  26226. diameter?: number;
  26227. diameterX?: number;
  26228. diameterY?: number;
  26229. diameterZ?: number;
  26230. arc?: number;
  26231. slice?: number;
  26232. sideOrientation?: number;
  26233. frontUVs?: Vector4;
  26234. backUVs?: Vector4;
  26235. }): VertexData;
  26236. /**
  26237. * Creates the VertexData for a cylinder, cone or prism
  26238. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26239. * * height sets the height (y direction) of the cylinder, optional, default 2
  26240. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26241. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26242. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26243. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26244. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26245. * * 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
  26246. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26247. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26248. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26249. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26251. * * 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)
  26252. * * 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)
  26253. * @returns the VertexData of the cylinder, cone or prism
  26254. */
  26255. static CreateCylinder(options: {
  26256. height?: number;
  26257. diameterTop?: number;
  26258. diameterBottom?: number;
  26259. diameter?: number;
  26260. tessellation?: number;
  26261. subdivisions?: number;
  26262. arc?: number;
  26263. faceColors?: Color4[];
  26264. faceUV?: Vector4[];
  26265. hasRings?: boolean;
  26266. enclose?: boolean;
  26267. sideOrientation?: number;
  26268. frontUVs?: Vector4;
  26269. backUVs?: Vector4;
  26270. }): VertexData;
  26271. /**
  26272. * Creates the VertexData for a torus
  26273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26274. * * diameter the diameter of the torus, optional default 1
  26275. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26276. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26277. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26278. * * 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)
  26279. * * 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)
  26280. * @returns the VertexData of the torus
  26281. */
  26282. static CreateTorus(options: {
  26283. diameter?: number;
  26284. thickness?: number;
  26285. tessellation?: number;
  26286. sideOrientation?: number;
  26287. frontUVs?: Vector4;
  26288. backUVs?: Vector4;
  26289. }): VertexData;
  26290. /**
  26291. * Creates the VertexData of the LineSystem
  26292. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26293. * - lines an array of lines, each line being an array of successive Vector3
  26294. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26295. * @returns the VertexData of the LineSystem
  26296. */
  26297. static CreateLineSystem(options: {
  26298. lines: Vector3[][];
  26299. colors?: Nullable<Color4[][]>;
  26300. }): VertexData;
  26301. /**
  26302. * Create the VertexData for a DashedLines
  26303. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26304. * - points an array successive Vector3
  26305. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26306. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26307. * - dashNb the intended total number of dashes, optional, default 200
  26308. * @returns the VertexData for the DashedLines
  26309. */
  26310. static CreateDashedLines(options: {
  26311. points: Vector3[];
  26312. dashSize?: number;
  26313. gapSize?: number;
  26314. dashNb?: number;
  26315. }): VertexData;
  26316. /**
  26317. * Creates the VertexData for a Ground
  26318. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26319. * - width the width (x direction) of the ground, optional, default 1
  26320. * - height the height (z direction) of the ground, optional, default 1
  26321. * - subdivisions the number of subdivisions per side, optional, default 1
  26322. * @returns the VertexData of the Ground
  26323. */
  26324. static CreateGround(options: {
  26325. width?: number;
  26326. height?: number;
  26327. subdivisions?: number;
  26328. subdivisionsX?: number;
  26329. subdivisionsY?: number;
  26330. }): VertexData;
  26331. /**
  26332. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26333. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26334. * * xmin the ground minimum X coordinate, optional, default -1
  26335. * * zmin the ground minimum Z coordinate, optional, default -1
  26336. * * xmax the ground maximum X coordinate, optional, default 1
  26337. * * zmax the ground maximum Z coordinate, optional, default 1
  26338. * * 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}
  26339. * * 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}
  26340. * @returns the VertexData of the TiledGround
  26341. */
  26342. static CreateTiledGround(options: {
  26343. xmin: number;
  26344. zmin: number;
  26345. xmax: number;
  26346. zmax: number;
  26347. subdivisions?: {
  26348. w: number;
  26349. h: number;
  26350. };
  26351. precision?: {
  26352. w: number;
  26353. h: number;
  26354. };
  26355. }): VertexData;
  26356. /**
  26357. * Creates the VertexData of the Ground designed from a heightmap
  26358. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26359. * * width the width (x direction) of the ground
  26360. * * height the height (z direction) of the ground
  26361. * * subdivisions the number of subdivisions per side
  26362. * * minHeight the minimum altitude on the ground, optional, default 0
  26363. * * maxHeight the maximum altitude on the ground, optional default 1
  26364. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26365. * * buffer the array holding the image color data
  26366. * * bufferWidth the width of image
  26367. * * bufferHeight the height of image
  26368. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26369. * @returns the VertexData of the Ground designed from a heightmap
  26370. */
  26371. static CreateGroundFromHeightMap(options: {
  26372. width: number;
  26373. height: number;
  26374. subdivisions: number;
  26375. minHeight: number;
  26376. maxHeight: number;
  26377. colorFilter: Color3;
  26378. buffer: Uint8Array;
  26379. bufferWidth: number;
  26380. bufferHeight: number;
  26381. alphaFilter: number;
  26382. }): VertexData;
  26383. /**
  26384. * Creates the VertexData for a Plane
  26385. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26386. * * size sets the width and height of the plane to the value of size, optional default 1
  26387. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26388. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26389. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26390. * * 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)
  26391. * * 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)
  26392. * @returns the VertexData of the box
  26393. */
  26394. static CreatePlane(options: {
  26395. size?: number;
  26396. width?: number;
  26397. height?: number;
  26398. sideOrientation?: number;
  26399. frontUVs?: Vector4;
  26400. backUVs?: Vector4;
  26401. }): VertexData;
  26402. /**
  26403. * Creates the VertexData of the Disc or regular Polygon
  26404. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26405. * * radius the radius of the disc, optional default 0.5
  26406. * * tessellation the number of polygon sides, optional, default 64
  26407. * * 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
  26408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26409. * * 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)
  26410. * * 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)
  26411. * @returns the VertexData of the box
  26412. */
  26413. static CreateDisc(options: {
  26414. radius?: number;
  26415. tessellation?: number;
  26416. arc?: number;
  26417. sideOrientation?: number;
  26418. frontUVs?: Vector4;
  26419. backUVs?: Vector4;
  26420. }): VertexData;
  26421. /**
  26422. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26423. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26424. * @param polygon a mesh built from polygonTriangulation.build()
  26425. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26426. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26427. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26428. * @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)
  26429. * @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)
  26430. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26431. * @returns the VertexData of the Polygon
  26432. */
  26433. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26434. /**
  26435. * Creates the VertexData of the IcoSphere
  26436. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26437. * * radius the radius of the IcoSphere, optional default 1
  26438. * * radiusX allows stretching in the x direction, optional, default radius
  26439. * * radiusY allows stretching in the y direction, optional, default radius
  26440. * * radiusZ allows stretching in the z direction, optional, default radius
  26441. * * flat when true creates a flat shaded mesh, optional, default true
  26442. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26444. * * 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)
  26445. * * 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)
  26446. * @returns the VertexData of the IcoSphere
  26447. */
  26448. static CreateIcoSphere(options: {
  26449. radius?: number;
  26450. radiusX?: number;
  26451. radiusY?: number;
  26452. radiusZ?: number;
  26453. flat?: boolean;
  26454. subdivisions?: number;
  26455. sideOrientation?: number;
  26456. frontUVs?: Vector4;
  26457. backUVs?: Vector4;
  26458. }): VertexData;
  26459. /**
  26460. * Creates the VertexData for a Polyhedron
  26461. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26462. * * type provided types are:
  26463. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26464. * * 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)
  26465. * * size the size of the IcoSphere, optional default 1
  26466. * * sizeX allows stretching in the x direction, optional, default size
  26467. * * sizeY allows stretching in the y direction, optional, default size
  26468. * * sizeZ allows stretching in the z direction, optional, default size
  26469. * * 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
  26470. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26471. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26472. * * flat when true creates a flat shaded mesh, optional, default true
  26473. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26475. * * 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)
  26476. * * 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)
  26477. * @returns the VertexData of the Polyhedron
  26478. */
  26479. static CreatePolyhedron(options: {
  26480. type?: number;
  26481. size?: number;
  26482. sizeX?: number;
  26483. sizeY?: number;
  26484. sizeZ?: number;
  26485. custom?: any;
  26486. faceUV?: Vector4[];
  26487. faceColors?: Color4[];
  26488. flat?: boolean;
  26489. sideOrientation?: number;
  26490. frontUVs?: Vector4;
  26491. backUVs?: Vector4;
  26492. }): VertexData;
  26493. /**
  26494. * Creates the VertexData for a TorusKnot
  26495. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26496. * * radius the radius of the torus knot, optional, default 2
  26497. * * tube the thickness of the tube, optional, default 0.5
  26498. * * radialSegments the number of sides on each tube segments, optional, default 32
  26499. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26500. * * p the number of windings around the z axis, optional, default 2
  26501. * * q the number of windings around the x axis, optional, default 3
  26502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26503. * * 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)
  26504. * * 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)
  26505. * @returns the VertexData of the Torus Knot
  26506. */
  26507. static CreateTorusKnot(options: {
  26508. radius?: number;
  26509. tube?: number;
  26510. radialSegments?: number;
  26511. tubularSegments?: number;
  26512. p?: number;
  26513. q?: number;
  26514. sideOrientation?: number;
  26515. frontUVs?: Vector4;
  26516. backUVs?: Vector4;
  26517. }): VertexData;
  26518. /**
  26519. * Compute normals for given positions and indices
  26520. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26521. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26522. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26523. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26524. * * facetNormals : optional array of facet normals (vector3)
  26525. * * facetPositions : optional array of facet positions (vector3)
  26526. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26527. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26528. * * bInfo : optional bounding info, required for facetPartitioning computation
  26529. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26530. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26531. * * useRightHandedSystem: optional boolean to for right handed system computation
  26532. * * depthSort : optional boolean to enable the facet depth sort computation
  26533. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26534. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26535. */
  26536. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26537. facetNormals?: any;
  26538. facetPositions?: any;
  26539. facetPartitioning?: any;
  26540. ratio?: number;
  26541. bInfo?: any;
  26542. bbSize?: Vector3;
  26543. subDiv?: any;
  26544. useRightHandedSystem?: boolean;
  26545. depthSort?: boolean;
  26546. distanceTo?: Vector3;
  26547. depthSortedFacets?: any;
  26548. }): void;
  26549. /** @hidden */
  26550. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26551. /**
  26552. * Applies VertexData created from the imported parameters to the geometry
  26553. * @param parsedVertexData the parsed data from an imported file
  26554. * @param geometry the geometry to apply the VertexData to
  26555. */
  26556. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26557. }
  26558. }
  26559. declare module "babylonjs/Morph/morphTarget" {
  26560. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26561. import { Observable } from "babylonjs/Misc/observable";
  26562. import { Nullable, FloatArray } from "babylonjs/types";
  26563. import { Scene } from "babylonjs/scene";
  26564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26565. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26566. /**
  26567. * Defines a target to use with MorphTargetManager
  26568. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26569. */
  26570. export class MorphTarget implements IAnimatable {
  26571. /** defines the name of the target */
  26572. name: string;
  26573. /**
  26574. * Gets or sets the list of animations
  26575. */
  26576. animations: import("babylonjs/Animations/animation").Animation[];
  26577. private _scene;
  26578. private _positions;
  26579. private _normals;
  26580. private _tangents;
  26581. private _uvs;
  26582. private _influence;
  26583. private _uniqueId;
  26584. /**
  26585. * Observable raised when the influence changes
  26586. */
  26587. onInfluenceChanged: Observable<boolean>;
  26588. /** @hidden */
  26589. _onDataLayoutChanged: Observable<void>;
  26590. /**
  26591. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26592. */
  26593. get influence(): number;
  26594. set influence(influence: number);
  26595. /**
  26596. * Gets or sets the id of the morph Target
  26597. */
  26598. id: string;
  26599. private _animationPropertiesOverride;
  26600. /**
  26601. * Gets or sets the animation properties override
  26602. */
  26603. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26604. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26605. /**
  26606. * Creates a new MorphTarget
  26607. * @param name defines the name of the target
  26608. * @param influence defines the influence to use
  26609. * @param scene defines the scene the morphtarget belongs to
  26610. */
  26611. constructor(
  26612. /** defines the name of the target */
  26613. name: string, influence?: number, scene?: Nullable<Scene>);
  26614. /**
  26615. * Gets the unique ID of this manager
  26616. */
  26617. get uniqueId(): number;
  26618. /**
  26619. * Gets a boolean defining if the target contains position data
  26620. */
  26621. get hasPositions(): boolean;
  26622. /**
  26623. * Gets a boolean defining if the target contains normal data
  26624. */
  26625. get hasNormals(): boolean;
  26626. /**
  26627. * Gets a boolean defining if the target contains tangent data
  26628. */
  26629. get hasTangents(): boolean;
  26630. /**
  26631. * Gets a boolean defining if the target contains texture coordinates data
  26632. */
  26633. get hasUVs(): boolean;
  26634. /**
  26635. * Affects position data to this target
  26636. * @param data defines the position data to use
  26637. */
  26638. setPositions(data: Nullable<FloatArray>): void;
  26639. /**
  26640. * Gets the position data stored in this target
  26641. * @returns a FloatArray containing the position data (or null if not present)
  26642. */
  26643. getPositions(): Nullable<FloatArray>;
  26644. /**
  26645. * Affects normal data to this target
  26646. * @param data defines the normal data to use
  26647. */
  26648. setNormals(data: Nullable<FloatArray>): void;
  26649. /**
  26650. * Gets the normal data stored in this target
  26651. * @returns a FloatArray containing the normal data (or null if not present)
  26652. */
  26653. getNormals(): Nullable<FloatArray>;
  26654. /**
  26655. * Affects tangent data to this target
  26656. * @param data defines the tangent data to use
  26657. */
  26658. setTangents(data: Nullable<FloatArray>): void;
  26659. /**
  26660. * Gets the tangent data stored in this target
  26661. * @returns a FloatArray containing the tangent data (or null if not present)
  26662. */
  26663. getTangents(): Nullable<FloatArray>;
  26664. /**
  26665. * Affects texture coordinates data to this target
  26666. * @param data defines the texture coordinates data to use
  26667. */
  26668. setUVs(data: Nullable<FloatArray>): void;
  26669. /**
  26670. * Gets the texture coordinates data stored in this target
  26671. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26672. */
  26673. getUVs(): Nullable<FloatArray>;
  26674. /**
  26675. * Clone the current target
  26676. * @returns a new MorphTarget
  26677. */
  26678. clone(): MorphTarget;
  26679. /**
  26680. * Serializes the current target into a Serialization object
  26681. * @returns the serialized object
  26682. */
  26683. serialize(): any;
  26684. /**
  26685. * Returns the string "MorphTarget"
  26686. * @returns "MorphTarget"
  26687. */
  26688. getClassName(): string;
  26689. /**
  26690. * Creates a new target from serialized data
  26691. * @param serializationObject defines the serialized data to use
  26692. * @returns a new MorphTarget
  26693. */
  26694. static Parse(serializationObject: any): MorphTarget;
  26695. /**
  26696. * Creates a MorphTarget from mesh data
  26697. * @param mesh defines the source mesh
  26698. * @param name defines the name to use for the new target
  26699. * @param influence defines the influence to attach to the target
  26700. * @returns a new MorphTarget
  26701. */
  26702. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26703. }
  26704. }
  26705. declare module "babylonjs/Morph/morphTargetManager" {
  26706. import { Nullable } from "babylonjs/types";
  26707. import { Scene } from "babylonjs/scene";
  26708. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26709. /**
  26710. * This class is used to deform meshes using morphing between different targets
  26711. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26712. */
  26713. export class MorphTargetManager {
  26714. private _targets;
  26715. private _targetInfluenceChangedObservers;
  26716. private _targetDataLayoutChangedObservers;
  26717. private _activeTargets;
  26718. private _scene;
  26719. private _influences;
  26720. private _supportsNormals;
  26721. private _supportsTangents;
  26722. private _supportsUVs;
  26723. private _vertexCount;
  26724. private _uniqueId;
  26725. private _tempInfluences;
  26726. /**
  26727. * Gets or sets a boolean indicating if normals must be morphed
  26728. */
  26729. enableNormalMorphing: boolean;
  26730. /**
  26731. * Gets or sets a boolean indicating if tangents must be morphed
  26732. */
  26733. enableTangentMorphing: boolean;
  26734. /**
  26735. * Gets or sets a boolean indicating if UV must be morphed
  26736. */
  26737. enableUVMorphing: boolean;
  26738. /**
  26739. * Creates a new MorphTargetManager
  26740. * @param scene defines the current scene
  26741. */
  26742. constructor(scene?: Nullable<Scene>);
  26743. /**
  26744. * Gets the unique ID of this manager
  26745. */
  26746. get uniqueId(): number;
  26747. /**
  26748. * Gets the number of vertices handled by this manager
  26749. */
  26750. get vertexCount(): number;
  26751. /**
  26752. * Gets a boolean indicating if this manager supports morphing of normals
  26753. */
  26754. get supportsNormals(): boolean;
  26755. /**
  26756. * Gets a boolean indicating if this manager supports morphing of tangents
  26757. */
  26758. get supportsTangents(): boolean;
  26759. /**
  26760. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26761. */
  26762. get supportsUVs(): boolean;
  26763. /**
  26764. * Gets the number of targets stored in this manager
  26765. */
  26766. get numTargets(): number;
  26767. /**
  26768. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26769. */
  26770. get numInfluencers(): number;
  26771. /**
  26772. * Gets the list of influences (one per target)
  26773. */
  26774. get influences(): Float32Array;
  26775. /**
  26776. * Gets the active target at specified index. An active target is a target with an influence > 0
  26777. * @param index defines the index to check
  26778. * @returns the requested target
  26779. */
  26780. getActiveTarget(index: number): MorphTarget;
  26781. /**
  26782. * Gets the target at specified index
  26783. * @param index defines the index to check
  26784. * @returns the requested target
  26785. */
  26786. getTarget(index: number): MorphTarget;
  26787. /**
  26788. * Add a new target to this manager
  26789. * @param target defines the target to add
  26790. */
  26791. addTarget(target: MorphTarget): void;
  26792. /**
  26793. * Removes a target from the manager
  26794. * @param target defines the target to remove
  26795. */
  26796. removeTarget(target: MorphTarget): void;
  26797. /**
  26798. * Clone the current manager
  26799. * @returns a new MorphTargetManager
  26800. */
  26801. clone(): MorphTargetManager;
  26802. /**
  26803. * Serializes the current manager into a Serialization object
  26804. * @returns the serialized object
  26805. */
  26806. serialize(): any;
  26807. private _syncActiveTargets;
  26808. /**
  26809. * Syncrhonize the targets with all the meshes using this morph target manager
  26810. */
  26811. synchronize(): void;
  26812. /**
  26813. * Creates a new MorphTargetManager from serialized data
  26814. * @param serializationObject defines the serialized data
  26815. * @param scene defines the hosting scene
  26816. * @returns the new MorphTargetManager
  26817. */
  26818. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26819. }
  26820. }
  26821. declare module "babylonjs/Meshes/meshLODLevel" {
  26822. import { Mesh } from "babylonjs/Meshes/mesh";
  26823. import { Nullable } from "babylonjs/types";
  26824. /**
  26825. * Class used to represent a specific level of detail of a mesh
  26826. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26827. */
  26828. export class MeshLODLevel {
  26829. /** Defines the distance where this level should start being displayed */
  26830. distance: number;
  26831. /** Defines the mesh to use to render this level */
  26832. mesh: Nullable<Mesh>;
  26833. /**
  26834. * Creates a new LOD level
  26835. * @param distance defines the distance where this level should star being displayed
  26836. * @param mesh defines the mesh to use to render this level
  26837. */
  26838. constructor(
  26839. /** Defines the distance where this level should start being displayed */
  26840. distance: number,
  26841. /** Defines the mesh to use to render this level */
  26842. mesh: Nullable<Mesh>);
  26843. }
  26844. }
  26845. declare module "babylonjs/Meshes/groundMesh" {
  26846. import { Scene } from "babylonjs/scene";
  26847. import { Vector3 } from "babylonjs/Maths/math.vector";
  26848. import { Mesh } from "babylonjs/Meshes/mesh";
  26849. /**
  26850. * Mesh representing the gorund
  26851. */
  26852. export class GroundMesh extends Mesh {
  26853. /** If octree should be generated */
  26854. generateOctree: boolean;
  26855. private _heightQuads;
  26856. /** @hidden */
  26857. _subdivisionsX: number;
  26858. /** @hidden */
  26859. _subdivisionsY: number;
  26860. /** @hidden */
  26861. _width: number;
  26862. /** @hidden */
  26863. _height: number;
  26864. /** @hidden */
  26865. _minX: number;
  26866. /** @hidden */
  26867. _maxX: number;
  26868. /** @hidden */
  26869. _minZ: number;
  26870. /** @hidden */
  26871. _maxZ: number;
  26872. constructor(name: string, scene: Scene);
  26873. /**
  26874. * "GroundMesh"
  26875. * @returns "GroundMesh"
  26876. */
  26877. getClassName(): string;
  26878. /**
  26879. * The minimum of x and y subdivisions
  26880. */
  26881. get subdivisions(): number;
  26882. /**
  26883. * X subdivisions
  26884. */
  26885. get subdivisionsX(): number;
  26886. /**
  26887. * Y subdivisions
  26888. */
  26889. get subdivisionsY(): number;
  26890. /**
  26891. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26892. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26893. * @param chunksCount the number of subdivisions for x and y
  26894. * @param octreeBlocksSize (Default: 32)
  26895. */
  26896. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26897. /**
  26898. * Returns a height (y) value in the Worl system :
  26899. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26900. * @param x x coordinate
  26901. * @param z z coordinate
  26902. * @returns the ground y position if (x, z) are outside the ground surface.
  26903. */
  26904. getHeightAtCoordinates(x: number, z: number): number;
  26905. /**
  26906. * Returns a normalized vector (Vector3) orthogonal to the ground
  26907. * at the ground coordinates (x, z) expressed in the World system.
  26908. * @param x x coordinate
  26909. * @param z z coordinate
  26910. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26911. */
  26912. getNormalAtCoordinates(x: number, z: number): Vector3;
  26913. /**
  26914. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26915. * at the ground coordinates (x, z) expressed in the World system.
  26916. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26917. * @param x x coordinate
  26918. * @param z z coordinate
  26919. * @param ref vector to store the result
  26920. * @returns the GroundMesh.
  26921. */
  26922. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26923. /**
  26924. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26925. * if the ground has been updated.
  26926. * This can be used in the render loop.
  26927. * @returns the GroundMesh.
  26928. */
  26929. updateCoordinateHeights(): GroundMesh;
  26930. private _getFacetAt;
  26931. private _initHeightQuads;
  26932. private _computeHeightQuads;
  26933. /**
  26934. * Serializes this ground mesh
  26935. * @param serializationObject object to write serialization to
  26936. */
  26937. serialize(serializationObject: any): void;
  26938. /**
  26939. * Parses a serialized ground mesh
  26940. * @param parsedMesh the serialized mesh
  26941. * @param scene the scene to create the ground mesh in
  26942. * @returns the created ground mesh
  26943. */
  26944. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26945. }
  26946. }
  26947. declare module "babylonjs/Physics/physicsJoint" {
  26948. import { Vector3 } from "babylonjs/Maths/math.vector";
  26949. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26950. /**
  26951. * Interface for Physics-Joint data
  26952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26953. */
  26954. export interface PhysicsJointData {
  26955. /**
  26956. * The main pivot of the joint
  26957. */
  26958. mainPivot?: Vector3;
  26959. /**
  26960. * The connected pivot of the joint
  26961. */
  26962. connectedPivot?: Vector3;
  26963. /**
  26964. * The main axis of the joint
  26965. */
  26966. mainAxis?: Vector3;
  26967. /**
  26968. * The connected axis of the joint
  26969. */
  26970. connectedAxis?: Vector3;
  26971. /**
  26972. * The collision of the joint
  26973. */
  26974. collision?: boolean;
  26975. /**
  26976. * Native Oimo/Cannon/Energy data
  26977. */
  26978. nativeParams?: any;
  26979. }
  26980. /**
  26981. * This is a holder class for the physics joint created by the physics plugin
  26982. * It holds a set of functions to control the underlying joint
  26983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26984. */
  26985. export class PhysicsJoint {
  26986. /**
  26987. * The type of the physics joint
  26988. */
  26989. type: number;
  26990. /**
  26991. * The data for the physics joint
  26992. */
  26993. jointData: PhysicsJointData;
  26994. private _physicsJoint;
  26995. protected _physicsPlugin: IPhysicsEnginePlugin;
  26996. /**
  26997. * Initializes the physics joint
  26998. * @param type The type of the physics joint
  26999. * @param jointData The data for the physics joint
  27000. */
  27001. constructor(
  27002. /**
  27003. * The type of the physics joint
  27004. */
  27005. type: number,
  27006. /**
  27007. * The data for the physics joint
  27008. */
  27009. jointData: PhysicsJointData);
  27010. /**
  27011. * Gets the physics joint
  27012. */
  27013. get physicsJoint(): any;
  27014. /**
  27015. * Sets the physics joint
  27016. */
  27017. set physicsJoint(newJoint: any);
  27018. /**
  27019. * Sets the physics plugin
  27020. */
  27021. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27022. /**
  27023. * Execute a function that is physics-plugin specific.
  27024. * @param {Function} func the function that will be executed.
  27025. * It accepts two parameters: the physics world and the physics joint
  27026. */
  27027. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27028. /**
  27029. * Distance-Joint type
  27030. */
  27031. static DistanceJoint: number;
  27032. /**
  27033. * Hinge-Joint type
  27034. */
  27035. static HingeJoint: number;
  27036. /**
  27037. * Ball-and-Socket joint type
  27038. */
  27039. static BallAndSocketJoint: number;
  27040. /**
  27041. * Wheel-Joint type
  27042. */
  27043. static WheelJoint: number;
  27044. /**
  27045. * Slider-Joint type
  27046. */
  27047. static SliderJoint: number;
  27048. /**
  27049. * Prismatic-Joint type
  27050. */
  27051. static PrismaticJoint: number;
  27052. /**
  27053. * Universal-Joint type
  27054. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27055. */
  27056. static UniversalJoint: number;
  27057. /**
  27058. * Hinge-Joint 2 type
  27059. */
  27060. static Hinge2Joint: number;
  27061. /**
  27062. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27063. */
  27064. static PointToPointJoint: number;
  27065. /**
  27066. * Spring-Joint type
  27067. */
  27068. static SpringJoint: number;
  27069. /**
  27070. * Lock-Joint type
  27071. */
  27072. static LockJoint: number;
  27073. }
  27074. /**
  27075. * A class representing a physics distance joint
  27076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27077. */
  27078. export class DistanceJoint extends PhysicsJoint {
  27079. /**
  27080. *
  27081. * @param jointData The data for the Distance-Joint
  27082. */
  27083. constructor(jointData: DistanceJointData);
  27084. /**
  27085. * Update the predefined distance.
  27086. * @param maxDistance The maximum preferred distance
  27087. * @param minDistance The minimum preferred distance
  27088. */
  27089. updateDistance(maxDistance: number, minDistance?: number): void;
  27090. }
  27091. /**
  27092. * Represents a Motor-Enabled Joint
  27093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27094. */
  27095. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27096. /**
  27097. * Initializes the Motor-Enabled Joint
  27098. * @param type The type of the joint
  27099. * @param jointData The physica joint data for the joint
  27100. */
  27101. constructor(type: number, jointData: PhysicsJointData);
  27102. /**
  27103. * Set the motor values.
  27104. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27105. * @param force the force to apply
  27106. * @param maxForce max force for this motor.
  27107. */
  27108. setMotor(force?: number, maxForce?: number): void;
  27109. /**
  27110. * Set the motor's limits.
  27111. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27112. * @param upperLimit The upper limit of the motor
  27113. * @param lowerLimit The lower limit of the motor
  27114. */
  27115. setLimit(upperLimit: number, lowerLimit?: number): void;
  27116. }
  27117. /**
  27118. * This class represents a single physics Hinge-Joint
  27119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27120. */
  27121. export class HingeJoint extends MotorEnabledJoint {
  27122. /**
  27123. * Initializes the Hinge-Joint
  27124. * @param jointData The joint data for the Hinge-Joint
  27125. */
  27126. constructor(jointData: PhysicsJointData);
  27127. /**
  27128. * Set the motor values.
  27129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27130. * @param {number} force the force to apply
  27131. * @param {number} maxForce max force for this motor.
  27132. */
  27133. setMotor(force?: number, maxForce?: number): void;
  27134. /**
  27135. * Set the motor's limits.
  27136. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27137. * @param upperLimit The upper limit of the motor
  27138. * @param lowerLimit The lower limit of the motor
  27139. */
  27140. setLimit(upperLimit: number, lowerLimit?: number): void;
  27141. }
  27142. /**
  27143. * This class represents a dual hinge physics joint (same as wheel joint)
  27144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27145. */
  27146. export class Hinge2Joint extends MotorEnabledJoint {
  27147. /**
  27148. * Initializes the Hinge2-Joint
  27149. * @param jointData The joint data for the Hinge2-Joint
  27150. */
  27151. constructor(jointData: PhysicsJointData);
  27152. /**
  27153. * Set the motor values.
  27154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27155. * @param {number} targetSpeed the speed the motor is to reach
  27156. * @param {number} maxForce max force for this motor.
  27157. * @param {motorIndex} the motor's index, 0 or 1.
  27158. */
  27159. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27160. /**
  27161. * Set the motor limits.
  27162. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27163. * @param {number} upperLimit the upper limit
  27164. * @param {number} lowerLimit lower limit
  27165. * @param {motorIndex} the motor's index, 0 or 1.
  27166. */
  27167. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27168. }
  27169. /**
  27170. * Interface for a motor enabled joint
  27171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27172. */
  27173. export interface IMotorEnabledJoint {
  27174. /**
  27175. * Physics joint
  27176. */
  27177. physicsJoint: any;
  27178. /**
  27179. * Sets the motor of the motor-enabled joint
  27180. * @param force The force of the motor
  27181. * @param maxForce The maximum force of the motor
  27182. * @param motorIndex The index of the motor
  27183. */
  27184. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27185. /**
  27186. * Sets the limit of the motor
  27187. * @param upperLimit The upper limit of the motor
  27188. * @param lowerLimit The lower limit of the motor
  27189. * @param motorIndex The index of the motor
  27190. */
  27191. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27192. }
  27193. /**
  27194. * Joint data for a Distance-Joint
  27195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27196. */
  27197. export interface DistanceJointData extends PhysicsJointData {
  27198. /**
  27199. * Max distance the 2 joint objects can be apart
  27200. */
  27201. maxDistance: number;
  27202. }
  27203. /**
  27204. * Joint data from a spring joint
  27205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27206. */
  27207. export interface SpringJointData extends PhysicsJointData {
  27208. /**
  27209. * Length of the spring
  27210. */
  27211. length: number;
  27212. /**
  27213. * Stiffness of the spring
  27214. */
  27215. stiffness: number;
  27216. /**
  27217. * Damping of the spring
  27218. */
  27219. damping: number;
  27220. /** this callback will be called when applying the force to the impostors. */
  27221. forceApplicationCallback: () => void;
  27222. }
  27223. }
  27224. declare module "babylonjs/Physics/physicsRaycastResult" {
  27225. import { Vector3 } from "babylonjs/Maths/math.vector";
  27226. /**
  27227. * Holds the data for the raycast result
  27228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27229. */
  27230. export class PhysicsRaycastResult {
  27231. private _hasHit;
  27232. private _hitDistance;
  27233. private _hitNormalWorld;
  27234. private _hitPointWorld;
  27235. private _rayFromWorld;
  27236. private _rayToWorld;
  27237. /**
  27238. * Gets if there was a hit
  27239. */
  27240. get hasHit(): boolean;
  27241. /**
  27242. * Gets the distance from the hit
  27243. */
  27244. get hitDistance(): number;
  27245. /**
  27246. * Gets the hit normal/direction in the world
  27247. */
  27248. get hitNormalWorld(): Vector3;
  27249. /**
  27250. * Gets the hit point in the world
  27251. */
  27252. get hitPointWorld(): Vector3;
  27253. /**
  27254. * Gets the ray "start point" of the ray in the world
  27255. */
  27256. get rayFromWorld(): Vector3;
  27257. /**
  27258. * Gets the ray "end point" of the ray in the world
  27259. */
  27260. get rayToWorld(): Vector3;
  27261. /**
  27262. * Sets the hit data (normal & point in world space)
  27263. * @param hitNormalWorld defines the normal in world space
  27264. * @param hitPointWorld defines the point in world space
  27265. */
  27266. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27267. /**
  27268. * Sets the distance from the start point to the hit point
  27269. * @param distance
  27270. */
  27271. setHitDistance(distance: number): void;
  27272. /**
  27273. * Calculates the distance manually
  27274. */
  27275. calculateHitDistance(): void;
  27276. /**
  27277. * Resets all the values to default
  27278. * @param from The from point on world space
  27279. * @param to The to point on world space
  27280. */
  27281. reset(from?: Vector3, to?: Vector3): void;
  27282. }
  27283. /**
  27284. * Interface for the size containing width and height
  27285. */
  27286. interface IXYZ {
  27287. /**
  27288. * X
  27289. */
  27290. x: number;
  27291. /**
  27292. * Y
  27293. */
  27294. y: number;
  27295. /**
  27296. * Z
  27297. */
  27298. z: number;
  27299. }
  27300. }
  27301. declare module "babylonjs/Physics/IPhysicsEngine" {
  27302. import { Nullable } from "babylonjs/types";
  27303. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27305. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27306. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27307. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27308. /**
  27309. * Interface used to describe a physics joint
  27310. */
  27311. export interface PhysicsImpostorJoint {
  27312. /** Defines the main impostor to which the joint is linked */
  27313. mainImpostor: PhysicsImpostor;
  27314. /** Defines the impostor that is connected to the main impostor using this joint */
  27315. connectedImpostor: PhysicsImpostor;
  27316. /** Defines the joint itself */
  27317. joint: PhysicsJoint;
  27318. }
  27319. /** @hidden */
  27320. export interface IPhysicsEnginePlugin {
  27321. world: any;
  27322. name: string;
  27323. setGravity(gravity: Vector3): void;
  27324. setTimeStep(timeStep: number): void;
  27325. getTimeStep(): number;
  27326. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27327. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27328. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27329. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27330. removePhysicsBody(impostor: PhysicsImpostor): void;
  27331. generateJoint(joint: PhysicsImpostorJoint): void;
  27332. removeJoint(joint: PhysicsImpostorJoint): void;
  27333. isSupported(): boolean;
  27334. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27335. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27336. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27337. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27338. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27339. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27340. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27341. getBodyMass(impostor: PhysicsImpostor): number;
  27342. getBodyFriction(impostor: PhysicsImpostor): number;
  27343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27344. getBodyRestitution(impostor: PhysicsImpostor): number;
  27345. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27346. getBodyPressure?(impostor: PhysicsImpostor): number;
  27347. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27348. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27349. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27350. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27351. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27352. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27353. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27354. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27355. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27356. sleepBody(impostor: PhysicsImpostor): void;
  27357. wakeUpBody(impostor: PhysicsImpostor): void;
  27358. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27360. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27361. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27362. getRadius(impostor: PhysicsImpostor): number;
  27363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27364. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27365. dispose(): void;
  27366. }
  27367. /**
  27368. * Interface used to define a physics engine
  27369. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27370. */
  27371. export interface IPhysicsEngine {
  27372. /**
  27373. * Gets the gravity vector used by the simulation
  27374. */
  27375. gravity: Vector3;
  27376. /**
  27377. * Sets the gravity vector used by the simulation
  27378. * @param gravity defines the gravity vector to use
  27379. */
  27380. setGravity(gravity: Vector3): void;
  27381. /**
  27382. * Set the time step of the physics engine.
  27383. * Default is 1/60.
  27384. * To slow it down, enter 1/600 for example.
  27385. * To speed it up, 1/30
  27386. * @param newTimeStep the new timestep to apply to this world.
  27387. */
  27388. setTimeStep(newTimeStep: number): void;
  27389. /**
  27390. * Get the time step of the physics engine.
  27391. * @returns the current time step
  27392. */
  27393. getTimeStep(): number;
  27394. /**
  27395. * Set the sub time step of the physics engine.
  27396. * Default is 0 meaning there is no sub steps
  27397. * To increase physics resolution precision, set a small value (like 1 ms)
  27398. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27399. */
  27400. setSubTimeStep(subTimeStep: number): void;
  27401. /**
  27402. * Get the sub time step of the physics engine.
  27403. * @returns the current sub time step
  27404. */
  27405. getSubTimeStep(): number;
  27406. /**
  27407. * Release all resources
  27408. */
  27409. dispose(): void;
  27410. /**
  27411. * Gets the name of the current physics plugin
  27412. * @returns the name of the plugin
  27413. */
  27414. getPhysicsPluginName(): string;
  27415. /**
  27416. * Adding a new impostor for the impostor tracking.
  27417. * This will be done by the impostor itself.
  27418. * @param impostor the impostor to add
  27419. */
  27420. addImpostor(impostor: PhysicsImpostor): void;
  27421. /**
  27422. * Remove an impostor from the engine.
  27423. * This impostor and its mesh will not longer be updated by the physics engine.
  27424. * @param impostor the impostor to remove
  27425. */
  27426. removeImpostor(impostor: PhysicsImpostor): void;
  27427. /**
  27428. * Add a joint to the physics engine
  27429. * @param mainImpostor defines the main impostor to which the joint is added.
  27430. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27431. * @param joint defines the joint that will connect both impostors.
  27432. */
  27433. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27434. /**
  27435. * Removes a joint from the simulation
  27436. * @param mainImpostor defines the impostor used with the joint
  27437. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27438. * @param joint defines the joint to remove
  27439. */
  27440. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27441. /**
  27442. * Gets the current plugin used to run the simulation
  27443. * @returns current plugin
  27444. */
  27445. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27446. /**
  27447. * Gets the list of physic impostors
  27448. * @returns an array of PhysicsImpostor
  27449. */
  27450. getImpostors(): Array<PhysicsImpostor>;
  27451. /**
  27452. * Gets the impostor for a physics enabled object
  27453. * @param object defines the object impersonated by the impostor
  27454. * @returns the PhysicsImpostor or null if not found
  27455. */
  27456. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27457. /**
  27458. * Gets the impostor for a physics body object
  27459. * @param body defines physics body used by the impostor
  27460. * @returns the PhysicsImpostor or null if not found
  27461. */
  27462. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27463. /**
  27464. * Does a raycast in the physics world
  27465. * @param from when should the ray start?
  27466. * @param to when should the ray end?
  27467. * @returns PhysicsRaycastResult
  27468. */
  27469. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27470. /**
  27471. * Called by the scene. No need to call it.
  27472. * @param delta defines the timespam between frames
  27473. */
  27474. _step(delta: number): void;
  27475. }
  27476. }
  27477. declare module "babylonjs/Physics/physicsImpostor" {
  27478. import { Nullable, IndicesArray } from "babylonjs/types";
  27479. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27482. import { Scene } from "babylonjs/scene";
  27483. import { Bone } from "babylonjs/Bones/bone";
  27484. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27485. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27486. import { Space } from "babylonjs/Maths/math.axis";
  27487. /**
  27488. * The interface for the physics imposter parameters
  27489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27490. */
  27491. export interface PhysicsImpostorParameters {
  27492. /**
  27493. * The mass of the physics imposter
  27494. */
  27495. mass: number;
  27496. /**
  27497. * The friction of the physics imposter
  27498. */
  27499. friction?: number;
  27500. /**
  27501. * The coefficient of restitution of the physics imposter
  27502. */
  27503. restitution?: number;
  27504. /**
  27505. * The native options of the physics imposter
  27506. */
  27507. nativeOptions?: any;
  27508. /**
  27509. * Specifies if the parent should be ignored
  27510. */
  27511. ignoreParent?: boolean;
  27512. /**
  27513. * Specifies if bi-directional transformations should be disabled
  27514. */
  27515. disableBidirectionalTransformation?: boolean;
  27516. /**
  27517. * The pressure inside the physics imposter, soft object only
  27518. */
  27519. pressure?: number;
  27520. /**
  27521. * The stiffness the physics imposter, soft object only
  27522. */
  27523. stiffness?: number;
  27524. /**
  27525. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27526. */
  27527. velocityIterations?: number;
  27528. /**
  27529. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27530. */
  27531. positionIterations?: number;
  27532. /**
  27533. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27534. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27535. * Add to fix multiple points
  27536. */
  27537. fixedPoints?: number;
  27538. /**
  27539. * The collision margin around a soft object
  27540. */
  27541. margin?: number;
  27542. /**
  27543. * The collision margin around a soft object
  27544. */
  27545. damping?: number;
  27546. /**
  27547. * The path for a rope based on an extrusion
  27548. */
  27549. path?: any;
  27550. /**
  27551. * The shape of an extrusion used for a rope based on an extrusion
  27552. */
  27553. shape?: any;
  27554. }
  27555. /**
  27556. * Interface for a physics-enabled object
  27557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27558. */
  27559. export interface IPhysicsEnabledObject {
  27560. /**
  27561. * The position of the physics-enabled object
  27562. */
  27563. position: Vector3;
  27564. /**
  27565. * The rotation of the physics-enabled object
  27566. */
  27567. rotationQuaternion: Nullable<Quaternion>;
  27568. /**
  27569. * The scale of the physics-enabled object
  27570. */
  27571. scaling: Vector3;
  27572. /**
  27573. * The rotation of the physics-enabled object
  27574. */
  27575. rotation?: Vector3;
  27576. /**
  27577. * The parent of the physics-enabled object
  27578. */
  27579. parent?: any;
  27580. /**
  27581. * The bounding info of the physics-enabled object
  27582. * @returns The bounding info of the physics-enabled object
  27583. */
  27584. getBoundingInfo(): BoundingInfo;
  27585. /**
  27586. * Computes the world matrix
  27587. * @param force Specifies if the world matrix should be computed by force
  27588. * @returns A world matrix
  27589. */
  27590. computeWorldMatrix(force: boolean): Matrix;
  27591. /**
  27592. * Gets the world matrix
  27593. * @returns A world matrix
  27594. */
  27595. getWorldMatrix?(): Matrix;
  27596. /**
  27597. * Gets the child meshes
  27598. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27599. * @returns An array of abstract meshes
  27600. */
  27601. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27602. /**
  27603. * Gets the vertex data
  27604. * @param kind The type of vertex data
  27605. * @returns A nullable array of numbers, or a float32 array
  27606. */
  27607. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27608. /**
  27609. * Gets the indices from the mesh
  27610. * @returns A nullable array of index arrays
  27611. */
  27612. getIndices?(): Nullable<IndicesArray>;
  27613. /**
  27614. * Gets the scene from the mesh
  27615. * @returns the indices array or null
  27616. */
  27617. getScene?(): Scene;
  27618. /**
  27619. * Gets the absolute position from the mesh
  27620. * @returns the absolute position
  27621. */
  27622. getAbsolutePosition(): Vector3;
  27623. /**
  27624. * Gets the absolute pivot point from the mesh
  27625. * @returns the absolute pivot point
  27626. */
  27627. getAbsolutePivotPoint(): Vector3;
  27628. /**
  27629. * Rotates the mesh
  27630. * @param axis The axis of rotation
  27631. * @param amount The amount of rotation
  27632. * @param space The space of the rotation
  27633. * @returns The rotation transform node
  27634. */
  27635. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27636. /**
  27637. * Translates the mesh
  27638. * @param axis The axis of translation
  27639. * @param distance The distance of translation
  27640. * @param space The space of the translation
  27641. * @returns The transform node
  27642. */
  27643. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27644. /**
  27645. * Sets the absolute position of the mesh
  27646. * @param absolutePosition The absolute position of the mesh
  27647. * @returns The transform node
  27648. */
  27649. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27650. /**
  27651. * Gets the class name of the mesh
  27652. * @returns The class name
  27653. */
  27654. getClassName(): string;
  27655. }
  27656. /**
  27657. * Represents a physics imposter
  27658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27659. */
  27660. export class PhysicsImpostor {
  27661. /**
  27662. * The physics-enabled object used as the physics imposter
  27663. */
  27664. object: IPhysicsEnabledObject;
  27665. /**
  27666. * The type of the physics imposter
  27667. */
  27668. type: number;
  27669. private _options;
  27670. private _scene?;
  27671. /**
  27672. * The default object size of the imposter
  27673. */
  27674. static DEFAULT_OBJECT_SIZE: Vector3;
  27675. /**
  27676. * The identity quaternion of the imposter
  27677. */
  27678. static IDENTITY_QUATERNION: Quaternion;
  27679. /** @hidden */
  27680. _pluginData: any;
  27681. private _physicsEngine;
  27682. private _physicsBody;
  27683. private _bodyUpdateRequired;
  27684. private _onBeforePhysicsStepCallbacks;
  27685. private _onAfterPhysicsStepCallbacks;
  27686. /** @hidden */
  27687. _onPhysicsCollideCallbacks: Array<{
  27688. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27689. otherImpostors: Array<PhysicsImpostor>;
  27690. }>;
  27691. private _deltaPosition;
  27692. private _deltaRotation;
  27693. private _deltaRotationConjugated;
  27694. /** @hidden */
  27695. _isFromLine: boolean;
  27696. private _parent;
  27697. private _isDisposed;
  27698. private static _tmpVecs;
  27699. private static _tmpQuat;
  27700. /**
  27701. * Specifies if the physics imposter is disposed
  27702. */
  27703. get isDisposed(): boolean;
  27704. /**
  27705. * Gets the mass of the physics imposter
  27706. */
  27707. get mass(): number;
  27708. set mass(value: number);
  27709. /**
  27710. * Gets the coefficient of friction
  27711. */
  27712. get friction(): number;
  27713. /**
  27714. * Sets the coefficient of friction
  27715. */
  27716. set friction(value: number);
  27717. /**
  27718. * Gets the coefficient of restitution
  27719. */
  27720. get restitution(): number;
  27721. /**
  27722. * Sets the coefficient of restitution
  27723. */
  27724. set restitution(value: number);
  27725. /**
  27726. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27727. */
  27728. get pressure(): number;
  27729. /**
  27730. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27731. */
  27732. set pressure(value: number);
  27733. /**
  27734. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27735. */
  27736. get stiffness(): number;
  27737. /**
  27738. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27739. */
  27740. set stiffness(value: number);
  27741. /**
  27742. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27743. */
  27744. get velocityIterations(): number;
  27745. /**
  27746. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27747. */
  27748. set velocityIterations(value: number);
  27749. /**
  27750. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27751. */
  27752. get positionIterations(): number;
  27753. /**
  27754. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27755. */
  27756. set positionIterations(value: number);
  27757. /**
  27758. * The unique id of the physics imposter
  27759. * set by the physics engine when adding this impostor to the array
  27760. */
  27761. uniqueId: number;
  27762. /**
  27763. * @hidden
  27764. */
  27765. soft: boolean;
  27766. /**
  27767. * @hidden
  27768. */
  27769. segments: number;
  27770. private _joints;
  27771. /**
  27772. * Initializes the physics imposter
  27773. * @param object The physics-enabled object used as the physics imposter
  27774. * @param type The type of the physics imposter
  27775. * @param _options The options for the physics imposter
  27776. * @param _scene The Babylon scene
  27777. */
  27778. constructor(
  27779. /**
  27780. * The physics-enabled object used as the physics imposter
  27781. */
  27782. object: IPhysicsEnabledObject,
  27783. /**
  27784. * The type of the physics imposter
  27785. */
  27786. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27787. /**
  27788. * This function will completly initialize this impostor.
  27789. * It will create a new body - but only if this mesh has no parent.
  27790. * If it has, this impostor will not be used other than to define the impostor
  27791. * of the child mesh.
  27792. * @hidden
  27793. */
  27794. _init(): void;
  27795. private _getPhysicsParent;
  27796. /**
  27797. * Should a new body be generated.
  27798. * @returns boolean specifying if body initialization is required
  27799. */
  27800. isBodyInitRequired(): boolean;
  27801. /**
  27802. * Sets the updated scaling
  27803. * @param updated Specifies if the scaling is updated
  27804. */
  27805. setScalingUpdated(): void;
  27806. /**
  27807. * Force a regeneration of this or the parent's impostor's body.
  27808. * Use under cautious - This will remove all joints already implemented.
  27809. */
  27810. forceUpdate(): void;
  27811. /**
  27812. * Gets the body that holds this impostor. Either its own, or its parent.
  27813. */
  27814. get physicsBody(): any;
  27815. /**
  27816. * Get the parent of the physics imposter
  27817. * @returns Physics imposter or null
  27818. */
  27819. get parent(): Nullable<PhysicsImpostor>;
  27820. /**
  27821. * Sets the parent of the physics imposter
  27822. */
  27823. set parent(value: Nullable<PhysicsImpostor>);
  27824. /**
  27825. * Set the physics body. Used mainly by the physics engine/plugin
  27826. */
  27827. set physicsBody(physicsBody: any);
  27828. /**
  27829. * Resets the update flags
  27830. */
  27831. resetUpdateFlags(): void;
  27832. /**
  27833. * Gets the object extend size
  27834. * @returns the object extend size
  27835. */
  27836. getObjectExtendSize(): Vector3;
  27837. /**
  27838. * Gets the object center
  27839. * @returns The object center
  27840. */
  27841. getObjectCenter(): Vector3;
  27842. /**
  27843. * Get a specific parameter from the options parameters
  27844. * @param paramName The object parameter name
  27845. * @returns The object parameter
  27846. */
  27847. getParam(paramName: string): any;
  27848. /**
  27849. * Sets a specific parameter in the options given to the physics plugin
  27850. * @param paramName The parameter name
  27851. * @param value The value of the parameter
  27852. */
  27853. setParam(paramName: string, value: number): void;
  27854. /**
  27855. * Specifically change the body's mass option. Won't recreate the physics body object
  27856. * @param mass The mass of the physics imposter
  27857. */
  27858. setMass(mass: number): void;
  27859. /**
  27860. * Gets the linear velocity
  27861. * @returns linear velocity or null
  27862. */
  27863. getLinearVelocity(): Nullable<Vector3>;
  27864. /**
  27865. * Sets the linear velocity
  27866. * @param velocity linear velocity or null
  27867. */
  27868. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27869. /**
  27870. * Gets the angular velocity
  27871. * @returns angular velocity or null
  27872. */
  27873. getAngularVelocity(): Nullable<Vector3>;
  27874. /**
  27875. * Sets the angular velocity
  27876. * @param velocity The velocity or null
  27877. */
  27878. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27879. /**
  27880. * Execute a function with the physics plugin native code
  27881. * Provide a function the will have two variables - the world object and the physics body object
  27882. * @param func The function to execute with the physics plugin native code
  27883. */
  27884. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27885. /**
  27886. * Register a function that will be executed before the physics world is stepping forward
  27887. * @param func The function to execute before the physics world is stepped forward
  27888. */
  27889. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27890. /**
  27891. * Unregister a function that will be executed before the physics world is stepping forward
  27892. * @param func The function to execute before the physics world is stepped forward
  27893. */
  27894. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27895. /**
  27896. * Register a function that will be executed after the physics step
  27897. * @param func The function to execute after physics step
  27898. */
  27899. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27900. /**
  27901. * Unregisters a function that will be executed after the physics step
  27902. * @param func The function to execute after physics step
  27903. */
  27904. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27905. /**
  27906. * register a function that will be executed when this impostor collides against a different body
  27907. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27908. * @param func Callback that is executed on collision
  27909. */
  27910. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27911. /**
  27912. * Unregisters the physics imposter on contact
  27913. * @param collideAgainst The physics object to collide against
  27914. * @param func Callback to execute on collision
  27915. */
  27916. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27917. private _tmpQuat;
  27918. private _tmpQuat2;
  27919. /**
  27920. * Get the parent rotation
  27921. * @returns The parent rotation
  27922. */
  27923. getParentsRotation(): Quaternion;
  27924. /**
  27925. * this function is executed by the physics engine.
  27926. */
  27927. beforeStep: () => void;
  27928. /**
  27929. * this function is executed by the physics engine
  27930. */
  27931. afterStep: () => void;
  27932. /**
  27933. * Legacy collision detection event support
  27934. */
  27935. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27936. /**
  27937. * event and body object due to cannon's event-based architecture.
  27938. */
  27939. onCollide: (e: {
  27940. body: any;
  27941. }) => void;
  27942. /**
  27943. * Apply a force
  27944. * @param force The force to apply
  27945. * @param contactPoint The contact point for the force
  27946. * @returns The physics imposter
  27947. */
  27948. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27949. /**
  27950. * Apply an impulse
  27951. * @param force The impulse force
  27952. * @param contactPoint The contact point for the impulse force
  27953. * @returns The physics imposter
  27954. */
  27955. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27956. /**
  27957. * A help function to create a joint
  27958. * @param otherImpostor A physics imposter used to create a joint
  27959. * @param jointType The type of joint
  27960. * @param jointData The data for the joint
  27961. * @returns The physics imposter
  27962. */
  27963. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27964. /**
  27965. * Add a joint to this impostor with a different impostor
  27966. * @param otherImpostor A physics imposter used to add a joint
  27967. * @param joint The joint to add
  27968. * @returns The physics imposter
  27969. */
  27970. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27971. /**
  27972. * Add an anchor to a cloth impostor
  27973. * @param otherImpostor rigid impostor to anchor to
  27974. * @param width ratio across width from 0 to 1
  27975. * @param height ratio up height from 0 to 1
  27976. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27977. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27978. * @returns impostor the soft imposter
  27979. */
  27980. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27981. /**
  27982. * Add a hook to a rope impostor
  27983. * @param otherImpostor rigid impostor to anchor to
  27984. * @param length ratio across rope from 0 to 1
  27985. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27986. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27987. * @returns impostor the rope imposter
  27988. */
  27989. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27990. /**
  27991. * Will keep this body still, in a sleep mode.
  27992. * @returns the physics imposter
  27993. */
  27994. sleep(): PhysicsImpostor;
  27995. /**
  27996. * Wake the body up.
  27997. * @returns The physics imposter
  27998. */
  27999. wakeUp(): PhysicsImpostor;
  28000. /**
  28001. * Clones the physics imposter
  28002. * @param newObject The physics imposter clones to this physics-enabled object
  28003. * @returns A nullable physics imposter
  28004. */
  28005. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28006. /**
  28007. * Disposes the physics imposter
  28008. */
  28009. dispose(): void;
  28010. /**
  28011. * Sets the delta position
  28012. * @param position The delta position amount
  28013. */
  28014. setDeltaPosition(position: Vector3): void;
  28015. /**
  28016. * Sets the delta rotation
  28017. * @param rotation The delta rotation amount
  28018. */
  28019. setDeltaRotation(rotation: Quaternion): void;
  28020. /**
  28021. * Gets the box size of the physics imposter and stores the result in the input parameter
  28022. * @param result Stores the box size
  28023. * @returns The physics imposter
  28024. */
  28025. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28026. /**
  28027. * Gets the radius of the physics imposter
  28028. * @returns Radius of the physics imposter
  28029. */
  28030. getRadius(): number;
  28031. /**
  28032. * Sync a bone with this impostor
  28033. * @param bone The bone to sync to the impostor.
  28034. * @param boneMesh The mesh that the bone is influencing.
  28035. * @param jointPivot The pivot of the joint / bone in local space.
  28036. * @param distToJoint Optional distance from the impostor to the joint.
  28037. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28038. */
  28039. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28040. /**
  28041. * Sync impostor to a bone
  28042. * @param bone The bone that the impostor will be synced to.
  28043. * @param boneMesh The mesh that the bone is influencing.
  28044. * @param jointPivot The pivot of the joint / bone in local space.
  28045. * @param distToJoint Optional distance from the impostor to the joint.
  28046. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28047. * @param boneAxis Optional vector3 axis the bone is aligned with
  28048. */
  28049. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28050. /**
  28051. * No-Imposter type
  28052. */
  28053. static NoImpostor: number;
  28054. /**
  28055. * Sphere-Imposter type
  28056. */
  28057. static SphereImpostor: number;
  28058. /**
  28059. * Box-Imposter type
  28060. */
  28061. static BoxImpostor: number;
  28062. /**
  28063. * Plane-Imposter type
  28064. */
  28065. static PlaneImpostor: number;
  28066. /**
  28067. * Mesh-imposter type
  28068. */
  28069. static MeshImpostor: number;
  28070. /**
  28071. * Capsule-Impostor type (Ammo.js plugin only)
  28072. */
  28073. static CapsuleImpostor: number;
  28074. /**
  28075. * Cylinder-Imposter type
  28076. */
  28077. static CylinderImpostor: number;
  28078. /**
  28079. * Particle-Imposter type
  28080. */
  28081. static ParticleImpostor: number;
  28082. /**
  28083. * Heightmap-Imposter type
  28084. */
  28085. static HeightmapImpostor: number;
  28086. /**
  28087. * ConvexHull-Impostor type (Ammo.js plugin only)
  28088. */
  28089. static ConvexHullImpostor: number;
  28090. /**
  28091. * Custom-Imposter type (Ammo.js plugin only)
  28092. */
  28093. static CustomImpostor: number;
  28094. /**
  28095. * Rope-Imposter type
  28096. */
  28097. static RopeImpostor: number;
  28098. /**
  28099. * Cloth-Imposter type
  28100. */
  28101. static ClothImpostor: number;
  28102. /**
  28103. * Softbody-Imposter type
  28104. */
  28105. static SoftbodyImpostor: number;
  28106. }
  28107. }
  28108. declare module "babylonjs/Meshes/mesh" {
  28109. import { Observable } from "babylonjs/Misc/observable";
  28110. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28111. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28112. import { Camera } from "babylonjs/Cameras/camera";
  28113. import { Scene } from "babylonjs/scene";
  28114. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28115. import { Color4 } from "babylonjs/Maths/math.color";
  28116. import { Engine } from "babylonjs/Engines/engine";
  28117. import { Node } from "babylonjs/node";
  28118. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28119. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28120. import { Buffer } from "babylonjs/Meshes/buffer";
  28121. import { Geometry } from "babylonjs/Meshes/geometry";
  28122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28123. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28124. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28125. import { Effect } from "babylonjs/Materials/effect";
  28126. import { Material } from "babylonjs/Materials/material";
  28127. import { Skeleton } from "babylonjs/Bones/skeleton";
  28128. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28129. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28130. import { Path3D } from "babylonjs/Maths/math.path";
  28131. import { Plane } from "babylonjs/Maths/math.plane";
  28132. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28133. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28134. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28135. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28136. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28137. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28138. /**
  28139. * @hidden
  28140. **/
  28141. export class _CreationDataStorage {
  28142. closePath?: boolean;
  28143. closeArray?: boolean;
  28144. idx: number[];
  28145. dashSize: number;
  28146. gapSize: number;
  28147. path3D: Path3D;
  28148. pathArray: Vector3[][];
  28149. arc: number;
  28150. radius: number;
  28151. cap: number;
  28152. tessellation: number;
  28153. }
  28154. /**
  28155. * @hidden
  28156. **/
  28157. class _InstanceDataStorage {
  28158. visibleInstances: any;
  28159. batchCache: _InstancesBatch;
  28160. instancesBufferSize: number;
  28161. instancesBuffer: Nullable<Buffer>;
  28162. instancesData: Float32Array;
  28163. overridenInstanceCount: number;
  28164. isFrozen: boolean;
  28165. previousBatch: Nullable<_InstancesBatch>;
  28166. hardwareInstancedRendering: boolean;
  28167. sideOrientation: number;
  28168. manualUpdate: boolean;
  28169. }
  28170. /**
  28171. * @hidden
  28172. **/
  28173. export class _InstancesBatch {
  28174. mustReturn: boolean;
  28175. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28176. renderSelf: boolean[];
  28177. hardwareInstancedRendering: boolean[];
  28178. }
  28179. /**
  28180. * @hidden
  28181. **/
  28182. class _ThinInstanceDataStorage {
  28183. instancesCount: number;
  28184. matrixBuffer: Nullable<Buffer>;
  28185. matrixBufferSize: number;
  28186. matrixData: Nullable<Float32Array>;
  28187. boundingVectors: Array<Vector3>;
  28188. }
  28189. /**
  28190. * Class used to represent renderable models
  28191. */
  28192. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28193. /**
  28194. * Mesh side orientation : usually the external or front surface
  28195. */
  28196. static readonly FRONTSIDE: number;
  28197. /**
  28198. * Mesh side orientation : usually the internal or back surface
  28199. */
  28200. static readonly BACKSIDE: number;
  28201. /**
  28202. * Mesh side orientation : both internal and external or front and back surfaces
  28203. */
  28204. static readonly DOUBLESIDE: number;
  28205. /**
  28206. * Mesh side orientation : by default, `FRONTSIDE`
  28207. */
  28208. static readonly DEFAULTSIDE: number;
  28209. /**
  28210. * Mesh cap setting : no cap
  28211. */
  28212. static readonly NO_CAP: number;
  28213. /**
  28214. * Mesh cap setting : one cap at the beginning of the mesh
  28215. */
  28216. static readonly CAP_START: number;
  28217. /**
  28218. * Mesh cap setting : one cap at the end of the mesh
  28219. */
  28220. static readonly CAP_END: number;
  28221. /**
  28222. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28223. */
  28224. static readonly CAP_ALL: number;
  28225. /**
  28226. * Mesh pattern setting : no flip or rotate
  28227. */
  28228. static readonly NO_FLIP: number;
  28229. /**
  28230. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28231. */
  28232. static readonly FLIP_TILE: number;
  28233. /**
  28234. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28235. */
  28236. static readonly ROTATE_TILE: number;
  28237. /**
  28238. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28239. */
  28240. static readonly FLIP_ROW: number;
  28241. /**
  28242. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28243. */
  28244. static readonly ROTATE_ROW: number;
  28245. /**
  28246. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28247. */
  28248. static readonly FLIP_N_ROTATE_TILE: number;
  28249. /**
  28250. * Mesh pattern setting : rotate pattern and rotate
  28251. */
  28252. static readonly FLIP_N_ROTATE_ROW: number;
  28253. /**
  28254. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28255. */
  28256. static readonly CENTER: number;
  28257. /**
  28258. * Mesh tile positioning : part tiles on left
  28259. */
  28260. static readonly LEFT: number;
  28261. /**
  28262. * Mesh tile positioning : part tiles on right
  28263. */
  28264. static readonly RIGHT: number;
  28265. /**
  28266. * Mesh tile positioning : part tiles on top
  28267. */
  28268. static readonly TOP: number;
  28269. /**
  28270. * Mesh tile positioning : part tiles on bottom
  28271. */
  28272. static readonly BOTTOM: number;
  28273. /**
  28274. * Gets the default side orientation.
  28275. * @param orientation the orientation to value to attempt to get
  28276. * @returns the default orientation
  28277. * @hidden
  28278. */
  28279. static _GetDefaultSideOrientation(orientation?: number): number;
  28280. private _internalMeshDataInfo;
  28281. /**
  28282. * An event triggered before rendering the mesh
  28283. */
  28284. get onBeforeRenderObservable(): Observable<Mesh>;
  28285. /**
  28286. * An event triggered before binding the mesh
  28287. */
  28288. get onBeforeBindObservable(): Observable<Mesh>;
  28289. /**
  28290. * An event triggered after rendering the mesh
  28291. */
  28292. get onAfterRenderObservable(): Observable<Mesh>;
  28293. /**
  28294. * An event triggered before drawing the mesh
  28295. */
  28296. get onBeforeDrawObservable(): Observable<Mesh>;
  28297. private _onBeforeDrawObserver;
  28298. /**
  28299. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28300. */
  28301. set onBeforeDraw(callback: () => void);
  28302. get hasInstances(): boolean;
  28303. get hasThinInstances(): boolean;
  28304. /**
  28305. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28306. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28307. */
  28308. delayLoadState: number;
  28309. /**
  28310. * Gets the list of instances created from this mesh
  28311. * it is not supposed to be modified manually.
  28312. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28313. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28314. */
  28315. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28316. /**
  28317. * Gets the file containing delay loading data for this mesh
  28318. */
  28319. delayLoadingFile: string;
  28320. /** @hidden */
  28321. _binaryInfo: any;
  28322. /**
  28323. * User defined function used to change how LOD level selection is done
  28324. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28325. */
  28326. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28327. /**
  28328. * Gets or sets the morph target manager
  28329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28330. */
  28331. get morphTargetManager(): Nullable<MorphTargetManager>;
  28332. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28333. /** @hidden */
  28334. _creationDataStorage: Nullable<_CreationDataStorage>;
  28335. /** @hidden */
  28336. _geometry: Nullable<Geometry>;
  28337. /** @hidden */
  28338. _delayInfo: Array<string>;
  28339. /** @hidden */
  28340. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28341. /** @hidden */
  28342. _instanceDataStorage: _InstanceDataStorage;
  28343. /** @hidden */
  28344. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28345. private _effectiveMaterial;
  28346. /** @hidden */
  28347. _shouldGenerateFlatShading: boolean;
  28348. /** @hidden */
  28349. _originalBuilderSideOrientation: number;
  28350. /**
  28351. * Use this property to change the original side orientation defined at construction time
  28352. */
  28353. overrideMaterialSideOrientation: Nullable<number>;
  28354. /**
  28355. * Gets the source mesh (the one used to clone this one from)
  28356. */
  28357. get source(): Nullable<Mesh>;
  28358. /**
  28359. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28360. */
  28361. get isUnIndexed(): boolean;
  28362. set isUnIndexed(value: boolean);
  28363. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28364. get worldMatrixInstancedBuffer(): Float32Array;
  28365. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28366. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28367. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28368. /**
  28369. * @constructor
  28370. * @param name The value used by scene.getMeshByName() to do a lookup.
  28371. * @param scene The scene to add this mesh to.
  28372. * @param parent The parent of this mesh, if it has one
  28373. * @param source An optional Mesh from which geometry is shared, cloned.
  28374. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28375. * When false, achieved by calling a clone(), also passing False.
  28376. * This will make creation of children, recursive.
  28377. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28378. */
  28379. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28380. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28381. doNotInstantiate: boolean;
  28382. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28383. /**
  28384. * Gets the class name
  28385. * @returns the string "Mesh".
  28386. */
  28387. getClassName(): string;
  28388. /** @hidden */
  28389. get _isMesh(): boolean;
  28390. /**
  28391. * Returns a description of this mesh
  28392. * @param fullDetails define if full details about this mesh must be used
  28393. * @returns a descriptive string representing this mesh
  28394. */
  28395. toString(fullDetails?: boolean): string;
  28396. /** @hidden */
  28397. _unBindEffect(): void;
  28398. /**
  28399. * Gets a boolean indicating if this mesh has LOD
  28400. */
  28401. get hasLODLevels(): boolean;
  28402. /**
  28403. * Gets the list of MeshLODLevel associated with the current mesh
  28404. * @returns an array of MeshLODLevel
  28405. */
  28406. getLODLevels(): MeshLODLevel[];
  28407. private _sortLODLevels;
  28408. /**
  28409. * Add a mesh as LOD level triggered at the given distance.
  28410. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28411. * @param distance The distance from the center of the object to show this level
  28412. * @param mesh The mesh to be added as LOD level (can be null)
  28413. * @return This mesh (for chaining)
  28414. */
  28415. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28416. /**
  28417. * Returns the LOD level mesh at the passed distance or null if not found.
  28418. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28419. * @param distance The distance from the center of the object to show this level
  28420. * @returns a Mesh or `null`
  28421. */
  28422. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28423. /**
  28424. * Remove a mesh from the LOD array
  28425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28426. * @param mesh defines the mesh to be removed
  28427. * @return This mesh (for chaining)
  28428. */
  28429. removeLODLevel(mesh: Mesh): Mesh;
  28430. /**
  28431. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28432. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28433. * @param camera defines the camera to use to compute distance
  28434. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28435. * @return This mesh (for chaining)
  28436. */
  28437. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28438. /**
  28439. * Gets the mesh internal Geometry object
  28440. */
  28441. get geometry(): Nullable<Geometry>;
  28442. /**
  28443. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28444. * @returns the total number of vertices
  28445. */
  28446. getTotalVertices(): number;
  28447. /**
  28448. * Returns the content of an associated vertex buffer
  28449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28450. * - VertexBuffer.PositionKind
  28451. * - VertexBuffer.UVKind
  28452. * - VertexBuffer.UV2Kind
  28453. * - VertexBuffer.UV3Kind
  28454. * - VertexBuffer.UV4Kind
  28455. * - VertexBuffer.UV5Kind
  28456. * - VertexBuffer.UV6Kind
  28457. * - VertexBuffer.ColorKind
  28458. * - VertexBuffer.MatricesIndicesKind
  28459. * - VertexBuffer.MatricesIndicesExtraKind
  28460. * - VertexBuffer.MatricesWeightsKind
  28461. * - VertexBuffer.MatricesWeightsExtraKind
  28462. * @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
  28463. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28464. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28465. */
  28466. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28467. /**
  28468. * Returns the mesh VertexBuffer object from the requested `kind`
  28469. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28470. * - VertexBuffer.PositionKind
  28471. * - VertexBuffer.NormalKind
  28472. * - VertexBuffer.UVKind
  28473. * - VertexBuffer.UV2Kind
  28474. * - VertexBuffer.UV3Kind
  28475. * - VertexBuffer.UV4Kind
  28476. * - VertexBuffer.UV5Kind
  28477. * - VertexBuffer.UV6Kind
  28478. * - VertexBuffer.ColorKind
  28479. * - VertexBuffer.MatricesIndicesKind
  28480. * - VertexBuffer.MatricesIndicesExtraKind
  28481. * - VertexBuffer.MatricesWeightsKind
  28482. * - VertexBuffer.MatricesWeightsExtraKind
  28483. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28484. */
  28485. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28486. /**
  28487. * Tests if a specific vertex buffer is associated with this mesh
  28488. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28489. * - VertexBuffer.PositionKind
  28490. * - VertexBuffer.NormalKind
  28491. * - VertexBuffer.UVKind
  28492. * - VertexBuffer.UV2Kind
  28493. * - VertexBuffer.UV3Kind
  28494. * - VertexBuffer.UV4Kind
  28495. * - VertexBuffer.UV5Kind
  28496. * - VertexBuffer.UV6Kind
  28497. * - VertexBuffer.ColorKind
  28498. * - VertexBuffer.MatricesIndicesKind
  28499. * - VertexBuffer.MatricesIndicesExtraKind
  28500. * - VertexBuffer.MatricesWeightsKind
  28501. * - VertexBuffer.MatricesWeightsExtraKind
  28502. * @returns a boolean
  28503. */
  28504. isVerticesDataPresent(kind: string): boolean;
  28505. /**
  28506. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28507. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28508. * - VertexBuffer.PositionKind
  28509. * - VertexBuffer.UVKind
  28510. * - VertexBuffer.UV2Kind
  28511. * - VertexBuffer.UV3Kind
  28512. * - VertexBuffer.UV4Kind
  28513. * - VertexBuffer.UV5Kind
  28514. * - VertexBuffer.UV6Kind
  28515. * - VertexBuffer.ColorKind
  28516. * - VertexBuffer.MatricesIndicesKind
  28517. * - VertexBuffer.MatricesIndicesExtraKind
  28518. * - VertexBuffer.MatricesWeightsKind
  28519. * - VertexBuffer.MatricesWeightsExtraKind
  28520. * @returns a boolean
  28521. */
  28522. isVertexBufferUpdatable(kind: string): boolean;
  28523. /**
  28524. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28525. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28526. * - VertexBuffer.PositionKind
  28527. * - VertexBuffer.NormalKind
  28528. * - VertexBuffer.UVKind
  28529. * - VertexBuffer.UV2Kind
  28530. * - VertexBuffer.UV3Kind
  28531. * - VertexBuffer.UV4Kind
  28532. * - VertexBuffer.UV5Kind
  28533. * - VertexBuffer.UV6Kind
  28534. * - VertexBuffer.ColorKind
  28535. * - VertexBuffer.MatricesIndicesKind
  28536. * - VertexBuffer.MatricesIndicesExtraKind
  28537. * - VertexBuffer.MatricesWeightsKind
  28538. * - VertexBuffer.MatricesWeightsExtraKind
  28539. * @returns an array of strings
  28540. */
  28541. getVerticesDataKinds(): string[];
  28542. /**
  28543. * Returns a positive integer : the total number of indices in this mesh geometry.
  28544. * @returns the numner of indices or zero if the mesh has no geometry.
  28545. */
  28546. getTotalIndices(): number;
  28547. /**
  28548. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28549. * @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.
  28550. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28551. * @returns the indices array or an empty array if the mesh has no geometry
  28552. */
  28553. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28554. get isBlocked(): boolean;
  28555. /**
  28556. * Determine if the current mesh is ready to be rendered
  28557. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28558. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28559. * @returns true if all associated assets are ready (material, textures, shaders)
  28560. */
  28561. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28562. /**
  28563. * 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.
  28564. */
  28565. get areNormalsFrozen(): boolean;
  28566. /**
  28567. * 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.
  28568. * @returns the current mesh
  28569. */
  28570. freezeNormals(): Mesh;
  28571. /**
  28572. * 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
  28573. * @returns the current mesh
  28574. */
  28575. unfreezeNormals(): Mesh;
  28576. /**
  28577. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28578. */
  28579. set overridenInstanceCount(count: number);
  28580. /** @hidden */
  28581. _preActivate(): Mesh;
  28582. /** @hidden */
  28583. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28584. /** @hidden */
  28585. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28586. protected _afterComputeWorldMatrix(): void;
  28587. /** @hidden */
  28588. _postActivate(): void;
  28589. /**
  28590. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28591. * This means the mesh underlying bounding box and sphere are recomputed.
  28592. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28593. * @returns the current mesh
  28594. */
  28595. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28596. /** @hidden */
  28597. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28598. /**
  28599. * This function will subdivide the mesh into multiple submeshes
  28600. * @param count defines the expected number of submeshes
  28601. */
  28602. subdivide(count: number): void;
  28603. /**
  28604. * Copy a FloatArray into a specific associated vertex buffer
  28605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28606. * - VertexBuffer.PositionKind
  28607. * - VertexBuffer.UVKind
  28608. * - VertexBuffer.UV2Kind
  28609. * - VertexBuffer.UV3Kind
  28610. * - VertexBuffer.UV4Kind
  28611. * - VertexBuffer.UV5Kind
  28612. * - VertexBuffer.UV6Kind
  28613. * - VertexBuffer.ColorKind
  28614. * - VertexBuffer.MatricesIndicesKind
  28615. * - VertexBuffer.MatricesIndicesExtraKind
  28616. * - VertexBuffer.MatricesWeightsKind
  28617. * - VertexBuffer.MatricesWeightsExtraKind
  28618. * @param data defines the data source
  28619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28620. * @param stride defines the data stride size (can be null)
  28621. * @returns the current mesh
  28622. */
  28623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28624. /**
  28625. * Delete a vertex buffer associated with this mesh
  28626. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28627. * - VertexBuffer.PositionKind
  28628. * - VertexBuffer.UVKind
  28629. * - VertexBuffer.UV2Kind
  28630. * - VertexBuffer.UV3Kind
  28631. * - VertexBuffer.UV4Kind
  28632. * - VertexBuffer.UV5Kind
  28633. * - VertexBuffer.UV6Kind
  28634. * - VertexBuffer.ColorKind
  28635. * - VertexBuffer.MatricesIndicesKind
  28636. * - VertexBuffer.MatricesIndicesExtraKind
  28637. * - VertexBuffer.MatricesWeightsKind
  28638. * - VertexBuffer.MatricesWeightsExtraKind
  28639. */
  28640. removeVerticesData(kind: string): void;
  28641. /**
  28642. * Flags an associated vertex buffer as updatable
  28643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28644. * - VertexBuffer.PositionKind
  28645. * - VertexBuffer.UVKind
  28646. * - VertexBuffer.UV2Kind
  28647. * - VertexBuffer.UV3Kind
  28648. * - VertexBuffer.UV4Kind
  28649. * - VertexBuffer.UV5Kind
  28650. * - VertexBuffer.UV6Kind
  28651. * - VertexBuffer.ColorKind
  28652. * - VertexBuffer.MatricesIndicesKind
  28653. * - VertexBuffer.MatricesIndicesExtraKind
  28654. * - VertexBuffer.MatricesWeightsKind
  28655. * - VertexBuffer.MatricesWeightsExtraKind
  28656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28657. */
  28658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28659. /**
  28660. * Sets the mesh global Vertex Buffer
  28661. * @param buffer defines the buffer to use
  28662. * @returns the current mesh
  28663. */
  28664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28665. /**
  28666. * Update a specific associated vertex buffer
  28667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28668. * - VertexBuffer.PositionKind
  28669. * - VertexBuffer.UVKind
  28670. * - VertexBuffer.UV2Kind
  28671. * - VertexBuffer.UV3Kind
  28672. * - VertexBuffer.UV4Kind
  28673. * - VertexBuffer.UV5Kind
  28674. * - VertexBuffer.UV6Kind
  28675. * - VertexBuffer.ColorKind
  28676. * - VertexBuffer.MatricesIndicesKind
  28677. * - VertexBuffer.MatricesIndicesExtraKind
  28678. * - VertexBuffer.MatricesWeightsKind
  28679. * - VertexBuffer.MatricesWeightsExtraKind
  28680. * @param data defines the data source
  28681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28682. * @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)
  28683. * @returns the current mesh
  28684. */
  28685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28686. /**
  28687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28691. * @returns the current mesh
  28692. */
  28693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28694. /**
  28695. * Creates a un-shared specific occurence of the geometry for the mesh.
  28696. * @returns the current mesh
  28697. */
  28698. makeGeometryUnique(): Mesh;
  28699. /**
  28700. * Set the index buffer of this mesh
  28701. * @param indices defines the source data
  28702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28704. * @returns the current mesh
  28705. */
  28706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28707. /**
  28708. * Update the current index buffer
  28709. * @param indices defines the source data
  28710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28711. * @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)
  28712. * @returns the current mesh
  28713. */
  28714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28715. /**
  28716. * Invert the geometry to move from a right handed system to a left handed one.
  28717. * @returns the current mesh
  28718. */
  28719. toLeftHanded(): Mesh;
  28720. /** @hidden */
  28721. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28722. /** @hidden */
  28723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28724. /**
  28725. * Registers for this mesh a javascript function called just before the rendering process
  28726. * @param func defines the function to call before rendering this mesh
  28727. * @returns the current mesh
  28728. */
  28729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28730. /**
  28731. * Disposes a previously registered javascript function called before the rendering
  28732. * @param func defines the function to remove
  28733. * @returns the current mesh
  28734. */
  28735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28736. /**
  28737. * Registers for this mesh a javascript function called just after the rendering is complete
  28738. * @param func defines the function to call after rendering this mesh
  28739. * @returns the current mesh
  28740. */
  28741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28742. /**
  28743. * Disposes a previously registered javascript function called after the rendering.
  28744. * @param func defines the function to remove
  28745. * @returns the current mesh
  28746. */
  28747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28748. /** @hidden */
  28749. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28750. /** @hidden */
  28751. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28752. /** @hidden */
  28753. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28754. /** @hidden */
  28755. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28756. /** @hidden */
  28757. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28758. /** @hidden */
  28759. _rebuild(): void;
  28760. /** @hidden */
  28761. _freeze(): void;
  28762. /** @hidden */
  28763. _unFreeze(): void;
  28764. /**
  28765. * 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
  28766. * @param subMesh defines the subMesh to render
  28767. * @param enableAlphaMode defines if alpha mode can be changed
  28768. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28769. * @returns the current mesh
  28770. */
  28771. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28772. private _onBeforeDraw;
  28773. /**
  28774. * Renormalize the mesh and patch it up if there are no weights
  28775. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28776. * However in the case of zero weights then we set just a single influence to 1.
  28777. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28778. */
  28779. cleanMatrixWeights(): void;
  28780. private normalizeSkinFourWeights;
  28781. private normalizeSkinWeightsAndExtra;
  28782. /**
  28783. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28784. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28785. * the user know there was an issue with importing the mesh
  28786. * @returns a validation object with skinned, valid and report string
  28787. */
  28788. validateSkinning(): {
  28789. skinned: boolean;
  28790. valid: boolean;
  28791. report: string;
  28792. };
  28793. /** @hidden */
  28794. _checkDelayState(): Mesh;
  28795. private _queueLoad;
  28796. /**
  28797. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28798. * A mesh is in the frustum if its bounding box intersects the frustum
  28799. * @param frustumPlanes defines the frustum to test
  28800. * @returns true if the mesh is in the frustum planes
  28801. */
  28802. isInFrustum(frustumPlanes: Plane[]): boolean;
  28803. /**
  28804. * Sets the mesh material by the material or multiMaterial `id` property
  28805. * @param id is a string identifying the material or the multiMaterial
  28806. * @returns the current mesh
  28807. */
  28808. setMaterialByID(id: string): Mesh;
  28809. /**
  28810. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28811. * @returns an array of IAnimatable
  28812. */
  28813. getAnimatables(): IAnimatable[];
  28814. /**
  28815. * Modifies the mesh geometry according to the passed transformation matrix.
  28816. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28817. * The mesh normals are modified using the same transformation.
  28818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28819. * @param transform defines the transform matrix to use
  28820. * @see http://doc.babylonjs.com/resources/baking_transformations
  28821. * @returns the current mesh
  28822. */
  28823. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28824. /**
  28825. * Modifies the mesh geometry according to its own current World Matrix.
  28826. * The mesh World Matrix is then reset.
  28827. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28829. * @see http://doc.babylonjs.com/resources/baking_transformations
  28830. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28831. * @returns the current mesh
  28832. */
  28833. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28834. /** @hidden */
  28835. get _positions(): Nullable<Vector3[]>;
  28836. /** @hidden */
  28837. _resetPointsArrayCache(): Mesh;
  28838. /** @hidden */
  28839. _generatePointsArray(): boolean;
  28840. /**
  28841. * Returns a new Mesh object generated from the current mesh properties.
  28842. * This method must not get confused with createInstance()
  28843. * @param name is a string, the name given to the new mesh
  28844. * @param newParent can be any Node object (default `null`)
  28845. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28846. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28847. * @returns a new mesh
  28848. */
  28849. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28850. /**
  28851. * Releases resources associated with this mesh.
  28852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28854. */
  28855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28856. /** @hidden */
  28857. _disposeInstanceSpecificData(): void;
  28858. /** @hidden */
  28859. _disposeThinInstanceSpecificData(): void;
  28860. /**
  28861. * Modifies the mesh geometry according to a displacement map.
  28862. * 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.
  28863. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28864. * @param url is a string, the URL from the image file is to be downloaded.
  28865. * @param minHeight is the lower limit of the displacement.
  28866. * @param maxHeight is the upper limit of the displacement.
  28867. * @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.
  28868. * @param uvOffset is an optional vector2 used to offset UV.
  28869. * @param uvScale is an optional vector2 used to scale UV.
  28870. * @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.
  28871. * @returns the Mesh.
  28872. */
  28873. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28874. /**
  28875. * Modifies the mesh geometry according to a displacementMap buffer.
  28876. * 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.
  28877. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28878. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28879. * @param heightMapWidth is the width of the buffer image.
  28880. * @param heightMapHeight is the height of the buffer image.
  28881. * @param minHeight is the lower limit of the displacement.
  28882. * @param maxHeight is the upper limit of the displacement.
  28883. * @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.
  28884. * @param uvOffset is an optional vector2 used to offset UV.
  28885. * @param uvScale is an optional vector2 used to scale UV.
  28886. * @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.
  28887. * @returns the Mesh.
  28888. */
  28889. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28890. /**
  28891. * Modify the mesh to get a flat shading rendering.
  28892. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28893. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28894. * @returns current mesh
  28895. */
  28896. convertToFlatShadedMesh(): Mesh;
  28897. /**
  28898. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28899. * In other words, more vertices, no more indices and a single bigger VBO.
  28900. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28901. * @returns current mesh
  28902. */
  28903. convertToUnIndexedMesh(): Mesh;
  28904. /**
  28905. * Inverses facet orientations.
  28906. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28907. * @param flipNormals will also inverts the normals
  28908. * @returns current mesh
  28909. */
  28910. flipFaces(flipNormals?: boolean): Mesh;
  28911. /**
  28912. * Increase the number of facets and hence vertices in a mesh
  28913. * Vertex normals are interpolated from existing vertex normals
  28914. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28915. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28916. */
  28917. increaseVertices(numberPerEdge: number): void;
  28918. /**
  28919. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28920. * This will undo any application of covertToFlatShadedMesh
  28921. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28922. */
  28923. forceSharedVertices(): void;
  28924. /** @hidden */
  28925. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28926. /** @hidden */
  28927. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28928. /**
  28929. * Creates a new InstancedMesh object from the mesh model.
  28930. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28931. * @param name defines the name of the new instance
  28932. * @returns a new InstancedMesh
  28933. */
  28934. createInstance(name: string): InstancedMesh;
  28935. /**
  28936. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28937. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28938. * @returns the current mesh
  28939. */
  28940. synchronizeInstances(): Mesh;
  28941. /**
  28942. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28943. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28944. * This should be used together with the simplification to avoid disappearing triangles.
  28945. * @param successCallback an optional success callback to be called after the optimization finished.
  28946. * @returns the current mesh
  28947. */
  28948. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28949. /**
  28950. * Serialize current mesh
  28951. * @param serializationObject defines the object which will receive the serialization data
  28952. */
  28953. serialize(serializationObject: any): void;
  28954. /** @hidden */
  28955. _syncGeometryWithMorphTargetManager(): void;
  28956. /** @hidden */
  28957. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28958. /**
  28959. * Returns a new Mesh object parsed from the source provided.
  28960. * @param parsedMesh is the source
  28961. * @param scene defines the hosting scene
  28962. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28963. * @returns a new Mesh
  28964. */
  28965. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28966. /**
  28967. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28968. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28969. * @param name defines the name of the mesh to create
  28970. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28971. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28972. * @param closePath creates a seam between the first and the last points of each path of the path array
  28973. * @param offset is taken in account only if the `pathArray` is containing a single path
  28974. * @param scene defines the hosting scene
  28975. * @param updatable defines if the mesh must be flagged as updatable
  28976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28977. * @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)
  28978. * @returns a new Mesh
  28979. */
  28980. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28981. /**
  28982. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28983. * @param name defines the name of the mesh to create
  28984. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28985. * @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
  28986. * @param scene defines the hosting scene
  28987. * @param updatable defines if the mesh must be flagged as updatable
  28988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28989. * @returns a new Mesh
  28990. */
  28991. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28992. /**
  28993. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28994. * @param name defines the name of the mesh to create
  28995. * @param size sets the size (float) of each box side (default 1)
  28996. * @param scene defines the hosting scene
  28997. * @param updatable defines if the mesh must be flagged as updatable
  28998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28999. * @returns a new Mesh
  29000. */
  29001. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29002. /**
  29003. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29004. * @param name defines the name of the mesh to create
  29005. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29006. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29007. * @param scene defines the hosting scene
  29008. * @param updatable defines if the mesh must be flagged as updatable
  29009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29010. * @returns a new Mesh
  29011. */
  29012. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29013. /**
  29014. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29015. * @param name defines the name of the mesh to create
  29016. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29017. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29018. * @param scene defines the hosting scene
  29019. * @returns a new Mesh
  29020. */
  29021. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29022. /**
  29023. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29024. * @param name defines the name of the mesh to create
  29025. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29026. * @param diameterTop set the top cap diameter (floats, default 1)
  29027. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29028. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29029. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29030. * @param scene defines the hosting scene
  29031. * @param updatable defines if the mesh must be flagged as updatable
  29032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29033. * @returns a new Mesh
  29034. */
  29035. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29036. /**
  29037. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29038. * @param name defines the name of the mesh to create
  29039. * @param diameter sets the diameter size (float) of the torus (default 1)
  29040. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29041. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29042. * @param scene defines the hosting scene
  29043. * @param updatable defines if the mesh must be flagged as updatable
  29044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29045. * @returns a new Mesh
  29046. */
  29047. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29048. /**
  29049. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29050. * @param name defines the name of the mesh to create
  29051. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29052. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29053. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29054. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29055. * @param p the number of windings on X axis (positive integers, default 2)
  29056. * @param q the number of windings on Y axis (positive integers, default 3)
  29057. * @param scene defines the hosting scene
  29058. * @param updatable defines if the mesh must be flagged as updatable
  29059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29060. * @returns a new Mesh
  29061. */
  29062. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29063. /**
  29064. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29065. * @param name defines the name of the mesh to create
  29066. * @param points is an array successive Vector3
  29067. * @param scene defines the hosting scene
  29068. * @param updatable defines if the mesh must be flagged as updatable
  29069. * @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).
  29070. * @returns a new Mesh
  29071. */
  29072. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29073. /**
  29074. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29075. * @param name defines the name of the mesh to create
  29076. * @param points is an array successive Vector3
  29077. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29078. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29079. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29080. * @param scene defines the hosting scene
  29081. * @param updatable defines if the mesh must be flagged as updatable
  29082. * @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)
  29083. * @returns a new Mesh
  29084. */
  29085. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29086. /**
  29087. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29088. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29089. * 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.
  29090. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29091. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29092. * Remember you can only change the shape positions, not their number when updating a polygon.
  29093. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29094. * @param name defines the name of the mesh to create
  29095. * @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
  29096. * @param scene defines the hosting scene
  29097. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29098. * @param updatable defines if the mesh must be flagged as updatable
  29099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29100. * @param earcutInjection can be used to inject your own earcut reference
  29101. * @returns a new Mesh
  29102. */
  29103. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29104. /**
  29105. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29106. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29107. * @param name defines the name of the mesh to create
  29108. * @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
  29109. * @param depth defines the height of extrusion
  29110. * @param scene defines the hosting scene
  29111. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29112. * @param updatable defines if the mesh must be flagged as updatable
  29113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29114. * @param earcutInjection can be used to inject your own earcut reference
  29115. * @returns a new Mesh
  29116. */
  29117. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29118. /**
  29119. * Creates an extruded shape mesh.
  29120. * 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
  29121. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29122. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29123. * @param name defines the name of the mesh to create
  29124. * @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
  29125. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29126. * @param scale is the value to scale the shape
  29127. * @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
  29128. * @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
  29129. * @param scene defines the hosting scene
  29130. * @param updatable defines if the mesh must be flagged as updatable
  29131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29132. * @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)
  29133. * @returns a new Mesh
  29134. */
  29135. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29136. /**
  29137. * Creates an custom extruded shape mesh.
  29138. * The custom extrusion is a parametric shape.
  29139. * It has no predefined shape. Its final shape will depend on the input parameters.
  29140. * Please consider using the same method from the MeshBuilder class instead
  29141. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29142. * @param name defines the name of the mesh to create
  29143. * @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
  29144. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29145. * @param scaleFunction is a custom Javascript function called on each path point
  29146. * @param rotationFunction is a custom Javascript function called on each path point
  29147. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29148. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29149. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  29150. * @param scene defines the hosting scene
  29151. * @param updatable defines if the mesh must be flagged as updatable
  29152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29153. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  29154. * @returns a new Mesh
  29155. */
  29156. static 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;
  29157. /**
  29158. * Creates lathe mesh.
  29159. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29160. * Please consider using the same method from the MeshBuilder class instead
  29161. * @param name defines the name of the mesh to create
  29162. * @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
  29163. * @param radius is the radius value of the lathe
  29164. * @param tessellation is the side number of the lathe.
  29165. * @param scene defines the hosting scene
  29166. * @param updatable defines if the mesh must be flagged as updatable
  29167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29168. * @returns a new Mesh
  29169. */
  29170. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29171. /**
  29172. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29173. * @param name defines the name of the mesh to create
  29174. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29175. * @param scene defines the hosting scene
  29176. * @param updatable defines if the mesh must be flagged as updatable
  29177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29178. * @returns a new Mesh
  29179. */
  29180. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29181. /**
  29182. * Creates a ground mesh.
  29183. * Please consider using the same method from the MeshBuilder class instead
  29184. * @param name defines the name of the mesh to create
  29185. * @param width set the width of the ground
  29186. * @param height set the height of the ground
  29187. * @param subdivisions sets the number of subdivisions per side
  29188. * @param scene defines the hosting scene
  29189. * @param updatable defines if the mesh must be flagged as updatable
  29190. * @returns a new Mesh
  29191. */
  29192. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29193. /**
  29194. * Creates a tiled ground mesh.
  29195. * Please consider using the same method from the MeshBuilder class instead
  29196. * @param name defines the name of the mesh to create
  29197. * @param xmin set the ground minimum X coordinate
  29198. * @param zmin set the ground minimum Y coordinate
  29199. * @param xmax set the ground maximum X coordinate
  29200. * @param zmax set the ground maximum Z coordinate
  29201. * @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
  29202. * @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
  29203. * @param scene defines the hosting scene
  29204. * @param updatable defines if the mesh must be flagged as updatable
  29205. * @returns a new Mesh
  29206. */
  29207. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29208. w: number;
  29209. h: number;
  29210. }, precision: {
  29211. w: number;
  29212. h: number;
  29213. }, scene: Scene, updatable?: boolean): Mesh;
  29214. /**
  29215. * Creates a ground mesh from a height map.
  29216. * Please consider using the same method from the MeshBuilder class instead
  29217. * @see http://doc.babylonjs.com/babylon101/height_map
  29218. * @param name defines the name of the mesh to create
  29219. * @param url sets the URL of the height map image resource
  29220. * @param width set the ground width size
  29221. * @param height set the ground height size
  29222. * @param subdivisions sets the number of subdivision per side
  29223. * @param minHeight is the minimum altitude on the ground
  29224. * @param maxHeight is the maximum altitude on the ground
  29225. * @param scene defines the hosting scene
  29226. * @param updatable defines if the mesh must be flagged as updatable
  29227. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29228. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29229. * @returns a new Mesh
  29230. */
  29231. 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;
  29232. /**
  29233. * Creates a tube mesh.
  29234. * The tube is a parametric shape.
  29235. * It has no predefined shape. Its final shape will depend on the input parameters.
  29236. * Please consider using the same method from the MeshBuilder class instead
  29237. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29238. * @param name defines the name of the mesh to create
  29239. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29240. * @param radius sets the tube radius size
  29241. * @param tessellation is the number of sides on the tubular surface
  29242. * @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
  29243. * @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
  29244. * @param scene defines the hosting scene
  29245. * @param updatable defines if the mesh must be flagged as updatable
  29246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29247. * @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)
  29248. * @returns a new Mesh
  29249. */
  29250. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29251. (i: number, distance: number): number;
  29252. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29253. /**
  29254. * Creates a polyhedron mesh.
  29255. * Please consider using the same method from the MeshBuilder class instead.
  29256. * * 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
  29257. * * The parameter `size` (positive float, default 1) sets the polygon size
  29258. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29259. * * 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`
  29260. * * 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
  29261. * * 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)`)
  29262. * * 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
  29263. * * 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
  29264. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29265. * * If you create a double-sided mesh, you can choose what parts of 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
  29266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29267. * @param name defines the name of the mesh to create
  29268. * @param options defines the options used to create the mesh
  29269. * @param scene defines the hosting scene
  29270. * @returns a new Mesh
  29271. */
  29272. static CreatePolyhedron(name: string, options: {
  29273. type?: number;
  29274. size?: number;
  29275. sizeX?: number;
  29276. sizeY?: number;
  29277. sizeZ?: number;
  29278. custom?: any;
  29279. faceUV?: Vector4[];
  29280. faceColors?: Color4[];
  29281. updatable?: boolean;
  29282. sideOrientation?: number;
  29283. }, scene: Scene): Mesh;
  29284. /**
  29285. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29286. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29287. * * 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`)
  29288. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29289. * * 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
  29290. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29291. * * If you create a double-sided mesh, you can choose what parts of 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
  29292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29293. * @param name defines the name of the mesh
  29294. * @param options defines the options used to create the mesh
  29295. * @param scene defines the hosting scene
  29296. * @returns a new Mesh
  29297. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29298. */
  29299. static CreateIcoSphere(name: string, options: {
  29300. radius?: number;
  29301. flat?: boolean;
  29302. subdivisions?: number;
  29303. sideOrientation?: number;
  29304. updatable?: boolean;
  29305. }, scene: Scene): Mesh;
  29306. /**
  29307. * Creates a decal mesh.
  29308. * Please consider using the same method from the MeshBuilder class instead.
  29309. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29310. * @param name defines the name of the mesh
  29311. * @param sourceMesh defines the mesh receiving the decal
  29312. * @param position sets the position of the decal in world coordinates
  29313. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29314. * @param size sets the decal scaling
  29315. * @param angle sets the angle to rotate the decal
  29316. * @returns a new Mesh
  29317. */
  29318. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29319. /**
  29320. * Prepare internal position array for software CPU skinning
  29321. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29322. */
  29323. setPositionsForCPUSkinning(): Float32Array;
  29324. /**
  29325. * Prepare internal normal array for software CPU skinning
  29326. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29327. */
  29328. setNormalsForCPUSkinning(): Float32Array;
  29329. /**
  29330. * Updates the vertex buffer by applying transformation from the bones
  29331. * @param skeleton defines the skeleton to apply to current mesh
  29332. * @returns the current mesh
  29333. */
  29334. applySkeleton(skeleton: Skeleton): Mesh;
  29335. /**
  29336. * 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
  29337. * @param meshes defines the list of meshes to scan
  29338. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29339. */
  29340. static MinMax(meshes: AbstractMesh[]): {
  29341. min: Vector3;
  29342. max: Vector3;
  29343. };
  29344. /**
  29345. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29346. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29347. * @returns a vector3
  29348. */
  29349. static Center(meshesOrMinMaxVector: {
  29350. min: Vector3;
  29351. max: Vector3;
  29352. } | AbstractMesh[]): Vector3;
  29353. /**
  29354. * Merge the array of meshes into a single mesh for performance reasons.
  29355. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29356. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29357. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29358. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29359. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29360. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29361. * @returns a new mesh
  29362. */
  29363. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29364. /** @hidden */
  29365. addInstance(instance: InstancedMesh): void;
  29366. /** @hidden */
  29367. removeInstance(instance: InstancedMesh): void;
  29368. }
  29369. }
  29370. declare module "babylonjs/Cameras/camera" {
  29371. import { SmartArray } from "babylonjs/Misc/smartArray";
  29372. import { Observable } from "babylonjs/Misc/observable";
  29373. import { Nullable } from "babylonjs/types";
  29374. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29375. import { Scene } from "babylonjs/scene";
  29376. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29377. import { Node } from "babylonjs/node";
  29378. import { Mesh } from "babylonjs/Meshes/mesh";
  29379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29380. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29381. import { Viewport } from "babylonjs/Maths/math.viewport";
  29382. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29384. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29385. import { Ray } from "babylonjs/Culling/ray";
  29386. /**
  29387. * This is the base class of all the camera used in the application.
  29388. * @see http://doc.babylonjs.com/features/cameras
  29389. */
  29390. export class Camera extends Node {
  29391. /** @hidden */
  29392. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29393. /**
  29394. * This is the default projection mode used by the cameras.
  29395. * It helps recreating a feeling of perspective and better appreciate depth.
  29396. * This is the best way to simulate real life cameras.
  29397. */
  29398. static readonly PERSPECTIVE_CAMERA: number;
  29399. /**
  29400. * This helps creating camera with an orthographic mode.
  29401. * 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.
  29402. */
  29403. static readonly ORTHOGRAPHIC_CAMERA: number;
  29404. /**
  29405. * This is the default FOV mode for perspective cameras.
  29406. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29407. */
  29408. static readonly FOVMODE_VERTICAL_FIXED: number;
  29409. /**
  29410. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29411. */
  29412. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29413. /**
  29414. * This specifies ther is no need for a camera rig.
  29415. * Basically only one eye is rendered corresponding to the camera.
  29416. */
  29417. static readonly RIG_MODE_NONE: number;
  29418. /**
  29419. * Simulates a camera Rig with one blue eye and one red eye.
  29420. * This can be use with 3d blue and red glasses.
  29421. */
  29422. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29423. /**
  29424. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29425. */
  29426. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29427. /**
  29428. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29429. */
  29430. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29431. /**
  29432. * Defines that both eyes of the camera will be rendered over under each other.
  29433. */
  29434. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29435. /**
  29436. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29437. */
  29438. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29439. /**
  29440. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29441. */
  29442. static readonly RIG_MODE_VR: number;
  29443. /**
  29444. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29445. */
  29446. static readonly RIG_MODE_WEBVR: number;
  29447. /**
  29448. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29449. */
  29450. static readonly RIG_MODE_CUSTOM: number;
  29451. /**
  29452. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29453. */
  29454. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29455. /**
  29456. * Define the input manager associated with the camera.
  29457. */
  29458. inputs: CameraInputsManager<Camera>;
  29459. /** @hidden */
  29460. _position: Vector3;
  29461. /**
  29462. * Define the current local position of the camera in the scene
  29463. */
  29464. get position(): Vector3;
  29465. set position(newPosition: Vector3);
  29466. /**
  29467. * The vector the camera should consider as up.
  29468. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29469. */
  29470. upVector: Vector3;
  29471. /**
  29472. * Define the current limit on the left side for an orthographic camera
  29473. * In scene unit
  29474. */
  29475. orthoLeft: Nullable<number>;
  29476. /**
  29477. * Define the current limit on the right side for an orthographic camera
  29478. * In scene unit
  29479. */
  29480. orthoRight: Nullable<number>;
  29481. /**
  29482. * Define the current limit on the bottom side for an orthographic camera
  29483. * In scene unit
  29484. */
  29485. orthoBottom: Nullable<number>;
  29486. /**
  29487. * Define the current limit on the top side for an orthographic camera
  29488. * In scene unit
  29489. */
  29490. orthoTop: Nullable<number>;
  29491. /**
  29492. * Field Of View is set in Radians. (default is 0.8)
  29493. */
  29494. fov: number;
  29495. /**
  29496. * Define the minimum distance the camera can see from.
  29497. * This is important to note that the depth buffer are not infinite and the closer it starts
  29498. * the more your scene might encounter depth fighting issue.
  29499. */
  29500. minZ: number;
  29501. /**
  29502. * Define the maximum distance the camera can see to.
  29503. * This is important to note that the depth buffer are not infinite and the further it end
  29504. * the more your scene might encounter depth fighting issue.
  29505. */
  29506. maxZ: number;
  29507. /**
  29508. * Define the default inertia of the camera.
  29509. * This helps giving a smooth feeling to the camera movement.
  29510. */
  29511. inertia: number;
  29512. /**
  29513. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29514. */
  29515. mode: number;
  29516. /**
  29517. * Define whether the camera is intermediate.
  29518. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29519. */
  29520. isIntermediate: boolean;
  29521. /**
  29522. * Define the viewport of the camera.
  29523. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29524. */
  29525. viewport: Viewport;
  29526. /**
  29527. * Restricts the camera to viewing objects with the same layerMask.
  29528. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29529. */
  29530. layerMask: number;
  29531. /**
  29532. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29533. */
  29534. fovMode: number;
  29535. /**
  29536. * Rig mode of the camera.
  29537. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29538. * This is normally controlled byt the camera themselves as internal use.
  29539. */
  29540. cameraRigMode: number;
  29541. /**
  29542. * Defines the distance between both "eyes" in case of a RIG
  29543. */
  29544. interaxialDistance: number;
  29545. /**
  29546. * Defines if stereoscopic rendering is done side by side or over under.
  29547. */
  29548. isStereoscopicSideBySide: boolean;
  29549. /**
  29550. * 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
  29551. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29552. * else in the scene. (Eg. security camera)
  29553. *
  29554. * 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)
  29555. */
  29556. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29557. /**
  29558. * When set, the camera will render to this render target instead of the default canvas
  29559. *
  29560. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29561. */
  29562. outputRenderTarget: Nullable<RenderTargetTexture>;
  29563. /**
  29564. * Observable triggered when the camera view matrix has changed.
  29565. */
  29566. onViewMatrixChangedObservable: Observable<Camera>;
  29567. /**
  29568. * Observable triggered when the camera Projection matrix has changed.
  29569. */
  29570. onProjectionMatrixChangedObservable: Observable<Camera>;
  29571. /**
  29572. * Observable triggered when the inputs have been processed.
  29573. */
  29574. onAfterCheckInputsObservable: Observable<Camera>;
  29575. /**
  29576. * Observable triggered when reset has been called and applied to the camera.
  29577. */
  29578. onRestoreStateObservable: Observable<Camera>;
  29579. /**
  29580. * Is this camera a part of a rig system?
  29581. */
  29582. isRigCamera: boolean;
  29583. /**
  29584. * If isRigCamera set to true this will be set with the parent camera.
  29585. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29586. */
  29587. rigParent?: Camera;
  29588. /** @hidden */
  29589. _cameraRigParams: any;
  29590. /** @hidden */
  29591. _rigCameras: Camera[];
  29592. /** @hidden */
  29593. _rigPostProcess: Nullable<PostProcess>;
  29594. protected _webvrViewMatrix: Matrix;
  29595. /** @hidden */
  29596. _skipRendering: boolean;
  29597. /** @hidden */
  29598. _projectionMatrix: Matrix;
  29599. /** @hidden */
  29600. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29601. /** @hidden */
  29602. _activeMeshes: SmartArray<AbstractMesh>;
  29603. protected _globalPosition: Vector3;
  29604. /** @hidden */
  29605. _computedViewMatrix: Matrix;
  29606. private _doNotComputeProjectionMatrix;
  29607. private _transformMatrix;
  29608. private _frustumPlanes;
  29609. private _refreshFrustumPlanes;
  29610. private _storedFov;
  29611. private _stateStored;
  29612. /**
  29613. * Instantiates a new camera object.
  29614. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29615. * @see http://doc.babylonjs.com/features/cameras
  29616. * @param name Defines the name of the camera in the scene
  29617. * @param position Defines the position of the camera
  29618. * @param scene Defines the scene the camera belongs too
  29619. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29620. */
  29621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29622. /**
  29623. * Store current camera state (fov, position, etc..)
  29624. * @returns the camera
  29625. */
  29626. storeState(): Camera;
  29627. /**
  29628. * Restores the camera state values if it has been stored. You must call storeState() first
  29629. */
  29630. protected _restoreStateValues(): boolean;
  29631. /**
  29632. * Restored camera state. You must call storeState() first.
  29633. * @returns true if restored and false otherwise
  29634. */
  29635. restoreState(): boolean;
  29636. /**
  29637. * Gets the class name of the camera.
  29638. * @returns the class name
  29639. */
  29640. getClassName(): string;
  29641. /** @hidden */
  29642. readonly _isCamera: boolean;
  29643. /**
  29644. * Gets a string representation of the camera useful for debug purpose.
  29645. * @param fullDetails Defines that a more verboe level of logging is required
  29646. * @returns the string representation
  29647. */
  29648. toString(fullDetails?: boolean): string;
  29649. /**
  29650. * Gets the current world space position of the camera.
  29651. */
  29652. get globalPosition(): Vector3;
  29653. /**
  29654. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29655. * @returns the active meshe list
  29656. */
  29657. getActiveMeshes(): SmartArray<AbstractMesh>;
  29658. /**
  29659. * Check whether a mesh is part of the current active mesh list of the camera
  29660. * @param mesh Defines the mesh to check
  29661. * @returns true if active, false otherwise
  29662. */
  29663. isActiveMesh(mesh: Mesh): boolean;
  29664. /**
  29665. * Is this camera ready to be used/rendered
  29666. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29667. * @return true if the camera is ready
  29668. */
  29669. isReady(completeCheck?: boolean): boolean;
  29670. /** @hidden */
  29671. _initCache(): void;
  29672. /** @hidden */
  29673. _updateCache(ignoreParentClass?: boolean): void;
  29674. /** @hidden */
  29675. _isSynchronized(): boolean;
  29676. /** @hidden */
  29677. _isSynchronizedViewMatrix(): boolean;
  29678. /** @hidden */
  29679. _isSynchronizedProjectionMatrix(): boolean;
  29680. /**
  29681. * Attach the input controls to a specific dom element to get the input from.
  29682. * @param element Defines the element the controls should be listened from
  29683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29684. */
  29685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29686. /**
  29687. * Detach the current controls from the specified dom element.
  29688. * @param element Defines the element to stop listening the inputs from
  29689. */
  29690. detachControl(element: HTMLElement): void;
  29691. /**
  29692. * Update the camera state according to the different inputs gathered during the frame.
  29693. */
  29694. update(): void;
  29695. /** @hidden */
  29696. _checkInputs(): void;
  29697. /** @hidden */
  29698. get rigCameras(): Camera[];
  29699. /**
  29700. * Gets the post process used by the rig cameras
  29701. */
  29702. get rigPostProcess(): Nullable<PostProcess>;
  29703. /**
  29704. * Internal, gets the first post proces.
  29705. * @returns the first post process to be run on this camera.
  29706. */
  29707. _getFirstPostProcess(): Nullable<PostProcess>;
  29708. private _cascadePostProcessesToRigCams;
  29709. /**
  29710. * Attach a post process to the camera.
  29711. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29712. * @param postProcess The post process to attach to the camera
  29713. * @param insertAt The position of the post process in case several of them are in use in the scene
  29714. * @returns the position the post process has been inserted at
  29715. */
  29716. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29717. /**
  29718. * Detach a post process to the camera.
  29719. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29720. * @param postProcess The post process to detach from the camera
  29721. */
  29722. detachPostProcess(postProcess: PostProcess): void;
  29723. /**
  29724. * Gets the current world matrix of the camera
  29725. */
  29726. getWorldMatrix(): Matrix;
  29727. /** @hidden */
  29728. _getViewMatrix(): Matrix;
  29729. /**
  29730. * Gets the current view matrix of the camera.
  29731. * @param force forces the camera to recompute the matrix without looking at the cached state
  29732. * @returns the view matrix
  29733. */
  29734. getViewMatrix(force?: boolean): Matrix;
  29735. /**
  29736. * Freeze the projection matrix.
  29737. * It will prevent the cache check of the camera projection compute and can speed up perf
  29738. * if no parameter of the camera are meant to change
  29739. * @param projection Defines manually a projection if necessary
  29740. */
  29741. freezeProjectionMatrix(projection?: Matrix): void;
  29742. /**
  29743. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29744. */
  29745. unfreezeProjectionMatrix(): void;
  29746. /**
  29747. * Gets the current projection matrix of the camera.
  29748. * @param force forces the camera to recompute the matrix without looking at the cached state
  29749. * @returns the projection matrix
  29750. */
  29751. getProjectionMatrix(force?: boolean): Matrix;
  29752. /**
  29753. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29754. * @returns a Matrix
  29755. */
  29756. getTransformationMatrix(): Matrix;
  29757. private _updateFrustumPlanes;
  29758. /**
  29759. * Checks if a cullable object (mesh...) is in the camera frustum
  29760. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29761. * @param target The object to check
  29762. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29763. * @returns true if the object is in frustum otherwise false
  29764. */
  29765. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29766. /**
  29767. * Checks if a cullable object (mesh...) is in the camera frustum
  29768. * Unlike isInFrustum this cheks the full bounding box
  29769. * @param target The object to check
  29770. * @returns true if the object is in frustum otherwise false
  29771. */
  29772. isCompletelyInFrustum(target: ICullable): boolean;
  29773. /**
  29774. * Gets a ray in the forward direction from the camera.
  29775. * @param length Defines the length of the ray to create
  29776. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29777. * @param origin Defines the start point of the ray which defaults to the camera position
  29778. * @returns the forward ray
  29779. */
  29780. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29781. /**
  29782. * Releases resources associated with this node.
  29783. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29784. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29785. */
  29786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29787. /** @hidden */
  29788. _isLeftCamera: boolean;
  29789. /**
  29790. * Gets the left camera of a rig setup in case of Rigged Camera
  29791. */
  29792. get isLeftCamera(): boolean;
  29793. /** @hidden */
  29794. _isRightCamera: boolean;
  29795. /**
  29796. * Gets the right camera of a rig setup in case of Rigged Camera
  29797. */
  29798. get isRightCamera(): boolean;
  29799. /**
  29800. * Gets the left camera of a rig setup in case of Rigged Camera
  29801. */
  29802. get leftCamera(): Nullable<FreeCamera>;
  29803. /**
  29804. * Gets the right camera of a rig setup in case of Rigged Camera
  29805. */
  29806. get rightCamera(): Nullable<FreeCamera>;
  29807. /**
  29808. * Gets the left camera target of a rig setup in case of Rigged Camera
  29809. * @returns the target position
  29810. */
  29811. getLeftTarget(): Nullable<Vector3>;
  29812. /**
  29813. * Gets the right camera target of a rig setup in case of Rigged Camera
  29814. * @returns the target position
  29815. */
  29816. getRightTarget(): Nullable<Vector3>;
  29817. /**
  29818. * @hidden
  29819. */
  29820. setCameraRigMode(mode: number, rigParams: any): void;
  29821. /** @hidden */
  29822. static _setStereoscopicRigMode(camera: Camera): void;
  29823. /** @hidden */
  29824. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29825. /** @hidden */
  29826. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29827. /** @hidden */
  29828. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29829. /** @hidden */
  29830. _getVRProjectionMatrix(): Matrix;
  29831. protected _updateCameraRotationMatrix(): void;
  29832. protected _updateWebVRCameraRotationMatrix(): void;
  29833. /**
  29834. * This function MUST be overwritten by the different WebVR cameras available.
  29835. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29836. * @hidden
  29837. */
  29838. _getWebVRProjectionMatrix(): Matrix;
  29839. /**
  29840. * This function MUST be overwritten by the different WebVR cameras available.
  29841. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29842. * @hidden
  29843. */
  29844. _getWebVRViewMatrix(): Matrix;
  29845. /** @hidden */
  29846. setCameraRigParameter(name: string, value: any): void;
  29847. /**
  29848. * needs to be overridden by children so sub has required properties to be copied
  29849. * @hidden
  29850. */
  29851. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29852. /**
  29853. * May need to be overridden by children
  29854. * @hidden
  29855. */
  29856. _updateRigCameras(): void;
  29857. /** @hidden */
  29858. _setupInputs(): void;
  29859. /**
  29860. * Serialiaze the camera setup to a json represention
  29861. * @returns the JSON representation
  29862. */
  29863. serialize(): any;
  29864. /**
  29865. * Clones the current camera.
  29866. * @param name The cloned camera name
  29867. * @returns the cloned camera
  29868. */
  29869. clone(name: string): Camera;
  29870. /**
  29871. * Gets the direction of the camera relative to a given local axis.
  29872. * @param localAxis Defines the reference axis to provide a relative direction.
  29873. * @return the direction
  29874. */
  29875. getDirection(localAxis: Vector3): Vector3;
  29876. /**
  29877. * Returns the current camera absolute rotation
  29878. */
  29879. get absoluteRotation(): Quaternion;
  29880. /**
  29881. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29882. * @param localAxis Defines the reference axis to provide a relative direction.
  29883. * @param result Defines the vector to store the result in
  29884. */
  29885. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29886. /**
  29887. * Gets a camera constructor for a given camera type
  29888. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29889. * @param name The name of the camera the result will be able to instantiate
  29890. * @param scene The scene the result will construct the camera in
  29891. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29892. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29893. * @returns a factory method to construc the camera
  29894. */
  29895. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29896. /**
  29897. * Compute the world matrix of the camera.
  29898. * @returns the camera world matrix
  29899. */
  29900. computeWorldMatrix(): Matrix;
  29901. /**
  29902. * Parse a JSON and creates the camera from the parsed information
  29903. * @param parsedCamera The JSON to parse
  29904. * @param scene The scene to instantiate the camera in
  29905. * @returns the newly constructed camera
  29906. */
  29907. static Parse(parsedCamera: any, scene: Scene): Camera;
  29908. }
  29909. }
  29910. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29911. import { Nullable } from "babylonjs/types";
  29912. import { Scene } from "babylonjs/scene";
  29913. import { Vector4 } from "babylonjs/Maths/math.vector";
  29914. import { Mesh } from "babylonjs/Meshes/mesh";
  29915. /**
  29916. * Class containing static functions to help procedurally build meshes
  29917. */
  29918. export class DiscBuilder {
  29919. /**
  29920. * Creates a plane polygonal mesh. By default, this is a disc
  29921. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29922. * * 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
  29923. * * 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
  29924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29927. * @param name defines the name of the mesh
  29928. * @param options defines the options used to create the mesh
  29929. * @param scene defines the hosting scene
  29930. * @returns the plane polygonal mesh
  29931. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29932. */
  29933. static CreateDisc(name: string, options: {
  29934. radius?: number;
  29935. tessellation?: number;
  29936. arc?: number;
  29937. updatable?: boolean;
  29938. sideOrientation?: number;
  29939. frontUVs?: Vector4;
  29940. backUVs?: Vector4;
  29941. }, scene?: Nullable<Scene>): Mesh;
  29942. }
  29943. }
  29944. declare module "babylonjs/Materials/fresnelParameters" {
  29945. import { DeepImmutable } from "babylonjs/types";
  29946. import { Color3 } from "babylonjs/Maths/math.color";
  29947. /**
  29948. * Options to be used when creating a FresnelParameters.
  29949. */
  29950. export type IFresnelParametersCreationOptions = {
  29951. /**
  29952. * Define the color used on edges (grazing angle)
  29953. */
  29954. leftColor?: Color3;
  29955. /**
  29956. * Define the color used on center
  29957. */
  29958. rightColor?: Color3;
  29959. /**
  29960. * Define bias applied to computed fresnel term
  29961. */
  29962. bias?: number;
  29963. /**
  29964. * Defined the power exponent applied to fresnel term
  29965. */
  29966. power?: number;
  29967. /**
  29968. * Define if the fresnel effect is enable or not.
  29969. */
  29970. isEnabled?: boolean;
  29971. };
  29972. /**
  29973. * Serialized format for FresnelParameters.
  29974. */
  29975. export type IFresnelParametersSerialized = {
  29976. /**
  29977. * Define the color used on edges (grazing angle) [as an array]
  29978. */
  29979. leftColor: number[];
  29980. /**
  29981. * Define the color used on center [as an array]
  29982. */
  29983. rightColor: number[];
  29984. /**
  29985. * Define bias applied to computed fresnel term
  29986. */
  29987. bias: number;
  29988. /**
  29989. * Defined the power exponent applied to fresnel term
  29990. */
  29991. power?: number;
  29992. /**
  29993. * Define if the fresnel effect is enable or not.
  29994. */
  29995. isEnabled: boolean;
  29996. };
  29997. /**
  29998. * This represents all the required information to add a fresnel effect on a material:
  29999. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30000. */
  30001. export class FresnelParameters {
  30002. private _isEnabled;
  30003. /**
  30004. * Define if the fresnel effect is enable or not.
  30005. */
  30006. get isEnabled(): boolean;
  30007. set isEnabled(value: boolean);
  30008. /**
  30009. * Define the color used on edges (grazing angle)
  30010. */
  30011. leftColor: Color3;
  30012. /**
  30013. * Define the color used on center
  30014. */
  30015. rightColor: Color3;
  30016. /**
  30017. * Define bias applied to computed fresnel term
  30018. */
  30019. bias: number;
  30020. /**
  30021. * Defined the power exponent applied to fresnel term
  30022. */
  30023. power: number;
  30024. /**
  30025. * Creates a new FresnelParameters object.
  30026. *
  30027. * @param options provide your own settings to optionally to override defaults
  30028. */
  30029. constructor(options?: IFresnelParametersCreationOptions);
  30030. /**
  30031. * Clones the current fresnel and its valuues
  30032. * @returns a clone fresnel configuration
  30033. */
  30034. clone(): FresnelParameters;
  30035. /**
  30036. * Determines equality between FresnelParameters objects
  30037. * @param otherFresnelParameters defines the second operand
  30038. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30039. */
  30040. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30041. /**
  30042. * Serializes the current fresnel parameters to a JSON representation.
  30043. * @return the JSON serialization
  30044. */
  30045. serialize(): IFresnelParametersSerialized;
  30046. /**
  30047. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30048. * @param parsedFresnelParameters Define the JSON representation
  30049. * @returns the parsed parameters
  30050. */
  30051. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30052. }
  30053. }
  30054. declare module "babylonjs/Materials/materialFlags" {
  30055. /**
  30056. * This groups all the flags used to control the materials channel.
  30057. */
  30058. export class MaterialFlags {
  30059. private static _DiffuseTextureEnabled;
  30060. /**
  30061. * Are diffuse textures enabled in the application.
  30062. */
  30063. static get DiffuseTextureEnabled(): boolean;
  30064. static set DiffuseTextureEnabled(value: boolean);
  30065. private static _AmbientTextureEnabled;
  30066. /**
  30067. * Are ambient textures enabled in the application.
  30068. */
  30069. static get AmbientTextureEnabled(): boolean;
  30070. static set AmbientTextureEnabled(value: boolean);
  30071. private static _OpacityTextureEnabled;
  30072. /**
  30073. * Are opacity textures enabled in the application.
  30074. */
  30075. static get OpacityTextureEnabled(): boolean;
  30076. static set OpacityTextureEnabled(value: boolean);
  30077. private static _ReflectionTextureEnabled;
  30078. /**
  30079. * Are reflection textures enabled in the application.
  30080. */
  30081. static get ReflectionTextureEnabled(): boolean;
  30082. static set ReflectionTextureEnabled(value: boolean);
  30083. private static _EmissiveTextureEnabled;
  30084. /**
  30085. * Are emissive textures enabled in the application.
  30086. */
  30087. static get EmissiveTextureEnabled(): boolean;
  30088. static set EmissiveTextureEnabled(value: boolean);
  30089. private static _SpecularTextureEnabled;
  30090. /**
  30091. * Are specular textures enabled in the application.
  30092. */
  30093. static get SpecularTextureEnabled(): boolean;
  30094. static set SpecularTextureEnabled(value: boolean);
  30095. private static _BumpTextureEnabled;
  30096. /**
  30097. * Are bump textures enabled in the application.
  30098. */
  30099. static get BumpTextureEnabled(): boolean;
  30100. static set BumpTextureEnabled(value: boolean);
  30101. private static _LightmapTextureEnabled;
  30102. /**
  30103. * Are lightmap textures enabled in the application.
  30104. */
  30105. static get LightmapTextureEnabled(): boolean;
  30106. static set LightmapTextureEnabled(value: boolean);
  30107. private static _RefractionTextureEnabled;
  30108. /**
  30109. * Are refraction textures enabled in the application.
  30110. */
  30111. static get RefractionTextureEnabled(): boolean;
  30112. static set RefractionTextureEnabled(value: boolean);
  30113. private static _ColorGradingTextureEnabled;
  30114. /**
  30115. * Are color grading textures enabled in the application.
  30116. */
  30117. static get ColorGradingTextureEnabled(): boolean;
  30118. static set ColorGradingTextureEnabled(value: boolean);
  30119. private static _FresnelEnabled;
  30120. /**
  30121. * Are fresnels enabled in the application.
  30122. */
  30123. static get FresnelEnabled(): boolean;
  30124. static set FresnelEnabled(value: boolean);
  30125. private static _ClearCoatTextureEnabled;
  30126. /**
  30127. * Are clear coat textures enabled in the application.
  30128. */
  30129. static get ClearCoatTextureEnabled(): boolean;
  30130. static set ClearCoatTextureEnabled(value: boolean);
  30131. private static _ClearCoatBumpTextureEnabled;
  30132. /**
  30133. * Are clear coat bump textures enabled in the application.
  30134. */
  30135. static get ClearCoatBumpTextureEnabled(): boolean;
  30136. static set ClearCoatBumpTextureEnabled(value: boolean);
  30137. private static _ClearCoatTintTextureEnabled;
  30138. /**
  30139. * Are clear coat tint textures enabled in the application.
  30140. */
  30141. static get ClearCoatTintTextureEnabled(): boolean;
  30142. static set ClearCoatTintTextureEnabled(value: boolean);
  30143. private static _SheenTextureEnabled;
  30144. /**
  30145. * Are sheen textures enabled in the application.
  30146. */
  30147. static get SheenTextureEnabled(): boolean;
  30148. static set SheenTextureEnabled(value: boolean);
  30149. private static _AnisotropicTextureEnabled;
  30150. /**
  30151. * Are anisotropic textures enabled in the application.
  30152. */
  30153. static get AnisotropicTextureEnabled(): boolean;
  30154. static set AnisotropicTextureEnabled(value: boolean);
  30155. private static _ThicknessTextureEnabled;
  30156. /**
  30157. * Are thickness textures enabled in the application.
  30158. */
  30159. static get ThicknessTextureEnabled(): boolean;
  30160. static set ThicknessTextureEnabled(value: boolean);
  30161. }
  30162. }
  30163. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30164. /** @hidden */
  30165. export var defaultFragmentDeclaration: {
  30166. name: string;
  30167. shader: string;
  30168. };
  30169. }
  30170. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30171. /** @hidden */
  30172. export var defaultUboDeclaration: {
  30173. name: string;
  30174. shader: string;
  30175. };
  30176. }
  30177. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30178. /** @hidden */
  30179. export var lightFragmentDeclaration: {
  30180. name: string;
  30181. shader: string;
  30182. };
  30183. }
  30184. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30185. /** @hidden */
  30186. export var lightUboDeclaration: {
  30187. name: string;
  30188. shader: string;
  30189. };
  30190. }
  30191. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30192. /** @hidden */
  30193. export var lightsFragmentFunctions: {
  30194. name: string;
  30195. shader: string;
  30196. };
  30197. }
  30198. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30199. /** @hidden */
  30200. export var shadowsFragmentFunctions: {
  30201. name: string;
  30202. shader: string;
  30203. };
  30204. }
  30205. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30206. /** @hidden */
  30207. export var fresnelFunction: {
  30208. name: string;
  30209. shader: string;
  30210. };
  30211. }
  30212. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30213. /** @hidden */
  30214. export var bumpFragmentMainFunctions: {
  30215. name: string;
  30216. shader: string;
  30217. };
  30218. }
  30219. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30220. /** @hidden */
  30221. export var bumpFragmentFunctions: {
  30222. name: string;
  30223. shader: string;
  30224. };
  30225. }
  30226. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30227. /** @hidden */
  30228. export var logDepthDeclaration: {
  30229. name: string;
  30230. shader: string;
  30231. };
  30232. }
  30233. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30234. /** @hidden */
  30235. export var bumpFragment: {
  30236. name: string;
  30237. shader: string;
  30238. };
  30239. }
  30240. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30241. /** @hidden */
  30242. export var depthPrePass: {
  30243. name: string;
  30244. shader: string;
  30245. };
  30246. }
  30247. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30248. /** @hidden */
  30249. export var lightFragment: {
  30250. name: string;
  30251. shader: string;
  30252. };
  30253. }
  30254. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30255. /** @hidden */
  30256. export var logDepthFragment: {
  30257. name: string;
  30258. shader: string;
  30259. };
  30260. }
  30261. declare module "babylonjs/Shaders/default.fragment" {
  30262. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30263. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30264. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30265. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30266. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30267. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30268. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30269. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30270. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30271. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30272. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30273. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30274. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30275. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30276. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30277. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30278. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30279. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30280. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30281. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30282. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30283. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30284. /** @hidden */
  30285. export var defaultPixelShader: {
  30286. name: string;
  30287. shader: string;
  30288. };
  30289. }
  30290. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30291. /** @hidden */
  30292. export var defaultVertexDeclaration: {
  30293. name: string;
  30294. shader: string;
  30295. };
  30296. }
  30297. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30298. /** @hidden */
  30299. export var bumpVertexDeclaration: {
  30300. name: string;
  30301. shader: string;
  30302. };
  30303. }
  30304. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30305. /** @hidden */
  30306. export var bumpVertex: {
  30307. name: string;
  30308. shader: string;
  30309. };
  30310. }
  30311. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30312. /** @hidden */
  30313. export var fogVertex: {
  30314. name: string;
  30315. shader: string;
  30316. };
  30317. }
  30318. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30319. /** @hidden */
  30320. export var shadowsVertex: {
  30321. name: string;
  30322. shader: string;
  30323. };
  30324. }
  30325. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30326. /** @hidden */
  30327. export var pointCloudVertex: {
  30328. name: string;
  30329. shader: string;
  30330. };
  30331. }
  30332. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30333. /** @hidden */
  30334. export var logDepthVertex: {
  30335. name: string;
  30336. shader: string;
  30337. };
  30338. }
  30339. declare module "babylonjs/Shaders/default.vertex" {
  30340. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30341. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30343. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30344. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30345. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30346. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30347. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30348. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30349. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30350. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30351. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30352. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30353. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30354. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30355. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30356. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30358. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30359. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30360. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30361. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30362. /** @hidden */
  30363. export var defaultVertexShader: {
  30364. name: string;
  30365. shader: string;
  30366. };
  30367. }
  30368. declare module "babylonjs/Materials/standardMaterial" {
  30369. import { SmartArray } from "babylonjs/Misc/smartArray";
  30370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30371. import { Nullable } from "babylonjs/types";
  30372. import { Scene } from "babylonjs/scene";
  30373. import { Matrix } from "babylonjs/Maths/math.vector";
  30374. import { Color3 } from "babylonjs/Maths/math.color";
  30375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30377. import { Mesh } from "babylonjs/Meshes/mesh";
  30378. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30379. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30380. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30381. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30382. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30384. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30385. import "babylonjs/Shaders/default.fragment";
  30386. import "babylonjs/Shaders/default.vertex";
  30387. /** @hidden */
  30388. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30389. MAINUV1: boolean;
  30390. MAINUV2: boolean;
  30391. DIFFUSE: boolean;
  30392. DIFFUSEDIRECTUV: number;
  30393. AMBIENT: boolean;
  30394. AMBIENTDIRECTUV: number;
  30395. OPACITY: boolean;
  30396. OPACITYDIRECTUV: number;
  30397. OPACITYRGB: boolean;
  30398. REFLECTION: boolean;
  30399. EMISSIVE: boolean;
  30400. EMISSIVEDIRECTUV: number;
  30401. SPECULAR: boolean;
  30402. SPECULARDIRECTUV: number;
  30403. BUMP: boolean;
  30404. BUMPDIRECTUV: number;
  30405. PARALLAX: boolean;
  30406. PARALLAXOCCLUSION: boolean;
  30407. SPECULAROVERALPHA: boolean;
  30408. CLIPPLANE: boolean;
  30409. CLIPPLANE2: boolean;
  30410. CLIPPLANE3: boolean;
  30411. CLIPPLANE4: boolean;
  30412. CLIPPLANE5: boolean;
  30413. CLIPPLANE6: boolean;
  30414. ALPHATEST: boolean;
  30415. DEPTHPREPASS: boolean;
  30416. ALPHAFROMDIFFUSE: boolean;
  30417. POINTSIZE: boolean;
  30418. FOG: boolean;
  30419. SPECULARTERM: boolean;
  30420. DIFFUSEFRESNEL: boolean;
  30421. OPACITYFRESNEL: boolean;
  30422. REFLECTIONFRESNEL: boolean;
  30423. REFRACTIONFRESNEL: boolean;
  30424. EMISSIVEFRESNEL: boolean;
  30425. FRESNEL: boolean;
  30426. NORMAL: boolean;
  30427. UV1: boolean;
  30428. UV2: boolean;
  30429. VERTEXCOLOR: boolean;
  30430. VERTEXALPHA: boolean;
  30431. NUM_BONE_INFLUENCERS: number;
  30432. BonesPerMesh: number;
  30433. BONETEXTURE: boolean;
  30434. INSTANCES: boolean;
  30435. THIN_INSTANCES: boolean;
  30436. GLOSSINESS: boolean;
  30437. ROUGHNESS: boolean;
  30438. EMISSIVEASILLUMINATION: boolean;
  30439. LINKEMISSIVEWITHDIFFUSE: boolean;
  30440. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30441. LIGHTMAP: boolean;
  30442. LIGHTMAPDIRECTUV: number;
  30443. OBJECTSPACE_NORMALMAP: boolean;
  30444. USELIGHTMAPASSHADOWMAP: boolean;
  30445. REFLECTIONMAP_3D: boolean;
  30446. REFLECTIONMAP_SPHERICAL: boolean;
  30447. REFLECTIONMAP_PLANAR: boolean;
  30448. REFLECTIONMAP_CUBIC: boolean;
  30449. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30450. REFLECTIONMAP_PROJECTION: boolean;
  30451. REFLECTIONMAP_SKYBOX: boolean;
  30452. REFLECTIONMAP_EXPLICIT: boolean;
  30453. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30454. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30455. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30456. INVERTCUBICMAP: boolean;
  30457. LOGARITHMICDEPTH: boolean;
  30458. REFRACTION: boolean;
  30459. REFRACTIONMAP_3D: boolean;
  30460. REFLECTIONOVERALPHA: boolean;
  30461. TWOSIDEDLIGHTING: boolean;
  30462. SHADOWFLOAT: boolean;
  30463. MORPHTARGETS: boolean;
  30464. MORPHTARGETS_NORMAL: boolean;
  30465. MORPHTARGETS_TANGENT: boolean;
  30466. MORPHTARGETS_UV: boolean;
  30467. NUM_MORPH_INFLUENCERS: number;
  30468. NONUNIFORMSCALING: boolean;
  30469. PREMULTIPLYALPHA: boolean;
  30470. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30471. ALPHABLEND: boolean;
  30472. RGBDLIGHTMAP: boolean;
  30473. RGBDREFLECTION: boolean;
  30474. RGBDREFRACTION: boolean;
  30475. IMAGEPROCESSING: boolean;
  30476. VIGNETTE: boolean;
  30477. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30478. VIGNETTEBLENDMODEOPAQUE: boolean;
  30479. TONEMAPPING: boolean;
  30480. TONEMAPPING_ACES: boolean;
  30481. CONTRAST: boolean;
  30482. COLORCURVES: boolean;
  30483. COLORGRADING: boolean;
  30484. COLORGRADING3D: boolean;
  30485. SAMPLER3DGREENDEPTH: boolean;
  30486. SAMPLER3DBGRMAP: boolean;
  30487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30488. MULTIVIEW: boolean;
  30489. /**
  30490. * If the reflection texture on this material is in linear color space
  30491. * @hidden
  30492. */
  30493. IS_REFLECTION_LINEAR: boolean;
  30494. /**
  30495. * If the refraction texture on this material is in linear color space
  30496. * @hidden
  30497. */
  30498. IS_REFRACTION_LINEAR: boolean;
  30499. EXPOSURE: boolean;
  30500. constructor();
  30501. setReflectionMode(modeToEnable: string): void;
  30502. }
  30503. /**
  30504. * This is the default material used in Babylon. It is the best trade off between quality
  30505. * and performances.
  30506. * @see http://doc.babylonjs.com/babylon101/materials
  30507. */
  30508. export class StandardMaterial extends PushMaterial {
  30509. private _diffuseTexture;
  30510. /**
  30511. * The basic texture of the material as viewed under a light.
  30512. */
  30513. diffuseTexture: Nullable<BaseTexture>;
  30514. private _ambientTexture;
  30515. /**
  30516. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30517. */
  30518. ambientTexture: Nullable<BaseTexture>;
  30519. private _opacityTexture;
  30520. /**
  30521. * Define the transparency of the material from a texture.
  30522. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30523. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30524. */
  30525. opacityTexture: Nullable<BaseTexture>;
  30526. private _reflectionTexture;
  30527. /**
  30528. * Define the texture used to display the reflection.
  30529. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30530. */
  30531. reflectionTexture: Nullable<BaseTexture>;
  30532. private _emissiveTexture;
  30533. /**
  30534. * Define texture of the material as if self lit.
  30535. * This will be mixed in the final result even in the absence of light.
  30536. */
  30537. emissiveTexture: Nullable<BaseTexture>;
  30538. private _specularTexture;
  30539. /**
  30540. * Define how the color and intensity of the highlight given by the light in the material.
  30541. */
  30542. specularTexture: Nullable<BaseTexture>;
  30543. private _bumpTexture;
  30544. /**
  30545. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30546. * 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.
  30547. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30548. */
  30549. bumpTexture: Nullable<BaseTexture>;
  30550. private _lightmapTexture;
  30551. /**
  30552. * Complex lighting can be computationally expensive to compute at runtime.
  30553. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30554. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30555. */
  30556. lightmapTexture: Nullable<BaseTexture>;
  30557. private _refractionTexture;
  30558. /**
  30559. * Define the texture used to display the refraction.
  30560. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30561. */
  30562. refractionTexture: Nullable<BaseTexture>;
  30563. /**
  30564. * The color of the material lit by the environmental background lighting.
  30565. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30566. */
  30567. ambientColor: Color3;
  30568. /**
  30569. * The basic color of the material as viewed under a light.
  30570. */
  30571. diffuseColor: Color3;
  30572. /**
  30573. * Define how the color and intensity of the highlight given by the light in the material.
  30574. */
  30575. specularColor: Color3;
  30576. /**
  30577. * Define the color of the material as if self lit.
  30578. * This will be mixed in the final result even in the absence of light.
  30579. */
  30580. emissiveColor: Color3;
  30581. /**
  30582. * Defines how sharp are the highlights in the material.
  30583. * The bigger the value the sharper giving a more glossy feeling to the result.
  30584. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30585. */
  30586. specularPower: number;
  30587. private _useAlphaFromDiffuseTexture;
  30588. /**
  30589. * Does the transparency come from the diffuse texture alpha channel.
  30590. */
  30591. useAlphaFromDiffuseTexture: boolean;
  30592. private _useEmissiveAsIllumination;
  30593. /**
  30594. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30595. */
  30596. useEmissiveAsIllumination: boolean;
  30597. private _linkEmissiveWithDiffuse;
  30598. /**
  30599. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30600. * the emissive level when the final color is close to one.
  30601. */
  30602. linkEmissiveWithDiffuse: boolean;
  30603. private _useSpecularOverAlpha;
  30604. /**
  30605. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30607. */
  30608. useSpecularOverAlpha: boolean;
  30609. private _useReflectionOverAlpha;
  30610. /**
  30611. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30612. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30613. */
  30614. useReflectionOverAlpha: boolean;
  30615. private _disableLighting;
  30616. /**
  30617. * Does lights from the scene impacts this material.
  30618. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30619. */
  30620. disableLighting: boolean;
  30621. private _useObjectSpaceNormalMap;
  30622. /**
  30623. * Allows using an object space normal map (instead of tangent space).
  30624. */
  30625. useObjectSpaceNormalMap: boolean;
  30626. private _useParallax;
  30627. /**
  30628. * Is parallax enabled or not.
  30629. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30630. */
  30631. useParallax: boolean;
  30632. private _useParallaxOcclusion;
  30633. /**
  30634. * Is parallax occlusion enabled or not.
  30635. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30636. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30637. */
  30638. useParallaxOcclusion: boolean;
  30639. /**
  30640. * 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.
  30641. */
  30642. parallaxScaleBias: number;
  30643. private _roughness;
  30644. /**
  30645. * Helps to define how blurry the reflections should appears in the material.
  30646. */
  30647. roughness: number;
  30648. /**
  30649. * In case of refraction, define the value of the index of refraction.
  30650. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30651. */
  30652. indexOfRefraction: number;
  30653. /**
  30654. * Invert the refraction texture alongside the y axis.
  30655. * It can be useful with procedural textures or probe for instance.
  30656. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30657. */
  30658. invertRefractionY: boolean;
  30659. /**
  30660. * Defines the alpha limits in alpha test mode.
  30661. */
  30662. alphaCutOff: number;
  30663. private _useLightmapAsShadowmap;
  30664. /**
  30665. * In case of light mapping, define whether the map contains light or shadow informations.
  30666. */
  30667. useLightmapAsShadowmap: boolean;
  30668. private _diffuseFresnelParameters;
  30669. /**
  30670. * Define the diffuse fresnel parameters of the material.
  30671. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30672. */
  30673. diffuseFresnelParameters: FresnelParameters;
  30674. private _opacityFresnelParameters;
  30675. /**
  30676. * Define the opacity fresnel parameters of the material.
  30677. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30678. */
  30679. opacityFresnelParameters: FresnelParameters;
  30680. private _reflectionFresnelParameters;
  30681. /**
  30682. * Define the reflection fresnel parameters of the material.
  30683. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30684. */
  30685. reflectionFresnelParameters: FresnelParameters;
  30686. private _refractionFresnelParameters;
  30687. /**
  30688. * Define the refraction fresnel parameters of the material.
  30689. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30690. */
  30691. refractionFresnelParameters: FresnelParameters;
  30692. private _emissiveFresnelParameters;
  30693. /**
  30694. * Define the emissive fresnel parameters of the material.
  30695. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30696. */
  30697. emissiveFresnelParameters: FresnelParameters;
  30698. private _useReflectionFresnelFromSpecular;
  30699. /**
  30700. * If true automatically deducts the fresnels values from the material specularity.
  30701. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30702. */
  30703. useReflectionFresnelFromSpecular: boolean;
  30704. private _useGlossinessFromSpecularMapAlpha;
  30705. /**
  30706. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30707. */
  30708. useGlossinessFromSpecularMapAlpha: boolean;
  30709. private _maxSimultaneousLights;
  30710. /**
  30711. * Defines the maximum number of lights that can be used in the material
  30712. */
  30713. maxSimultaneousLights: number;
  30714. private _invertNormalMapX;
  30715. /**
  30716. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30717. */
  30718. invertNormalMapX: boolean;
  30719. private _invertNormalMapY;
  30720. /**
  30721. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30722. */
  30723. invertNormalMapY: boolean;
  30724. private _twoSidedLighting;
  30725. /**
  30726. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30727. */
  30728. twoSidedLighting: boolean;
  30729. /**
  30730. * Default configuration related to image processing available in the standard Material.
  30731. */
  30732. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30733. /**
  30734. * Gets the image processing configuration used either in this material.
  30735. */
  30736. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30737. /**
  30738. * Sets the Default image processing configuration used either in the this material.
  30739. *
  30740. * If sets to null, the scene one is in use.
  30741. */
  30742. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30743. /**
  30744. * Keep track of the image processing observer to allow dispose and replace.
  30745. */
  30746. private _imageProcessingObserver;
  30747. /**
  30748. * Attaches a new image processing configuration to the Standard Material.
  30749. * @param configuration
  30750. */
  30751. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30752. /**
  30753. * Gets wether the color curves effect is enabled.
  30754. */
  30755. get cameraColorCurvesEnabled(): boolean;
  30756. /**
  30757. * Sets wether the color curves effect is enabled.
  30758. */
  30759. set cameraColorCurvesEnabled(value: boolean);
  30760. /**
  30761. * Gets wether the color grading effect is enabled.
  30762. */
  30763. get cameraColorGradingEnabled(): boolean;
  30764. /**
  30765. * Gets wether the color grading effect is enabled.
  30766. */
  30767. set cameraColorGradingEnabled(value: boolean);
  30768. /**
  30769. * Gets wether tonemapping is enabled or not.
  30770. */
  30771. get cameraToneMappingEnabled(): boolean;
  30772. /**
  30773. * Sets wether tonemapping is enabled or not
  30774. */
  30775. set cameraToneMappingEnabled(value: boolean);
  30776. /**
  30777. * The camera exposure used on this material.
  30778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30779. * This corresponds to a photographic exposure.
  30780. */
  30781. get cameraExposure(): number;
  30782. /**
  30783. * The camera exposure used on this material.
  30784. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30785. * This corresponds to a photographic exposure.
  30786. */
  30787. set cameraExposure(value: number);
  30788. /**
  30789. * Gets The camera contrast used on this material.
  30790. */
  30791. get cameraContrast(): number;
  30792. /**
  30793. * Sets The camera contrast used on this material.
  30794. */
  30795. set cameraContrast(value: number);
  30796. /**
  30797. * Gets the Color Grading 2D Lookup Texture.
  30798. */
  30799. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30800. /**
  30801. * Sets the Color Grading 2D Lookup Texture.
  30802. */
  30803. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30804. /**
  30805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30807. * 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;
  30808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30809. */
  30810. get cameraColorCurves(): Nullable<ColorCurves>;
  30811. /**
  30812. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30813. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30814. * 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;
  30815. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30816. */
  30817. set cameraColorCurves(value: Nullable<ColorCurves>);
  30818. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30819. protected _worldViewProjectionMatrix: Matrix;
  30820. protected _globalAmbientColor: Color3;
  30821. protected _useLogarithmicDepth: boolean;
  30822. protected _rebuildInParallel: boolean;
  30823. /**
  30824. * Instantiates a new standard material.
  30825. * This is the default material used in Babylon. It is the best trade off between quality
  30826. * and performances.
  30827. * @see http://doc.babylonjs.com/babylon101/materials
  30828. * @param name Define the name of the material in the scene
  30829. * @param scene Define the scene the material belong to
  30830. */
  30831. constructor(name: string, scene: Scene);
  30832. /**
  30833. * Gets a boolean indicating that current material needs to register RTT
  30834. */
  30835. get hasRenderTargetTextures(): boolean;
  30836. /**
  30837. * Gets the current class name of the material e.g. "StandardMaterial"
  30838. * Mainly use in serialization.
  30839. * @returns the class name
  30840. */
  30841. getClassName(): string;
  30842. /**
  30843. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30844. * You can try switching to logarithmic depth.
  30845. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30846. */
  30847. get useLogarithmicDepth(): boolean;
  30848. set useLogarithmicDepth(value: boolean);
  30849. /**
  30850. * Specifies if the material will require alpha blending
  30851. * @returns a boolean specifying if alpha blending is needed
  30852. */
  30853. needAlphaBlending(): boolean;
  30854. /**
  30855. * Specifies if this material should be rendered in alpha test mode
  30856. * @returns a boolean specifying if an alpha test is needed.
  30857. */
  30858. needAlphaTesting(): boolean;
  30859. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30860. /**
  30861. * Get the texture used for alpha test purpose.
  30862. * @returns the diffuse texture in case of the standard material.
  30863. */
  30864. getAlphaTestTexture(): Nullable<BaseTexture>;
  30865. /**
  30866. * Get if the submesh is ready to be used and all its information available.
  30867. * Child classes can use it to update shaders
  30868. * @param mesh defines the mesh to check
  30869. * @param subMesh defines which submesh to check
  30870. * @param useInstances specifies that instances should be used
  30871. * @returns a boolean indicating that the submesh is ready or not
  30872. */
  30873. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30874. /**
  30875. * Builds the material UBO layouts.
  30876. * Used internally during the effect preparation.
  30877. */
  30878. buildUniformLayout(): void;
  30879. /**
  30880. * Unbinds the material from the mesh
  30881. */
  30882. unbind(): void;
  30883. /**
  30884. * Binds the submesh to this material by preparing the effect and shader to draw
  30885. * @param world defines the world transformation matrix
  30886. * @param mesh defines the mesh containing the submesh
  30887. * @param subMesh defines the submesh to bind the material to
  30888. */
  30889. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30890. /**
  30891. * Get the list of animatables in the material.
  30892. * @returns the list of animatables object used in the material
  30893. */
  30894. getAnimatables(): IAnimatable[];
  30895. /**
  30896. * Gets the active textures from the material
  30897. * @returns an array of textures
  30898. */
  30899. getActiveTextures(): BaseTexture[];
  30900. /**
  30901. * Specifies if the material uses a texture
  30902. * @param texture defines the texture to check against the material
  30903. * @returns a boolean specifying if the material uses the texture
  30904. */
  30905. hasTexture(texture: BaseTexture): boolean;
  30906. /**
  30907. * Disposes the material
  30908. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30909. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30910. */
  30911. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30912. /**
  30913. * Makes a duplicate of the material, and gives it a new name
  30914. * @param name defines the new name for the duplicated material
  30915. * @returns the cloned material
  30916. */
  30917. clone(name: string): StandardMaterial;
  30918. /**
  30919. * Serializes this material in a JSON representation
  30920. * @returns the serialized material object
  30921. */
  30922. serialize(): any;
  30923. /**
  30924. * Creates a standard material from parsed material data
  30925. * @param source defines the JSON representation of the material
  30926. * @param scene defines the hosting scene
  30927. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30928. * @returns a new standard material
  30929. */
  30930. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30931. /**
  30932. * Are diffuse textures enabled in the application.
  30933. */
  30934. static get DiffuseTextureEnabled(): boolean;
  30935. static set DiffuseTextureEnabled(value: boolean);
  30936. /**
  30937. * Are ambient textures enabled in the application.
  30938. */
  30939. static get AmbientTextureEnabled(): boolean;
  30940. static set AmbientTextureEnabled(value: boolean);
  30941. /**
  30942. * Are opacity textures enabled in the application.
  30943. */
  30944. static get OpacityTextureEnabled(): boolean;
  30945. static set OpacityTextureEnabled(value: boolean);
  30946. /**
  30947. * Are reflection textures enabled in the application.
  30948. */
  30949. static get ReflectionTextureEnabled(): boolean;
  30950. static set ReflectionTextureEnabled(value: boolean);
  30951. /**
  30952. * Are emissive textures enabled in the application.
  30953. */
  30954. static get EmissiveTextureEnabled(): boolean;
  30955. static set EmissiveTextureEnabled(value: boolean);
  30956. /**
  30957. * Are specular textures enabled in the application.
  30958. */
  30959. static get SpecularTextureEnabled(): boolean;
  30960. static set SpecularTextureEnabled(value: boolean);
  30961. /**
  30962. * Are bump textures enabled in the application.
  30963. */
  30964. static get BumpTextureEnabled(): boolean;
  30965. static set BumpTextureEnabled(value: boolean);
  30966. /**
  30967. * Are lightmap textures enabled in the application.
  30968. */
  30969. static get LightmapTextureEnabled(): boolean;
  30970. static set LightmapTextureEnabled(value: boolean);
  30971. /**
  30972. * Are refraction textures enabled in the application.
  30973. */
  30974. static get RefractionTextureEnabled(): boolean;
  30975. static set RefractionTextureEnabled(value: boolean);
  30976. /**
  30977. * Are color grading textures enabled in the application.
  30978. */
  30979. static get ColorGradingTextureEnabled(): boolean;
  30980. static set ColorGradingTextureEnabled(value: boolean);
  30981. /**
  30982. * Are fresnels enabled in the application.
  30983. */
  30984. static get FresnelEnabled(): boolean;
  30985. static set FresnelEnabled(value: boolean);
  30986. }
  30987. }
  30988. declare module "babylonjs/Particles/solidParticleSystem" {
  30989. import { Nullable } from "babylonjs/types";
  30990. import { Mesh } from "babylonjs/Meshes/mesh";
  30991. import { Scene, IDisposable } from "babylonjs/scene";
  30992. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  30993. import { Material } from "babylonjs/Materials/material";
  30994. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  30995. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  30996. /**
  30997. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30998. *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.
  30999. * The SPS is also a particle system. It provides some methods to manage the particles.
  31000. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31001. *
  31002. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  31003. */
  31004. export class SolidParticleSystem implements IDisposable {
  31005. /**
  31006. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31007. * Example : var p = SPS.particles[i];
  31008. */
  31009. particles: SolidParticle[];
  31010. /**
  31011. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31012. */
  31013. nbParticles: number;
  31014. /**
  31015. * If the particles must ever face the camera (default false). Useful for planar particles.
  31016. */
  31017. billboard: boolean;
  31018. /**
  31019. * Recompute normals when adding a shape
  31020. */
  31021. recomputeNormals: boolean;
  31022. /**
  31023. * This a counter ofr your own usage. It's not set by any SPS functions.
  31024. */
  31025. counter: number;
  31026. /**
  31027. * The SPS name. This name is also given to the underlying mesh.
  31028. */
  31029. name: string;
  31030. /**
  31031. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31032. */
  31033. mesh: Mesh;
  31034. /**
  31035. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31036. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31037. */
  31038. vars: any;
  31039. /**
  31040. * This array is populated when the SPS is set as 'pickable'.
  31041. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31042. * Each element of this array is an object `{idx: int, faceId: int}`.
  31043. * `idx` is the picked particle index in the `SPS.particles` array
  31044. * `faceId` is the picked face index counted within this particle.
  31045. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31046. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31047. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31048. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31049. */
  31050. pickedParticles: {
  31051. idx: number;
  31052. faceId: number;
  31053. }[];
  31054. /**
  31055. * This array is populated when the SPS is set as 'pickable'
  31056. * Each key of this array is a submesh index.
  31057. * Each element of this array is a second array defined like this :
  31058. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31059. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31060. * `idx` is the picked particle index in the `SPS.particles` array
  31061. * `faceId` is the picked face index counted within this particle.
  31062. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31063. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31064. */
  31065. pickedBySubMesh: {
  31066. idx: number;
  31067. faceId: number;
  31068. }[][];
  31069. /**
  31070. * This array is populated when `enableDepthSort` is set to true.
  31071. * Each element of this array is an instance of the class DepthSortedParticle.
  31072. */
  31073. depthSortedParticles: DepthSortedParticle[];
  31074. /**
  31075. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31076. * @hidden
  31077. */
  31078. _bSphereOnly: boolean;
  31079. /**
  31080. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31081. * @hidden
  31082. */
  31083. _bSphereRadiusFactor: number;
  31084. private _scene;
  31085. private _positions;
  31086. private _indices;
  31087. private _normals;
  31088. private _colors;
  31089. private _uvs;
  31090. private _indices32;
  31091. private _positions32;
  31092. private _normals32;
  31093. private _fixedNormal32;
  31094. private _colors32;
  31095. private _uvs32;
  31096. private _index;
  31097. private _updatable;
  31098. private _pickable;
  31099. private _isVisibilityBoxLocked;
  31100. private _alwaysVisible;
  31101. private _depthSort;
  31102. private _expandable;
  31103. private _shapeCounter;
  31104. private _copy;
  31105. private _color;
  31106. private _computeParticleColor;
  31107. private _computeParticleTexture;
  31108. private _computeParticleRotation;
  31109. private _computeParticleVertex;
  31110. private _computeBoundingBox;
  31111. private _depthSortParticles;
  31112. private _camera;
  31113. private _mustUnrotateFixedNormals;
  31114. private _particlesIntersect;
  31115. private _needs32Bits;
  31116. private _isNotBuilt;
  31117. private _lastParticleId;
  31118. private _idxOfId;
  31119. private _multimaterialEnabled;
  31120. private _useModelMaterial;
  31121. private _indicesByMaterial;
  31122. private _materialIndexes;
  31123. private _depthSortFunction;
  31124. private _materialSortFunction;
  31125. private _materials;
  31126. private _multimaterial;
  31127. private _materialIndexesById;
  31128. private _defaultMaterial;
  31129. private _autoUpdateSubMeshes;
  31130. private _tmpVertex;
  31131. /**
  31132. * Creates a SPS (Solid Particle System) object.
  31133. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31134. * @param scene (Scene) is the scene in which the SPS is added.
  31135. * @param options defines the options of the sps e.g.
  31136. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31137. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31138. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31139. * * 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.
  31140. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31141. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31142. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31143. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31144. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31145. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31146. */
  31147. constructor(name: string, scene: Scene, options?: {
  31148. updatable?: boolean;
  31149. isPickable?: boolean;
  31150. enableDepthSort?: boolean;
  31151. particleIntersection?: boolean;
  31152. boundingSphereOnly?: boolean;
  31153. bSphereRadiusFactor?: number;
  31154. expandable?: boolean;
  31155. useModelMaterial?: boolean;
  31156. enableMultiMaterial?: boolean;
  31157. });
  31158. /**
  31159. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31160. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31161. * @returns the created mesh
  31162. */
  31163. buildMesh(): Mesh;
  31164. /**
  31165. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31166. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31167. * Thus the particles generated from `digest()` have their property `position` set yet.
  31168. * @param mesh ( Mesh ) is the mesh to be digested
  31169. * @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
  31170. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31171. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31172. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31173. * @returns the current SPS
  31174. */
  31175. digest(mesh: Mesh, options?: {
  31176. facetNb?: number;
  31177. number?: number;
  31178. delta?: number;
  31179. storage?: [];
  31180. }): SolidParticleSystem;
  31181. /**
  31182. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31183. * @hidden
  31184. */
  31185. private _unrotateFixedNormals;
  31186. /**
  31187. * Resets the temporary working copy particle
  31188. * @hidden
  31189. */
  31190. private _resetCopy;
  31191. /**
  31192. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31193. * @param p the current index in the positions array to be updated
  31194. * @param ind the current index in the indices array
  31195. * @param shape a Vector3 array, the shape geometry
  31196. * @param positions the positions array to be updated
  31197. * @param meshInd the shape indices array
  31198. * @param indices the indices array to be updated
  31199. * @param meshUV the shape uv array
  31200. * @param uvs the uv array to be updated
  31201. * @param meshCol the shape color array
  31202. * @param colors the color array to be updated
  31203. * @param meshNor the shape normals array
  31204. * @param normals the normals array to be updated
  31205. * @param idx the particle index
  31206. * @param idxInShape the particle index in its shape
  31207. * @param options the addShape() method passed options
  31208. * @model the particle model
  31209. * @hidden
  31210. */
  31211. private _meshBuilder;
  31212. /**
  31213. * Returns a shape Vector3 array from positions float array
  31214. * @param positions float array
  31215. * @returns a vector3 array
  31216. * @hidden
  31217. */
  31218. private _posToShape;
  31219. /**
  31220. * Returns a shapeUV array from a float uvs (array deep copy)
  31221. * @param uvs as a float array
  31222. * @returns a shapeUV array
  31223. * @hidden
  31224. */
  31225. private _uvsToShapeUV;
  31226. /**
  31227. * Adds a new particle object in the particles array
  31228. * @param idx particle index in particles array
  31229. * @param id particle id
  31230. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31231. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31232. * @param model particle ModelShape object
  31233. * @param shapeId model shape identifier
  31234. * @param idxInShape index of the particle in the current model
  31235. * @param bInfo model bounding info object
  31236. * @param storage target storage array, if any
  31237. * @hidden
  31238. */
  31239. private _addParticle;
  31240. /**
  31241. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31242. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31243. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31244. * @param nb (positive integer) the number of particles to be created from this model
  31245. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31246. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31247. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31248. * @returns the number of shapes in the system
  31249. */
  31250. addShape(mesh: Mesh, nb: number, options?: {
  31251. positionFunction?: any;
  31252. vertexFunction?: any;
  31253. storage?: [];
  31254. }): number;
  31255. /**
  31256. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31257. * @hidden
  31258. */
  31259. private _rebuildParticle;
  31260. /**
  31261. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31262. * @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.
  31263. * @returns the SPS.
  31264. */
  31265. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31266. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31267. * Returns an array with the removed particles.
  31268. * 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.
  31269. * The SPS can't be empty so at least one particle needs to remain in place.
  31270. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31271. * @param start index of the first particle to remove
  31272. * @param end index of the last particle to remove (included)
  31273. * @returns an array populated with the removed particles
  31274. */
  31275. removeParticles(start: number, end: number): SolidParticle[];
  31276. /**
  31277. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31278. * @param solidParticleArray an array populated with Solid Particles objects
  31279. * @returns the SPS
  31280. */
  31281. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31282. /**
  31283. * Creates a new particle and modifies the SPS mesh geometry :
  31284. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31285. * - calls _addParticle() to populate the particle array
  31286. * factorized code from addShape() and insertParticlesFromArray()
  31287. * @param idx particle index in the particles array
  31288. * @param i particle index in its shape
  31289. * @param modelShape particle ModelShape object
  31290. * @param shape shape vertex array
  31291. * @param meshInd shape indices array
  31292. * @param meshUV shape uv array
  31293. * @param meshCol shape color array
  31294. * @param meshNor shape normals array
  31295. * @param bbInfo shape bounding info
  31296. * @param storage target particle storage
  31297. * @options addShape() passed options
  31298. * @hidden
  31299. */
  31300. private _insertNewParticle;
  31301. /**
  31302. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31303. * This method calls `updateParticle()` for each particle of the SPS.
  31304. * For an animated SPS, it is usually called within the render loop.
  31305. * 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.
  31306. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31307. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31308. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31309. * @returns the SPS.
  31310. */
  31311. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31312. /**
  31313. * Disposes the SPS.
  31314. */
  31315. dispose(): void;
  31316. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31317. * idx is the particle index in the SPS
  31318. * faceId is the picked face index counted within this particle.
  31319. * Returns null if the pickInfo can't identify a picked particle.
  31320. * @param pickingInfo (PickingInfo object)
  31321. * @returns {idx: number, faceId: number} or null
  31322. */
  31323. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31324. idx: number;
  31325. faceId: number;
  31326. }>;
  31327. /**
  31328. * Returns a SolidParticle object from its identifier : particle.id
  31329. * @param id (integer) the particle Id
  31330. * @returns the searched particle or null if not found in the SPS.
  31331. */
  31332. getParticleById(id: number): Nullable<SolidParticle>;
  31333. /**
  31334. * Returns a new array populated with the particles having the passed shapeId.
  31335. * @param shapeId (integer) the shape identifier
  31336. * @returns a new solid particle array
  31337. */
  31338. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31339. /**
  31340. * Populates the passed array "ref" with the particles having the passed shapeId.
  31341. * @param shapeId the shape identifier
  31342. * @returns the SPS
  31343. * @param ref
  31344. */
  31345. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31346. /**
  31347. * Computes the required SubMeshes according the materials assigned to the particles.
  31348. * @returns the solid particle system.
  31349. * Does nothing if called before the SPS mesh is built.
  31350. */
  31351. computeSubMeshes(): SolidParticleSystem;
  31352. /**
  31353. * Sorts the solid particles by material when MultiMaterial is enabled.
  31354. * Updates the indices32 array.
  31355. * Updates the indicesByMaterial array.
  31356. * Updates the mesh indices array.
  31357. * @returns the SPS
  31358. * @hidden
  31359. */
  31360. private _sortParticlesByMaterial;
  31361. /**
  31362. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31363. * @hidden
  31364. */
  31365. private _setMaterialIndexesById;
  31366. /**
  31367. * Returns an array with unique values of Materials from the passed array
  31368. * @param array the material array to be checked and filtered
  31369. * @hidden
  31370. */
  31371. private _filterUniqueMaterialId;
  31372. /**
  31373. * Sets a new Standard Material as _defaultMaterial if not already set.
  31374. * @hidden
  31375. */
  31376. private _setDefaultMaterial;
  31377. /**
  31378. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31379. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31380. * @returns the SPS.
  31381. */
  31382. refreshVisibleSize(): SolidParticleSystem;
  31383. /**
  31384. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31385. * @param size the size (float) of the visibility box
  31386. * note : this doesn't lock the SPS mesh bounding box.
  31387. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31388. */
  31389. setVisibilityBox(size: number): void;
  31390. /**
  31391. * Gets whether the SPS as always visible or not
  31392. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31393. */
  31394. get isAlwaysVisible(): boolean;
  31395. /**
  31396. * Sets the SPS as always visible or not
  31397. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31398. */
  31399. set isAlwaysVisible(val: boolean);
  31400. /**
  31401. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31402. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31403. */
  31404. set isVisibilityBoxLocked(val: boolean);
  31405. /**
  31406. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31408. */
  31409. get isVisibilityBoxLocked(): boolean;
  31410. /**
  31411. * Tells to `setParticles()` to compute the particle rotations or not.
  31412. * Default value : true. The SPS is faster when it's set to false.
  31413. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31414. */
  31415. set computeParticleRotation(val: boolean);
  31416. /**
  31417. * Tells to `setParticles()` to compute the particle colors or not.
  31418. * Default value : true. The SPS is faster when it's set to false.
  31419. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31420. */
  31421. set computeParticleColor(val: boolean);
  31422. set computeParticleTexture(val: boolean);
  31423. /**
  31424. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31425. * Default value : false. The SPS is faster when it's set to false.
  31426. * Note : the particle custom vertex positions aren't stored values.
  31427. */
  31428. set computeParticleVertex(val: boolean);
  31429. /**
  31430. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31431. */
  31432. set computeBoundingBox(val: boolean);
  31433. /**
  31434. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31435. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31436. * Default : `true`
  31437. */
  31438. set depthSortParticles(val: boolean);
  31439. /**
  31440. * Gets if `setParticles()` computes the particle rotations or not.
  31441. * Default value : true. The SPS is faster when it's set to false.
  31442. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31443. */
  31444. get computeParticleRotation(): boolean;
  31445. /**
  31446. * Gets if `setParticles()` computes the particle colors or not.
  31447. * Default value : true. The SPS is faster when it's set to false.
  31448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31449. */
  31450. get computeParticleColor(): boolean;
  31451. /**
  31452. * Gets if `setParticles()` computes the particle textures or not.
  31453. * Default value : true. The SPS is faster when it's set to false.
  31454. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31455. */
  31456. get computeParticleTexture(): boolean;
  31457. /**
  31458. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31459. * Default value : false. The SPS is faster when it's set to false.
  31460. * Note : the particle custom vertex positions aren't stored values.
  31461. */
  31462. get computeParticleVertex(): boolean;
  31463. /**
  31464. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31465. */
  31466. get computeBoundingBox(): boolean;
  31467. /**
  31468. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31469. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31470. * Default : `true`
  31471. */
  31472. get depthSortParticles(): boolean;
  31473. /**
  31474. * Gets if the SPS is created as expandable at construction time.
  31475. * Default : `false`
  31476. */
  31477. get expandable(): boolean;
  31478. /**
  31479. * Gets if the SPS supports the Multi Materials
  31480. */
  31481. get multimaterialEnabled(): boolean;
  31482. /**
  31483. * Gets if the SPS uses the model materials for its own multimaterial.
  31484. */
  31485. get useModelMaterial(): boolean;
  31486. /**
  31487. * The SPS used material array.
  31488. */
  31489. get materials(): Material[];
  31490. /**
  31491. * Sets the SPS MultiMaterial from the passed materials.
  31492. * Note : the passed array is internally copied and not used then by reference.
  31493. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31494. */
  31495. setMultiMaterial(materials: Material[]): void;
  31496. /**
  31497. * The SPS computed multimaterial object
  31498. */
  31499. get multimaterial(): MultiMaterial;
  31500. set multimaterial(mm: MultiMaterial);
  31501. /**
  31502. * If the subMeshes must be updated on the next call to setParticles()
  31503. */
  31504. get autoUpdateSubMeshes(): boolean;
  31505. set autoUpdateSubMeshes(val: boolean);
  31506. /**
  31507. * This function does nothing. It may be overwritten to set all the particle first values.
  31508. * The SPS doesn't call this function, you may have to call it by your own.
  31509. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31510. */
  31511. initParticles(): void;
  31512. /**
  31513. * This function does nothing. It may be overwritten to recycle a particle.
  31514. * The SPS doesn't call this function, you may have to call it by your own.
  31515. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31516. * @param particle The particle to recycle
  31517. * @returns the recycled particle
  31518. */
  31519. recycleParticle(particle: SolidParticle): SolidParticle;
  31520. /**
  31521. * Updates a particle : this function should be overwritten by the user.
  31522. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31523. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31524. * @example : just set a particle position or velocity and recycle conditions
  31525. * @param particle The particle to update
  31526. * @returns the updated particle
  31527. */
  31528. updateParticle(particle: SolidParticle): SolidParticle;
  31529. /**
  31530. * Updates a vertex of a particle : it can be overwritten by the user.
  31531. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31532. * @param particle the current particle
  31533. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31534. * @param pt the index of the current vertex in the particle shape
  31535. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31536. * @example : just set a vertex particle position or color
  31537. * @returns the sps
  31538. */
  31539. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31540. /**
  31541. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31542. * This does nothing and may be overwritten by the user.
  31543. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31544. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31545. * @param update the boolean update value actually passed to setParticles()
  31546. */
  31547. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31548. /**
  31549. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31550. * This will be passed three parameters.
  31551. * This does nothing and may be overwritten by the user.
  31552. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31553. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31554. * @param update the boolean update value actually passed to setParticles()
  31555. */
  31556. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31557. }
  31558. }
  31559. declare module "babylonjs/Particles/solidParticle" {
  31560. import { Nullable } from "babylonjs/types";
  31561. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31562. import { Color4 } from "babylonjs/Maths/math.color";
  31563. import { Mesh } from "babylonjs/Meshes/mesh";
  31564. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31565. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31566. import { Plane } from "babylonjs/Maths/math.plane";
  31567. import { Material } from "babylonjs/Materials/material";
  31568. /**
  31569. * Represents one particle of a solid particle system.
  31570. */
  31571. export class SolidParticle {
  31572. /**
  31573. * particle global index
  31574. */
  31575. idx: number;
  31576. /**
  31577. * particle identifier
  31578. */
  31579. id: number;
  31580. /**
  31581. * The color of the particle
  31582. */
  31583. color: Nullable<Color4>;
  31584. /**
  31585. * The world space position of the particle.
  31586. */
  31587. position: Vector3;
  31588. /**
  31589. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31590. */
  31591. rotation: Vector3;
  31592. /**
  31593. * The world space rotation quaternion of the particle.
  31594. */
  31595. rotationQuaternion: Nullable<Quaternion>;
  31596. /**
  31597. * The scaling of the particle.
  31598. */
  31599. scaling: Vector3;
  31600. /**
  31601. * The uvs of the particle.
  31602. */
  31603. uvs: Vector4;
  31604. /**
  31605. * The current speed of the particle.
  31606. */
  31607. velocity: Vector3;
  31608. /**
  31609. * The pivot point in the particle local space.
  31610. */
  31611. pivot: Vector3;
  31612. /**
  31613. * Must the particle be translated from its pivot point in its local space ?
  31614. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31615. * Default : false
  31616. */
  31617. translateFromPivot: boolean;
  31618. /**
  31619. * Is the particle active or not ?
  31620. */
  31621. alive: boolean;
  31622. /**
  31623. * Is the particle visible or not ?
  31624. */
  31625. isVisible: boolean;
  31626. /**
  31627. * Index of this particle in the global "positions" array (Internal use)
  31628. * @hidden
  31629. */
  31630. _pos: number;
  31631. /**
  31632. * @hidden Index of this particle in the global "indices" array (Internal use)
  31633. */
  31634. _ind: number;
  31635. /**
  31636. * @hidden ModelShape of this particle (Internal use)
  31637. */
  31638. _model: ModelShape;
  31639. /**
  31640. * ModelShape id of this particle
  31641. */
  31642. shapeId: number;
  31643. /**
  31644. * Index of the particle in its shape id
  31645. */
  31646. idxInShape: number;
  31647. /**
  31648. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31649. */
  31650. _modelBoundingInfo: BoundingInfo;
  31651. /**
  31652. * @hidden Particle BoundingInfo object (Internal use)
  31653. */
  31654. _boundingInfo: BoundingInfo;
  31655. /**
  31656. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31657. */
  31658. _sps: SolidParticleSystem;
  31659. /**
  31660. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31661. */
  31662. _stillInvisible: boolean;
  31663. /**
  31664. * @hidden Last computed particle rotation matrix
  31665. */
  31666. _rotationMatrix: number[];
  31667. /**
  31668. * Parent particle Id, if any.
  31669. * Default null.
  31670. */
  31671. parentId: Nullable<number>;
  31672. /**
  31673. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31674. */
  31675. materialIndex: Nullable<number>;
  31676. /**
  31677. * Custom object or properties.
  31678. */
  31679. props: Nullable<any>;
  31680. /**
  31681. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31682. * The possible values are :
  31683. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31684. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31685. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31686. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31687. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31688. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31689. * */
  31690. cullingStrategy: number;
  31691. /**
  31692. * @hidden Internal global position in the SPS.
  31693. */
  31694. _globalPosition: Vector3;
  31695. /**
  31696. * Creates a Solid Particle object.
  31697. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31698. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31699. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31700. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31701. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31702. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31703. * @param shapeId (integer) is the model shape identifier in the SPS.
  31704. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31705. * @param sps defines the sps it is associated to
  31706. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31707. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31708. */
  31709. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31710. /**
  31711. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31712. * @param target the particle target
  31713. * @returns the current particle
  31714. */
  31715. copyToRef(target: SolidParticle): SolidParticle;
  31716. /**
  31717. * Legacy support, changed scale to scaling
  31718. */
  31719. get scale(): Vector3;
  31720. /**
  31721. * Legacy support, changed scale to scaling
  31722. */
  31723. set scale(scale: Vector3);
  31724. /**
  31725. * Legacy support, changed quaternion to rotationQuaternion
  31726. */
  31727. get quaternion(): Nullable<Quaternion>;
  31728. /**
  31729. * Legacy support, changed quaternion to rotationQuaternion
  31730. */
  31731. set quaternion(q: Nullable<Quaternion>);
  31732. /**
  31733. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31734. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31735. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31736. * @returns true if it intersects
  31737. */
  31738. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31739. /**
  31740. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31741. * A particle is in the frustum if its bounding box intersects the frustum
  31742. * @param frustumPlanes defines the frustum to test
  31743. * @returns true if the particle is in the frustum planes
  31744. */
  31745. isInFrustum(frustumPlanes: Plane[]): boolean;
  31746. /**
  31747. * get the rotation matrix of the particle
  31748. * @hidden
  31749. */
  31750. getRotationMatrix(m: Matrix): void;
  31751. }
  31752. /**
  31753. * Represents the shape of the model used by one particle of a solid particle system.
  31754. * SPS internal tool, don't use it manually.
  31755. */
  31756. export class ModelShape {
  31757. /**
  31758. * The shape id
  31759. * @hidden
  31760. */
  31761. shapeID: number;
  31762. /**
  31763. * flat array of model positions (internal use)
  31764. * @hidden
  31765. */
  31766. _shape: Vector3[];
  31767. /**
  31768. * flat array of model UVs (internal use)
  31769. * @hidden
  31770. */
  31771. _shapeUV: number[];
  31772. /**
  31773. * color array of the model
  31774. * @hidden
  31775. */
  31776. _shapeColors: number[];
  31777. /**
  31778. * indices array of the model
  31779. * @hidden
  31780. */
  31781. _indices: number[];
  31782. /**
  31783. * normals array of the model
  31784. * @hidden
  31785. */
  31786. _normals: number[];
  31787. /**
  31788. * length of the shape in the model indices array (internal use)
  31789. * @hidden
  31790. */
  31791. _indicesLength: number;
  31792. /**
  31793. * Custom position function (internal use)
  31794. * @hidden
  31795. */
  31796. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31797. /**
  31798. * Custom vertex function (internal use)
  31799. * @hidden
  31800. */
  31801. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31802. /**
  31803. * Model material (internal use)
  31804. * @hidden
  31805. */
  31806. _material: Nullable<Material>;
  31807. /**
  31808. * 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.
  31809. * SPS internal tool, don't use it manually.
  31810. * @hidden
  31811. */
  31812. 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>);
  31813. }
  31814. /**
  31815. * Represents a Depth Sorted Particle in the solid particle system.
  31816. * @hidden
  31817. */
  31818. export class DepthSortedParticle {
  31819. /**
  31820. * Particle index
  31821. */
  31822. idx: number;
  31823. /**
  31824. * Index of the particle in the "indices" array
  31825. */
  31826. ind: number;
  31827. /**
  31828. * Length of the particle shape in the "indices" array
  31829. */
  31830. indicesLength: number;
  31831. /**
  31832. * Squared distance from the particle to the camera
  31833. */
  31834. sqDistance: number;
  31835. /**
  31836. * Material index when used with MultiMaterials
  31837. */
  31838. materialIndex: number;
  31839. /**
  31840. * Creates a new sorted particle
  31841. * @param materialIndex
  31842. */
  31843. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31844. }
  31845. /**
  31846. * Represents a solid particle vertex
  31847. */
  31848. export class SolidParticleVertex {
  31849. /**
  31850. * Vertex position
  31851. */
  31852. position: Vector3;
  31853. /**
  31854. * Vertex color
  31855. */
  31856. color: Color4;
  31857. /**
  31858. * Vertex UV
  31859. */
  31860. uv: Vector2;
  31861. /**
  31862. * Creates a new solid particle vertex
  31863. */
  31864. constructor();
  31865. /** Vertex x coordinate */
  31866. get x(): number;
  31867. set x(val: number);
  31868. /** Vertex y coordinate */
  31869. get y(): number;
  31870. set y(val: number);
  31871. /** Vertex z coordinate */
  31872. get z(): number;
  31873. set z(val: number);
  31874. }
  31875. }
  31876. declare module "babylonjs/Collisions/meshCollisionData" {
  31877. import { Collider } from "babylonjs/Collisions/collider";
  31878. import { Vector3 } from "babylonjs/Maths/math.vector";
  31879. import { Nullable } from "babylonjs/types";
  31880. import { Observer } from "babylonjs/Misc/observable";
  31881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31882. /**
  31883. * @hidden
  31884. */
  31885. export class _MeshCollisionData {
  31886. _checkCollisions: boolean;
  31887. _collisionMask: number;
  31888. _collisionGroup: number;
  31889. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31890. _collider: Nullable<Collider>;
  31891. _oldPositionForCollisions: Vector3;
  31892. _diffPositionForCollisions: Vector3;
  31893. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31894. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31895. }
  31896. }
  31897. declare module "babylonjs/Meshes/abstractMesh" {
  31898. import { Observable } from "babylonjs/Misc/observable";
  31899. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31900. import { Camera } from "babylonjs/Cameras/camera";
  31901. import { Scene, IDisposable } from "babylonjs/scene";
  31902. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31903. import { Node } from "babylonjs/node";
  31904. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31905. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31907. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31908. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31909. import { Material } from "babylonjs/Materials/material";
  31910. import { Light } from "babylonjs/Lights/light";
  31911. import { Skeleton } from "babylonjs/Bones/skeleton";
  31912. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31913. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31914. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31915. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31916. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31917. import { Plane } from "babylonjs/Maths/math.plane";
  31918. import { Ray } from "babylonjs/Culling/ray";
  31919. import { Collider } from "babylonjs/Collisions/collider";
  31920. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31921. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31922. /** @hidden */
  31923. class _FacetDataStorage {
  31924. facetPositions: Vector3[];
  31925. facetNormals: Vector3[];
  31926. facetPartitioning: number[][];
  31927. facetNb: number;
  31928. partitioningSubdivisions: number;
  31929. partitioningBBoxRatio: number;
  31930. facetDataEnabled: boolean;
  31931. facetParameters: any;
  31932. bbSize: Vector3;
  31933. subDiv: {
  31934. max: number;
  31935. X: number;
  31936. Y: number;
  31937. Z: number;
  31938. };
  31939. facetDepthSort: boolean;
  31940. facetDepthSortEnabled: boolean;
  31941. depthSortedIndices: IndicesArray;
  31942. depthSortedFacets: {
  31943. ind: number;
  31944. sqDistance: number;
  31945. }[];
  31946. facetDepthSortFunction: (f1: {
  31947. ind: number;
  31948. sqDistance: number;
  31949. }, f2: {
  31950. ind: number;
  31951. sqDistance: number;
  31952. }) => number;
  31953. facetDepthSortFrom: Vector3;
  31954. facetDepthSortOrigin: Vector3;
  31955. invertedMatrix: Matrix;
  31956. }
  31957. /**
  31958. * @hidden
  31959. **/
  31960. class _InternalAbstractMeshDataInfo {
  31961. _hasVertexAlpha: boolean;
  31962. _useVertexColors: boolean;
  31963. _numBoneInfluencers: number;
  31964. _applyFog: boolean;
  31965. _receiveShadows: boolean;
  31966. _facetData: _FacetDataStorage;
  31967. _visibility: number;
  31968. _skeleton: Nullable<Skeleton>;
  31969. _layerMask: number;
  31970. _computeBonesUsingShaders: boolean;
  31971. _isActive: boolean;
  31972. _onlyForInstances: boolean;
  31973. _isActiveIntermediate: boolean;
  31974. _onlyForInstancesIntermediate: boolean;
  31975. _actAsRegularMesh: boolean;
  31976. }
  31977. /**
  31978. * Class used to store all common mesh properties
  31979. */
  31980. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31981. /** No occlusion */
  31982. static OCCLUSION_TYPE_NONE: number;
  31983. /** Occlusion set to optimisitic */
  31984. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31985. /** Occlusion set to strict */
  31986. static OCCLUSION_TYPE_STRICT: number;
  31987. /** Use an accurante occlusion algorithm */
  31988. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31989. /** Use a conservative occlusion algorithm */
  31990. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31992. * Test order :
  31993. * Is the bounding sphere outside the frustum ?
  31994. * If not, are the bounding box vertices outside the frustum ?
  31995. * It not, then the cullable object is in the frustum.
  31996. */
  31997. static readonly CULLINGSTRATEGY_STANDARD: number;
  31998. /** Culling strategy : Bounding Sphere Only.
  31999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32000. * It's also less accurate than the standard because some not visible objects can still be selected.
  32001. * Test : is the bounding sphere outside the frustum ?
  32002. * If not, then the cullable object is in the frustum.
  32003. */
  32004. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32005. /** Culling strategy : Optimistic Inclusion.
  32006. * This in an inclusion test first, then the standard exclusion test.
  32007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32008. * 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.
  32009. * Anyway, it's as accurate as the standard strategy.
  32010. * Test :
  32011. * Is the cullable object bounding sphere center in the frustum ?
  32012. * If not, apply the default culling strategy.
  32013. */
  32014. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32018. * 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.
  32019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32020. * Test :
  32021. * Is the cullable object bounding sphere center in the frustum ?
  32022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32023. */
  32024. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32025. /**
  32026. * No billboard
  32027. */
  32028. static get BILLBOARDMODE_NONE(): number;
  32029. /** Billboard on X axis */
  32030. static get BILLBOARDMODE_X(): number;
  32031. /** Billboard on Y axis */
  32032. static get BILLBOARDMODE_Y(): number;
  32033. /** Billboard on Z axis */
  32034. static get BILLBOARDMODE_Z(): number;
  32035. /** Billboard on all axes */
  32036. static get BILLBOARDMODE_ALL(): number;
  32037. /** Billboard on using position instead of orientation */
  32038. static get BILLBOARDMODE_USE_POSITION(): number;
  32039. /** @hidden */
  32040. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32041. /**
  32042. * The culling strategy to use to check whether the mesh must be rendered or not.
  32043. * This value can be changed at any time and will be used on the next render mesh selection.
  32044. * The possible values are :
  32045. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32046. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32047. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32048. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32049. * Please read each static variable documentation to get details about the culling process.
  32050. * */
  32051. cullingStrategy: number;
  32052. /**
  32053. * Gets the number of facets in the mesh
  32054. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32055. */
  32056. get facetNb(): number;
  32057. /**
  32058. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32060. */
  32061. get partitioningSubdivisions(): number;
  32062. set partitioningSubdivisions(nb: number);
  32063. /**
  32064. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32065. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32067. */
  32068. get partitioningBBoxRatio(): number;
  32069. set partitioningBBoxRatio(ratio: number);
  32070. /**
  32071. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32072. * Works only for updatable meshes.
  32073. * Doesn't work with multi-materials
  32074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32075. */
  32076. get mustDepthSortFacets(): boolean;
  32077. set mustDepthSortFacets(sort: boolean);
  32078. /**
  32079. * The location (Vector3) where the facet depth sort must be computed from.
  32080. * By default, the active camera position.
  32081. * Used only when facet depth sort is enabled
  32082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32083. */
  32084. get facetDepthSortFrom(): Vector3;
  32085. set facetDepthSortFrom(location: Vector3);
  32086. /**
  32087. * gets a boolean indicating if facetData is enabled
  32088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32089. */
  32090. get isFacetDataEnabled(): boolean;
  32091. /** @hidden */
  32092. _updateNonUniformScalingState(value: boolean): boolean;
  32093. /**
  32094. * An event triggered when this mesh collides with another one
  32095. */
  32096. onCollideObservable: Observable<AbstractMesh>;
  32097. /** Set a function to call when this mesh collides with another one */
  32098. set onCollide(callback: () => void);
  32099. /**
  32100. * An event triggered when the collision's position changes
  32101. */
  32102. onCollisionPositionChangeObservable: Observable<Vector3>;
  32103. /** Set a function to call when the collision's position changes */
  32104. set onCollisionPositionChange(callback: () => void);
  32105. /**
  32106. * An event triggered when material is changed
  32107. */
  32108. onMaterialChangedObservable: Observable<AbstractMesh>;
  32109. /**
  32110. * Gets or sets the orientation for POV movement & rotation
  32111. */
  32112. definedFacingForward: boolean;
  32113. /** @hidden */
  32114. _occlusionQuery: Nullable<WebGLQuery>;
  32115. /** @hidden */
  32116. _renderingGroup: Nullable<RenderingGroup>;
  32117. /**
  32118. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32119. */
  32120. get visibility(): number;
  32121. /**
  32122. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32123. */
  32124. set visibility(value: number);
  32125. /** Gets or sets the alpha index used to sort transparent meshes
  32126. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32127. */
  32128. alphaIndex: number;
  32129. /**
  32130. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32131. */
  32132. isVisible: boolean;
  32133. /**
  32134. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32135. */
  32136. isPickable: boolean;
  32137. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32138. showSubMeshesBoundingBox: boolean;
  32139. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32140. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32141. */
  32142. isBlocker: boolean;
  32143. /**
  32144. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32145. */
  32146. enablePointerMoveEvents: boolean;
  32147. /**
  32148. * Specifies the rendering group id for this mesh (0 by default)
  32149. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32150. */
  32151. renderingGroupId: number;
  32152. private _material;
  32153. /** Gets or sets current material */
  32154. get material(): Nullable<Material>;
  32155. set material(value: Nullable<Material>);
  32156. /**
  32157. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32158. * @see http://doc.babylonjs.com/babylon101/shadows
  32159. */
  32160. get receiveShadows(): boolean;
  32161. set receiveShadows(value: boolean);
  32162. /** Defines color to use when rendering outline */
  32163. outlineColor: Color3;
  32164. /** Define width to use when rendering outline */
  32165. outlineWidth: number;
  32166. /** Defines color to use when rendering overlay */
  32167. overlayColor: Color3;
  32168. /** Defines alpha to use when rendering overlay */
  32169. overlayAlpha: number;
  32170. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32171. get hasVertexAlpha(): boolean;
  32172. set hasVertexAlpha(value: boolean);
  32173. /** 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) */
  32174. get useVertexColors(): boolean;
  32175. set useVertexColors(value: boolean);
  32176. /**
  32177. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32178. */
  32179. get computeBonesUsingShaders(): boolean;
  32180. set computeBonesUsingShaders(value: boolean);
  32181. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32182. get numBoneInfluencers(): number;
  32183. set numBoneInfluencers(value: number);
  32184. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32185. get applyFog(): boolean;
  32186. set applyFog(value: boolean);
  32187. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32188. useOctreeForRenderingSelection: boolean;
  32189. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32190. useOctreeForPicking: boolean;
  32191. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32192. useOctreeForCollisions: boolean;
  32193. /**
  32194. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32195. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32196. */
  32197. get layerMask(): number;
  32198. set layerMask(value: number);
  32199. /**
  32200. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32201. */
  32202. alwaysSelectAsActiveMesh: boolean;
  32203. /**
  32204. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32205. */
  32206. doNotSyncBoundingInfo: boolean;
  32207. /**
  32208. * Gets or sets the current action manager
  32209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32210. */
  32211. actionManager: Nullable<AbstractActionManager>;
  32212. private _meshCollisionData;
  32213. /**
  32214. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32216. */
  32217. ellipsoid: Vector3;
  32218. /**
  32219. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32220. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32221. */
  32222. ellipsoidOffset: Vector3;
  32223. /**
  32224. * Gets or sets a collision mask used to mask collisions (default is -1).
  32225. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32226. */
  32227. get collisionMask(): number;
  32228. set collisionMask(mask: number);
  32229. /**
  32230. * Gets or sets the current collision group mask (-1 by default).
  32231. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32232. */
  32233. get collisionGroup(): number;
  32234. set collisionGroup(mask: number);
  32235. /**
  32236. * Gets or sets current surrounding meshes (null by default).
  32237. *
  32238. * By default collision detection is tested against every mesh in the scene.
  32239. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32240. * meshes will be tested for the collision.
  32241. *
  32242. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32243. */
  32244. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32245. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32246. /**
  32247. * Defines edge width used when edgesRenderer is enabled
  32248. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32249. */
  32250. edgesWidth: number;
  32251. /**
  32252. * Defines edge color used when edgesRenderer is enabled
  32253. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32254. */
  32255. edgesColor: Color4;
  32256. /** @hidden */
  32257. _edgesRenderer: Nullable<IEdgesRenderer>;
  32258. /** @hidden */
  32259. _masterMesh: Nullable<AbstractMesh>;
  32260. /** @hidden */
  32261. _boundingInfo: Nullable<BoundingInfo>;
  32262. /** @hidden */
  32263. _renderId: number;
  32264. /**
  32265. * Gets or sets the list of subMeshes
  32266. * @see http://doc.babylonjs.com/how_to/multi_materials
  32267. */
  32268. subMeshes: SubMesh[];
  32269. /** @hidden */
  32270. _intersectionsInProgress: AbstractMesh[];
  32271. /** @hidden */
  32272. _unIndexed: boolean;
  32273. /** @hidden */
  32274. _lightSources: Light[];
  32275. /** Gets the list of lights affecting that mesh */
  32276. get lightSources(): Light[];
  32277. /** @hidden */
  32278. get _positions(): Nullable<Vector3[]>;
  32279. /** @hidden */
  32280. _waitingData: {
  32281. lods: Nullable<any>;
  32282. actions: Nullable<any>;
  32283. freezeWorldMatrix: Nullable<boolean>;
  32284. };
  32285. /** @hidden */
  32286. _bonesTransformMatrices: Nullable<Float32Array>;
  32287. /** @hidden */
  32288. _transformMatrixTexture: Nullable<RawTexture>;
  32289. /**
  32290. * Gets or sets a skeleton to apply skining transformations
  32291. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32292. */
  32293. set skeleton(value: Nullable<Skeleton>);
  32294. get skeleton(): Nullable<Skeleton>;
  32295. /**
  32296. * An event triggered when the mesh is rebuilt.
  32297. */
  32298. onRebuildObservable: Observable<AbstractMesh>;
  32299. /**
  32300. * Creates a new AbstractMesh
  32301. * @param name defines the name of the mesh
  32302. * @param scene defines the hosting scene
  32303. */
  32304. constructor(name: string, scene?: Nullable<Scene>);
  32305. /**
  32306. * Returns the string "AbstractMesh"
  32307. * @returns "AbstractMesh"
  32308. */
  32309. getClassName(): string;
  32310. /**
  32311. * Gets a string representation of the current mesh
  32312. * @param fullDetails defines a boolean indicating if full details must be included
  32313. * @returns a string representation of the current mesh
  32314. */
  32315. toString(fullDetails?: boolean): string;
  32316. /**
  32317. * @hidden
  32318. */
  32319. protected _getEffectiveParent(): Nullable<Node>;
  32320. /** @hidden */
  32321. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32322. /** @hidden */
  32323. _rebuild(): void;
  32324. /** @hidden */
  32325. _resyncLightSources(): void;
  32326. /** @hidden */
  32327. _resyncLightSource(light: Light): void;
  32328. /** @hidden */
  32329. _unBindEffect(): void;
  32330. /** @hidden */
  32331. _removeLightSource(light: Light, dispose: boolean): void;
  32332. private _markSubMeshesAsDirty;
  32333. /** @hidden */
  32334. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32335. /** @hidden */
  32336. _markSubMeshesAsAttributesDirty(): void;
  32337. /** @hidden */
  32338. _markSubMeshesAsMiscDirty(): void;
  32339. /**
  32340. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32341. */
  32342. get scaling(): Vector3;
  32343. set scaling(newScaling: Vector3);
  32344. /**
  32345. * Returns true if the mesh is blocked. Implemented by child classes
  32346. */
  32347. get isBlocked(): boolean;
  32348. /**
  32349. * Returns the mesh itself by default. Implemented by child classes
  32350. * @param camera defines the camera to use to pick the right LOD level
  32351. * @returns the currentAbstractMesh
  32352. */
  32353. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32354. /**
  32355. * Returns 0 by default. Implemented by child classes
  32356. * @returns an integer
  32357. */
  32358. getTotalVertices(): number;
  32359. /**
  32360. * Returns a positive integer : the total number of indices in this mesh geometry.
  32361. * @returns the numner of indices or zero if the mesh has no geometry.
  32362. */
  32363. getTotalIndices(): number;
  32364. /**
  32365. * Returns null by default. Implemented by child classes
  32366. * @returns null
  32367. */
  32368. getIndices(): Nullable<IndicesArray>;
  32369. /**
  32370. * Returns the array of the requested vertex data kind. Implemented by child classes
  32371. * @param kind defines the vertex data kind to use
  32372. * @returns null
  32373. */
  32374. getVerticesData(kind: string): Nullable<FloatArray>;
  32375. /**
  32376. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32377. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32378. * Note that a new underlying VertexBuffer object is created each call.
  32379. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32380. * @param kind defines vertex data kind:
  32381. * * VertexBuffer.PositionKind
  32382. * * VertexBuffer.UVKind
  32383. * * VertexBuffer.UV2Kind
  32384. * * VertexBuffer.UV3Kind
  32385. * * VertexBuffer.UV4Kind
  32386. * * VertexBuffer.UV5Kind
  32387. * * VertexBuffer.UV6Kind
  32388. * * VertexBuffer.ColorKind
  32389. * * VertexBuffer.MatricesIndicesKind
  32390. * * VertexBuffer.MatricesIndicesExtraKind
  32391. * * VertexBuffer.MatricesWeightsKind
  32392. * * VertexBuffer.MatricesWeightsExtraKind
  32393. * @param data defines the data source
  32394. * @param updatable defines if the data must be flagged as updatable (or static)
  32395. * @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
  32396. * @returns the current mesh
  32397. */
  32398. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32399. /**
  32400. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32401. * If the mesh has no geometry, it is simply returned as it is.
  32402. * @param kind defines vertex data kind:
  32403. * * VertexBuffer.PositionKind
  32404. * * VertexBuffer.UVKind
  32405. * * VertexBuffer.UV2Kind
  32406. * * VertexBuffer.UV3Kind
  32407. * * VertexBuffer.UV4Kind
  32408. * * VertexBuffer.UV5Kind
  32409. * * VertexBuffer.UV6Kind
  32410. * * VertexBuffer.ColorKind
  32411. * * VertexBuffer.MatricesIndicesKind
  32412. * * VertexBuffer.MatricesIndicesExtraKind
  32413. * * VertexBuffer.MatricesWeightsKind
  32414. * * VertexBuffer.MatricesWeightsExtraKind
  32415. * @param data defines the data source
  32416. * @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
  32417. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32418. * @returns the current mesh
  32419. */
  32420. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32421. /**
  32422. * Sets the mesh indices,
  32423. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32424. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32425. * @param totalVertices Defines the total number of vertices
  32426. * @returns the current mesh
  32427. */
  32428. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32429. /**
  32430. * Gets a boolean indicating if specific vertex data is present
  32431. * @param kind defines the vertex data kind to use
  32432. * @returns true is data kind is present
  32433. */
  32434. isVerticesDataPresent(kind: string): boolean;
  32435. /**
  32436. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32437. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32438. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32439. * @returns a BoundingInfo
  32440. */
  32441. getBoundingInfo(): BoundingInfo;
  32442. /**
  32443. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32444. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32445. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32446. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32447. * @returns the current mesh
  32448. */
  32449. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32450. /**
  32451. * Overwrite the current bounding info
  32452. * @param boundingInfo defines the new bounding info
  32453. * @returns the current mesh
  32454. */
  32455. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32456. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32457. get useBones(): boolean;
  32458. /** @hidden */
  32459. _preActivate(): void;
  32460. /** @hidden */
  32461. _preActivateForIntermediateRendering(renderId: number): void;
  32462. /** @hidden */
  32463. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32464. /** @hidden */
  32465. _postActivate(): void;
  32466. /** @hidden */
  32467. _freeze(): void;
  32468. /** @hidden */
  32469. _unFreeze(): void;
  32470. /**
  32471. * Gets the current world matrix
  32472. * @returns a Matrix
  32473. */
  32474. getWorldMatrix(): Matrix;
  32475. /** @hidden */
  32476. _getWorldMatrixDeterminant(): number;
  32477. /**
  32478. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32479. */
  32480. get isAnInstance(): boolean;
  32481. /**
  32482. * Gets a boolean indicating if this mesh has instances
  32483. */
  32484. get hasInstances(): boolean;
  32485. /**
  32486. * Gets a boolean indicating if this mesh has thin instances
  32487. */
  32488. get hasThinInstances(): boolean;
  32489. /**
  32490. * Perform relative position change from the point of view of behind the front of the mesh.
  32491. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32492. * Supports definition of mesh facing forward or backward
  32493. * @param amountRight defines the distance on the right axis
  32494. * @param amountUp defines the distance on the up axis
  32495. * @param amountForward defines the distance on the forward axis
  32496. * @returns the current mesh
  32497. */
  32498. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32499. /**
  32500. * Calculate relative position change from the point of view of behind the front of the mesh.
  32501. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32502. * Supports definition of mesh facing forward or backward
  32503. * @param amountRight defines the distance on the right axis
  32504. * @param amountUp defines the distance on the up axis
  32505. * @param amountForward defines the distance on the forward axis
  32506. * @returns the new displacement vector
  32507. */
  32508. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32509. /**
  32510. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32511. * Supports definition of mesh facing forward or backward
  32512. * @param flipBack defines the flip
  32513. * @param twirlClockwise defines the twirl
  32514. * @param tiltRight defines the tilt
  32515. * @returns the current mesh
  32516. */
  32517. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32518. /**
  32519. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32520. * Supports definition of mesh facing forward or backward.
  32521. * @param flipBack defines the flip
  32522. * @param twirlClockwise defines the twirl
  32523. * @param tiltRight defines the tilt
  32524. * @returns the new rotation vector
  32525. */
  32526. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32527. /**
  32528. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32529. * This means the mesh underlying bounding box and sphere are recomputed.
  32530. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32531. * @returns the current mesh
  32532. */
  32533. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32534. /** @hidden */
  32535. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32536. /** @hidden */
  32537. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32538. /** @hidden */
  32539. _updateBoundingInfo(): AbstractMesh;
  32540. /** @hidden */
  32541. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32542. /** @hidden */
  32543. protected _afterComputeWorldMatrix(): void;
  32544. /** @hidden */
  32545. get _effectiveMesh(): AbstractMesh;
  32546. /**
  32547. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32548. * A mesh is in the frustum if its bounding box intersects the frustum
  32549. * @param frustumPlanes defines the frustum to test
  32550. * @returns true if the mesh is in the frustum planes
  32551. */
  32552. isInFrustum(frustumPlanes: Plane[]): boolean;
  32553. /**
  32554. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32555. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32556. * @param frustumPlanes defines the frustum to test
  32557. * @returns true if the mesh is completely in the frustum planes
  32558. */
  32559. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32560. /**
  32561. * True if the mesh intersects another mesh or a SolidParticle object
  32562. * @param mesh defines a target mesh or SolidParticle to test
  32563. * @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)
  32564. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32565. * @returns true if there is an intersection
  32566. */
  32567. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32568. /**
  32569. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32570. * @param point defines the point to test
  32571. * @returns true if there is an intersection
  32572. */
  32573. intersectsPoint(point: Vector3): boolean;
  32574. /**
  32575. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32577. */
  32578. get checkCollisions(): boolean;
  32579. set checkCollisions(collisionEnabled: boolean);
  32580. /**
  32581. * Gets Collider object used to compute collisions (not physics)
  32582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32583. */
  32584. get collider(): Nullable<Collider>;
  32585. /**
  32586. * Move the mesh using collision engine
  32587. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32588. * @param displacement defines the requested displacement vector
  32589. * @returns the current mesh
  32590. */
  32591. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32592. private _onCollisionPositionChange;
  32593. /** @hidden */
  32594. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32595. /** @hidden */
  32596. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32597. /** @hidden */
  32598. _checkCollision(collider: Collider): AbstractMesh;
  32599. /** @hidden */
  32600. _generatePointsArray(): boolean;
  32601. /**
  32602. * Checks if the passed Ray intersects with the mesh
  32603. * @param ray defines the ray to use
  32604. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32605. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32606. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32607. * @returns the picking info
  32608. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32609. */
  32610. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32611. /**
  32612. * Clones the current mesh
  32613. * @param name defines the mesh name
  32614. * @param newParent defines the new mesh parent
  32615. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32616. * @returns the new mesh
  32617. */
  32618. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32619. /**
  32620. * Disposes all the submeshes of the current meshnp
  32621. * @returns the current mesh
  32622. */
  32623. releaseSubMeshes(): AbstractMesh;
  32624. /**
  32625. * Releases resources associated with this abstract mesh.
  32626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32628. */
  32629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32630. /**
  32631. * Adds the passed mesh as a child to the current mesh
  32632. * @param mesh defines the child mesh
  32633. * @returns the current mesh
  32634. */
  32635. addChild(mesh: AbstractMesh): AbstractMesh;
  32636. /**
  32637. * Removes the passed mesh from the current mesh children list
  32638. * @param mesh defines the child mesh
  32639. * @returns the current mesh
  32640. */
  32641. removeChild(mesh: AbstractMesh): AbstractMesh;
  32642. /** @hidden */
  32643. private _initFacetData;
  32644. /**
  32645. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32646. * This method can be called within the render loop.
  32647. * 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
  32648. * @returns the current mesh
  32649. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32650. */
  32651. updateFacetData(): AbstractMesh;
  32652. /**
  32653. * Returns the facetLocalNormals array.
  32654. * The normals are expressed in the mesh local spac
  32655. * @returns an array of Vector3
  32656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32657. */
  32658. getFacetLocalNormals(): Vector3[];
  32659. /**
  32660. * Returns the facetLocalPositions array.
  32661. * The facet positions are expressed in the mesh local space
  32662. * @returns an array of Vector3
  32663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32664. */
  32665. getFacetLocalPositions(): Vector3[];
  32666. /**
  32667. * Returns the facetLocalPartioning array
  32668. * @returns an array of array of numbers
  32669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32670. */
  32671. getFacetLocalPartitioning(): number[][];
  32672. /**
  32673. * Returns the i-th facet position in the world system.
  32674. * This method allocates a new Vector3 per call
  32675. * @param i defines the facet index
  32676. * @returns a new Vector3
  32677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32678. */
  32679. getFacetPosition(i: number): Vector3;
  32680. /**
  32681. * Sets the reference Vector3 with the i-th facet position in the world system
  32682. * @param i defines the facet index
  32683. * @param ref defines the target vector
  32684. * @returns the current mesh
  32685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32686. */
  32687. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32688. /**
  32689. * Returns the i-th facet normal in the world system.
  32690. * This method allocates a new Vector3 per call
  32691. * @param i defines the facet index
  32692. * @returns a new Vector3
  32693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32694. */
  32695. getFacetNormal(i: number): Vector3;
  32696. /**
  32697. * Sets the reference Vector3 with the i-th facet normal in the world system
  32698. * @param i defines the facet index
  32699. * @param ref defines the target vector
  32700. * @returns the current mesh
  32701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32702. */
  32703. getFacetNormalToRef(i: number, ref: Vector3): this;
  32704. /**
  32705. * 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)
  32706. * @param x defines x coordinate
  32707. * @param y defines y coordinate
  32708. * @param z defines z coordinate
  32709. * @returns the array of facet indexes
  32710. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32711. */
  32712. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32713. /**
  32714. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32715. * @param projected sets as the (x,y,z) world projection on the facet
  32716. * @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
  32717. * @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
  32718. * @param x defines x coordinate
  32719. * @param y defines y coordinate
  32720. * @param z defines z coordinate
  32721. * @returns the face index if found (or null instead)
  32722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32723. */
  32724. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32725. /**
  32726. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32727. * @param projected sets as the (x,y,z) local projection on the facet
  32728. * @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
  32729. * @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
  32730. * @param x defines x coordinate
  32731. * @param y defines y coordinate
  32732. * @param z defines z coordinate
  32733. * @returns the face index if found (or null instead)
  32734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32735. */
  32736. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32737. /**
  32738. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32739. * @returns the parameters
  32740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32741. */
  32742. getFacetDataParameters(): any;
  32743. /**
  32744. * Disables the feature FacetData and frees the related memory
  32745. * @returns the current mesh
  32746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32747. */
  32748. disableFacetData(): AbstractMesh;
  32749. /**
  32750. * Updates the AbstractMesh indices array
  32751. * @param indices defines the data source
  32752. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32753. * @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)
  32754. * @returns the current mesh
  32755. */
  32756. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32757. /**
  32758. * Creates new normals data for the mesh
  32759. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32760. * @returns the current mesh
  32761. */
  32762. createNormals(updatable: boolean): AbstractMesh;
  32763. /**
  32764. * Align the mesh with a normal
  32765. * @param normal defines the normal to use
  32766. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32767. * @returns the current mesh
  32768. */
  32769. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32770. /** @hidden */
  32771. _checkOcclusionQuery(): boolean;
  32772. /**
  32773. * Disables the mesh edge rendering mode
  32774. * @returns the currentAbstractMesh
  32775. */
  32776. disableEdgesRendering(): AbstractMesh;
  32777. /**
  32778. * Enables the edge rendering mode on the mesh.
  32779. * This mode makes the mesh edges visible
  32780. * @param epsilon defines the maximal distance between two angles to detect a face
  32781. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32782. * @returns the currentAbstractMesh
  32783. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32784. */
  32785. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32786. }
  32787. }
  32788. declare module "babylonjs/Actions/actionEvent" {
  32789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32790. import { Nullable } from "babylonjs/types";
  32791. import { Sprite } from "babylonjs/Sprites/sprite";
  32792. import { Scene } from "babylonjs/scene";
  32793. import { Vector2 } from "babylonjs/Maths/math.vector";
  32794. /**
  32795. * Interface used to define ActionEvent
  32796. */
  32797. export interface IActionEvent {
  32798. /** The mesh or sprite that triggered the action */
  32799. source: any;
  32800. /** The X mouse cursor position at the time of the event */
  32801. pointerX: number;
  32802. /** The Y mouse cursor position at the time of the event */
  32803. pointerY: number;
  32804. /** The mesh that is currently pointed at (can be null) */
  32805. meshUnderPointer: Nullable<AbstractMesh>;
  32806. /** the original (browser) event that triggered the ActionEvent */
  32807. sourceEvent?: any;
  32808. /** additional data for the event */
  32809. additionalData?: any;
  32810. }
  32811. /**
  32812. * ActionEvent is the event being sent when an action is triggered.
  32813. */
  32814. export class ActionEvent implements IActionEvent {
  32815. /** The mesh or sprite that triggered the action */
  32816. source: any;
  32817. /** The X mouse cursor position at the time of the event */
  32818. pointerX: number;
  32819. /** The Y mouse cursor position at the time of the event */
  32820. pointerY: number;
  32821. /** The mesh that is currently pointed at (can be null) */
  32822. meshUnderPointer: Nullable<AbstractMesh>;
  32823. /** the original (browser) event that triggered the ActionEvent */
  32824. sourceEvent?: any;
  32825. /** additional data for the event */
  32826. additionalData?: any;
  32827. /**
  32828. * Creates a new ActionEvent
  32829. * @param source The mesh or sprite that triggered the action
  32830. * @param pointerX The X mouse cursor position at the time of the event
  32831. * @param pointerY The Y mouse cursor position at the time of the event
  32832. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32833. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32834. * @param additionalData additional data for the event
  32835. */
  32836. constructor(
  32837. /** The mesh or sprite that triggered the action */
  32838. source: any,
  32839. /** The X mouse cursor position at the time of the event */
  32840. pointerX: number,
  32841. /** The Y mouse cursor position at the time of the event */
  32842. pointerY: number,
  32843. /** The mesh that is currently pointed at (can be null) */
  32844. meshUnderPointer: Nullable<AbstractMesh>,
  32845. /** the original (browser) event that triggered the ActionEvent */
  32846. sourceEvent?: any,
  32847. /** additional data for the event */
  32848. additionalData?: any);
  32849. /**
  32850. * Helper function to auto-create an ActionEvent from a source mesh.
  32851. * @param source The source mesh that triggered the event
  32852. * @param evt The original (browser) event
  32853. * @param additionalData additional data for the event
  32854. * @returns the new ActionEvent
  32855. */
  32856. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32857. /**
  32858. * Helper function to auto-create an ActionEvent from a source sprite
  32859. * @param source The source sprite that triggered the event
  32860. * @param scene Scene associated with the sprite
  32861. * @param evt The original (browser) event
  32862. * @param additionalData additional data for the event
  32863. * @returns the new ActionEvent
  32864. */
  32865. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32866. /**
  32867. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32868. * @param scene the scene where the event occurred
  32869. * @param evt The original (browser) event
  32870. * @returns the new ActionEvent
  32871. */
  32872. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32873. /**
  32874. * Helper function to auto-create an ActionEvent from a primitive
  32875. * @param prim defines the target primitive
  32876. * @param pointerPos defines the pointer position
  32877. * @param evt The original (browser) event
  32878. * @param additionalData additional data for the event
  32879. * @returns the new ActionEvent
  32880. */
  32881. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32882. }
  32883. }
  32884. declare module "babylonjs/Actions/abstractActionManager" {
  32885. import { IDisposable } from "babylonjs/scene";
  32886. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32887. import { IAction } from "babylonjs/Actions/action";
  32888. import { Nullable } from "babylonjs/types";
  32889. /**
  32890. * Abstract class used to decouple action Manager from scene and meshes.
  32891. * Do not instantiate.
  32892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32893. */
  32894. export abstract class AbstractActionManager implements IDisposable {
  32895. /** Gets the list of active triggers */
  32896. static Triggers: {
  32897. [key: string]: number;
  32898. };
  32899. /** Gets the cursor to use when hovering items */
  32900. hoverCursor: string;
  32901. /** Gets the list of actions */
  32902. actions: IAction[];
  32903. /**
  32904. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32905. */
  32906. isRecursive: boolean;
  32907. /**
  32908. * Releases all associated resources
  32909. */
  32910. abstract dispose(): void;
  32911. /**
  32912. * Does this action manager has pointer triggers
  32913. */
  32914. abstract get hasPointerTriggers(): boolean;
  32915. /**
  32916. * Does this action manager has pick triggers
  32917. */
  32918. abstract get hasPickTriggers(): boolean;
  32919. /**
  32920. * Process a specific trigger
  32921. * @param trigger defines the trigger to process
  32922. * @param evt defines the event details to be processed
  32923. */
  32924. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32925. /**
  32926. * Does this action manager handles actions of any of the given triggers
  32927. * @param triggers defines the triggers to be tested
  32928. * @return a boolean indicating whether one (or more) of the triggers is handled
  32929. */
  32930. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32931. /**
  32932. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32933. * speed.
  32934. * @param triggerA defines the trigger to be tested
  32935. * @param triggerB defines the trigger to be tested
  32936. * @return a boolean indicating whether one (or more) of the triggers is handled
  32937. */
  32938. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32939. /**
  32940. * Does this action manager handles actions of a given trigger
  32941. * @param trigger defines the trigger to be tested
  32942. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32943. * @return whether the trigger is handled
  32944. */
  32945. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32946. /**
  32947. * Serialize this manager to a JSON object
  32948. * @param name defines the property name to store this manager
  32949. * @returns a JSON representation of this manager
  32950. */
  32951. abstract serialize(name: string): any;
  32952. /**
  32953. * Registers an action to this action manager
  32954. * @param action defines the action to be registered
  32955. * @return the action amended (prepared) after registration
  32956. */
  32957. abstract registerAction(action: IAction): Nullable<IAction>;
  32958. /**
  32959. * Unregisters an action to this action manager
  32960. * @param action defines the action to be unregistered
  32961. * @return a boolean indicating whether the action has been unregistered
  32962. */
  32963. abstract unregisterAction(action: IAction): Boolean;
  32964. /**
  32965. * Does exist one action manager with at least one trigger
  32966. **/
  32967. static get HasTriggers(): boolean;
  32968. /**
  32969. * Does exist one action manager with at least one pick trigger
  32970. **/
  32971. static get HasPickTriggers(): boolean;
  32972. /**
  32973. * Does exist one action manager that handles actions of a given trigger
  32974. * @param trigger defines the trigger to be tested
  32975. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32976. **/
  32977. static HasSpecificTrigger(trigger: number): boolean;
  32978. }
  32979. }
  32980. declare module "babylonjs/node" {
  32981. import { Scene } from "babylonjs/scene";
  32982. import { Nullable } from "babylonjs/types";
  32983. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  32984. import { Engine } from "babylonjs/Engines/engine";
  32985. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  32986. import { Observable } from "babylonjs/Misc/observable";
  32987. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32988. import { IInspectable } from "babylonjs/Misc/iInspectable";
  32989. import { Animatable } from "babylonjs/Animations/animatable";
  32990. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32991. import { Animation } from "babylonjs/Animations/animation";
  32992. import { AnimationRange } from "babylonjs/Animations/animationRange";
  32993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32994. /**
  32995. * Defines how a node can be built from a string name.
  32996. */
  32997. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32998. /**
  32999. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33000. */
  33001. export class Node implements IBehaviorAware<Node> {
  33002. /** @hidden */
  33003. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  33004. private static _NodeConstructors;
  33005. /**
  33006. * Add a new node constructor
  33007. * @param type defines the type name of the node to construct
  33008. * @param constructorFunc defines the constructor function
  33009. */
  33010. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33011. /**
  33012. * Returns a node constructor based on type name
  33013. * @param type defines the type name
  33014. * @param name defines the new node name
  33015. * @param scene defines the hosting scene
  33016. * @param options defines optional options to transmit to constructors
  33017. * @returns the new constructor or null
  33018. */
  33019. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33020. /**
  33021. * Gets or sets the name of the node
  33022. */
  33023. name: string;
  33024. /**
  33025. * Gets or sets the id of the node
  33026. */
  33027. id: string;
  33028. /**
  33029. * Gets or sets the unique id of the node
  33030. */
  33031. uniqueId: number;
  33032. /**
  33033. * Gets or sets a string used to store user defined state for the node
  33034. */
  33035. state: string;
  33036. /**
  33037. * Gets or sets an object used to store user defined information for the node
  33038. */
  33039. metadata: any;
  33040. /**
  33041. * For internal use only. Please do not use.
  33042. */
  33043. reservedDataStore: any;
  33044. /**
  33045. * List of inspectable custom properties (used by the Inspector)
  33046. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33047. */
  33048. inspectableCustomProperties: IInspectable[];
  33049. private _doNotSerialize;
  33050. /**
  33051. * Gets or sets a boolean used to define if the node must be serialized
  33052. */
  33053. get doNotSerialize(): boolean;
  33054. set doNotSerialize(value: boolean);
  33055. /** @hidden */
  33056. _isDisposed: boolean;
  33057. /**
  33058. * Gets a list of Animations associated with the node
  33059. */
  33060. animations: import("babylonjs/Animations/animation").Animation[];
  33061. protected _ranges: {
  33062. [name: string]: Nullable<AnimationRange>;
  33063. };
  33064. /**
  33065. * Callback raised when the node is ready to be used
  33066. */
  33067. onReady: Nullable<(node: Node) => void>;
  33068. private _isEnabled;
  33069. private _isParentEnabled;
  33070. private _isReady;
  33071. /** @hidden */
  33072. _currentRenderId: number;
  33073. private _parentUpdateId;
  33074. /** @hidden */
  33075. _childUpdateId: number;
  33076. /** @hidden */
  33077. _waitingParentId: Nullable<string>;
  33078. /** @hidden */
  33079. _scene: Scene;
  33080. /** @hidden */
  33081. _cache: any;
  33082. private _parentNode;
  33083. private _children;
  33084. /** @hidden */
  33085. _worldMatrix: Matrix;
  33086. /** @hidden */
  33087. _worldMatrixDeterminant: number;
  33088. /** @hidden */
  33089. _worldMatrixDeterminantIsDirty: boolean;
  33090. /** @hidden */
  33091. private _sceneRootNodesIndex;
  33092. /**
  33093. * Gets a boolean indicating if the node has been disposed
  33094. * @returns true if the node was disposed
  33095. */
  33096. isDisposed(): boolean;
  33097. /**
  33098. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33099. * @see https://doc.babylonjs.com/how_to/parenting
  33100. */
  33101. set parent(parent: Nullable<Node>);
  33102. get parent(): Nullable<Node>;
  33103. /** @hidden */
  33104. _addToSceneRootNodes(): void;
  33105. /** @hidden */
  33106. _removeFromSceneRootNodes(): void;
  33107. private _animationPropertiesOverride;
  33108. /**
  33109. * Gets or sets the animation properties override
  33110. */
  33111. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33112. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33113. /**
  33114. * Gets a string idenfifying the name of the class
  33115. * @returns "Node" string
  33116. */
  33117. getClassName(): string;
  33118. /** @hidden */
  33119. readonly _isNode: boolean;
  33120. /**
  33121. * An event triggered when the mesh is disposed
  33122. */
  33123. onDisposeObservable: Observable<Node>;
  33124. private _onDisposeObserver;
  33125. /**
  33126. * Sets a callback that will be raised when the node will be disposed
  33127. */
  33128. set onDispose(callback: () => void);
  33129. /**
  33130. * Creates a new Node
  33131. * @param name the name and id to be given to this node
  33132. * @param scene the scene this node will be added to
  33133. */
  33134. constructor(name: string, scene?: Nullable<Scene>);
  33135. /**
  33136. * Gets the scene of the node
  33137. * @returns a scene
  33138. */
  33139. getScene(): Scene;
  33140. /**
  33141. * Gets the engine of the node
  33142. * @returns a Engine
  33143. */
  33144. getEngine(): Engine;
  33145. private _behaviors;
  33146. /**
  33147. * Attach a behavior to the node
  33148. * @see http://doc.babylonjs.com/features/behaviour
  33149. * @param behavior defines the behavior to attach
  33150. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33151. * @returns the current Node
  33152. */
  33153. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33154. /**
  33155. * Remove an attached behavior
  33156. * @see http://doc.babylonjs.com/features/behaviour
  33157. * @param behavior defines the behavior to attach
  33158. * @returns the current Node
  33159. */
  33160. removeBehavior(behavior: Behavior<Node>): Node;
  33161. /**
  33162. * Gets the list of attached behaviors
  33163. * @see http://doc.babylonjs.com/features/behaviour
  33164. */
  33165. get behaviors(): Behavior<Node>[];
  33166. /**
  33167. * Gets an attached behavior by name
  33168. * @param name defines the name of the behavior to look for
  33169. * @see http://doc.babylonjs.com/features/behaviour
  33170. * @returns null if behavior was not found else the requested behavior
  33171. */
  33172. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33173. /**
  33174. * Returns the latest update of the World matrix
  33175. * @returns a Matrix
  33176. */
  33177. getWorldMatrix(): Matrix;
  33178. /** @hidden */
  33179. _getWorldMatrixDeterminant(): number;
  33180. /**
  33181. * Returns directly the latest state of the mesh World matrix.
  33182. * A Matrix is returned.
  33183. */
  33184. get worldMatrixFromCache(): Matrix;
  33185. /** @hidden */
  33186. _initCache(): void;
  33187. /** @hidden */
  33188. updateCache(force?: boolean): void;
  33189. /** @hidden */
  33190. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33191. /** @hidden */
  33192. _updateCache(ignoreParentClass?: boolean): void;
  33193. /** @hidden */
  33194. _isSynchronized(): boolean;
  33195. /** @hidden */
  33196. _markSyncedWithParent(): void;
  33197. /** @hidden */
  33198. isSynchronizedWithParent(): boolean;
  33199. /** @hidden */
  33200. isSynchronized(): boolean;
  33201. /**
  33202. * Is this node ready to be used/rendered
  33203. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33204. * @return true if the node is ready
  33205. */
  33206. isReady(completeCheck?: boolean): boolean;
  33207. /**
  33208. * Is this node enabled?
  33209. * 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
  33210. * @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
  33211. * @return whether this node (and its parent) is enabled
  33212. */
  33213. isEnabled(checkAncestors?: boolean): boolean;
  33214. /** @hidden */
  33215. protected _syncParentEnabledState(): void;
  33216. /**
  33217. * Set the enabled state of this node
  33218. * @param value defines the new enabled state
  33219. */
  33220. setEnabled(value: boolean): void;
  33221. /**
  33222. * Is this node a descendant of the given node?
  33223. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33224. * @param ancestor defines the parent node to inspect
  33225. * @returns a boolean indicating if this node is a descendant of the given node
  33226. */
  33227. isDescendantOf(ancestor: Node): boolean;
  33228. /** @hidden */
  33229. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33230. /**
  33231. * Will return all nodes that have this node as ascendant
  33232. * @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
  33233. * @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
  33234. * @return all children nodes of all types
  33235. */
  33236. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33237. /**
  33238. * Get all child-meshes of this node
  33239. * @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)
  33240. * @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
  33241. * @returns an array of AbstractMesh
  33242. */
  33243. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33244. /**
  33245. * Get all direct children of this node
  33246. * @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
  33247. * @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)
  33248. * @returns an array of Node
  33249. */
  33250. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33251. /** @hidden */
  33252. _setReady(state: boolean): void;
  33253. /**
  33254. * Get an animation by name
  33255. * @param name defines the name of the animation to look for
  33256. * @returns null if not found else the requested animation
  33257. */
  33258. getAnimationByName(name: string): Nullable<Animation>;
  33259. /**
  33260. * Creates an animation range for this node
  33261. * @param name defines the name of the range
  33262. * @param from defines the starting key
  33263. * @param to defines the end key
  33264. */
  33265. createAnimationRange(name: string, from: number, to: number): void;
  33266. /**
  33267. * Delete a specific animation range
  33268. * @param name defines the name of the range to delete
  33269. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33270. */
  33271. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33272. /**
  33273. * Get an animation range by name
  33274. * @param name defines the name of the animation range to look for
  33275. * @returns null if not found else the requested animation range
  33276. */
  33277. getAnimationRange(name: string): Nullable<AnimationRange>;
  33278. /**
  33279. * Gets the list of all animation ranges defined on this node
  33280. * @returns an array
  33281. */
  33282. getAnimationRanges(): Nullable<AnimationRange>[];
  33283. /**
  33284. * Will start the animation sequence
  33285. * @param name defines the range frames for animation sequence
  33286. * @param loop defines if the animation should loop (false by default)
  33287. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33288. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33289. * @returns the object created for this animation. If range does not exist, it will return null
  33290. */
  33291. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33292. /**
  33293. * Serialize animation ranges into a JSON compatible object
  33294. * @returns serialization object
  33295. */
  33296. serializeAnimationRanges(): any;
  33297. /**
  33298. * Computes the world matrix of the node
  33299. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33300. * @returns the world matrix
  33301. */
  33302. computeWorldMatrix(force?: boolean): Matrix;
  33303. /**
  33304. * Releases resources associated with this node.
  33305. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33306. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33307. */
  33308. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33309. /**
  33310. * Parse animation range data from a serialization object and store them into a given node
  33311. * @param node defines where to store the animation ranges
  33312. * @param parsedNode defines the serialization object to read data from
  33313. * @param scene defines the hosting scene
  33314. */
  33315. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33316. /**
  33317. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33318. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33319. * @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
  33320. * @returns the new bounding vectors
  33321. */
  33322. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33323. min: Vector3;
  33324. max: Vector3;
  33325. };
  33326. }
  33327. }
  33328. declare module "babylonjs/Animations/animation" {
  33329. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33330. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33331. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33332. import { Nullable } from "babylonjs/types";
  33333. import { Scene } from "babylonjs/scene";
  33334. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33335. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33336. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33337. import { Node } from "babylonjs/node";
  33338. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33339. import { Size } from "babylonjs/Maths/math.size";
  33340. import { Animatable } from "babylonjs/Animations/animatable";
  33341. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33342. /**
  33343. * @hidden
  33344. */
  33345. export class _IAnimationState {
  33346. key: number;
  33347. repeatCount: number;
  33348. workValue?: any;
  33349. loopMode?: number;
  33350. offsetValue?: any;
  33351. highLimitValue?: any;
  33352. }
  33353. /**
  33354. * Class used to store any kind of animation
  33355. */
  33356. export class Animation {
  33357. /**Name of the animation */
  33358. name: string;
  33359. /**Property to animate */
  33360. targetProperty: string;
  33361. /**The frames per second of the animation */
  33362. framePerSecond: number;
  33363. /**The data type of the animation */
  33364. dataType: number;
  33365. /**The loop mode of the animation */
  33366. loopMode?: number | undefined;
  33367. /**Specifies if blending should be enabled */
  33368. enableBlending?: boolean | undefined;
  33369. /**
  33370. * Use matrix interpolation instead of using direct key value when animating matrices
  33371. */
  33372. static AllowMatricesInterpolation: boolean;
  33373. /**
  33374. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33375. */
  33376. static AllowMatrixDecomposeForInterpolation: boolean;
  33377. /** Define the Url to load snippets */
  33378. static SnippetUrl: string;
  33379. /** Snippet ID if the animation was created from the snippet server */
  33380. snippetId: string;
  33381. /**
  33382. * Stores the key frames of the animation
  33383. */
  33384. private _keys;
  33385. /**
  33386. * Stores the easing function of the animation
  33387. */
  33388. private _easingFunction;
  33389. /**
  33390. * @hidden Internal use only
  33391. */
  33392. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33393. /**
  33394. * The set of event that will be linked to this animation
  33395. */
  33396. private _events;
  33397. /**
  33398. * Stores an array of target property paths
  33399. */
  33400. targetPropertyPath: string[];
  33401. /**
  33402. * Stores the blending speed of the animation
  33403. */
  33404. blendingSpeed: number;
  33405. /**
  33406. * Stores the animation ranges for the animation
  33407. */
  33408. private _ranges;
  33409. /**
  33410. * @hidden Internal use
  33411. */
  33412. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33413. /**
  33414. * Sets up an animation
  33415. * @param property The property to animate
  33416. * @param animationType The animation type to apply
  33417. * @param framePerSecond The frames per second of the animation
  33418. * @param easingFunction The easing function used in the animation
  33419. * @returns The created animation
  33420. */
  33421. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33422. /**
  33423. * Create and start an animation on a node
  33424. * @param name defines the name of the global animation that will be run on all nodes
  33425. * @param node defines the root node where the animation will take place
  33426. * @param targetProperty defines property to animate
  33427. * @param framePerSecond defines the number of frame per second yo use
  33428. * @param totalFrame defines the number of frames in total
  33429. * @param from defines the initial value
  33430. * @param to defines the final value
  33431. * @param loopMode defines which loop mode you want to use (off by default)
  33432. * @param easingFunction defines the easing function to use (linear by default)
  33433. * @param onAnimationEnd defines the callback to call when animation end
  33434. * @returns the animatable created for this animation
  33435. */
  33436. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33437. /**
  33438. * Create and start an animation on a node and its descendants
  33439. * @param name defines the name of the global animation that will be run on all nodes
  33440. * @param node defines the root node where the animation will take place
  33441. * @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
  33442. * @param targetProperty defines property to animate
  33443. * @param framePerSecond defines the number of frame per second to use
  33444. * @param totalFrame defines the number of frames in total
  33445. * @param from defines the initial value
  33446. * @param to defines the final value
  33447. * @param loopMode defines which loop mode you want to use (off by default)
  33448. * @param easingFunction defines the easing function to use (linear by default)
  33449. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33450. * @returns the list of animatables created for all nodes
  33451. * @example https://www.babylonjs-playground.com/#MH0VLI
  33452. */
  33453. 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[]>;
  33454. /**
  33455. * Creates a new animation, merges it with the existing animations and starts it
  33456. * @param name Name of the animation
  33457. * @param node Node which contains the scene that begins the animations
  33458. * @param targetProperty Specifies which property to animate
  33459. * @param framePerSecond The frames per second of the animation
  33460. * @param totalFrame The total number of frames
  33461. * @param from The frame at the beginning of the animation
  33462. * @param to The frame at the end of the animation
  33463. * @param loopMode Specifies the loop mode of the animation
  33464. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33465. * @param onAnimationEnd Callback to run once the animation is complete
  33466. * @returns Nullable animation
  33467. */
  33468. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33469. /**
  33470. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33471. * @param sourceAnimation defines the Animation containing keyframes to convert
  33472. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33473. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33474. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33475. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33476. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33477. */
  33478. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33479. /**
  33480. * Transition property of an host to the target Value
  33481. * @param property The property to transition
  33482. * @param targetValue The target Value of the property
  33483. * @param host The object where the property to animate belongs
  33484. * @param scene Scene used to run the animation
  33485. * @param frameRate Framerate (in frame/s) to use
  33486. * @param transition The transition type we want to use
  33487. * @param duration The duration of the animation, in milliseconds
  33488. * @param onAnimationEnd Callback trigger at the end of the animation
  33489. * @returns Nullable animation
  33490. */
  33491. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33492. /**
  33493. * Return the array of runtime animations currently using this animation
  33494. */
  33495. get runtimeAnimations(): RuntimeAnimation[];
  33496. /**
  33497. * Specifies if any of the runtime animations are currently running
  33498. */
  33499. get hasRunningRuntimeAnimations(): boolean;
  33500. /**
  33501. * Initializes the animation
  33502. * @param name Name of the animation
  33503. * @param targetProperty Property to animate
  33504. * @param framePerSecond The frames per second of the animation
  33505. * @param dataType The data type of the animation
  33506. * @param loopMode The loop mode of the animation
  33507. * @param enableBlending Specifies if blending should be enabled
  33508. */
  33509. constructor(
  33510. /**Name of the animation */
  33511. name: string,
  33512. /**Property to animate */
  33513. targetProperty: string,
  33514. /**The frames per second of the animation */
  33515. framePerSecond: number,
  33516. /**The data type of the animation */
  33517. dataType: number,
  33518. /**The loop mode of the animation */
  33519. loopMode?: number | undefined,
  33520. /**Specifies if blending should be enabled */
  33521. enableBlending?: boolean | undefined);
  33522. /**
  33523. * Converts the animation to a string
  33524. * @param fullDetails support for multiple levels of logging within scene loading
  33525. * @returns String form of the animation
  33526. */
  33527. toString(fullDetails?: boolean): string;
  33528. /**
  33529. * Add an event to this animation
  33530. * @param event Event to add
  33531. */
  33532. addEvent(event: AnimationEvent): void;
  33533. /**
  33534. * Remove all events found at the given frame
  33535. * @param frame The frame to remove events from
  33536. */
  33537. removeEvents(frame: number): void;
  33538. /**
  33539. * Retrieves all the events from the animation
  33540. * @returns Events from the animation
  33541. */
  33542. getEvents(): AnimationEvent[];
  33543. /**
  33544. * Creates an animation range
  33545. * @param name Name of the animation range
  33546. * @param from Starting frame of the animation range
  33547. * @param to Ending frame of the animation
  33548. */
  33549. createRange(name: string, from: number, to: number): void;
  33550. /**
  33551. * Deletes an animation range by name
  33552. * @param name Name of the animation range to delete
  33553. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33554. */
  33555. deleteRange(name: string, deleteFrames?: boolean): void;
  33556. /**
  33557. * Gets the animation range by name, or null if not defined
  33558. * @param name Name of the animation range
  33559. * @returns Nullable animation range
  33560. */
  33561. getRange(name: string): Nullable<AnimationRange>;
  33562. /**
  33563. * Gets the key frames from the animation
  33564. * @returns The key frames of the animation
  33565. */
  33566. getKeys(): Array<IAnimationKey>;
  33567. /**
  33568. * Gets the highest frame rate of the animation
  33569. * @returns Highest frame rate of the animation
  33570. */
  33571. getHighestFrame(): number;
  33572. /**
  33573. * Gets the easing function of the animation
  33574. * @returns Easing function of the animation
  33575. */
  33576. getEasingFunction(): IEasingFunction;
  33577. /**
  33578. * Sets the easing function of the animation
  33579. * @param easingFunction A custom mathematical formula for animation
  33580. */
  33581. setEasingFunction(easingFunction: EasingFunction): void;
  33582. /**
  33583. * Interpolates a scalar linearly
  33584. * @param startValue Start value of the animation curve
  33585. * @param endValue End value of the animation curve
  33586. * @param gradient Scalar amount to interpolate
  33587. * @returns Interpolated scalar value
  33588. */
  33589. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33590. /**
  33591. * Interpolates a scalar cubically
  33592. * @param startValue Start value of the animation curve
  33593. * @param outTangent End tangent of the animation
  33594. * @param endValue End value of the animation curve
  33595. * @param inTangent Start tangent of the animation curve
  33596. * @param gradient Scalar amount to interpolate
  33597. * @returns Interpolated scalar value
  33598. */
  33599. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33600. /**
  33601. * Interpolates a quaternion using a spherical linear interpolation
  33602. * @param startValue Start value of the animation curve
  33603. * @param endValue End value of the animation curve
  33604. * @param gradient Scalar amount to interpolate
  33605. * @returns Interpolated quaternion value
  33606. */
  33607. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33608. /**
  33609. * Interpolates a quaternion cubically
  33610. * @param startValue Start value of the animation curve
  33611. * @param outTangent End tangent of the animation curve
  33612. * @param endValue End value of the animation curve
  33613. * @param inTangent Start tangent of the animation curve
  33614. * @param gradient Scalar amount to interpolate
  33615. * @returns Interpolated quaternion value
  33616. */
  33617. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33618. /**
  33619. * Interpolates a Vector3 linearl
  33620. * @param startValue Start value of the animation curve
  33621. * @param endValue End value of the animation curve
  33622. * @param gradient Scalar amount to interpolate
  33623. * @returns Interpolated scalar value
  33624. */
  33625. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33626. /**
  33627. * Interpolates a Vector3 cubically
  33628. * @param startValue Start value of the animation curve
  33629. * @param outTangent End tangent of the animation
  33630. * @param endValue End value of the animation curve
  33631. * @param inTangent Start tangent of the animation curve
  33632. * @param gradient Scalar amount to interpolate
  33633. * @returns InterpolatedVector3 value
  33634. */
  33635. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33636. /**
  33637. * Interpolates a Vector2 linearly
  33638. * @param startValue Start value of the animation curve
  33639. * @param endValue End value of the animation curve
  33640. * @param gradient Scalar amount to interpolate
  33641. * @returns Interpolated Vector2 value
  33642. */
  33643. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33644. /**
  33645. * Interpolates a Vector2 cubically
  33646. * @param startValue Start value of the animation curve
  33647. * @param outTangent End tangent of the animation
  33648. * @param endValue End value of the animation curve
  33649. * @param inTangent Start tangent of the animation curve
  33650. * @param gradient Scalar amount to interpolate
  33651. * @returns Interpolated Vector2 value
  33652. */
  33653. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33654. /**
  33655. * Interpolates a size linearly
  33656. * @param startValue Start value of the animation curve
  33657. * @param endValue End value of the animation curve
  33658. * @param gradient Scalar amount to interpolate
  33659. * @returns Interpolated Size value
  33660. */
  33661. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33662. /**
  33663. * Interpolates a Color3 linearly
  33664. * @param startValue Start value of the animation curve
  33665. * @param endValue End value of the animation curve
  33666. * @param gradient Scalar amount to interpolate
  33667. * @returns Interpolated Color3 value
  33668. */
  33669. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33670. /**
  33671. * Interpolates a Color4 linearly
  33672. * @param startValue Start value of the animation curve
  33673. * @param endValue End value of the animation curve
  33674. * @param gradient Scalar amount to interpolate
  33675. * @returns Interpolated Color3 value
  33676. */
  33677. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33678. /**
  33679. * @hidden Internal use only
  33680. */
  33681. _getKeyValue(value: any): any;
  33682. /**
  33683. * @hidden Internal use only
  33684. */
  33685. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33686. /**
  33687. * Defines the function to use to interpolate matrices
  33688. * @param startValue defines the start matrix
  33689. * @param endValue defines the end matrix
  33690. * @param gradient defines the gradient between both matrices
  33691. * @param result defines an optional target matrix where to store the interpolation
  33692. * @returns the interpolated matrix
  33693. */
  33694. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33695. /**
  33696. * Makes a copy of the animation
  33697. * @returns Cloned animation
  33698. */
  33699. clone(): Animation;
  33700. /**
  33701. * Sets the key frames of the animation
  33702. * @param values The animation key frames to set
  33703. */
  33704. setKeys(values: Array<IAnimationKey>): void;
  33705. /**
  33706. * Serializes the animation to an object
  33707. * @returns Serialized object
  33708. */
  33709. serialize(): any;
  33710. /**
  33711. * Float animation type
  33712. */
  33713. static readonly ANIMATIONTYPE_FLOAT: number;
  33714. /**
  33715. * Vector3 animation type
  33716. */
  33717. static readonly ANIMATIONTYPE_VECTOR3: number;
  33718. /**
  33719. * Quaternion animation type
  33720. */
  33721. static readonly ANIMATIONTYPE_QUATERNION: number;
  33722. /**
  33723. * Matrix animation type
  33724. */
  33725. static readonly ANIMATIONTYPE_MATRIX: number;
  33726. /**
  33727. * Color3 animation type
  33728. */
  33729. static readonly ANIMATIONTYPE_COLOR3: number;
  33730. /**
  33731. * Color3 animation type
  33732. */
  33733. static readonly ANIMATIONTYPE_COLOR4: number;
  33734. /**
  33735. * Vector2 animation type
  33736. */
  33737. static readonly ANIMATIONTYPE_VECTOR2: number;
  33738. /**
  33739. * Size animation type
  33740. */
  33741. static readonly ANIMATIONTYPE_SIZE: number;
  33742. /**
  33743. * Relative Loop Mode
  33744. */
  33745. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33746. /**
  33747. * Cycle Loop Mode
  33748. */
  33749. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33750. /**
  33751. * Constant Loop Mode
  33752. */
  33753. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33754. /** @hidden */
  33755. static _UniversalLerp(left: any, right: any, amount: number): any;
  33756. /**
  33757. * Parses an animation object and creates an animation
  33758. * @param parsedAnimation Parsed animation object
  33759. * @returns Animation object
  33760. */
  33761. static Parse(parsedAnimation: any): Animation;
  33762. /**
  33763. * Appends the serialized animations from the source animations
  33764. * @param source Source containing the animations
  33765. * @param destination Target to store the animations
  33766. */
  33767. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33768. /**
  33769. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33770. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33771. * @param url defines the url to load from
  33772. * @returns a promise that will resolve to the new animation or an array of animations
  33773. */
  33774. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33775. /**
  33776. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33777. * @param snippetId defines the snippet to load
  33778. * @returns a promise that will resolve to the new animation or a new array of animations
  33779. */
  33780. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33781. }
  33782. }
  33783. declare module "babylonjs/Animations/animatable.interface" {
  33784. import { Nullable } from "babylonjs/types";
  33785. import { Animation } from "babylonjs/Animations/animation";
  33786. /**
  33787. * Interface containing an array of animations
  33788. */
  33789. export interface IAnimatable {
  33790. /**
  33791. * Array of animations
  33792. */
  33793. animations: Nullable<Array<Animation>>;
  33794. }
  33795. }
  33796. declare module "babylonjs/Misc/decorators" {
  33797. import { Nullable } from "babylonjs/types";
  33798. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33799. import { Scene } from "babylonjs/scene";
  33800. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33801. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33802. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33803. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33804. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33805. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33806. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33807. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33808. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33809. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33810. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33811. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33812. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33813. /**
  33814. * Decorator used to define property that can be serialized as reference to a camera
  33815. * @param sourceName defines the name of the property to decorate
  33816. */
  33817. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33818. /**
  33819. * Class used to help serialization objects
  33820. */
  33821. export class SerializationHelper {
  33822. /** @hidden */
  33823. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33824. /** @hidden */
  33825. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33826. /** @hidden */
  33827. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33828. /** @hidden */
  33829. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33830. /**
  33831. * Appends the serialized animations from the source animations
  33832. * @param source Source containing the animations
  33833. * @param destination Target to store the animations
  33834. */
  33835. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33836. /**
  33837. * Static function used to serialized a specific entity
  33838. * @param entity defines the entity to serialize
  33839. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33840. * @returns a JSON compatible object representing the serialization of the entity
  33841. */
  33842. static Serialize<T>(entity: T, serializationObject?: any): any;
  33843. /**
  33844. * Creates a new entity from a serialization data object
  33845. * @param creationFunction defines a function used to instanciated the new entity
  33846. * @param source defines the source serialization data
  33847. * @param scene defines the hosting scene
  33848. * @param rootUrl defines the root url for resources
  33849. * @returns a new entity
  33850. */
  33851. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33852. /**
  33853. * Clones an object
  33854. * @param creationFunction defines the function used to instanciate the new object
  33855. * @param source defines the source object
  33856. * @returns the cloned object
  33857. */
  33858. static Clone<T>(creationFunction: () => T, source: T): T;
  33859. /**
  33860. * Instanciates a new object based on a source one (some data will be shared between both object)
  33861. * @param creationFunction defines the function used to instanciate the new object
  33862. * @param source defines the source object
  33863. * @returns the new object
  33864. */
  33865. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33866. }
  33867. }
  33868. declare module "babylonjs/Materials/Textures/baseTexture" {
  33869. import { Observable } from "babylonjs/Misc/observable";
  33870. import { Nullable } from "babylonjs/types";
  33871. import { Scene } from "babylonjs/scene";
  33872. import { Matrix } from "babylonjs/Maths/math.vector";
  33873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33875. import { ISize } from "babylonjs/Maths/math.size";
  33876. import "babylonjs/Misc/fileTools";
  33877. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33878. /**
  33879. * Base class of all the textures in babylon.
  33880. * It groups all the common properties the materials, post process, lights... might need
  33881. * in order to make a correct use of the texture.
  33882. */
  33883. export class BaseTexture implements IAnimatable {
  33884. /**
  33885. * Default anisotropic filtering level for the application.
  33886. * It is set to 4 as a good tradeoff between perf and quality.
  33887. */
  33888. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33889. /**
  33890. * Gets or sets the unique id of the texture
  33891. */
  33892. uniqueId: number;
  33893. /**
  33894. * Define the name of the texture.
  33895. */
  33896. name: string;
  33897. /**
  33898. * Gets or sets an object used to store user defined information.
  33899. */
  33900. metadata: any;
  33901. /**
  33902. * For internal use only. Please do not use.
  33903. */
  33904. reservedDataStore: any;
  33905. private _hasAlpha;
  33906. /**
  33907. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33908. */
  33909. set hasAlpha(value: boolean);
  33910. get hasAlpha(): boolean;
  33911. /**
  33912. * Defines if the alpha value should be determined via the rgb values.
  33913. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33914. */
  33915. getAlphaFromRGB: boolean;
  33916. /**
  33917. * Intensity or strength of the texture.
  33918. * It is commonly used by materials to fine tune the intensity of the texture
  33919. */
  33920. level: number;
  33921. /**
  33922. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33923. * This is part of the texture as textures usually maps to one uv set.
  33924. */
  33925. coordinatesIndex: number;
  33926. private _coordinatesMode;
  33927. /**
  33928. * How a texture is mapped.
  33929. *
  33930. * | Value | Type | Description |
  33931. * | ----- | ----------------------------------- | ----------- |
  33932. * | 0 | EXPLICIT_MODE | |
  33933. * | 1 | SPHERICAL_MODE | |
  33934. * | 2 | PLANAR_MODE | |
  33935. * | 3 | CUBIC_MODE | |
  33936. * | 4 | PROJECTION_MODE | |
  33937. * | 5 | SKYBOX_MODE | |
  33938. * | 6 | INVCUBIC_MODE | |
  33939. * | 7 | EQUIRECTANGULAR_MODE | |
  33940. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33941. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33942. */
  33943. set coordinatesMode(value: number);
  33944. get coordinatesMode(): number;
  33945. /**
  33946. * | Value | Type | Description |
  33947. * | ----- | ------------------ | ----------- |
  33948. * | 0 | CLAMP_ADDRESSMODE | |
  33949. * | 1 | WRAP_ADDRESSMODE | |
  33950. * | 2 | MIRROR_ADDRESSMODE | |
  33951. */
  33952. wrapU: number;
  33953. /**
  33954. * | Value | Type | Description |
  33955. * | ----- | ------------------ | ----------- |
  33956. * | 0 | CLAMP_ADDRESSMODE | |
  33957. * | 1 | WRAP_ADDRESSMODE | |
  33958. * | 2 | MIRROR_ADDRESSMODE | |
  33959. */
  33960. wrapV: number;
  33961. /**
  33962. * | Value | Type | Description |
  33963. * | ----- | ------------------ | ----------- |
  33964. * | 0 | CLAMP_ADDRESSMODE | |
  33965. * | 1 | WRAP_ADDRESSMODE | |
  33966. * | 2 | MIRROR_ADDRESSMODE | |
  33967. */
  33968. wrapR: number;
  33969. /**
  33970. * With compliant hardware and browser (supporting anisotropic filtering)
  33971. * this defines the level of anisotropic filtering in the texture.
  33972. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33973. */
  33974. anisotropicFilteringLevel: number;
  33975. /**
  33976. * Define if the texture is a cube texture or if false a 2d texture.
  33977. */
  33978. get isCube(): boolean;
  33979. set isCube(value: boolean);
  33980. /**
  33981. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33982. */
  33983. get is3D(): boolean;
  33984. set is3D(value: boolean);
  33985. /**
  33986. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33987. */
  33988. get is2DArray(): boolean;
  33989. set is2DArray(value: boolean);
  33990. /**
  33991. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33992. * HDR texture are usually stored in linear space.
  33993. * This only impacts the PBR and Background materials
  33994. */
  33995. gammaSpace: boolean;
  33996. /**
  33997. * Gets or sets whether or not the texture contains RGBD data.
  33998. */
  33999. get isRGBD(): boolean;
  34000. set isRGBD(value: boolean);
  34001. /**
  34002. * Is Z inverted in the texture (useful in a cube texture).
  34003. */
  34004. invertZ: boolean;
  34005. /**
  34006. * Are mip maps generated for this texture or not.
  34007. */
  34008. get noMipmap(): boolean;
  34009. /**
  34010. * @hidden
  34011. */
  34012. lodLevelInAlpha: boolean;
  34013. /**
  34014. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34015. */
  34016. get lodGenerationOffset(): number;
  34017. set lodGenerationOffset(value: number);
  34018. /**
  34019. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34020. */
  34021. get lodGenerationScale(): number;
  34022. set lodGenerationScale(value: number);
  34023. /**
  34024. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34025. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34026. * average roughness values.
  34027. */
  34028. get linearSpecularLOD(): boolean;
  34029. set linearSpecularLOD(value: boolean);
  34030. /**
  34031. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34032. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34033. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34034. */
  34035. get irradianceTexture(): Nullable<BaseTexture>;
  34036. set irradianceTexture(value: Nullable<BaseTexture>);
  34037. /**
  34038. * Define if the texture is a render target.
  34039. */
  34040. isRenderTarget: boolean;
  34041. /**
  34042. * Define the unique id of the texture in the scene.
  34043. */
  34044. get uid(): string;
  34045. /** @hidden */
  34046. _prefiltered: boolean;
  34047. /**
  34048. * Return a string representation of the texture.
  34049. * @returns the texture as a string
  34050. */
  34051. toString(): string;
  34052. /**
  34053. * Get the class name of the texture.
  34054. * @returns "BaseTexture"
  34055. */
  34056. getClassName(): string;
  34057. /**
  34058. * Define the list of animation attached to the texture.
  34059. */
  34060. animations: import("babylonjs/Animations/animation").Animation[];
  34061. /**
  34062. * An event triggered when the texture is disposed.
  34063. */
  34064. onDisposeObservable: Observable<BaseTexture>;
  34065. private _onDisposeObserver;
  34066. /**
  34067. * Callback triggered when the texture has been disposed.
  34068. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34069. */
  34070. set onDispose(callback: () => void);
  34071. /**
  34072. * Define the current state of the loading sequence when in delayed load mode.
  34073. */
  34074. delayLoadState: number;
  34075. private _scene;
  34076. private _engine;
  34077. /** @hidden */
  34078. _texture: Nullable<InternalTexture>;
  34079. private _uid;
  34080. /**
  34081. * Define if the texture is preventinga material to render or not.
  34082. * If not and the texture is not ready, the engine will use a default black texture instead.
  34083. */
  34084. get isBlocking(): boolean;
  34085. /**
  34086. * Instantiates a new BaseTexture.
  34087. * Base class of all the textures in babylon.
  34088. * It groups all the common properties the materials, post process, lights... might need
  34089. * in order to make a correct use of the texture.
  34090. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34091. */
  34092. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34093. /**
  34094. * Get the scene the texture belongs to.
  34095. * @returns the scene or null if undefined
  34096. */
  34097. getScene(): Nullable<Scene>;
  34098. /** @hidden */
  34099. protected _getEngine(): Nullable<ThinEngine>;
  34100. /**
  34101. * Get the texture transform matrix used to offset tile the texture for istance.
  34102. * @returns the transformation matrix
  34103. */
  34104. getTextureMatrix(): Matrix;
  34105. /**
  34106. * Get the texture reflection matrix used to rotate/transform the reflection.
  34107. * @returns the reflection matrix
  34108. */
  34109. getReflectionTextureMatrix(): Matrix;
  34110. /**
  34111. * Get the underlying lower level texture from Babylon.
  34112. * @returns the insternal texture
  34113. */
  34114. getInternalTexture(): Nullable<InternalTexture>;
  34115. /**
  34116. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34117. * @returns true if ready or not blocking
  34118. */
  34119. isReadyOrNotBlocking(): boolean;
  34120. /**
  34121. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34122. * @returns true if fully ready
  34123. */
  34124. isReady(): boolean;
  34125. private _cachedSize;
  34126. /**
  34127. * Get the size of the texture.
  34128. * @returns the texture size.
  34129. */
  34130. getSize(): ISize;
  34131. /**
  34132. * Get the base size of the texture.
  34133. * It can be different from the size if the texture has been resized for POT for instance
  34134. * @returns the base size
  34135. */
  34136. getBaseSize(): ISize;
  34137. /**
  34138. * Update the sampling mode of the texture.
  34139. * Default is Trilinear mode.
  34140. *
  34141. * | Value | Type | Description |
  34142. * | ----- | ------------------ | ----------- |
  34143. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34144. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34145. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34146. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34147. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34148. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34149. * | 7 | NEAREST_LINEAR | |
  34150. * | 8 | NEAREST_NEAREST | |
  34151. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34152. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34153. * | 11 | LINEAR_LINEAR | |
  34154. * | 12 | LINEAR_NEAREST | |
  34155. *
  34156. * > _mag_: magnification filter (close to the viewer)
  34157. * > _min_: minification filter (far from the viewer)
  34158. * > _mip_: filter used between mip map levels
  34159. *@param samplingMode Define the new sampling mode of the texture
  34160. */
  34161. updateSamplingMode(samplingMode: number): void;
  34162. /**
  34163. * Scales the texture if is `canRescale()`
  34164. * @param ratio the resize factor we want to use to rescale
  34165. */
  34166. scale(ratio: number): void;
  34167. /**
  34168. * Get if the texture can rescale.
  34169. */
  34170. get canRescale(): boolean;
  34171. /** @hidden */
  34172. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34173. /** @hidden */
  34174. _rebuild(): void;
  34175. /**
  34176. * Triggers the load sequence in delayed load mode.
  34177. */
  34178. delayLoad(): void;
  34179. /**
  34180. * Clones the texture.
  34181. * @returns the cloned texture
  34182. */
  34183. clone(): Nullable<BaseTexture>;
  34184. /**
  34185. * Get the texture underlying type (INT, FLOAT...)
  34186. */
  34187. get textureType(): number;
  34188. /**
  34189. * Get the texture underlying format (RGB, RGBA...)
  34190. */
  34191. get textureFormat(): number;
  34192. /**
  34193. * Indicates that textures need to be re-calculated for all materials
  34194. */
  34195. protected _markAllSubMeshesAsTexturesDirty(): void;
  34196. /**
  34197. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34198. * This will returns an RGBA array buffer containing either in values (0-255) or
  34199. * float values (0-1) depending of the underlying buffer type.
  34200. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34201. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34202. * @param buffer defines a user defined buffer to fill with data (can be null)
  34203. * @returns The Array buffer containing the pixels data.
  34204. */
  34205. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34206. /**
  34207. * Release and destroy the underlying lower level texture aka internalTexture.
  34208. */
  34209. releaseInternalTexture(): void;
  34210. /** @hidden */
  34211. get _lodTextureHigh(): Nullable<BaseTexture>;
  34212. /** @hidden */
  34213. get _lodTextureMid(): Nullable<BaseTexture>;
  34214. /** @hidden */
  34215. get _lodTextureLow(): Nullable<BaseTexture>;
  34216. /**
  34217. * Dispose the texture and release its associated resources.
  34218. */
  34219. dispose(): void;
  34220. /**
  34221. * Serialize the texture into a JSON representation that can be parsed later on.
  34222. * @returns the JSON representation of the texture
  34223. */
  34224. serialize(): any;
  34225. /**
  34226. * Helper function to be called back once a list of texture contains only ready textures.
  34227. * @param textures Define the list of textures to wait for
  34228. * @param callback Define the callback triggered once the entire list will be ready
  34229. */
  34230. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34231. private static _isScene;
  34232. }
  34233. }
  34234. declare module "babylonjs/Materials/effect" {
  34235. import { Observable } from "babylonjs/Misc/observable";
  34236. import { Nullable } from "babylonjs/types";
  34237. import { IDisposable } from "babylonjs/scene";
  34238. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34239. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34240. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34241. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34242. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34243. import { Engine } from "babylonjs/Engines/engine";
  34244. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34248. /**
  34249. * Options to be used when creating an effect.
  34250. */
  34251. export interface IEffectCreationOptions {
  34252. /**
  34253. * Atrributes that will be used in the shader.
  34254. */
  34255. attributes: string[];
  34256. /**
  34257. * Uniform varible names that will be set in the shader.
  34258. */
  34259. uniformsNames: string[];
  34260. /**
  34261. * Uniform buffer variable names that will be set in the shader.
  34262. */
  34263. uniformBuffersNames: string[];
  34264. /**
  34265. * Sampler texture variable names that will be set in the shader.
  34266. */
  34267. samplers: string[];
  34268. /**
  34269. * Define statements that will be set in the shader.
  34270. */
  34271. defines: any;
  34272. /**
  34273. * Possible fallbacks for this effect to improve performance when needed.
  34274. */
  34275. fallbacks: Nullable<IEffectFallbacks>;
  34276. /**
  34277. * Callback that will be called when the shader is compiled.
  34278. */
  34279. onCompiled: Nullable<(effect: Effect) => void>;
  34280. /**
  34281. * Callback that will be called if an error occurs during shader compilation.
  34282. */
  34283. onError: Nullable<(effect: Effect, errors: string) => void>;
  34284. /**
  34285. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34286. */
  34287. indexParameters?: any;
  34288. /**
  34289. * Max number of lights that can be used in the shader.
  34290. */
  34291. maxSimultaneousLights?: number;
  34292. /**
  34293. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34294. */
  34295. transformFeedbackVaryings?: Nullable<string[]>;
  34296. /**
  34297. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  34298. */
  34299. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34300. }
  34301. /**
  34302. * Effect containing vertex and fragment shader that can be executed on an object.
  34303. */
  34304. export class Effect implements IDisposable {
  34305. /**
  34306. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34307. */
  34308. static ShadersRepository: string;
  34309. /**
  34310. * Enable logging of the shader code when a compilation error occurs
  34311. */
  34312. static LogShaderCodeOnCompilationError: boolean;
  34313. /**
  34314. * Name of the effect.
  34315. */
  34316. name: any;
  34317. /**
  34318. * String container all the define statements that should be set on the shader.
  34319. */
  34320. defines: string;
  34321. /**
  34322. * Callback that will be called when the shader is compiled.
  34323. */
  34324. onCompiled: Nullable<(effect: Effect) => void>;
  34325. /**
  34326. * Callback that will be called if an error occurs during shader compilation.
  34327. */
  34328. onError: Nullable<(effect: Effect, errors: string) => void>;
  34329. /**
  34330. * Callback that will be called when effect is bound.
  34331. */
  34332. onBind: Nullable<(effect: Effect) => void>;
  34333. /**
  34334. * Unique ID of the effect.
  34335. */
  34336. uniqueId: number;
  34337. /**
  34338. * Observable that will be called when the shader is compiled.
  34339. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34340. */
  34341. onCompileObservable: Observable<Effect>;
  34342. /**
  34343. * Observable that will be called if an error occurs during shader compilation.
  34344. */
  34345. onErrorObservable: Observable<Effect>;
  34346. /** @hidden */
  34347. _onBindObservable: Nullable<Observable<Effect>>;
  34348. /**
  34349. * @hidden
  34350. * Specifies if the effect was previously ready
  34351. */
  34352. _wasPreviouslyReady: boolean;
  34353. /**
  34354. * Observable that will be called when effect is bound.
  34355. */
  34356. get onBindObservable(): Observable<Effect>;
  34357. /** @hidden */
  34358. _bonesComputationForcedToCPU: boolean;
  34359. private static _uniqueIdSeed;
  34360. private _engine;
  34361. private _uniformBuffersNames;
  34362. private _uniformBuffersNamesList;
  34363. private _uniformsNames;
  34364. private _samplerList;
  34365. private _samplers;
  34366. private _isReady;
  34367. private _compilationError;
  34368. private _allFallbacksProcessed;
  34369. private _attributesNames;
  34370. private _attributes;
  34371. private _attributeLocationByName;
  34372. private _uniforms;
  34373. /**
  34374. * Key for the effect.
  34375. * @hidden
  34376. */
  34377. _key: string;
  34378. private _indexParameters;
  34379. private _fallbacks;
  34380. private _vertexSourceCode;
  34381. private _fragmentSourceCode;
  34382. private _vertexSourceCodeOverride;
  34383. private _fragmentSourceCodeOverride;
  34384. private _transformFeedbackVaryings;
  34385. /**
  34386. * Compiled shader to webGL program.
  34387. * @hidden
  34388. */
  34389. _pipelineContext: Nullable<IPipelineContext>;
  34390. private _valueCache;
  34391. private static _baseCache;
  34392. /**
  34393. * Instantiates an effect.
  34394. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34395. * @param baseName Name of the effect.
  34396. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34397. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34398. * @param samplers List of sampler variables that will be passed to the shader.
  34399. * @param engine Engine to be used to render the effect
  34400. * @param defines Define statements to be added to the shader.
  34401. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34402. * @param onCompiled Callback that will be called when the shader is compiled.
  34403. * @param onError Callback that will be called if an error occurs during shader compilation.
  34404. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34405. */
  34406. 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);
  34407. private _useFinalCode;
  34408. /**
  34409. * Unique key for this effect
  34410. */
  34411. get key(): string;
  34412. /**
  34413. * If the effect has been compiled and prepared.
  34414. * @returns if the effect is compiled and prepared.
  34415. */
  34416. isReady(): boolean;
  34417. private _isReadyInternal;
  34418. /**
  34419. * The engine the effect was initialized with.
  34420. * @returns the engine.
  34421. */
  34422. getEngine(): Engine;
  34423. /**
  34424. * The pipeline context for this effect
  34425. * @returns the associated pipeline context
  34426. */
  34427. getPipelineContext(): Nullable<IPipelineContext>;
  34428. /**
  34429. * The set of names of attribute variables for the shader.
  34430. * @returns An array of attribute names.
  34431. */
  34432. getAttributesNames(): string[];
  34433. /**
  34434. * Returns the attribute at the given index.
  34435. * @param index The index of the attribute.
  34436. * @returns The location of the attribute.
  34437. */
  34438. getAttributeLocation(index: number): number;
  34439. /**
  34440. * Returns the attribute based on the name of the variable.
  34441. * @param name of the attribute to look up.
  34442. * @returns the attribute location.
  34443. */
  34444. getAttributeLocationByName(name: string): number;
  34445. /**
  34446. * The number of attributes.
  34447. * @returns the numnber of attributes.
  34448. */
  34449. getAttributesCount(): number;
  34450. /**
  34451. * Gets the index of a uniform variable.
  34452. * @param uniformName of the uniform to look up.
  34453. * @returns the index.
  34454. */
  34455. getUniformIndex(uniformName: string): number;
  34456. /**
  34457. * Returns the attribute based on the name of the variable.
  34458. * @param uniformName of the uniform to look up.
  34459. * @returns the location of the uniform.
  34460. */
  34461. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34462. /**
  34463. * Returns an array of sampler variable names
  34464. * @returns The array of sampler variable names.
  34465. */
  34466. getSamplers(): string[];
  34467. /**
  34468. * Returns an array of uniform variable names
  34469. * @returns The array of uniform variable names.
  34470. */
  34471. getUniformNames(): string[];
  34472. /**
  34473. * Returns an array of uniform buffer variable names
  34474. * @returns The array of uniform buffer variable names.
  34475. */
  34476. getUniformBuffersNames(): string[];
  34477. /**
  34478. * Returns the index parameters used to create the effect
  34479. * @returns The index parameters object
  34480. */
  34481. getIndexParameters(): any;
  34482. /**
  34483. * The error from the last compilation.
  34484. * @returns the error string.
  34485. */
  34486. getCompilationError(): string;
  34487. /**
  34488. * Gets a boolean indicating that all fallbacks were used during compilation
  34489. * @returns true if all fallbacks were used
  34490. */
  34491. allFallbacksProcessed(): boolean;
  34492. /**
  34493. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34494. * @param func The callback to be used.
  34495. */
  34496. executeWhenCompiled(func: (effect: Effect) => void): void;
  34497. private _checkIsReady;
  34498. private _loadShader;
  34499. /**
  34500. * Gets the vertex shader source code of this effect
  34501. */
  34502. get vertexSourceCode(): string;
  34503. /**
  34504. * Gets the fragment shader source code of this effect
  34505. */
  34506. get fragmentSourceCode(): string;
  34507. /**
  34508. * Recompiles the webGL program
  34509. * @param vertexSourceCode The source code for the vertex shader.
  34510. * @param fragmentSourceCode The source code for the fragment shader.
  34511. * @param onCompiled Callback called when completed.
  34512. * @param onError Callback called on error.
  34513. * @hidden
  34514. */
  34515. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34516. /**
  34517. * Prepares the effect
  34518. * @hidden
  34519. */
  34520. _prepareEffect(): void;
  34521. private _getShaderCodeAndErrorLine;
  34522. private _processCompilationErrors;
  34523. /**
  34524. * Checks if the effect is supported. (Must be called after compilation)
  34525. */
  34526. get isSupported(): boolean;
  34527. /**
  34528. * Binds a texture to the engine to be used as output of the shader.
  34529. * @param channel Name of the output variable.
  34530. * @param texture Texture to bind.
  34531. * @hidden
  34532. */
  34533. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34534. /**
  34535. * Sets a texture on the engine to be used in the shader.
  34536. * @param channel Name of the sampler variable.
  34537. * @param texture Texture to set.
  34538. */
  34539. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34540. /**
  34541. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34542. * @param channel Name of the sampler variable.
  34543. * @param texture Texture to set.
  34544. */
  34545. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34546. /**
  34547. * Sets an array of textures on the engine to be used in the shader.
  34548. * @param channel Name of the variable.
  34549. * @param textures Textures to set.
  34550. */
  34551. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34552. /**
  34553. * 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)
  34554. * @param channel Name of the sampler variable.
  34555. * @param postProcess Post process to get the input texture from.
  34556. */
  34557. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34558. /**
  34559. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34560. * 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)
  34561. * @param channel Name of the sampler variable.
  34562. * @param postProcess Post process to get the output texture from.
  34563. */
  34564. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34565. /** @hidden */
  34566. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34567. /** @hidden */
  34568. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34569. /** @hidden */
  34570. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34571. /** @hidden */
  34572. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34573. /**
  34574. * Binds a buffer to a uniform.
  34575. * @param buffer Buffer to bind.
  34576. * @param name Name of the uniform variable to bind to.
  34577. */
  34578. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34579. /**
  34580. * Binds block to a uniform.
  34581. * @param blockName Name of the block to bind.
  34582. * @param index Index to bind.
  34583. */
  34584. bindUniformBlock(blockName: string, index: number): void;
  34585. /**
  34586. * Sets an interger value on a uniform variable.
  34587. * @param uniformName Name of the variable.
  34588. * @param value Value to be set.
  34589. * @returns this effect.
  34590. */
  34591. setInt(uniformName: string, value: number): Effect;
  34592. /**
  34593. * Sets an int array on a uniform variable.
  34594. * @param uniformName Name of the variable.
  34595. * @param array array to be set.
  34596. * @returns this effect.
  34597. */
  34598. setIntArray(uniformName: string, array: Int32Array): Effect;
  34599. /**
  34600. * 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)
  34601. * @param uniformName Name of the variable.
  34602. * @param array array to be set.
  34603. * @returns this effect.
  34604. */
  34605. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34606. /**
  34607. * 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)
  34608. * @param uniformName Name of the variable.
  34609. * @param array array to be set.
  34610. * @returns this effect.
  34611. */
  34612. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34613. /**
  34614. * 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)
  34615. * @param uniformName Name of the variable.
  34616. * @param array array to be set.
  34617. * @returns this effect.
  34618. */
  34619. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34620. /**
  34621. * Sets an float array on a uniform variable.
  34622. * @param uniformName Name of the variable.
  34623. * @param array array to be set.
  34624. * @returns this effect.
  34625. */
  34626. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34627. /**
  34628. * 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)
  34629. * @param uniformName Name of the variable.
  34630. * @param array array to be set.
  34631. * @returns this effect.
  34632. */
  34633. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34634. /**
  34635. * 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)
  34636. * @param uniformName Name of the variable.
  34637. * @param array array to be set.
  34638. * @returns this effect.
  34639. */
  34640. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34641. /**
  34642. * 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)
  34643. * @param uniformName Name of the variable.
  34644. * @param array array to be set.
  34645. * @returns this effect.
  34646. */
  34647. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34648. /**
  34649. * Sets an array on a uniform variable.
  34650. * @param uniformName Name of the variable.
  34651. * @param array array to be set.
  34652. * @returns this effect.
  34653. */
  34654. setArray(uniformName: string, array: number[]): Effect;
  34655. /**
  34656. * 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)
  34657. * @param uniformName Name of the variable.
  34658. * @param array array to be set.
  34659. * @returns this effect.
  34660. */
  34661. setArray2(uniformName: string, array: number[]): Effect;
  34662. /**
  34663. * 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)
  34664. * @param uniformName Name of the variable.
  34665. * @param array array to be set.
  34666. * @returns this effect.
  34667. */
  34668. setArray3(uniformName: string, array: number[]): Effect;
  34669. /**
  34670. * 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)
  34671. * @param uniformName Name of the variable.
  34672. * @param array array to be set.
  34673. * @returns this effect.
  34674. */
  34675. setArray4(uniformName: string, array: number[]): Effect;
  34676. /**
  34677. * Sets matrices on a uniform variable.
  34678. * @param uniformName Name of the variable.
  34679. * @param matrices matrices to be set.
  34680. * @returns this effect.
  34681. */
  34682. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34683. /**
  34684. * Sets matrix on a uniform variable.
  34685. * @param uniformName Name of the variable.
  34686. * @param matrix matrix to be set.
  34687. * @returns this effect.
  34688. */
  34689. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34690. /**
  34691. * 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)
  34692. * @param uniformName Name of the variable.
  34693. * @param matrix matrix to be set.
  34694. * @returns this effect.
  34695. */
  34696. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34697. /**
  34698. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34699. * @param uniformName Name of the variable.
  34700. * @param matrix matrix to be set.
  34701. * @returns this effect.
  34702. */
  34703. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34704. /**
  34705. * Sets a float on a uniform variable.
  34706. * @param uniformName Name of the variable.
  34707. * @param value value to be set.
  34708. * @returns this effect.
  34709. */
  34710. setFloat(uniformName: string, value: number): Effect;
  34711. /**
  34712. * Sets a boolean on a uniform variable.
  34713. * @param uniformName Name of the variable.
  34714. * @param bool value to be set.
  34715. * @returns this effect.
  34716. */
  34717. setBool(uniformName: string, bool: boolean): Effect;
  34718. /**
  34719. * Sets a Vector2 on a uniform variable.
  34720. * @param uniformName Name of the variable.
  34721. * @param vector2 vector2 to be set.
  34722. * @returns this effect.
  34723. */
  34724. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34725. /**
  34726. * Sets a float2 on a uniform variable.
  34727. * @param uniformName Name of the variable.
  34728. * @param x First float in float2.
  34729. * @param y Second float in float2.
  34730. * @returns this effect.
  34731. */
  34732. setFloat2(uniformName: string, x: number, y: number): Effect;
  34733. /**
  34734. * Sets a Vector3 on a uniform variable.
  34735. * @param uniformName Name of the variable.
  34736. * @param vector3 Value to be set.
  34737. * @returns this effect.
  34738. */
  34739. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34740. /**
  34741. * Sets a float3 on a uniform variable.
  34742. * @param uniformName Name of the variable.
  34743. * @param x First float in float3.
  34744. * @param y Second float in float3.
  34745. * @param z Third float in float3.
  34746. * @returns this effect.
  34747. */
  34748. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34749. /**
  34750. * Sets a Vector4 on a uniform variable.
  34751. * @param uniformName Name of the variable.
  34752. * @param vector4 Value to be set.
  34753. * @returns this effect.
  34754. */
  34755. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34756. /**
  34757. * Sets a float4 on a uniform variable.
  34758. * @param uniformName Name of the variable.
  34759. * @param x First float in float4.
  34760. * @param y Second float in float4.
  34761. * @param z Third float in float4.
  34762. * @param w Fourth float in float4.
  34763. * @returns this effect.
  34764. */
  34765. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34766. /**
  34767. * Sets a Color3 on a uniform variable.
  34768. * @param uniformName Name of the variable.
  34769. * @param color3 Value to be set.
  34770. * @returns this effect.
  34771. */
  34772. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34773. /**
  34774. * Sets a Color4 on a uniform variable.
  34775. * @param uniformName Name of the variable.
  34776. * @param color3 Value to be set.
  34777. * @param alpha Alpha value to be set.
  34778. * @returns this effect.
  34779. */
  34780. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34781. /**
  34782. * Sets a Color4 on a uniform variable
  34783. * @param uniformName defines the name of the variable
  34784. * @param color4 defines the value to be set
  34785. * @returns this effect.
  34786. */
  34787. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34788. /** Release all associated resources */
  34789. dispose(): void;
  34790. /**
  34791. * This function will add a new shader to the shader store
  34792. * @param name the name of the shader
  34793. * @param pixelShader optional pixel shader content
  34794. * @param vertexShader optional vertex shader content
  34795. */
  34796. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34797. /**
  34798. * Store of each shader (The can be looked up using effect.key)
  34799. */
  34800. static ShadersStore: {
  34801. [key: string]: string;
  34802. };
  34803. /**
  34804. * Store of each included file for a shader (The can be looked up using effect.key)
  34805. */
  34806. static IncludesShadersStore: {
  34807. [key: string]: string;
  34808. };
  34809. /**
  34810. * Resets the cache of effects.
  34811. */
  34812. static ResetCache(): void;
  34813. }
  34814. }
  34815. declare module "babylonjs/Engines/engineCapabilities" {
  34816. /**
  34817. * Interface used to describe the capabilities of the engine relatively to the current browser
  34818. */
  34819. export interface EngineCapabilities {
  34820. /** Maximum textures units per fragment shader */
  34821. maxTexturesImageUnits: number;
  34822. /** Maximum texture units per vertex shader */
  34823. maxVertexTextureImageUnits: number;
  34824. /** Maximum textures units in the entire pipeline */
  34825. maxCombinedTexturesImageUnits: number;
  34826. /** Maximum texture size */
  34827. maxTextureSize: number;
  34828. /** Maximum texture samples */
  34829. maxSamples?: number;
  34830. /** Maximum cube texture size */
  34831. maxCubemapTextureSize: number;
  34832. /** Maximum render texture size */
  34833. maxRenderTextureSize: number;
  34834. /** Maximum number of vertex attributes */
  34835. maxVertexAttribs: number;
  34836. /** Maximum number of varyings */
  34837. maxVaryingVectors: number;
  34838. /** Maximum number of uniforms per vertex shader */
  34839. maxVertexUniformVectors: number;
  34840. /** Maximum number of uniforms per fragment shader */
  34841. maxFragmentUniformVectors: number;
  34842. /** Defines if standard derivates (dx/dy) are supported */
  34843. standardDerivatives: boolean;
  34844. /** Defines if s3tc texture compression is supported */
  34845. s3tc?: WEBGL_compressed_texture_s3tc;
  34846. /** Defines if pvrtc texture compression is supported */
  34847. pvrtc: any;
  34848. /** Defines if etc1 texture compression is supported */
  34849. etc1: any;
  34850. /** Defines if etc2 texture compression is supported */
  34851. etc2: any;
  34852. /** Defines if astc texture compression is supported */
  34853. astc: any;
  34854. /** Defines if float textures are supported */
  34855. textureFloat: boolean;
  34856. /** Defines if vertex array objects are supported */
  34857. vertexArrayObject: boolean;
  34858. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34859. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34860. /** Gets the maximum level of anisotropy supported */
  34861. maxAnisotropy: number;
  34862. /** Defines if instancing is supported */
  34863. instancedArrays: boolean;
  34864. /** Defines if 32 bits indices are supported */
  34865. uintIndices: boolean;
  34866. /** Defines if high precision shaders are supported */
  34867. highPrecisionShaderSupported: boolean;
  34868. /** Defines if depth reading in the fragment shader is supported */
  34869. fragmentDepthSupported: boolean;
  34870. /** Defines if float texture linear filtering is supported*/
  34871. textureFloatLinearFiltering: boolean;
  34872. /** Defines if rendering to float textures is supported */
  34873. textureFloatRender: boolean;
  34874. /** Defines if half float textures are supported*/
  34875. textureHalfFloat: boolean;
  34876. /** Defines if half float texture linear filtering is supported*/
  34877. textureHalfFloatLinearFiltering: boolean;
  34878. /** Defines if rendering to half float textures is supported */
  34879. textureHalfFloatRender: boolean;
  34880. /** Defines if textureLOD shader command is supported */
  34881. textureLOD: boolean;
  34882. /** Defines if draw buffers extension is supported */
  34883. drawBuffersExtension: boolean;
  34884. /** Defines if depth textures are supported */
  34885. depthTextureExtension: boolean;
  34886. /** Defines if float color buffer are supported */
  34887. colorBufferFloat: boolean;
  34888. /** Gets disjoint timer query extension (null if not supported) */
  34889. timerQuery?: EXT_disjoint_timer_query;
  34890. /** Defines if timestamp can be used with timer query */
  34891. canUseTimestampForTimerQuery: boolean;
  34892. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34893. multiview?: any;
  34894. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34895. oculusMultiview?: any;
  34896. /** Function used to let the system compiles shaders in background */
  34897. parallelShaderCompile?: {
  34898. COMPLETION_STATUS_KHR: number;
  34899. };
  34900. /** Max number of texture samples for MSAA */
  34901. maxMSAASamples: number;
  34902. /** Defines if the blend min max extension is supported */
  34903. blendMinMax: boolean;
  34904. }
  34905. }
  34906. declare module "babylonjs/States/depthCullingState" {
  34907. import { Nullable } from "babylonjs/types";
  34908. /**
  34909. * @hidden
  34910. **/
  34911. export class DepthCullingState {
  34912. private _isDepthTestDirty;
  34913. private _isDepthMaskDirty;
  34914. private _isDepthFuncDirty;
  34915. private _isCullFaceDirty;
  34916. private _isCullDirty;
  34917. private _isZOffsetDirty;
  34918. private _isFrontFaceDirty;
  34919. private _depthTest;
  34920. private _depthMask;
  34921. private _depthFunc;
  34922. private _cull;
  34923. private _cullFace;
  34924. private _zOffset;
  34925. private _frontFace;
  34926. /**
  34927. * Initializes the state.
  34928. */
  34929. constructor();
  34930. get isDirty(): boolean;
  34931. get zOffset(): number;
  34932. set zOffset(value: number);
  34933. get cullFace(): Nullable<number>;
  34934. set cullFace(value: Nullable<number>);
  34935. get cull(): Nullable<boolean>;
  34936. set cull(value: Nullable<boolean>);
  34937. get depthFunc(): Nullable<number>;
  34938. set depthFunc(value: Nullable<number>);
  34939. get depthMask(): boolean;
  34940. set depthMask(value: boolean);
  34941. get depthTest(): boolean;
  34942. set depthTest(value: boolean);
  34943. get frontFace(): Nullable<number>;
  34944. set frontFace(value: Nullable<number>);
  34945. reset(): void;
  34946. apply(gl: WebGLRenderingContext): void;
  34947. }
  34948. }
  34949. declare module "babylonjs/States/stencilState" {
  34950. /**
  34951. * @hidden
  34952. **/
  34953. export class StencilState {
  34954. /** 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 */
  34955. static readonly ALWAYS: number;
  34956. /** Passed to stencilOperation to specify that stencil value must be kept */
  34957. static readonly KEEP: number;
  34958. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34959. static readonly REPLACE: number;
  34960. private _isStencilTestDirty;
  34961. private _isStencilMaskDirty;
  34962. private _isStencilFuncDirty;
  34963. private _isStencilOpDirty;
  34964. private _stencilTest;
  34965. private _stencilMask;
  34966. private _stencilFunc;
  34967. private _stencilFuncRef;
  34968. private _stencilFuncMask;
  34969. private _stencilOpStencilFail;
  34970. private _stencilOpDepthFail;
  34971. private _stencilOpStencilDepthPass;
  34972. get isDirty(): boolean;
  34973. get stencilFunc(): number;
  34974. set stencilFunc(value: number);
  34975. get stencilFuncRef(): number;
  34976. set stencilFuncRef(value: number);
  34977. get stencilFuncMask(): number;
  34978. set stencilFuncMask(value: number);
  34979. get stencilOpStencilFail(): number;
  34980. set stencilOpStencilFail(value: number);
  34981. get stencilOpDepthFail(): number;
  34982. set stencilOpDepthFail(value: number);
  34983. get stencilOpStencilDepthPass(): number;
  34984. set stencilOpStencilDepthPass(value: number);
  34985. get stencilMask(): number;
  34986. set stencilMask(value: number);
  34987. get stencilTest(): boolean;
  34988. set stencilTest(value: boolean);
  34989. constructor();
  34990. reset(): void;
  34991. apply(gl: WebGLRenderingContext): void;
  34992. }
  34993. }
  34994. declare module "babylonjs/States/alphaCullingState" {
  34995. /**
  34996. * @hidden
  34997. **/
  34998. export class AlphaState {
  34999. private _isAlphaBlendDirty;
  35000. private _isBlendFunctionParametersDirty;
  35001. private _isBlendEquationParametersDirty;
  35002. private _isBlendConstantsDirty;
  35003. private _alphaBlend;
  35004. private _blendFunctionParameters;
  35005. private _blendEquationParameters;
  35006. private _blendConstants;
  35007. /**
  35008. * Initializes the state.
  35009. */
  35010. constructor();
  35011. get isDirty(): boolean;
  35012. get alphaBlend(): boolean;
  35013. set alphaBlend(value: boolean);
  35014. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35015. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35016. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35017. reset(): void;
  35018. apply(gl: WebGLRenderingContext): void;
  35019. }
  35020. }
  35021. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35022. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35023. /** @hidden */
  35024. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35025. attributeProcessor(attribute: string): string;
  35026. varyingProcessor(varying: string, isFragment: boolean): string;
  35027. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35028. }
  35029. }
  35030. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35031. /**
  35032. * Interface for attribute information associated with buffer instanciation
  35033. */
  35034. export interface InstancingAttributeInfo {
  35035. /**
  35036. * Name of the GLSL attribute
  35037. * if attribute index is not specified, this is used to retrieve the index from the effect
  35038. */
  35039. attributeName: string;
  35040. /**
  35041. * Index/offset of the attribute in the vertex shader
  35042. * if not specified, this will be computes from the name.
  35043. */
  35044. index?: number;
  35045. /**
  35046. * size of the attribute, 1, 2, 3 or 4
  35047. */
  35048. attributeSize: number;
  35049. /**
  35050. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35051. */
  35052. offset: number;
  35053. /**
  35054. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35055. * default to 1
  35056. */
  35057. divisor?: number;
  35058. /**
  35059. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35060. * default is FLOAT
  35061. */
  35062. attributeType?: number;
  35063. /**
  35064. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35065. */
  35066. normalized?: boolean;
  35067. }
  35068. }
  35069. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35070. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35071. import { Nullable } from "babylonjs/types";
  35072. module "babylonjs/Engines/thinEngine" {
  35073. interface ThinEngine {
  35074. /**
  35075. * Update a video texture
  35076. * @param texture defines the texture to update
  35077. * @param video defines the video element to use
  35078. * @param invertY defines if data must be stored with Y axis inverted
  35079. */
  35080. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35081. }
  35082. }
  35083. }
  35084. declare module "babylonjs/Materials/Textures/videoTexture" {
  35085. import { Observable } from "babylonjs/Misc/observable";
  35086. import { Nullable } from "babylonjs/types";
  35087. import { Scene } from "babylonjs/scene";
  35088. import { Texture } from "babylonjs/Materials/Textures/texture";
  35089. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35090. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35091. /**
  35092. * Settings for finer control over video usage
  35093. */
  35094. export interface VideoTextureSettings {
  35095. /**
  35096. * Applies `autoplay` to video, if specified
  35097. */
  35098. autoPlay?: boolean;
  35099. /**
  35100. * Applies `loop` to video, if specified
  35101. */
  35102. loop?: boolean;
  35103. /**
  35104. * Automatically updates internal texture from video at every frame in the render loop
  35105. */
  35106. autoUpdateTexture: boolean;
  35107. /**
  35108. * Image src displayed during the video loading or until the user interacts with the video.
  35109. */
  35110. poster?: string;
  35111. }
  35112. /**
  35113. * If you want to display a video in your scene, this is the special texture for that.
  35114. * This special texture works similar to other textures, with the exception of a few parameters.
  35115. * @see https://doc.babylonjs.com/how_to/video_texture
  35116. */
  35117. export class VideoTexture extends Texture {
  35118. /**
  35119. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35120. */
  35121. readonly autoUpdateTexture: boolean;
  35122. /**
  35123. * The video instance used by the texture internally
  35124. */
  35125. readonly video: HTMLVideoElement;
  35126. private _onUserActionRequestedObservable;
  35127. /**
  35128. * Event triggerd when a dom action is required by the user to play the video.
  35129. * This happens due to recent changes in browser policies preventing video to auto start.
  35130. */
  35131. get onUserActionRequestedObservable(): Observable<Texture>;
  35132. private _generateMipMaps;
  35133. private _stillImageCaptured;
  35134. private _displayingPosterTexture;
  35135. private _settings;
  35136. private _createInternalTextureOnEvent;
  35137. private _frameId;
  35138. private _currentSrc;
  35139. /**
  35140. * Creates a video texture.
  35141. * If you want to display a video in your scene, this is the special texture for that.
  35142. * This special texture works similar to other textures, with the exception of a few parameters.
  35143. * @see https://doc.babylonjs.com/how_to/video_texture
  35144. * @param name optional name, will detect from video source, if not defined
  35145. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35146. * @param scene is obviously the current scene.
  35147. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35148. * @param invertY is false by default but can be used to invert video on Y axis
  35149. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35150. * @param settings allows finer control over video usage
  35151. */
  35152. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35153. private _getName;
  35154. private _getVideo;
  35155. private _createInternalTexture;
  35156. private reset;
  35157. /**
  35158. * @hidden Internal method to initiate `update`.
  35159. */
  35160. _rebuild(): void;
  35161. /**
  35162. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35163. */
  35164. update(): void;
  35165. /**
  35166. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35167. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35168. */
  35169. updateTexture(isVisible: boolean): void;
  35170. protected _updateInternalTexture: () => void;
  35171. /**
  35172. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35173. * @param url New url.
  35174. */
  35175. updateURL(url: string): void;
  35176. /**
  35177. * Clones the texture.
  35178. * @returns the cloned texture
  35179. */
  35180. clone(): VideoTexture;
  35181. /**
  35182. * Dispose the texture and release its associated resources.
  35183. */
  35184. dispose(): void;
  35185. /**
  35186. * Creates a video texture straight from a stream.
  35187. * @param scene Define the scene the texture should be created in
  35188. * @param stream Define the stream the texture should be created from
  35189. * @returns The created video texture as a promise
  35190. */
  35191. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35192. /**
  35193. * Creates a video texture straight from your WebCam video feed.
  35194. * @param scene Define the scene the texture should be created in
  35195. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35196. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35197. * @returns The created video texture as a promise
  35198. */
  35199. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35200. minWidth: number;
  35201. maxWidth: number;
  35202. minHeight: number;
  35203. maxHeight: number;
  35204. deviceId: string;
  35205. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35206. /**
  35207. * Creates a video texture straight from your WebCam video feed.
  35208. * @param scene Define the scene the texture should be created in
  35209. * @param onReady Define a callback to triggered once the texture will be ready
  35210. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35211. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35212. */
  35213. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35214. minWidth: number;
  35215. maxWidth: number;
  35216. minHeight: number;
  35217. maxHeight: number;
  35218. deviceId: string;
  35219. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35220. }
  35221. }
  35222. declare module "babylonjs/Engines/thinEngine" {
  35223. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35224. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35225. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35226. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35227. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35228. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35229. import { Observable } from "babylonjs/Misc/observable";
  35230. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35231. import { StencilState } from "babylonjs/States/stencilState";
  35232. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35233. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35234. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35235. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35236. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35237. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35238. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35239. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35240. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35241. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35242. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35243. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35244. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35245. import { WebRequest } from "babylonjs/Misc/webRequest";
  35246. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35247. /**
  35248. * Defines the interface used by objects working like Scene
  35249. * @hidden
  35250. */
  35251. export interface ISceneLike {
  35252. _addPendingData(data: any): void;
  35253. _removePendingData(data: any): void;
  35254. offlineProvider: IOfflineProvider;
  35255. }
  35256. /** Interface defining initialization parameters for Engine class */
  35257. export interface EngineOptions extends WebGLContextAttributes {
  35258. /**
  35259. * Defines if the engine should no exceed a specified device ratio
  35260. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35261. */
  35262. limitDeviceRatio?: number;
  35263. /**
  35264. * Defines if webvr should be enabled automatically
  35265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35266. */
  35267. autoEnableWebVR?: boolean;
  35268. /**
  35269. * Defines if webgl2 should be turned off even if supported
  35270. * @see http://doc.babylonjs.com/features/webgl2
  35271. */
  35272. disableWebGL2Support?: boolean;
  35273. /**
  35274. * Defines if webaudio should be initialized as well
  35275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35276. */
  35277. audioEngine?: boolean;
  35278. /**
  35279. * Defines if animations should run using a deterministic lock step
  35280. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35281. */
  35282. deterministicLockstep?: boolean;
  35283. /** Defines the maximum steps to use with deterministic lock step mode */
  35284. lockstepMaxSteps?: number;
  35285. /** Defines the seconds between each deterministic lock step */
  35286. timeStep?: number;
  35287. /**
  35288. * Defines that engine should ignore context lost events
  35289. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35290. */
  35291. doNotHandleContextLost?: boolean;
  35292. /**
  35293. * Defines that engine should ignore modifying touch action attribute and style
  35294. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35295. */
  35296. doNotHandleTouchAction?: boolean;
  35297. /**
  35298. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35299. */
  35300. useHighPrecisionFloats?: boolean;
  35301. /**
  35302. * Make the canvas XR Compatible for XR sessions
  35303. */
  35304. xrCompatible?: boolean;
  35305. }
  35306. /**
  35307. * The base engine class (root of all engines)
  35308. */
  35309. export class ThinEngine {
  35310. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35311. static ExceptionList: ({
  35312. key: string;
  35313. capture: string;
  35314. captureConstraint: number;
  35315. targets: string[];
  35316. } | {
  35317. key: string;
  35318. capture: null;
  35319. captureConstraint: null;
  35320. targets: string[];
  35321. })[];
  35322. /** @hidden */
  35323. static _TextureLoaders: IInternalTextureLoader[];
  35324. /**
  35325. * Returns the current npm package of the sdk
  35326. */
  35327. static get NpmPackage(): string;
  35328. /**
  35329. * Returns the current version of the framework
  35330. */
  35331. static get Version(): string;
  35332. /**
  35333. * Returns a string describing the current engine
  35334. */
  35335. get description(): string;
  35336. /**
  35337. * Gets or sets the epsilon value used by collision engine
  35338. */
  35339. static CollisionsEpsilon: number;
  35340. /**
  35341. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35342. */
  35343. static get ShadersRepository(): string;
  35344. static set ShadersRepository(value: string);
  35345. /** @hidden */
  35346. _shaderProcessor: IShaderProcessor;
  35347. /**
  35348. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35349. */
  35350. forcePOTTextures: boolean;
  35351. /**
  35352. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35353. */
  35354. isFullscreen: boolean;
  35355. /**
  35356. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35357. */
  35358. cullBackFaces: boolean;
  35359. /**
  35360. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35361. */
  35362. renderEvenInBackground: boolean;
  35363. /**
  35364. * Gets or sets a boolean indicating that cache can be kept between frames
  35365. */
  35366. preventCacheWipeBetweenFrames: boolean;
  35367. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35368. validateShaderPrograms: boolean;
  35369. /**
  35370. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35371. * This can provide greater z depth for distant objects.
  35372. */
  35373. useReverseDepthBuffer: boolean;
  35374. /**
  35375. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35376. */
  35377. disableUniformBuffers: boolean;
  35378. /** @hidden */
  35379. _uniformBuffers: UniformBuffer[];
  35380. /**
  35381. * Gets a boolean indicating that the engine supports uniform buffers
  35382. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35383. */
  35384. get supportsUniformBuffers(): boolean;
  35385. /** @hidden */
  35386. _gl: WebGLRenderingContext;
  35387. /** @hidden */
  35388. _webGLVersion: number;
  35389. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35390. protected _windowIsBackground: boolean;
  35391. protected _creationOptions: EngineOptions;
  35392. protected _highPrecisionShadersAllowed: boolean;
  35393. /** @hidden */
  35394. get _shouldUseHighPrecisionShader(): boolean;
  35395. /**
  35396. * Gets a boolean indicating that only power of 2 textures are supported
  35397. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35398. */
  35399. get needPOTTextures(): boolean;
  35400. /** @hidden */
  35401. _badOS: boolean;
  35402. /** @hidden */
  35403. _badDesktopOS: boolean;
  35404. private _hardwareScalingLevel;
  35405. /** @hidden */
  35406. _caps: EngineCapabilities;
  35407. private _isStencilEnable;
  35408. private _glVersion;
  35409. private _glRenderer;
  35410. private _glVendor;
  35411. /** @hidden */
  35412. _videoTextureSupported: boolean;
  35413. protected _renderingQueueLaunched: boolean;
  35414. protected _activeRenderLoops: (() => void)[];
  35415. /**
  35416. * Observable signaled when a context lost event is raised
  35417. */
  35418. onContextLostObservable: Observable<ThinEngine>;
  35419. /**
  35420. * Observable signaled when a context restored event is raised
  35421. */
  35422. onContextRestoredObservable: Observable<ThinEngine>;
  35423. private _onContextLost;
  35424. private _onContextRestored;
  35425. protected _contextWasLost: boolean;
  35426. /** @hidden */
  35427. _doNotHandleContextLost: boolean;
  35428. /**
  35429. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35431. */
  35432. get doNotHandleContextLost(): boolean;
  35433. set doNotHandleContextLost(value: boolean);
  35434. /**
  35435. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35436. */
  35437. disableVertexArrayObjects: boolean;
  35438. /** @hidden */
  35439. protected _colorWrite: boolean;
  35440. /** @hidden */
  35441. protected _colorWriteChanged: boolean;
  35442. /** @hidden */
  35443. protected _depthCullingState: DepthCullingState;
  35444. /** @hidden */
  35445. protected _stencilState: StencilState;
  35446. /** @hidden */
  35447. _alphaState: AlphaState;
  35448. /** @hidden */
  35449. _alphaMode: number;
  35450. /** @hidden */
  35451. _alphaEquation: number;
  35452. /** @hidden */
  35453. _internalTexturesCache: InternalTexture[];
  35454. /** @hidden */
  35455. protected _activeChannel: number;
  35456. private _currentTextureChannel;
  35457. /** @hidden */
  35458. protected _boundTexturesCache: {
  35459. [key: string]: Nullable<InternalTexture>;
  35460. };
  35461. /** @hidden */
  35462. protected _currentEffect: Nullable<Effect>;
  35463. /** @hidden */
  35464. protected _currentProgram: Nullable<WebGLProgram>;
  35465. private _compiledEffects;
  35466. private _vertexAttribArraysEnabled;
  35467. /** @hidden */
  35468. protected _cachedViewport: Nullable<IViewportLike>;
  35469. private _cachedVertexArrayObject;
  35470. /** @hidden */
  35471. protected _cachedVertexBuffers: any;
  35472. /** @hidden */
  35473. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35474. /** @hidden */
  35475. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35476. /** @hidden */
  35477. _currentRenderTarget: Nullable<InternalTexture>;
  35478. private _uintIndicesCurrentlySet;
  35479. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35480. /** @hidden */
  35481. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35482. /** @hidden */
  35483. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35484. private _currentBufferPointers;
  35485. private _currentInstanceLocations;
  35486. private _currentInstanceBuffers;
  35487. private _textureUnits;
  35488. /** @hidden */
  35489. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35490. /** @hidden */
  35491. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35492. /** @hidden */
  35493. _boundRenderFunction: any;
  35494. private _vaoRecordInProgress;
  35495. private _mustWipeVertexAttributes;
  35496. private _emptyTexture;
  35497. private _emptyCubeTexture;
  35498. private _emptyTexture3D;
  35499. private _emptyTexture2DArray;
  35500. /** @hidden */
  35501. _frameHandler: number;
  35502. private _nextFreeTextureSlots;
  35503. private _maxSimultaneousTextures;
  35504. private _activeRequests;
  35505. /** @hidden */
  35506. _transformTextureUrl: Nullable<(url: string) => string>;
  35507. protected get _supportsHardwareTextureRescaling(): boolean;
  35508. private _framebufferDimensionsObject;
  35509. /**
  35510. * sets the object from which width and height will be taken from when getting render width and height
  35511. * Will fallback to the gl object
  35512. * @param dimensions the framebuffer width and height that will be used.
  35513. */
  35514. set framebufferDimensionsObject(dimensions: Nullable<{
  35515. framebufferWidth: number;
  35516. framebufferHeight: number;
  35517. }>);
  35518. /**
  35519. * Gets the current viewport
  35520. */
  35521. get currentViewport(): Nullable<IViewportLike>;
  35522. /**
  35523. * Gets the default empty texture
  35524. */
  35525. get emptyTexture(): InternalTexture;
  35526. /**
  35527. * Gets the default empty 3D texture
  35528. */
  35529. get emptyTexture3D(): InternalTexture;
  35530. /**
  35531. * Gets the default empty 2D array texture
  35532. */
  35533. get emptyTexture2DArray(): InternalTexture;
  35534. /**
  35535. * Gets the default empty cube texture
  35536. */
  35537. get emptyCubeTexture(): InternalTexture;
  35538. /**
  35539. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35540. */
  35541. readonly premultipliedAlpha: boolean;
  35542. /**
  35543. * Observable event triggered before each texture is initialized
  35544. */
  35545. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35546. /**
  35547. * Creates a new engine
  35548. * @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
  35549. * @param antialias defines enable antialiasing (default: false)
  35550. * @param options defines further options to be sent to the getContext() function
  35551. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35552. */
  35553. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35554. private _rebuildInternalTextures;
  35555. private _rebuildEffects;
  35556. /**
  35557. * Gets a boolean indicating if all created effects are ready
  35558. * @returns true if all effects are ready
  35559. */
  35560. areAllEffectsReady(): boolean;
  35561. protected _rebuildBuffers(): void;
  35562. protected _initGLContext(): void;
  35563. /**
  35564. * Gets version of the current webGL context
  35565. */
  35566. get webGLVersion(): number;
  35567. /**
  35568. * Gets a string idenfifying the name of the class
  35569. * @returns "Engine" string
  35570. */
  35571. getClassName(): string;
  35572. /**
  35573. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35574. */
  35575. get isStencilEnable(): boolean;
  35576. /** @hidden */
  35577. _prepareWorkingCanvas(): void;
  35578. /**
  35579. * Reset the texture cache to empty state
  35580. */
  35581. resetTextureCache(): void;
  35582. /**
  35583. * Gets an object containing information about the current webGL context
  35584. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35585. */
  35586. getGlInfo(): {
  35587. vendor: string;
  35588. renderer: string;
  35589. version: string;
  35590. };
  35591. /**
  35592. * Defines the hardware scaling level.
  35593. * By default the hardware scaling level is computed from the window device ratio.
  35594. * 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.
  35595. * @param level defines the level to use
  35596. */
  35597. setHardwareScalingLevel(level: number): void;
  35598. /**
  35599. * Gets the current hardware scaling level.
  35600. * By default the hardware scaling level is computed from the window device ratio.
  35601. * 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.
  35602. * @returns a number indicating the current hardware scaling level
  35603. */
  35604. getHardwareScalingLevel(): number;
  35605. /**
  35606. * Gets the list of loaded textures
  35607. * @returns an array containing all loaded textures
  35608. */
  35609. getLoadedTexturesCache(): InternalTexture[];
  35610. /**
  35611. * Gets the object containing all engine capabilities
  35612. * @returns the EngineCapabilities object
  35613. */
  35614. getCaps(): EngineCapabilities;
  35615. /**
  35616. * stop executing a render loop function and remove it from the execution array
  35617. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35618. */
  35619. stopRenderLoop(renderFunction?: () => void): void;
  35620. /** @hidden */
  35621. _renderLoop(): void;
  35622. /**
  35623. * Gets the HTML canvas attached with the current webGL context
  35624. * @returns a HTML canvas
  35625. */
  35626. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35627. /**
  35628. * Gets host window
  35629. * @returns the host window object
  35630. */
  35631. getHostWindow(): Nullable<Window>;
  35632. /**
  35633. * Gets the current render width
  35634. * @param useScreen defines if screen size must be used (or the current render target if any)
  35635. * @returns a number defining the current render width
  35636. */
  35637. getRenderWidth(useScreen?: boolean): number;
  35638. /**
  35639. * Gets the current render height
  35640. * @param useScreen defines if screen size must be used (or the current render target if any)
  35641. * @returns a number defining the current render height
  35642. */
  35643. getRenderHeight(useScreen?: boolean): number;
  35644. /**
  35645. * Can be used to override the current requestAnimationFrame requester.
  35646. * @hidden
  35647. */
  35648. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35649. /**
  35650. * Register and execute a render loop. The engine can have more than one render function
  35651. * @param renderFunction defines the function to continuously execute
  35652. */
  35653. runRenderLoop(renderFunction: () => void): void;
  35654. /**
  35655. * Clear the current render buffer or the current render target (if any is set up)
  35656. * @param color defines the color to use
  35657. * @param backBuffer defines if the back buffer must be cleared
  35658. * @param depth defines if the depth buffer must be cleared
  35659. * @param stencil defines if the stencil buffer must be cleared
  35660. */
  35661. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35662. private _viewportCached;
  35663. /** @hidden */
  35664. _viewport(x: number, y: number, width: number, height: number): void;
  35665. /**
  35666. * Set the WebGL's viewport
  35667. * @param viewport defines the viewport element to be used
  35668. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35669. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35670. */
  35671. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35672. /**
  35673. * Begin a new frame
  35674. */
  35675. beginFrame(): void;
  35676. /**
  35677. * Enf the current frame
  35678. */
  35679. endFrame(): void;
  35680. /**
  35681. * Resize the view according to the canvas' size
  35682. */
  35683. resize(): void;
  35684. /**
  35685. * Force a specific size of the canvas
  35686. * @param width defines the new canvas' width
  35687. * @param height defines the new canvas' height
  35688. */
  35689. setSize(width: number, height: number): void;
  35690. /**
  35691. * Binds the frame buffer to the specified texture.
  35692. * @param texture The texture to render to or null for the default canvas
  35693. * @param faceIndex The face of the texture to render to in case of cube texture
  35694. * @param requiredWidth The width of the target to render to
  35695. * @param requiredHeight The height of the target to render to
  35696. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35697. * @param lodLevel defines the lod level to bind to the frame buffer
  35698. * @param layer defines the 2d array index to bind to frame buffer to
  35699. */
  35700. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35701. /** @hidden */
  35702. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35703. /**
  35704. * Unbind the current render target texture from the webGL context
  35705. * @param texture defines the render target texture to unbind
  35706. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35707. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35708. */
  35709. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35710. /**
  35711. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35712. */
  35713. flushFramebuffer(): void;
  35714. /**
  35715. * Unbind the current render target and bind the default framebuffer
  35716. */
  35717. restoreDefaultFramebuffer(): void;
  35718. /** @hidden */
  35719. protected _resetVertexBufferBinding(): void;
  35720. /**
  35721. * Creates a vertex buffer
  35722. * @param data the data for the vertex buffer
  35723. * @returns the new WebGL static buffer
  35724. */
  35725. createVertexBuffer(data: DataArray): DataBuffer;
  35726. private _createVertexBuffer;
  35727. /**
  35728. * Creates a dynamic vertex buffer
  35729. * @param data the data for the dynamic vertex buffer
  35730. * @returns the new WebGL dynamic buffer
  35731. */
  35732. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35733. protected _resetIndexBufferBinding(): void;
  35734. /**
  35735. * Creates a new index buffer
  35736. * @param indices defines the content of the index buffer
  35737. * @param updatable defines if the index buffer must be updatable
  35738. * @returns a new webGL buffer
  35739. */
  35740. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35741. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35742. /**
  35743. * Bind a webGL buffer to the webGL context
  35744. * @param buffer defines the buffer to bind
  35745. */
  35746. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35747. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35748. private bindBuffer;
  35749. /**
  35750. * update the bound buffer with the given data
  35751. * @param data defines the data to update
  35752. */
  35753. updateArrayBuffer(data: Float32Array): void;
  35754. private _vertexAttribPointer;
  35755. /** @hidden */
  35756. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35757. private _bindVertexBuffersAttributes;
  35758. /**
  35759. * Records a vertex array object
  35760. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35761. * @param vertexBuffers defines the list of vertex buffers to store
  35762. * @param indexBuffer defines the index buffer to store
  35763. * @param effect defines the effect to store
  35764. * @returns the new vertex array object
  35765. */
  35766. recordVertexArrayObject(vertexBuffers: {
  35767. [key: string]: VertexBuffer;
  35768. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35769. /**
  35770. * Bind a specific vertex array object
  35771. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35772. * @param vertexArrayObject defines the vertex array object to bind
  35773. * @param indexBuffer defines the index buffer to bind
  35774. */
  35775. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35776. /**
  35777. * Bind webGl buffers directly to the webGL context
  35778. * @param vertexBuffer defines the vertex buffer to bind
  35779. * @param indexBuffer defines the index buffer to bind
  35780. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35781. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35782. * @param effect defines the effect associated with the vertex buffer
  35783. */
  35784. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35785. private _unbindVertexArrayObject;
  35786. /**
  35787. * Bind a list of vertex buffers to the webGL context
  35788. * @param vertexBuffers defines the list of vertex buffers to bind
  35789. * @param indexBuffer defines the index buffer to bind
  35790. * @param effect defines the effect associated with the vertex buffers
  35791. */
  35792. bindBuffers(vertexBuffers: {
  35793. [key: string]: Nullable<VertexBuffer>;
  35794. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35795. /**
  35796. * Unbind all instance attributes
  35797. */
  35798. unbindInstanceAttributes(): void;
  35799. /**
  35800. * Release and free the memory of a vertex array object
  35801. * @param vao defines the vertex array object to delete
  35802. */
  35803. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35804. /** @hidden */
  35805. _releaseBuffer(buffer: DataBuffer): boolean;
  35806. protected _deleteBuffer(buffer: DataBuffer): void;
  35807. /**
  35808. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35809. * @param instancesBuffer defines the webGL buffer to update and bind
  35810. * @param data defines the data to store in the buffer
  35811. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35812. */
  35813. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35814. /**
  35815. * Bind the content of a webGL buffer used with instantiation
  35816. * @param instancesBuffer defines the webGL buffer to bind
  35817. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35818. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35819. */
  35820. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35821. /**
  35822. * Disable the instance attribute corresponding to the name in parameter
  35823. * @param name defines the name of the attribute to disable
  35824. */
  35825. disableInstanceAttributeByName(name: string): void;
  35826. /**
  35827. * Disable the instance attribute corresponding to the location in parameter
  35828. * @param attributeLocation defines the attribute location of the attribute to disable
  35829. */
  35830. disableInstanceAttribute(attributeLocation: number): void;
  35831. /**
  35832. * Disable the attribute corresponding to the location in parameter
  35833. * @param attributeLocation defines the attribute location of the attribute to disable
  35834. */
  35835. disableAttributeByIndex(attributeLocation: number): void;
  35836. /**
  35837. * Send a draw order
  35838. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35839. * @param indexStart defines the starting index
  35840. * @param indexCount defines the number of index to draw
  35841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35842. */
  35843. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35844. /**
  35845. * Draw a list of points
  35846. * @param verticesStart defines the index of first vertex to draw
  35847. * @param verticesCount defines the count of vertices to draw
  35848. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35849. */
  35850. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35851. /**
  35852. * Draw a list of unindexed primitives
  35853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35854. * @param verticesStart defines the index of first vertex to draw
  35855. * @param verticesCount defines the count of vertices to draw
  35856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35857. */
  35858. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35859. /**
  35860. * Draw a list of indexed primitives
  35861. * @param fillMode defines the primitive to use
  35862. * @param indexStart defines the starting index
  35863. * @param indexCount defines the number of index to draw
  35864. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35865. */
  35866. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35867. /**
  35868. * Draw a list of unindexed primitives
  35869. * @param fillMode defines the primitive to use
  35870. * @param verticesStart defines the index of first vertex to draw
  35871. * @param verticesCount defines the count of vertices to draw
  35872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35873. */
  35874. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35875. private _drawMode;
  35876. /** @hidden */
  35877. protected _reportDrawCall(): void;
  35878. /** @hidden */
  35879. _releaseEffect(effect: Effect): void;
  35880. /** @hidden */
  35881. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35882. /**
  35883. * Create a new effect (used to store vertex/fragment shaders)
  35884. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35885. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35886. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35887. * @param samplers defines an array of string used to represent textures
  35888. * @param defines defines the string containing the defines to use to compile the shaders
  35889. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35890. * @param onCompiled defines a function to call when the effect creation is successful
  35891. * @param onError defines a function to call when the effect creation has failed
  35892. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35893. * @returns the new Effect
  35894. */
  35895. 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;
  35896. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35897. private _compileShader;
  35898. private _compileRawShader;
  35899. /** @hidden */
  35900. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35901. /**
  35902. * Directly creates a webGL program
  35903. * @param pipelineContext defines the pipeline context to attach to
  35904. * @param vertexCode defines the vertex shader code to use
  35905. * @param fragmentCode defines the fragment shader code to use
  35906. * @param context defines the webGL context to use (if not set, the current one will be used)
  35907. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35908. * @returns the new webGL program
  35909. */
  35910. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35911. /**
  35912. * Creates a webGL program
  35913. * @param pipelineContext defines the pipeline context to attach to
  35914. * @param vertexCode defines the vertex shader code to use
  35915. * @param fragmentCode defines the fragment shader code to use
  35916. * @param defines defines the string containing the defines to use to compile the shaders
  35917. * @param context defines the webGL context to use (if not set, the current one will be used)
  35918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35919. * @returns the new webGL program
  35920. */
  35921. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35922. /**
  35923. * Creates a new pipeline context
  35924. * @returns the new pipeline
  35925. */
  35926. createPipelineContext(): IPipelineContext;
  35927. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35928. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35929. /** @hidden */
  35930. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35931. /** @hidden */
  35932. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35933. /** @hidden */
  35934. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35935. /**
  35936. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35937. * @param pipelineContext defines the pipeline context to use
  35938. * @param uniformsNames defines the list of uniform names
  35939. * @returns an array of webGL uniform locations
  35940. */
  35941. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35942. /**
  35943. * Gets the lsit of active attributes for a given webGL program
  35944. * @param pipelineContext defines the pipeline context to use
  35945. * @param attributesNames defines the list of attribute names to get
  35946. * @returns an array of indices indicating the offset of each attribute
  35947. */
  35948. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35949. /**
  35950. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35951. * @param effect defines the effect to activate
  35952. */
  35953. enableEffect(effect: Nullable<Effect>): void;
  35954. /**
  35955. * Set the value of an uniform to a number (int)
  35956. * @param uniform defines the webGL uniform location where to store the value
  35957. * @param value defines the int number to store
  35958. */
  35959. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35960. /**
  35961. * Set the value of an uniform to an array of int32
  35962. * @param uniform defines the webGL uniform location where to store the value
  35963. * @param array defines the array of int32 to store
  35964. */
  35965. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35966. /**
  35967. * Set the value of an uniform to an array of int32 (stored as vec2)
  35968. * @param uniform defines the webGL uniform location where to store the value
  35969. * @param array defines the array of int32 to store
  35970. */
  35971. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35972. /**
  35973. * Set the value of an uniform to an array of int32 (stored as vec3)
  35974. * @param uniform defines the webGL uniform location where to store the value
  35975. * @param array defines the array of int32 to store
  35976. */
  35977. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35978. /**
  35979. * Set the value of an uniform to an array of int32 (stored as vec4)
  35980. * @param uniform defines the webGL uniform location where to store the value
  35981. * @param array defines the array of int32 to store
  35982. */
  35983. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35984. /**
  35985. * Set the value of an uniform to an array of number
  35986. * @param uniform defines the webGL uniform location where to store the value
  35987. * @param array defines the array of number to store
  35988. */
  35989. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35990. /**
  35991. * Set the value of an uniform to an array of number (stored as vec2)
  35992. * @param uniform defines the webGL uniform location where to store the value
  35993. * @param array defines the array of number to store
  35994. */
  35995. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35996. /**
  35997. * Set the value of an uniform to an array of number (stored as vec3)
  35998. * @param uniform defines the webGL uniform location where to store the value
  35999. * @param array defines the array of number to store
  36000. */
  36001. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36002. /**
  36003. * Set the value of an uniform to an array of number (stored as vec4)
  36004. * @param uniform defines the webGL uniform location where to store the value
  36005. * @param array defines the array of number to store
  36006. */
  36007. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36008. /**
  36009. * Set the value of an uniform to an array of float32 (stored as matrices)
  36010. * @param uniform defines the webGL uniform location where to store the value
  36011. * @param matrices defines the array of float32 to store
  36012. */
  36013. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36014. /**
  36015. * Set the value of an uniform to a matrix (3x3)
  36016. * @param uniform defines the webGL uniform location where to store the value
  36017. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36018. */
  36019. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36020. /**
  36021. * Set the value of an uniform to a matrix (2x2)
  36022. * @param uniform defines the webGL uniform location where to store the value
  36023. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36024. */
  36025. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36026. /**
  36027. * Set the value of an uniform to a number (float)
  36028. * @param uniform defines the webGL uniform location where to store the value
  36029. * @param value defines the float number to store
  36030. */
  36031. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36032. /**
  36033. * Set the value of an uniform to a vec2
  36034. * @param uniform defines the webGL uniform location where to store the value
  36035. * @param x defines the 1st component of the value
  36036. * @param y defines the 2nd component of the value
  36037. */
  36038. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36039. /**
  36040. * Set the value of an uniform to a vec3
  36041. * @param uniform defines the webGL uniform location where to store the value
  36042. * @param x defines the 1st component of the value
  36043. * @param y defines the 2nd component of the value
  36044. * @param z defines the 3rd component of the value
  36045. */
  36046. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36047. /**
  36048. * Set the value of an uniform to a vec4
  36049. * @param uniform defines the webGL uniform location where to store the value
  36050. * @param x defines the 1st component of the value
  36051. * @param y defines the 2nd component of the value
  36052. * @param z defines the 3rd component of the value
  36053. * @param w defines the 4th component of the value
  36054. */
  36055. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36056. /**
  36057. * Apply all cached states (depth, culling, stencil and alpha)
  36058. */
  36059. applyStates(): void;
  36060. /**
  36061. * Enable or disable color writing
  36062. * @param enable defines the state to set
  36063. */
  36064. setColorWrite(enable: boolean): void;
  36065. /**
  36066. * Gets a boolean indicating if color writing is enabled
  36067. * @returns the current color writing state
  36068. */
  36069. getColorWrite(): boolean;
  36070. /**
  36071. * Gets the depth culling state manager
  36072. */
  36073. get depthCullingState(): DepthCullingState;
  36074. /**
  36075. * Gets the alpha state manager
  36076. */
  36077. get alphaState(): AlphaState;
  36078. /**
  36079. * Gets the stencil state manager
  36080. */
  36081. get stencilState(): StencilState;
  36082. /**
  36083. * Clears the list of texture accessible through engine.
  36084. * This can help preventing texture load conflict due to name collision.
  36085. */
  36086. clearInternalTexturesCache(): void;
  36087. /**
  36088. * Force the entire cache to be cleared
  36089. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36090. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36091. */
  36092. wipeCaches(bruteForce?: boolean): void;
  36093. /** @hidden */
  36094. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36095. min: number;
  36096. mag: number;
  36097. };
  36098. /** @hidden */
  36099. _createTexture(): WebGLTexture;
  36100. /**
  36101. * Usually called from Texture.ts.
  36102. * Passed information to create a WebGLTexture
  36103. * @param url defines a value which contains one of the following:
  36104. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36105. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36106. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36107. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36108. * @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)
  36109. * @param scene needed for loading to the correct scene
  36110. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36111. * @param onLoad optional callback to be called upon successful completion
  36112. * @param onError optional callback to be called upon failure
  36113. * @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
  36114. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36115. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36116. * @param forcedExtension defines the extension to use to pick the right loader
  36117. * @param mimeType defines an optional mime type
  36118. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36119. */
  36120. 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;
  36121. /**
  36122. * Loads an image as an HTMLImageElement.
  36123. * @param input url string, ArrayBuffer, or Blob to load
  36124. * @param onLoad callback called when the image successfully loads
  36125. * @param onError callback called when the image fails to load
  36126. * @param offlineProvider offline provider for caching
  36127. * @param mimeType optional mime type
  36128. * @returns the HTMLImageElement of the loaded image
  36129. * @hidden
  36130. */
  36131. 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>;
  36132. /**
  36133. * @hidden
  36134. */
  36135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36136. private _unpackFlipYCached;
  36137. /**
  36138. * In case you are sharing the context with other applications, it might
  36139. * be interested to not cache the unpack flip y state to ensure a consistent
  36140. * value would be set.
  36141. */
  36142. enableUnpackFlipYCached: boolean;
  36143. /** @hidden */
  36144. _unpackFlipY(value: boolean): void;
  36145. /** @hidden */
  36146. _getUnpackAlignement(): number;
  36147. private _getTextureTarget;
  36148. /**
  36149. * Update the sampling mode of a given texture
  36150. * @param samplingMode defines the required sampling mode
  36151. * @param texture defines the texture to update
  36152. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36153. */
  36154. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36155. /**
  36156. * Update the sampling mode of a given texture
  36157. * @param texture defines the texture to update
  36158. * @param wrapU defines the texture wrap mode of the u coordinates
  36159. * @param wrapV defines the texture wrap mode of the v coordinates
  36160. * @param wrapR defines the texture wrap mode of the r coordinates
  36161. */
  36162. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36163. /** @hidden */
  36164. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36165. width: number;
  36166. height: number;
  36167. layers?: number;
  36168. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36169. /** @hidden */
  36170. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36171. /** @hidden */
  36172. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36173. /**
  36174. * Update a portion of an internal texture
  36175. * @param texture defines the texture to update
  36176. * @param imageData defines the data to store into the texture
  36177. * @param xOffset defines the x coordinates of the update rectangle
  36178. * @param yOffset defines the y coordinates of the update rectangle
  36179. * @param width defines the width of the update rectangle
  36180. * @param height defines the height of the update rectangle
  36181. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36182. * @param lod defines the lod level to update (0 by default)
  36183. */
  36184. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36185. /** @hidden */
  36186. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36187. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36188. private _prepareWebGLTexture;
  36189. /** @hidden */
  36190. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36191. private _getDepthStencilBuffer;
  36192. /** @hidden */
  36193. _releaseFramebufferObjects(texture: InternalTexture): void;
  36194. /** @hidden */
  36195. _releaseTexture(texture: InternalTexture): void;
  36196. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36197. protected _setProgram(program: WebGLProgram): void;
  36198. protected _boundUniforms: {
  36199. [key: number]: WebGLUniformLocation;
  36200. };
  36201. /**
  36202. * Binds an effect to the webGL context
  36203. * @param effect defines the effect to bind
  36204. */
  36205. bindSamplers(effect: Effect): void;
  36206. private _activateCurrentTexture;
  36207. /** @hidden */
  36208. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36209. /** @hidden */
  36210. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36211. /**
  36212. * Unbind all textures from the webGL context
  36213. */
  36214. unbindAllTextures(): void;
  36215. /**
  36216. * Sets a texture to the according uniform.
  36217. * @param channel The texture channel
  36218. * @param uniform The uniform to set
  36219. * @param texture The texture to apply
  36220. */
  36221. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36222. private _bindSamplerUniformToChannel;
  36223. private _getTextureWrapMode;
  36224. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36225. /**
  36226. * Sets an array of texture to the webGL context
  36227. * @param channel defines the channel where the texture array must be set
  36228. * @param uniform defines the associated uniform location
  36229. * @param textures defines the array of textures to bind
  36230. */
  36231. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36232. /** @hidden */
  36233. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36234. private _setTextureParameterFloat;
  36235. private _setTextureParameterInteger;
  36236. /**
  36237. * Unbind all vertex attributes from the webGL context
  36238. */
  36239. unbindAllAttributes(): void;
  36240. /**
  36241. * 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
  36242. */
  36243. releaseEffects(): void;
  36244. /**
  36245. * Dispose and release all associated resources
  36246. */
  36247. dispose(): void;
  36248. /**
  36249. * Attach a new callback raised when context lost event is fired
  36250. * @param callback defines the callback to call
  36251. */
  36252. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36253. /**
  36254. * Attach a new callback raised when context restored event is fired
  36255. * @param callback defines the callback to call
  36256. */
  36257. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36258. /**
  36259. * Get the current error code of the webGL context
  36260. * @returns the error code
  36261. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36262. */
  36263. getError(): number;
  36264. private _canRenderToFloatFramebuffer;
  36265. private _canRenderToHalfFloatFramebuffer;
  36266. private _canRenderToFramebuffer;
  36267. /** @hidden */
  36268. _getWebGLTextureType(type: number): number;
  36269. /** @hidden */
  36270. _getInternalFormat(format: number): number;
  36271. /** @hidden */
  36272. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36273. /** @hidden */
  36274. _getRGBAMultiSampleBufferFormat(type: number): number;
  36275. /** @hidden */
  36276. _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;
  36277. /**
  36278. * Loads a file from a url
  36279. * @param url url to load
  36280. * @param onSuccess callback called when the file successfully loads
  36281. * @param onProgress callback called while file is loading (if the server supports this mode)
  36282. * @param offlineProvider defines the offline provider for caching
  36283. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36284. * @param onError callback called when the file fails to load
  36285. * @returns a file request object
  36286. * @hidden
  36287. */
  36288. 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;
  36289. /**
  36290. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36291. * @param x defines the x coordinate of the rectangle where pixels must be read
  36292. * @param y defines the y coordinate of the rectangle where pixels must be read
  36293. * @param width defines the width of the rectangle where pixels must be read
  36294. * @param height defines the height of the rectangle where pixels must be read
  36295. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36296. * @returns a Uint8Array containing RGBA colors
  36297. */
  36298. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36299. private static _isSupported;
  36300. /**
  36301. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36302. * @returns true if the engine can be created
  36303. * @ignorenaming
  36304. */
  36305. static isSupported(): boolean;
  36306. /**
  36307. * Find the next highest power of two.
  36308. * @param x Number to start search from.
  36309. * @return Next highest power of two.
  36310. */
  36311. static CeilingPOT(x: number): number;
  36312. /**
  36313. * Find the next lowest power of two.
  36314. * @param x Number to start search from.
  36315. * @return Next lowest power of two.
  36316. */
  36317. static FloorPOT(x: number): number;
  36318. /**
  36319. * Find the nearest power of two.
  36320. * @param x Number to start search from.
  36321. * @return Next nearest power of two.
  36322. */
  36323. static NearestPOT(x: number): number;
  36324. /**
  36325. * Get the closest exponent of two
  36326. * @param value defines the value to approximate
  36327. * @param max defines the maximum value to return
  36328. * @param mode defines how to define the closest value
  36329. * @returns closest exponent of two of the given value
  36330. */
  36331. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36332. /**
  36333. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36334. * @param func - the function to be called
  36335. * @param requester - the object that will request the next frame. Falls back to window.
  36336. * @returns frame number
  36337. */
  36338. static QueueNewFrame(func: () => void, requester?: any): number;
  36339. /**
  36340. * Gets host document
  36341. * @returns the host document object
  36342. */
  36343. getHostDocument(): Nullable<Document>;
  36344. }
  36345. }
  36346. declare module "babylonjs/Maths/sphericalPolynomial" {
  36347. import { Vector3 } from "babylonjs/Maths/math.vector";
  36348. import { Color3 } from "babylonjs/Maths/math.color";
  36349. /**
  36350. * Class representing spherical harmonics coefficients to the 3rd degree
  36351. */
  36352. export class SphericalHarmonics {
  36353. /**
  36354. * Defines whether or not the harmonics have been prescaled for rendering.
  36355. */
  36356. preScaled: boolean;
  36357. /**
  36358. * The l0,0 coefficients of the spherical harmonics
  36359. */
  36360. l00: Vector3;
  36361. /**
  36362. * The l1,-1 coefficients of the spherical harmonics
  36363. */
  36364. l1_1: Vector3;
  36365. /**
  36366. * The l1,0 coefficients of the spherical harmonics
  36367. */
  36368. l10: Vector3;
  36369. /**
  36370. * The l1,1 coefficients of the spherical harmonics
  36371. */
  36372. l11: Vector3;
  36373. /**
  36374. * The l2,-2 coefficients of the spherical harmonics
  36375. */
  36376. l2_2: Vector3;
  36377. /**
  36378. * The l2,-1 coefficients of the spherical harmonics
  36379. */
  36380. l2_1: Vector3;
  36381. /**
  36382. * The l2,0 coefficients of the spherical harmonics
  36383. */
  36384. l20: Vector3;
  36385. /**
  36386. * The l2,1 coefficients of the spherical harmonics
  36387. */
  36388. l21: Vector3;
  36389. /**
  36390. * The l2,2 coefficients of the spherical harmonics
  36391. */
  36392. l22: Vector3;
  36393. /**
  36394. * Adds a light to the spherical harmonics
  36395. * @param direction the direction of the light
  36396. * @param color the color of the light
  36397. * @param deltaSolidAngle the delta solid angle of the light
  36398. */
  36399. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36400. /**
  36401. * Scales the spherical harmonics by the given amount
  36402. * @param scale the amount to scale
  36403. */
  36404. scaleInPlace(scale: number): void;
  36405. /**
  36406. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36407. *
  36408. * ```
  36409. * E_lm = A_l * L_lm
  36410. * ```
  36411. *
  36412. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36413. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36414. * the scaling factors are given in equation 9.
  36415. */
  36416. convertIncidentRadianceToIrradiance(): void;
  36417. /**
  36418. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36419. *
  36420. * ```
  36421. * L = (1/pi) * E * rho
  36422. * ```
  36423. *
  36424. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36425. */
  36426. convertIrradianceToLambertianRadiance(): void;
  36427. /**
  36428. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36429. * required operations at run time.
  36430. *
  36431. * This is simply done by scaling back the SH with Ylm constants parameter.
  36432. * The trigonometric part being applied by the shader at run time.
  36433. */
  36434. preScaleForRendering(): void;
  36435. /**
  36436. * Constructs a spherical harmonics from an array.
  36437. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36438. * @returns the spherical harmonics
  36439. */
  36440. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36441. /**
  36442. * Gets the spherical harmonics from polynomial
  36443. * @param polynomial the spherical polynomial
  36444. * @returns the spherical harmonics
  36445. */
  36446. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36447. }
  36448. /**
  36449. * Class representing spherical polynomial coefficients to the 3rd degree
  36450. */
  36451. export class SphericalPolynomial {
  36452. private _harmonics;
  36453. /**
  36454. * The spherical harmonics used to create the polynomials.
  36455. */
  36456. get preScaledHarmonics(): SphericalHarmonics;
  36457. /**
  36458. * The x coefficients of the spherical polynomial
  36459. */
  36460. x: Vector3;
  36461. /**
  36462. * The y coefficients of the spherical polynomial
  36463. */
  36464. y: Vector3;
  36465. /**
  36466. * The z coefficients of the spherical polynomial
  36467. */
  36468. z: Vector3;
  36469. /**
  36470. * The xx coefficients of the spherical polynomial
  36471. */
  36472. xx: Vector3;
  36473. /**
  36474. * The yy coefficients of the spherical polynomial
  36475. */
  36476. yy: Vector3;
  36477. /**
  36478. * The zz coefficients of the spherical polynomial
  36479. */
  36480. zz: Vector3;
  36481. /**
  36482. * The xy coefficients of the spherical polynomial
  36483. */
  36484. xy: Vector3;
  36485. /**
  36486. * The yz coefficients of the spherical polynomial
  36487. */
  36488. yz: Vector3;
  36489. /**
  36490. * The zx coefficients of the spherical polynomial
  36491. */
  36492. zx: Vector3;
  36493. /**
  36494. * Adds an ambient color to the spherical polynomial
  36495. * @param color the color to add
  36496. */
  36497. addAmbient(color: Color3): void;
  36498. /**
  36499. * Scales the spherical polynomial by the given amount
  36500. * @param scale the amount to scale
  36501. */
  36502. scaleInPlace(scale: number): void;
  36503. /**
  36504. * Gets the spherical polynomial from harmonics
  36505. * @param harmonics the spherical harmonics
  36506. * @returns the spherical polynomial
  36507. */
  36508. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36509. /**
  36510. * Constructs a spherical polynomial from an array.
  36511. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36512. * @returns the spherical polynomial
  36513. */
  36514. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36515. }
  36516. }
  36517. declare module "babylonjs/Materials/Textures/internalTexture" {
  36518. import { Observable } from "babylonjs/Misc/observable";
  36519. import { Nullable, int } from "babylonjs/types";
  36520. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36522. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36523. /**
  36524. * Defines the source of the internal texture
  36525. */
  36526. export enum InternalTextureSource {
  36527. /**
  36528. * The source of the texture data is unknown
  36529. */
  36530. Unknown = 0,
  36531. /**
  36532. * Texture data comes from an URL
  36533. */
  36534. Url = 1,
  36535. /**
  36536. * Texture data is only used for temporary storage
  36537. */
  36538. Temp = 2,
  36539. /**
  36540. * Texture data comes from raw data (ArrayBuffer)
  36541. */
  36542. Raw = 3,
  36543. /**
  36544. * Texture content is dynamic (video or dynamic texture)
  36545. */
  36546. Dynamic = 4,
  36547. /**
  36548. * Texture content is generated by rendering to it
  36549. */
  36550. RenderTarget = 5,
  36551. /**
  36552. * Texture content is part of a multi render target process
  36553. */
  36554. MultiRenderTarget = 6,
  36555. /**
  36556. * Texture data comes from a cube data file
  36557. */
  36558. Cube = 7,
  36559. /**
  36560. * Texture data comes from a raw cube data
  36561. */
  36562. CubeRaw = 8,
  36563. /**
  36564. * Texture data come from a prefiltered cube data file
  36565. */
  36566. CubePrefiltered = 9,
  36567. /**
  36568. * Texture content is raw 3D data
  36569. */
  36570. Raw3D = 10,
  36571. /**
  36572. * Texture content is raw 2D array data
  36573. */
  36574. Raw2DArray = 11,
  36575. /**
  36576. * Texture content is a depth texture
  36577. */
  36578. Depth = 12,
  36579. /**
  36580. * Texture data comes from a raw cube data encoded with RGBD
  36581. */
  36582. CubeRawRGBD = 13
  36583. }
  36584. /**
  36585. * Class used to store data associated with WebGL texture data for the engine
  36586. * This class should not be used directly
  36587. */
  36588. export class InternalTexture {
  36589. /** @hidden */
  36590. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36591. /**
  36592. * Defines if the texture is ready
  36593. */
  36594. isReady: boolean;
  36595. /**
  36596. * Defines if the texture is a cube texture
  36597. */
  36598. isCube: boolean;
  36599. /**
  36600. * Defines if the texture contains 3D data
  36601. */
  36602. is3D: boolean;
  36603. /**
  36604. * Defines if the texture contains 2D array data
  36605. */
  36606. is2DArray: boolean;
  36607. /**
  36608. * Defines if the texture contains multiview data
  36609. */
  36610. isMultiview: boolean;
  36611. /**
  36612. * Gets the URL used to load this texture
  36613. */
  36614. url: string;
  36615. /**
  36616. * Gets the sampling mode of the texture
  36617. */
  36618. samplingMode: number;
  36619. /**
  36620. * Gets a boolean indicating if the texture needs mipmaps generation
  36621. */
  36622. generateMipMaps: boolean;
  36623. /**
  36624. * Gets the number of samples used by the texture (WebGL2+ only)
  36625. */
  36626. samples: number;
  36627. /**
  36628. * Gets the type of the texture (int, float...)
  36629. */
  36630. type: number;
  36631. /**
  36632. * Gets the format of the texture (RGB, RGBA...)
  36633. */
  36634. format: number;
  36635. /**
  36636. * Observable called when the texture is loaded
  36637. */
  36638. onLoadedObservable: Observable<InternalTexture>;
  36639. /**
  36640. * Gets the width of the texture
  36641. */
  36642. width: number;
  36643. /**
  36644. * Gets the height of the texture
  36645. */
  36646. height: number;
  36647. /**
  36648. * Gets the depth of the texture
  36649. */
  36650. depth: number;
  36651. /**
  36652. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36653. */
  36654. baseWidth: number;
  36655. /**
  36656. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36657. */
  36658. baseHeight: number;
  36659. /**
  36660. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36661. */
  36662. baseDepth: number;
  36663. /**
  36664. * Gets a boolean indicating if the texture is inverted on Y axis
  36665. */
  36666. invertY: boolean;
  36667. /** @hidden */
  36668. _invertVScale: boolean;
  36669. /** @hidden */
  36670. _associatedChannel: number;
  36671. /** @hidden */
  36672. _source: InternalTextureSource;
  36673. /** @hidden */
  36674. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36675. /** @hidden */
  36676. _bufferView: Nullable<ArrayBufferView>;
  36677. /** @hidden */
  36678. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36679. /** @hidden */
  36680. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36681. /** @hidden */
  36682. _size: number;
  36683. /** @hidden */
  36684. _extension: string;
  36685. /** @hidden */
  36686. _files: Nullable<string[]>;
  36687. /** @hidden */
  36688. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36689. /** @hidden */
  36690. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36691. /** @hidden */
  36692. _framebuffer: Nullable<WebGLFramebuffer>;
  36693. /** @hidden */
  36694. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36695. /** @hidden */
  36696. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36697. /** @hidden */
  36698. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36699. /** @hidden */
  36700. _attachments: Nullable<number[]>;
  36701. /** @hidden */
  36702. _cachedCoordinatesMode: Nullable<number>;
  36703. /** @hidden */
  36704. _cachedWrapU: Nullable<number>;
  36705. /** @hidden */
  36706. _cachedWrapV: Nullable<number>;
  36707. /** @hidden */
  36708. _cachedWrapR: Nullable<number>;
  36709. /** @hidden */
  36710. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36711. /** @hidden */
  36712. _isDisabled: boolean;
  36713. /** @hidden */
  36714. _compression: Nullable<string>;
  36715. /** @hidden */
  36716. _generateStencilBuffer: boolean;
  36717. /** @hidden */
  36718. _generateDepthBuffer: boolean;
  36719. /** @hidden */
  36720. _comparisonFunction: number;
  36721. /** @hidden */
  36722. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36723. /** @hidden */
  36724. _lodGenerationScale: number;
  36725. /** @hidden */
  36726. _lodGenerationOffset: number;
  36727. /** @hidden */
  36728. _depthStencilTexture: Nullable<InternalTexture>;
  36729. /** @hidden */
  36730. _colorTextureArray: Nullable<WebGLTexture>;
  36731. /** @hidden */
  36732. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36733. /** @hidden */
  36734. _lodTextureHigh: Nullable<BaseTexture>;
  36735. /** @hidden */
  36736. _lodTextureMid: Nullable<BaseTexture>;
  36737. /** @hidden */
  36738. _lodTextureLow: Nullable<BaseTexture>;
  36739. /** @hidden */
  36740. _isRGBD: boolean;
  36741. /** @hidden */
  36742. _linearSpecularLOD: boolean;
  36743. /** @hidden */
  36744. _irradianceTexture: Nullable<BaseTexture>;
  36745. /** @hidden */
  36746. _webGLTexture: Nullable<WebGLTexture>;
  36747. /** @hidden */
  36748. _references: number;
  36749. private _engine;
  36750. /**
  36751. * Gets the Engine the texture belongs to.
  36752. * @returns The babylon engine
  36753. */
  36754. getEngine(): ThinEngine;
  36755. /**
  36756. * Gets the data source type of the texture
  36757. */
  36758. get source(): InternalTextureSource;
  36759. /**
  36760. * Creates a new InternalTexture
  36761. * @param engine defines the engine to use
  36762. * @param source defines the type of data that will be used
  36763. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36764. */
  36765. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36766. /**
  36767. * Increments the number of references (ie. the number of Texture that point to it)
  36768. */
  36769. incrementReferences(): void;
  36770. /**
  36771. * Change the size of the texture (not the size of the content)
  36772. * @param width defines the new width
  36773. * @param height defines the new height
  36774. * @param depth defines the new depth (1 by default)
  36775. */
  36776. updateSize(width: int, height: int, depth?: int): void;
  36777. /** @hidden */
  36778. _rebuild(): void;
  36779. /** @hidden */
  36780. _swapAndDie(target: InternalTexture): void;
  36781. /**
  36782. * Dispose the current allocated resources
  36783. */
  36784. dispose(): void;
  36785. }
  36786. }
  36787. declare module "babylonjs/Audio/analyser" {
  36788. import { Scene } from "babylonjs/scene";
  36789. /**
  36790. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36792. */
  36793. export class Analyser {
  36794. /**
  36795. * Gets or sets the smoothing
  36796. * @ignorenaming
  36797. */
  36798. SMOOTHING: number;
  36799. /**
  36800. * Gets or sets the FFT table size
  36801. * @ignorenaming
  36802. */
  36803. FFT_SIZE: number;
  36804. /**
  36805. * Gets or sets the bar graph amplitude
  36806. * @ignorenaming
  36807. */
  36808. BARGRAPHAMPLITUDE: number;
  36809. /**
  36810. * Gets or sets the position of the debug canvas
  36811. * @ignorenaming
  36812. */
  36813. DEBUGCANVASPOS: {
  36814. x: number;
  36815. y: number;
  36816. };
  36817. /**
  36818. * Gets or sets the debug canvas size
  36819. * @ignorenaming
  36820. */
  36821. DEBUGCANVASSIZE: {
  36822. width: number;
  36823. height: number;
  36824. };
  36825. private _byteFreqs;
  36826. private _byteTime;
  36827. private _floatFreqs;
  36828. private _webAudioAnalyser;
  36829. private _debugCanvas;
  36830. private _debugCanvasContext;
  36831. private _scene;
  36832. private _registerFunc;
  36833. private _audioEngine;
  36834. /**
  36835. * Creates a new analyser
  36836. * @param scene defines hosting scene
  36837. */
  36838. constructor(scene: Scene);
  36839. /**
  36840. * Get the number of data values you will have to play with for the visualization
  36841. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36842. * @returns a number
  36843. */
  36844. getFrequencyBinCount(): number;
  36845. /**
  36846. * Gets the current frequency data as a byte array
  36847. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36848. * @returns a Uint8Array
  36849. */
  36850. getByteFrequencyData(): Uint8Array;
  36851. /**
  36852. * Gets the current waveform as a byte array
  36853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36854. * @returns a Uint8Array
  36855. */
  36856. getByteTimeDomainData(): Uint8Array;
  36857. /**
  36858. * Gets the current frequency data as a float array
  36859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36860. * @returns a Float32Array
  36861. */
  36862. getFloatFrequencyData(): Float32Array;
  36863. /**
  36864. * Renders the debug canvas
  36865. */
  36866. drawDebugCanvas(): void;
  36867. /**
  36868. * Stops rendering the debug canvas and removes it
  36869. */
  36870. stopDebugCanvas(): void;
  36871. /**
  36872. * Connects two audio nodes
  36873. * @param inputAudioNode defines first node to connect
  36874. * @param outputAudioNode defines second node to connect
  36875. */
  36876. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36877. /**
  36878. * Releases all associated resources
  36879. */
  36880. dispose(): void;
  36881. }
  36882. }
  36883. declare module "babylonjs/Audio/audioEngine" {
  36884. import { IDisposable } from "babylonjs/scene";
  36885. import { Analyser } from "babylonjs/Audio/analyser";
  36886. import { Nullable } from "babylonjs/types";
  36887. import { Observable } from "babylonjs/Misc/observable";
  36888. /**
  36889. * This represents an audio engine and it is responsible
  36890. * to play, synchronize and analyse sounds throughout the application.
  36891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36892. */
  36893. export interface IAudioEngine extends IDisposable {
  36894. /**
  36895. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36896. */
  36897. readonly canUseWebAudio: boolean;
  36898. /**
  36899. * Gets the current AudioContext if available.
  36900. */
  36901. readonly audioContext: Nullable<AudioContext>;
  36902. /**
  36903. * The master gain node defines the global audio volume of your audio engine.
  36904. */
  36905. readonly masterGain: GainNode;
  36906. /**
  36907. * Gets whether or not mp3 are supported by your browser.
  36908. */
  36909. readonly isMP3supported: boolean;
  36910. /**
  36911. * Gets whether or not ogg are supported by your browser.
  36912. */
  36913. readonly isOGGsupported: boolean;
  36914. /**
  36915. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36916. * @ignoreNaming
  36917. */
  36918. WarnedWebAudioUnsupported: boolean;
  36919. /**
  36920. * Defines if the audio engine relies on a custom unlocked button.
  36921. * In this case, the embedded button will not be displayed.
  36922. */
  36923. useCustomUnlockedButton: boolean;
  36924. /**
  36925. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36926. */
  36927. readonly unlocked: boolean;
  36928. /**
  36929. * Event raised when audio has been unlocked on the browser.
  36930. */
  36931. onAudioUnlockedObservable: Observable<AudioEngine>;
  36932. /**
  36933. * Event raised when audio has been locked on the browser.
  36934. */
  36935. onAudioLockedObservable: Observable<AudioEngine>;
  36936. /**
  36937. * Flags the audio engine in Locked state.
  36938. * This happens due to new browser policies preventing audio to autoplay.
  36939. */
  36940. lock(): void;
  36941. /**
  36942. * Unlocks the audio engine once a user action has been done on the dom.
  36943. * This is helpful to resume play once browser policies have been satisfied.
  36944. */
  36945. unlock(): void;
  36946. /**
  36947. * Gets the global volume sets on the master gain.
  36948. * @returns the global volume if set or -1 otherwise
  36949. */
  36950. getGlobalVolume(): number;
  36951. /**
  36952. * Sets the global volume of your experience (sets on the master gain).
  36953. * @param newVolume Defines the new global volume of the application
  36954. */
  36955. setGlobalVolume(newVolume: number): void;
  36956. /**
  36957. * Connect the audio engine to an audio analyser allowing some amazing
  36958. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36960. * @param analyser The analyser to connect to the engine
  36961. */
  36962. connectToAnalyser(analyser: Analyser): void;
  36963. }
  36964. /**
  36965. * This represents the default audio engine used in babylon.
  36966. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36968. */
  36969. export class AudioEngine implements IAudioEngine {
  36970. private _audioContext;
  36971. private _audioContextInitialized;
  36972. private _muteButton;
  36973. private _hostElement;
  36974. /**
  36975. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36976. */
  36977. canUseWebAudio: boolean;
  36978. /**
  36979. * The master gain node defines the global audio volume of your audio engine.
  36980. */
  36981. masterGain: GainNode;
  36982. /**
  36983. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36984. * @ignoreNaming
  36985. */
  36986. WarnedWebAudioUnsupported: boolean;
  36987. /**
  36988. * Gets whether or not mp3 are supported by your browser.
  36989. */
  36990. isMP3supported: boolean;
  36991. /**
  36992. * Gets whether or not ogg are supported by your browser.
  36993. */
  36994. isOGGsupported: boolean;
  36995. /**
  36996. * Gets whether audio has been unlocked on the device.
  36997. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36998. * a user interaction has happened.
  36999. */
  37000. unlocked: boolean;
  37001. /**
  37002. * Defines if the audio engine relies on a custom unlocked button.
  37003. * In this case, the embedded button will not be displayed.
  37004. */
  37005. useCustomUnlockedButton: boolean;
  37006. /**
  37007. * Event raised when audio has been unlocked on the browser.
  37008. */
  37009. onAudioUnlockedObservable: Observable<AudioEngine>;
  37010. /**
  37011. * Event raised when audio has been locked on the browser.
  37012. */
  37013. onAudioLockedObservable: Observable<AudioEngine>;
  37014. /**
  37015. * Gets the current AudioContext if available.
  37016. */
  37017. get audioContext(): Nullable<AudioContext>;
  37018. private _connectedAnalyser;
  37019. /**
  37020. * Instantiates a new audio engine.
  37021. *
  37022. * There should be only one per page as some browsers restrict the number
  37023. * of audio contexts you can create.
  37024. * @param hostElement defines the host element where to display the mute icon if necessary
  37025. */
  37026. constructor(hostElement?: Nullable<HTMLElement>);
  37027. /**
  37028. * Flags the audio engine in Locked state.
  37029. * This happens due to new browser policies preventing audio to autoplay.
  37030. */
  37031. lock(): void;
  37032. /**
  37033. * Unlocks the audio engine once a user action has been done on the dom.
  37034. * This is helpful to resume play once browser policies have been satisfied.
  37035. */
  37036. unlock(): void;
  37037. private _resumeAudioContext;
  37038. private _initializeAudioContext;
  37039. private _tryToRun;
  37040. private _triggerRunningState;
  37041. private _triggerSuspendedState;
  37042. private _displayMuteButton;
  37043. private _moveButtonToTopLeft;
  37044. private _onResize;
  37045. private _hideMuteButton;
  37046. /**
  37047. * Destroy and release the resources associated with the audio ccontext.
  37048. */
  37049. dispose(): void;
  37050. /**
  37051. * Gets the global volume sets on the master gain.
  37052. * @returns the global volume if set or -1 otherwise
  37053. */
  37054. getGlobalVolume(): number;
  37055. /**
  37056. * Sets the global volume of your experience (sets on the master gain).
  37057. * @param newVolume Defines the new global volume of the application
  37058. */
  37059. setGlobalVolume(newVolume: number): void;
  37060. /**
  37061. * Connect the audio engine to an audio analyser allowing some amazing
  37062. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37064. * @param analyser The analyser to connect to the engine
  37065. */
  37066. connectToAnalyser(analyser: Analyser): void;
  37067. }
  37068. }
  37069. declare module "babylonjs/Loading/loadingScreen" {
  37070. /**
  37071. * Interface used to present a loading screen while loading a scene
  37072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37073. */
  37074. export interface ILoadingScreen {
  37075. /**
  37076. * Function called to display the loading screen
  37077. */
  37078. displayLoadingUI: () => void;
  37079. /**
  37080. * Function called to hide the loading screen
  37081. */
  37082. hideLoadingUI: () => void;
  37083. /**
  37084. * Gets or sets the color to use for the background
  37085. */
  37086. loadingUIBackgroundColor: string;
  37087. /**
  37088. * Gets or sets the text to display while loading
  37089. */
  37090. loadingUIText: string;
  37091. }
  37092. /**
  37093. * Class used for the default loading screen
  37094. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37095. */
  37096. export class DefaultLoadingScreen implements ILoadingScreen {
  37097. private _renderingCanvas;
  37098. private _loadingText;
  37099. private _loadingDivBackgroundColor;
  37100. private _loadingDiv;
  37101. private _loadingTextDiv;
  37102. /** Gets or sets the logo url to use for the default loading screen */
  37103. static DefaultLogoUrl: string;
  37104. /** Gets or sets the spinner url to use for the default loading screen */
  37105. static DefaultSpinnerUrl: string;
  37106. /**
  37107. * Creates a new default loading screen
  37108. * @param _renderingCanvas defines the canvas used to render the scene
  37109. * @param _loadingText defines the default text to display
  37110. * @param _loadingDivBackgroundColor defines the default background color
  37111. */
  37112. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37113. /**
  37114. * Function called to display the loading screen
  37115. */
  37116. displayLoadingUI(): void;
  37117. /**
  37118. * Function called to hide the loading screen
  37119. */
  37120. hideLoadingUI(): void;
  37121. /**
  37122. * Gets or sets the text to display while loading
  37123. */
  37124. set loadingUIText(text: string);
  37125. get loadingUIText(): string;
  37126. /**
  37127. * Gets or sets the color to use for the background
  37128. */
  37129. get loadingUIBackgroundColor(): string;
  37130. set loadingUIBackgroundColor(color: string);
  37131. private _resizeLoadingUI;
  37132. }
  37133. }
  37134. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37135. /**
  37136. * Interface for any object that can request an animation frame
  37137. */
  37138. export interface ICustomAnimationFrameRequester {
  37139. /**
  37140. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37141. */
  37142. renderFunction?: Function;
  37143. /**
  37144. * Called to request the next frame to render to
  37145. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37146. */
  37147. requestAnimationFrame: Function;
  37148. /**
  37149. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37150. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37151. */
  37152. requestID?: number;
  37153. }
  37154. }
  37155. declare module "babylonjs/Misc/performanceMonitor" {
  37156. /**
  37157. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37158. */
  37159. export class PerformanceMonitor {
  37160. private _enabled;
  37161. private _rollingFrameTime;
  37162. private _lastFrameTimeMs;
  37163. /**
  37164. * constructor
  37165. * @param frameSampleSize The number of samples required to saturate the sliding window
  37166. */
  37167. constructor(frameSampleSize?: number);
  37168. /**
  37169. * Samples current frame
  37170. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37171. */
  37172. sampleFrame(timeMs?: number): void;
  37173. /**
  37174. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37175. */
  37176. get averageFrameTime(): number;
  37177. /**
  37178. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37179. */
  37180. get averageFrameTimeVariance(): number;
  37181. /**
  37182. * Returns the frame time of the most recent frame
  37183. */
  37184. get instantaneousFrameTime(): number;
  37185. /**
  37186. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37187. */
  37188. get averageFPS(): number;
  37189. /**
  37190. * Returns the average framerate in frames per second using the most recent frame time
  37191. */
  37192. get instantaneousFPS(): number;
  37193. /**
  37194. * Returns true if enough samples have been taken to completely fill the sliding window
  37195. */
  37196. get isSaturated(): boolean;
  37197. /**
  37198. * Enables contributions to the sliding window sample set
  37199. */
  37200. enable(): void;
  37201. /**
  37202. * Disables contributions to the sliding window sample set
  37203. * Samples will not be interpolated over the disabled period
  37204. */
  37205. disable(): void;
  37206. /**
  37207. * Returns true if sampling is enabled
  37208. */
  37209. get isEnabled(): boolean;
  37210. /**
  37211. * Resets performance monitor
  37212. */
  37213. reset(): void;
  37214. }
  37215. /**
  37216. * RollingAverage
  37217. *
  37218. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37219. */
  37220. export class RollingAverage {
  37221. /**
  37222. * Current average
  37223. */
  37224. average: number;
  37225. /**
  37226. * Current variance
  37227. */
  37228. variance: number;
  37229. protected _samples: Array<number>;
  37230. protected _sampleCount: number;
  37231. protected _pos: number;
  37232. protected _m2: number;
  37233. /**
  37234. * constructor
  37235. * @param length The number of samples required to saturate the sliding window
  37236. */
  37237. constructor(length: number);
  37238. /**
  37239. * Adds a sample to the sample set
  37240. * @param v The sample value
  37241. */
  37242. add(v: number): void;
  37243. /**
  37244. * Returns previously added values or null if outside of history or outside the sliding window domain
  37245. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37246. * @return Value previously recorded with add() or null if outside of range
  37247. */
  37248. history(i: number): number;
  37249. /**
  37250. * Returns true if enough samples have been taken to completely fill the sliding window
  37251. * @return true if sample-set saturated
  37252. */
  37253. isSaturated(): boolean;
  37254. /**
  37255. * Resets the rolling average (equivalent to 0 samples taken so far)
  37256. */
  37257. reset(): void;
  37258. /**
  37259. * Wraps a value around the sample range boundaries
  37260. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37261. * @return Wrapped position in sample range
  37262. */
  37263. protected _wrapPosition(i: number): number;
  37264. }
  37265. }
  37266. declare module "babylonjs/Misc/perfCounter" {
  37267. /**
  37268. * This class is used to track a performance counter which is number based.
  37269. * The user has access to many properties which give statistics of different nature.
  37270. *
  37271. * The implementer can track two kinds of Performance Counter: time and count.
  37272. * 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.
  37273. * 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.
  37274. */
  37275. export class PerfCounter {
  37276. /**
  37277. * Gets or sets a global boolean to turn on and off all the counters
  37278. */
  37279. static Enabled: boolean;
  37280. /**
  37281. * Returns the smallest value ever
  37282. */
  37283. get min(): number;
  37284. /**
  37285. * Returns the biggest value ever
  37286. */
  37287. get max(): number;
  37288. /**
  37289. * Returns the average value since the performance counter is running
  37290. */
  37291. get average(): number;
  37292. /**
  37293. * Returns the average value of the last second the counter was monitored
  37294. */
  37295. get lastSecAverage(): number;
  37296. /**
  37297. * Returns the current value
  37298. */
  37299. get current(): number;
  37300. /**
  37301. * Gets the accumulated total
  37302. */
  37303. get total(): number;
  37304. /**
  37305. * Gets the total value count
  37306. */
  37307. get count(): number;
  37308. /**
  37309. * Creates a new counter
  37310. */
  37311. constructor();
  37312. /**
  37313. * Call this method to start monitoring a new frame.
  37314. * 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.
  37315. */
  37316. fetchNewFrame(): void;
  37317. /**
  37318. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37319. * @param newCount the count value to add to the monitored count
  37320. * @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.
  37321. */
  37322. addCount(newCount: number, fetchResult: boolean): void;
  37323. /**
  37324. * Start monitoring this performance counter
  37325. */
  37326. beginMonitoring(): void;
  37327. /**
  37328. * Compute the time lapsed since the previous beginMonitoring() call.
  37329. * @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
  37330. */
  37331. endMonitoring(newFrame?: boolean): void;
  37332. private _fetchResult;
  37333. private _startMonitoringTime;
  37334. private _min;
  37335. private _max;
  37336. private _average;
  37337. private _current;
  37338. private _totalValueCount;
  37339. private _totalAccumulated;
  37340. private _lastSecAverage;
  37341. private _lastSecAccumulated;
  37342. private _lastSecTime;
  37343. private _lastSecValueCount;
  37344. }
  37345. }
  37346. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37347. module "babylonjs/Engines/thinEngine" {
  37348. interface ThinEngine {
  37349. /**
  37350. * Sets alpha constants used by some alpha blending modes
  37351. * @param r defines the red component
  37352. * @param g defines the green component
  37353. * @param b defines the blue component
  37354. * @param a defines the alpha component
  37355. */
  37356. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37357. /**
  37358. * Sets the current alpha mode
  37359. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37360. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37361. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37362. */
  37363. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37364. /**
  37365. * Gets the current alpha mode
  37366. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37367. * @returns the current alpha mode
  37368. */
  37369. getAlphaMode(): number;
  37370. /**
  37371. * Sets the current alpha equation
  37372. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37373. */
  37374. setAlphaEquation(equation: number): void;
  37375. /**
  37376. * Gets the current alpha equation.
  37377. * @returns the current alpha equation
  37378. */
  37379. getAlphaEquation(): number;
  37380. }
  37381. }
  37382. }
  37383. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37385. import { Nullable } from "babylonjs/types";
  37386. module "babylonjs/Engines/thinEngine" {
  37387. interface ThinEngine {
  37388. /** @hidden */
  37389. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37390. }
  37391. }
  37392. }
  37393. declare module "babylonjs/Engines/engine" {
  37394. import { Observable } from "babylonjs/Misc/observable";
  37395. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37396. import { Scene } from "babylonjs/scene";
  37397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37398. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37399. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37400. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37401. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37402. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37403. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37404. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37405. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37406. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37407. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37408. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37409. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37410. import "babylonjs/Engines/Extensions/engine.alpha";
  37411. import "babylonjs/Engines/Extensions/engine.readTexture";
  37412. import { Material } from "babylonjs/Materials/material";
  37413. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37414. /**
  37415. * Defines the interface used by display changed events
  37416. */
  37417. export interface IDisplayChangedEventArgs {
  37418. /** Gets the vrDisplay object (if any) */
  37419. vrDisplay: Nullable<any>;
  37420. /** Gets a boolean indicating if webVR is supported */
  37421. vrSupported: boolean;
  37422. }
  37423. /**
  37424. * Defines the interface used by objects containing a viewport (like a camera)
  37425. */
  37426. interface IViewportOwnerLike {
  37427. /**
  37428. * Gets or sets the viewport
  37429. */
  37430. viewport: IViewportLike;
  37431. }
  37432. /**
  37433. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37434. */
  37435. export class Engine extends ThinEngine {
  37436. /** Defines that alpha blending is disabled */
  37437. static readonly ALPHA_DISABLE: number;
  37438. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37439. static readonly ALPHA_ADD: number;
  37440. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37441. static readonly ALPHA_COMBINE: number;
  37442. /** Defines that alpha blending to DEST - SRC * DEST */
  37443. static readonly ALPHA_SUBTRACT: number;
  37444. /** Defines that alpha blending to SRC * DEST */
  37445. static readonly ALPHA_MULTIPLY: number;
  37446. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37447. static readonly ALPHA_MAXIMIZED: number;
  37448. /** Defines that alpha blending to SRC + DEST */
  37449. static readonly ALPHA_ONEONE: number;
  37450. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37451. static readonly ALPHA_PREMULTIPLIED: number;
  37452. /**
  37453. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37454. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37455. */
  37456. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37457. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37458. static readonly ALPHA_INTERPOLATE: number;
  37459. /**
  37460. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37461. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37462. */
  37463. static readonly ALPHA_SCREENMODE: number;
  37464. /** Defines that the ressource is not delayed*/
  37465. static readonly DELAYLOADSTATE_NONE: number;
  37466. /** Defines that the ressource was successfully delay loaded */
  37467. static readonly DELAYLOADSTATE_LOADED: number;
  37468. /** Defines that the ressource is currently delay loading */
  37469. static readonly DELAYLOADSTATE_LOADING: number;
  37470. /** Defines that the ressource is delayed and has not started loading */
  37471. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37473. static readonly NEVER: number;
  37474. /** 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 */
  37475. static readonly ALWAYS: number;
  37476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37477. static readonly LESS: number;
  37478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37479. static readonly EQUAL: number;
  37480. /** 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 */
  37481. static readonly LEQUAL: number;
  37482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37483. static readonly GREATER: number;
  37484. /** 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 */
  37485. static readonly GEQUAL: number;
  37486. /** 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 */
  37487. static readonly NOTEQUAL: number;
  37488. /** Passed to stencilOperation to specify that stencil value must be kept */
  37489. static readonly KEEP: number;
  37490. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37491. static readonly REPLACE: number;
  37492. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37493. static readonly INCR: number;
  37494. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37495. static readonly DECR: number;
  37496. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37497. static readonly INVERT: number;
  37498. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37499. static readonly INCR_WRAP: number;
  37500. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37501. static readonly DECR_WRAP: number;
  37502. /** Texture is not repeating outside of 0..1 UVs */
  37503. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37504. /** Texture is repeating outside of 0..1 UVs */
  37505. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37506. /** Texture is repeating and mirrored */
  37507. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37508. /** ALPHA */
  37509. static readonly TEXTUREFORMAT_ALPHA: number;
  37510. /** LUMINANCE */
  37511. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37512. /** LUMINANCE_ALPHA */
  37513. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37514. /** RGB */
  37515. static readonly TEXTUREFORMAT_RGB: number;
  37516. /** RGBA */
  37517. static readonly TEXTUREFORMAT_RGBA: number;
  37518. /** RED */
  37519. static readonly TEXTUREFORMAT_RED: number;
  37520. /** RED (2nd reference) */
  37521. static readonly TEXTUREFORMAT_R: number;
  37522. /** RG */
  37523. static readonly TEXTUREFORMAT_RG: number;
  37524. /** RED_INTEGER */
  37525. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37526. /** RED_INTEGER (2nd reference) */
  37527. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37528. /** RG_INTEGER */
  37529. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37530. /** RGB_INTEGER */
  37531. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37532. /** RGBA_INTEGER */
  37533. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37534. /** UNSIGNED_BYTE */
  37535. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37536. /** UNSIGNED_BYTE (2nd reference) */
  37537. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37538. /** FLOAT */
  37539. static readonly TEXTURETYPE_FLOAT: number;
  37540. /** HALF_FLOAT */
  37541. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37542. /** BYTE */
  37543. static readonly TEXTURETYPE_BYTE: number;
  37544. /** SHORT */
  37545. static readonly TEXTURETYPE_SHORT: number;
  37546. /** UNSIGNED_SHORT */
  37547. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37548. /** INT */
  37549. static readonly TEXTURETYPE_INT: number;
  37550. /** UNSIGNED_INT */
  37551. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37552. /** UNSIGNED_SHORT_4_4_4_4 */
  37553. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37554. /** UNSIGNED_SHORT_5_5_5_1 */
  37555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37556. /** UNSIGNED_SHORT_5_6_5 */
  37557. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37558. /** UNSIGNED_INT_2_10_10_10_REV */
  37559. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37560. /** UNSIGNED_INT_24_8 */
  37561. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37562. /** UNSIGNED_INT_10F_11F_11F_REV */
  37563. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37564. /** UNSIGNED_INT_5_9_9_9_REV */
  37565. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37566. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37567. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37568. /** nearest is mag = nearest and min = nearest and mip = linear */
  37569. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37570. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37571. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37572. /** Trilinear is mag = linear and min = linear and mip = linear */
  37573. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37574. /** nearest is mag = nearest and min = nearest and mip = linear */
  37575. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37576. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37577. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37578. /** Trilinear is mag = linear and min = linear and mip = linear */
  37579. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37580. /** mag = nearest and min = nearest and mip = nearest */
  37581. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37582. /** mag = nearest and min = linear and mip = nearest */
  37583. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37584. /** mag = nearest and min = linear and mip = linear */
  37585. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37586. /** mag = nearest and min = linear and mip = none */
  37587. static readonly TEXTURE_NEAREST_LINEAR: number;
  37588. /** mag = nearest and min = nearest and mip = none */
  37589. static readonly TEXTURE_NEAREST_NEAREST: number;
  37590. /** mag = linear and min = nearest and mip = nearest */
  37591. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37592. /** mag = linear and min = nearest and mip = linear */
  37593. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37594. /** mag = linear and min = linear and mip = none */
  37595. static readonly TEXTURE_LINEAR_LINEAR: number;
  37596. /** mag = linear and min = nearest and mip = none */
  37597. static readonly TEXTURE_LINEAR_NEAREST: number;
  37598. /** Explicit coordinates mode */
  37599. static readonly TEXTURE_EXPLICIT_MODE: number;
  37600. /** Spherical coordinates mode */
  37601. static readonly TEXTURE_SPHERICAL_MODE: number;
  37602. /** Planar coordinates mode */
  37603. static readonly TEXTURE_PLANAR_MODE: number;
  37604. /** Cubic coordinates mode */
  37605. static readonly TEXTURE_CUBIC_MODE: number;
  37606. /** Projection coordinates mode */
  37607. static readonly TEXTURE_PROJECTION_MODE: number;
  37608. /** Skybox coordinates mode */
  37609. static readonly TEXTURE_SKYBOX_MODE: number;
  37610. /** Inverse Cubic coordinates mode */
  37611. static readonly TEXTURE_INVCUBIC_MODE: number;
  37612. /** Equirectangular coordinates mode */
  37613. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37614. /** Equirectangular Fixed coordinates mode */
  37615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37616. /** Equirectangular Fixed Mirrored coordinates mode */
  37617. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37618. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37619. static readonly SCALEMODE_FLOOR: number;
  37620. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37621. static readonly SCALEMODE_NEAREST: number;
  37622. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37623. static readonly SCALEMODE_CEILING: number;
  37624. /**
  37625. * Returns the current npm package of the sdk
  37626. */
  37627. static get NpmPackage(): string;
  37628. /**
  37629. * Returns the current version of the framework
  37630. */
  37631. static get Version(): string;
  37632. /** Gets the list of created engines */
  37633. static get Instances(): Engine[];
  37634. /**
  37635. * Gets the latest created engine
  37636. */
  37637. static get LastCreatedEngine(): Nullable<Engine>;
  37638. /**
  37639. * Gets the latest created scene
  37640. */
  37641. static get LastCreatedScene(): Nullable<Scene>;
  37642. /**
  37643. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37644. * @param flag defines which part of the materials must be marked as dirty
  37645. * @param predicate defines a predicate used to filter which materials should be affected
  37646. */
  37647. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37648. /**
  37649. * Method called to create the default loading screen.
  37650. * This can be overriden in your own app.
  37651. * @param canvas The rendering canvas element
  37652. * @returns The loading screen
  37653. */
  37654. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37655. /**
  37656. * Method called to create the default rescale post process on each engine.
  37657. */
  37658. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37659. /**
  37660. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37661. **/
  37662. enableOfflineSupport: boolean;
  37663. /**
  37664. * 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)
  37665. **/
  37666. disableManifestCheck: boolean;
  37667. /**
  37668. * Gets the list of created scenes
  37669. */
  37670. scenes: Scene[];
  37671. /**
  37672. * Event raised when a new scene is created
  37673. */
  37674. onNewSceneAddedObservable: Observable<Scene>;
  37675. /**
  37676. * Gets the list of created postprocesses
  37677. */
  37678. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37679. /**
  37680. * Gets a boolean indicating if the pointer is currently locked
  37681. */
  37682. isPointerLock: boolean;
  37683. /**
  37684. * Observable event triggered each time the rendering canvas is resized
  37685. */
  37686. onResizeObservable: Observable<Engine>;
  37687. /**
  37688. * Observable event triggered each time the canvas loses focus
  37689. */
  37690. onCanvasBlurObservable: Observable<Engine>;
  37691. /**
  37692. * Observable event triggered each time the canvas gains focus
  37693. */
  37694. onCanvasFocusObservable: Observable<Engine>;
  37695. /**
  37696. * Observable event triggered each time the canvas receives pointerout event
  37697. */
  37698. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37699. /**
  37700. * Observable raised when the engine begins a new frame
  37701. */
  37702. onBeginFrameObservable: Observable<Engine>;
  37703. /**
  37704. * If set, will be used to request the next animation frame for the render loop
  37705. */
  37706. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37707. /**
  37708. * Observable raised when the engine ends the current frame
  37709. */
  37710. onEndFrameObservable: Observable<Engine>;
  37711. /**
  37712. * Observable raised when the engine is about to compile a shader
  37713. */
  37714. onBeforeShaderCompilationObservable: Observable<Engine>;
  37715. /**
  37716. * Observable raised when the engine has jsut compiled a shader
  37717. */
  37718. onAfterShaderCompilationObservable: Observable<Engine>;
  37719. /**
  37720. * Gets the audio engine
  37721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37722. * @ignorenaming
  37723. */
  37724. static audioEngine: IAudioEngine;
  37725. /**
  37726. * Default AudioEngine factory responsible of creating the Audio Engine.
  37727. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37728. */
  37729. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37730. /**
  37731. * Default offline support factory responsible of creating a tool used to store data locally.
  37732. * By default, this will create a Database object if the workload has been embedded.
  37733. */
  37734. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37735. private _loadingScreen;
  37736. private _pointerLockRequested;
  37737. private _rescalePostProcess;
  37738. private _deterministicLockstep;
  37739. private _lockstepMaxSteps;
  37740. private _timeStep;
  37741. protected get _supportsHardwareTextureRescaling(): boolean;
  37742. private _fps;
  37743. private _deltaTime;
  37744. /** @hidden */
  37745. _drawCalls: PerfCounter;
  37746. /** 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 */
  37747. canvasTabIndex: number;
  37748. /**
  37749. * Turn this value on if you want to pause FPS computation when in background
  37750. */
  37751. disablePerformanceMonitorInBackground: boolean;
  37752. private _performanceMonitor;
  37753. /**
  37754. * Gets the performance monitor attached to this engine
  37755. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37756. */
  37757. get performanceMonitor(): PerformanceMonitor;
  37758. private _onFocus;
  37759. private _onBlur;
  37760. private _onCanvasPointerOut;
  37761. private _onCanvasBlur;
  37762. private _onCanvasFocus;
  37763. private _onFullscreenChange;
  37764. private _onPointerLockChange;
  37765. /**
  37766. * Gets the HTML element used to attach event listeners
  37767. * @returns a HTML element
  37768. */
  37769. getInputElement(): Nullable<HTMLElement>;
  37770. /**
  37771. * Creates a new engine
  37772. * @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
  37773. * @param antialias defines enable antialiasing (default: false)
  37774. * @param options defines further options to be sent to the getContext() function
  37775. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37776. */
  37777. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37778. /**
  37779. * Gets current aspect ratio
  37780. * @param viewportOwner defines the camera to use to get the aspect ratio
  37781. * @param useScreen defines if screen size must be used (or the current render target if any)
  37782. * @returns a number defining the aspect ratio
  37783. */
  37784. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37785. /**
  37786. * Gets current screen aspect ratio
  37787. * @returns a number defining the aspect ratio
  37788. */
  37789. getScreenAspectRatio(): number;
  37790. /**
  37791. * Gets the client rect of the HTML canvas attached with the current webGL context
  37792. * @returns a client rectanglee
  37793. */
  37794. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37795. /**
  37796. * Gets the client rect of the HTML element used for events
  37797. * @returns a client rectanglee
  37798. */
  37799. getInputElementClientRect(): Nullable<ClientRect>;
  37800. /**
  37801. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37802. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37803. * @returns true if engine is in deterministic lock step mode
  37804. */
  37805. isDeterministicLockStep(): boolean;
  37806. /**
  37807. * Gets the max steps when engine is running in deterministic lock step
  37808. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37809. * @returns the max steps
  37810. */
  37811. getLockstepMaxSteps(): number;
  37812. /**
  37813. * Returns the time in ms between steps when using deterministic lock step.
  37814. * @returns time step in (ms)
  37815. */
  37816. getTimeStep(): number;
  37817. /**
  37818. * Force the mipmap generation for the given render target texture
  37819. * @param texture defines the render target texture to use
  37820. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37821. */
  37822. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37823. /** States */
  37824. /**
  37825. * Set various states to the webGL context
  37826. * @param culling defines backface culling state
  37827. * @param zOffset defines the value to apply to zOffset (0 by default)
  37828. * @param force defines if states must be applied even if cache is up to date
  37829. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37830. */
  37831. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37832. /**
  37833. * Set the z offset to apply to current rendering
  37834. * @param value defines the offset to apply
  37835. */
  37836. setZOffset(value: number): void;
  37837. /**
  37838. * Gets the current value of the zOffset
  37839. * @returns the current zOffset state
  37840. */
  37841. getZOffset(): number;
  37842. /**
  37843. * Enable or disable depth buffering
  37844. * @param enable defines the state to set
  37845. */
  37846. setDepthBuffer(enable: boolean): void;
  37847. /**
  37848. * Gets a boolean indicating if depth writing is enabled
  37849. * @returns the current depth writing state
  37850. */
  37851. getDepthWrite(): boolean;
  37852. /**
  37853. * Enable or disable depth writing
  37854. * @param enable defines the state to set
  37855. */
  37856. setDepthWrite(enable: boolean): void;
  37857. /**
  37858. * Gets a boolean indicating if stencil buffer is enabled
  37859. * @returns the current stencil buffer state
  37860. */
  37861. getStencilBuffer(): boolean;
  37862. /**
  37863. * Enable or disable the stencil buffer
  37864. * @param enable defines if the stencil buffer must be enabled or disabled
  37865. */
  37866. setStencilBuffer(enable: boolean): void;
  37867. /**
  37868. * Gets the current stencil mask
  37869. * @returns a number defining the new stencil mask to use
  37870. */
  37871. getStencilMask(): number;
  37872. /**
  37873. * Sets the current stencil mask
  37874. * @param mask defines the new stencil mask to use
  37875. */
  37876. setStencilMask(mask: number): void;
  37877. /**
  37878. * Gets the current stencil function
  37879. * @returns a number defining the stencil function to use
  37880. */
  37881. getStencilFunction(): number;
  37882. /**
  37883. * Gets the current stencil reference value
  37884. * @returns a number defining the stencil reference value to use
  37885. */
  37886. getStencilFunctionReference(): number;
  37887. /**
  37888. * Gets the current stencil mask
  37889. * @returns a number defining the stencil mask to use
  37890. */
  37891. getStencilFunctionMask(): number;
  37892. /**
  37893. * Sets the current stencil function
  37894. * @param stencilFunc defines the new stencil function to use
  37895. */
  37896. setStencilFunction(stencilFunc: number): void;
  37897. /**
  37898. * Sets the current stencil reference
  37899. * @param reference defines the new stencil reference to use
  37900. */
  37901. setStencilFunctionReference(reference: number): void;
  37902. /**
  37903. * Sets the current stencil mask
  37904. * @param mask defines the new stencil mask to use
  37905. */
  37906. setStencilFunctionMask(mask: number): void;
  37907. /**
  37908. * Gets the current stencil operation when stencil fails
  37909. * @returns a number defining stencil operation to use when stencil fails
  37910. */
  37911. getStencilOperationFail(): number;
  37912. /**
  37913. * Gets the current stencil operation when depth fails
  37914. * @returns a number defining stencil operation to use when depth fails
  37915. */
  37916. getStencilOperationDepthFail(): number;
  37917. /**
  37918. * Gets the current stencil operation when stencil passes
  37919. * @returns a number defining stencil operation to use when stencil passes
  37920. */
  37921. getStencilOperationPass(): number;
  37922. /**
  37923. * Sets the stencil operation to use when stencil fails
  37924. * @param operation defines the stencil operation to use when stencil fails
  37925. */
  37926. setStencilOperationFail(operation: number): void;
  37927. /**
  37928. * Sets the stencil operation to use when depth fails
  37929. * @param operation defines the stencil operation to use when depth fails
  37930. */
  37931. setStencilOperationDepthFail(operation: number): void;
  37932. /**
  37933. * Sets the stencil operation to use when stencil passes
  37934. * @param operation defines the stencil operation to use when stencil passes
  37935. */
  37936. setStencilOperationPass(operation: number): void;
  37937. /**
  37938. * Sets a boolean indicating if the dithering state is enabled or disabled
  37939. * @param value defines the dithering state
  37940. */
  37941. setDitheringState(value: boolean): void;
  37942. /**
  37943. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37944. * @param value defines the rasterizer state
  37945. */
  37946. setRasterizerState(value: boolean): void;
  37947. /**
  37948. * Gets the current depth function
  37949. * @returns a number defining the depth function
  37950. */
  37951. getDepthFunction(): Nullable<number>;
  37952. /**
  37953. * Sets the current depth function
  37954. * @param depthFunc defines the function to use
  37955. */
  37956. setDepthFunction(depthFunc: number): void;
  37957. /**
  37958. * Sets the current depth function to GREATER
  37959. */
  37960. setDepthFunctionToGreater(): void;
  37961. /**
  37962. * Sets the current depth function to GEQUAL
  37963. */
  37964. setDepthFunctionToGreaterOrEqual(): void;
  37965. /**
  37966. * Sets the current depth function to LESS
  37967. */
  37968. setDepthFunctionToLess(): void;
  37969. /**
  37970. * Sets the current depth function to LEQUAL
  37971. */
  37972. setDepthFunctionToLessOrEqual(): void;
  37973. private _cachedStencilBuffer;
  37974. private _cachedStencilFunction;
  37975. private _cachedStencilMask;
  37976. private _cachedStencilOperationPass;
  37977. private _cachedStencilOperationFail;
  37978. private _cachedStencilOperationDepthFail;
  37979. private _cachedStencilReference;
  37980. /**
  37981. * Caches the the state of the stencil buffer
  37982. */
  37983. cacheStencilState(): void;
  37984. /**
  37985. * Restores the state of the stencil buffer
  37986. */
  37987. restoreStencilState(): void;
  37988. /**
  37989. * Directly set the WebGL Viewport
  37990. * @param x defines the x coordinate of the viewport (in screen space)
  37991. * @param y defines the y coordinate of the viewport (in screen space)
  37992. * @param width defines the width of the viewport (in screen space)
  37993. * @param height defines the height of the viewport (in screen space)
  37994. * @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
  37995. */
  37996. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37997. /**
  37998. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37999. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38000. * @param y defines the y-coordinate of the corner of the clear rectangle
  38001. * @param width defines the width of the clear rectangle
  38002. * @param height defines the height of the clear rectangle
  38003. * @param clearColor defines the clear color
  38004. */
  38005. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38006. /**
  38007. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38008. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38009. * @param y defines the y-coordinate of the corner of the clear rectangle
  38010. * @param width defines the width of the clear rectangle
  38011. * @param height defines the height of the clear rectangle
  38012. */
  38013. enableScissor(x: number, y: number, width: number, height: number): void;
  38014. /**
  38015. * Disable previously set scissor test rectangle
  38016. */
  38017. disableScissor(): void;
  38018. protected _reportDrawCall(): void;
  38019. /**
  38020. * Initializes a webVR display and starts listening to display change events
  38021. * The onVRDisplayChangedObservable will be notified upon these changes
  38022. * @returns The onVRDisplayChangedObservable
  38023. */
  38024. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38025. /** @hidden */
  38026. _prepareVRComponent(): void;
  38027. /** @hidden */
  38028. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38029. /** @hidden */
  38030. _submitVRFrame(): void;
  38031. /**
  38032. * Call this function to leave webVR mode
  38033. * Will do nothing if webVR is not supported or if there is no webVR device
  38034. * @see http://doc.babylonjs.com/how_to/webvr_camera
  38035. */
  38036. disableVR(): void;
  38037. /**
  38038. * Gets a boolean indicating that the system is in VR mode and is presenting
  38039. * @returns true if VR mode is engaged
  38040. */
  38041. isVRPresenting(): boolean;
  38042. /** @hidden */
  38043. _requestVRFrame(): void;
  38044. /** @hidden */
  38045. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38046. /**
  38047. * Gets the source code of the vertex shader associated with a specific webGL program
  38048. * @param program defines the program to use
  38049. * @returns a string containing the source code of the vertex shader associated with the program
  38050. */
  38051. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38052. /**
  38053. * Gets the source code of the fragment shader associated with a specific webGL program
  38054. * @param program defines the program to use
  38055. * @returns a string containing the source code of the fragment shader associated with the program
  38056. */
  38057. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38058. /**
  38059. * Sets a depth stencil texture from a render target to the according uniform.
  38060. * @param channel The texture channel
  38061. * @param uniform The uniform to set
  38062. * @param texture The render target texture containing the depth stencil texture to apply
  38063. */
  38064. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38065. /**
  38066. * Sets a texture to the webGL context from a postprocess
  38067. * @param channel defines the channel to use
  38068. * @param postProcess defines the source postprocess
  38069. */
  38070. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38071. /**
  38072. * Binds the output of the passed in post process to the texture channel specified
  38073. * @param channel The channel the texture should be bound to
  38074. * @param postProcess The post process which's output should be bound
  38075. */
  38076. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38077. protected _rebuildBuffers(): void;
  38078. /** @hidden */
  38079. _renderFrame(): void;
  38080. _renderLoop(): void;
  38081. /** @hidden */
  38082. _renderViews(): boolean;
  38083. /**
  38084. * Toggle full screen mode
  38085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38086. */
  38087. switchFullscreen(requestPointerLock: boolean): void;
  38088. /**
  38089. * Enters full screen mode
  38090. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38091. */
  38092. enterFullscreen(requestPointerLock: boolean): void;
  38093. /**
  38094. * Exits full screen mode
  38095. */
  38096. exitFullscreen(): void;
  38097. /**
  38098. * Enters Pointerlock mode
  38099. */
  38100. enterPointerlock(): void;
  38101. /**
  38102. * Exits Pointerlock mode
  38103. */
  38104. exitPointerlock(): void;
  38105. /**
  38106. * Begin a new frame
  38107. */
  38108. beginFrame(): void;
  38109. /**
  38110. * Enf the current frame
  38111. */
  38112. endFrame(): void;
  38113. resize(): void;
  38114. /**
  38115. * Force a specific size of the canvas
  38116. * @param width defines the new canvas' width
  38117. * @param height defines the new canvas' height
  38118. */
  38119. setSize(width: number, height: number): void;
  38120. /**
  38121. * Updates a dynamic vertex buffer.
  38122. * @param vertexBuffer the vertex buffer to update
  38123. * @param data the data used to update the vertex buffer
  38124. * @param byteOffset the byte offset of the data
  38125. * @param byteLength the byte length of the data
  38126. */
  38127. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38128. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38129. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38130. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38131. _releaseTexture(texture: InternalTexture): void;
  38132. /**
  38133. * @hidden
  38134. * Rescales a texture
  38135. * @param source input texutre
  38136. * @param destination destination texture
  38137. * @param scene scene to use to render the resize
  38138. * @param internalFormat format to use when resizing
  38139. * @param onComplete callback to be called when resize has completed
  38140. */
  38141. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38142. /**
  38143. * Gets the current framerate
  38144. * @returns a number representing the framerate
  38145. */
  38146. getFps(): number;
  38147. /**
  38148. * Gets the time spent between current and previous frame
  38149. * @returns a number representing the delta time in ms
  38150. */
  38151. getDeltaTime(): number;
  38152. private _measureFps;
  38153. /** @hidden */
  38154. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38155. /**
  38156. * Update a dynamic index buffer
  38157. * @param indexBuffer defines the target index buffer
  38158. * @param indices defines the data to update
  38159. * @param offset defines the offset in the target index buffer where update should start
  38160. */
  38161. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38162. /**
  38163. * Updates the sample count of a render target texture
  38164. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38165. * @param texture defines the texture to update
  38166. * @param samples defines the sample count to set
  38167. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38168. */
  38169. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38170. /**
  38171. * Updates a depth texture Comparison Mode and Function.
  38172. * If the comparison Function is equal to 0, the mode will be set to none.
  38173. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38174. * @param texture The texture to set the comparison function for
  38175. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38176. */
  38177. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38178. /**
  38179. * Creates a webGL buffer to use with instanciation
  38180. * @param capacity defines the size of the buffer
  38181. * @returns the webGL buffer
  38182. */
  38183. createInstancesBuffer(capacity: number): DataBuffer;
  38184. /**
  38185. * Delete a webGL buffer used with instanciation
  38186. * @param buffer defines the webGL buffer to delete
  38187. */
  38188. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38189. private _clientWaitAsync;
  38190. /** @hidden */
  38191. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38192. dispose(): void;
  38193. private _disableTouchAction;
  38194. /**
  38195. * Display the loading screen
  38196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38197. */
  38198. displayLoadingUI(): void;
  38199. /**
  38200. * Hide the loading screen
  38201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38202. */
  38203. hideLoadingUI(): void;
  38204. /**
  38205. * Gets the current loading screen object
  38206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38207. */
  38208. get loadingScreen(): ILoadingScreen;
  38209. /**
  38210. * Sets the current loading screen object
  38211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38212. */
  38213. set loadingScreen(loadingScreen: ILoadingScreen);
  38214. /**
  38215. * Sets the current loading screen text
  38216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38217. */
  38218. set loadingUIText(text: string);
  38219. /**
  38220. * Sets the current loading screen background color
  38221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38222. */
  38223. set loadingUIBackgroundColor(color: string);
  38224. /** Pointerlock and fullscreen */
  38225. /**
  38226. * Ask the browser to promote the current element to pointerlock mode
  38227. * @param element defines the DOM element to promote
  38228. */
  38229. static _RequestPointerlock(element: HTMLElement): void;
  38230. /**
  38231. * Asks the browser to exit pointerlock mode
  38232. */
  38233. static _ExitPointerlock(): void;
  38234. /**
  38235. * Ask the browser to promote the current element to fullscreen rendering mode
  38236. * @param element defines the DOM element to promote
  38237. */
  38238. static _RequestFullscreen(element: HTMLElement): void;
  38239. /**
  38240. * Asks the browser to exit fullscreen mode
  38241. */
  38242. static _ExitFullscreen(): void;
  38243. }
  38244. }
  38245. declare module "babylonjs/Engines/engineStore" {
  38246. import { Nullable } from "babylonjs/types";
  38247. import { Engine } from "babylonjs/Engines/engine";
  38248. import { Scene } from "babylonjs/scene";
  38249. /**
  38250. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38251. * during the life time of the application.
  38252. */
  38253. export class EngineStore {
  38254. /** Gets the list of created engines */
  38255. static Instances: import("babylonjs/Engines/engine").Engine[];
  38256. /** @hidden */
  38257. static _LastCreatedScene: Nullable<Scene>;
  38258. /**
  38259. * Gets the latest created engine
  38260. */
  38261. static get LastCreatedEngine(): Nullable<Engine>;
  38262. /**
  38263. * Gets the latest created scene
  38264. */
  38265. static get LastCreatedScene(): Nullable<Scene>;
  38266. /**
  38267. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38268. * @ignorenaming
  38269. */
  38270. static UseFallbackTexture: boolean;
  38271. /**
  38272. * Texture content used if a texture cannot loaded
  38273. * @ignorenaming
  38274. */
  38275. static FallbackTexture: string;
  38276. }
  38277. }
  38278. declare module "babylonjs/Misc/promise" {
  38279. /**
  38280. * Helper class that provides a small promise polyfill
  38281. */
  38282. export class PromisePolyfill {
  38283. /**
  38284. * Static function used to check if the polyfill is required
  38285. * If this is the case then the function will inject the polyfill to window.Promise
  38286. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38287. */
  38288. static Apply(force?: boolean): void;
  38289. }
  38290. }
  38291. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38292. /**
  38293. * Interface for screenshot methods with describe argument called `size` as object with options
  38294. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38295. */
  38296. export interface IScreenshotSize {
  38297. /**
  38298. * number in pixels for canvas height
  38299. */
  38300. height?: number;
  38301. /**
  38302. * multiplier allowing render at a higher or lower resolution
  38303. * If value is defined then height and width will be ignored and taken from camera
  38304. */
  38305. precision?: number;
  38306. /**
  38307. * number in pixels for canvas width
  38308. */
  38309. width?: number;
  38310. }
  38311. }
  38312. declare module "babylonjs/Misc/tools" {
  38313. import { Nullable, float } from "babylonjs/types";
  38314. import { DomManagement } from "babylonjs/Misc/domManagement";
  38315. import { WebRequest } from "babylonjs/Misc/webRequest";
  38316. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38317. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38318. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38319. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38320. import { Camera } from "babylonjs/Cameras/camera";
  38321. import { Engine } from "babylonjs/Engines/engine";
  38322. interface IColor4Like {
  38323. r: float;
  38324. g: float;
  38325. b: float;
  38326. a: float;
  38327. }
  38328. /**
  38329. * Class containing a set of static utilities functions
  38330. */
  38331. export class Tools {
  38332. /**
  38333. * Gets or sets the base URL to use to load assets
  38334. */
  38335. static get BaseUrl(): string;
  38336. static set BaseUrl(value: string);
  38337. /**
  38338. * Enable/Disable Custom HTTP Request Headers globally.
  38339. * default = false
  38340. * @see CustomRequestHeaders
  38341. */
  38342. static UseCustomRequestHeaders: boolean;
  38343. /**
  38344. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38345. * i.e. when loading files, where the server/service expects an Authorization header
  38346. */
  38347. static CustomRequestHeaders: {
  38348. [key: string]: string;
  38349. };
  38350. /**
  38351. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38352. */
  38353. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38354. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38355. /**
  38356. * Default behaviour for cors in the application.
  38357. * It can be a string if the expected behavior is identical in the entire app.
  38358. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38359. */
  38360. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38361. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38362. /**
  38363. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38364. * @ignorenaming
  38365. */
  38366. static get UseFallbackTexture(): boolean;
  38367. static set UseFallbackTexture(value: boolean);
  38368. /**
  38369. * Use this object to register external classes like custom textures or material
  38370. * to allow the laoders to instantiate them
  38371. */
  38372. static get RegisteredExternalClasses(): {
  38373. [key: string]: Object;
  38374. };
  38375. static set RegisteredExternalClasses(classes: {
  38376. [key: string]: Object;
  38377. });
  38378. /**
  38379. * Texture content used if a texture cannot loaded
  38380. * @ignorenaming
  38381. */
  38382. static get fallbackTexture(): string;
  38383. static set fallbackTexture(value: string);
  38384. /**
  38385. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38386. * @param u defines the coordinate on X axis
  38387. * @param v defines the coordinate on Y axis
  38388. * @param width defines the width of the source data
  38389. * @param height defines the height of the source data
  38390. * @param pixels defines the source byte array
  38391. * @param color defines the output color
  38392. */
  38393. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38394. /**
  38395. * Interpolates between a and b via alpha
  38396. * @param a The lower value (returned when alpha = 0)
  38397. * @param b The upper value (returned when alpha = 1)
  38398. * @param alpha The interpolation-factor
  38399. * @return The mixed value
  38400. */
  38401. static Mix(a: number, b: number, alpha: number): number;
  38402. /**
  38403. * Tries to instantiate a new object from a given class name
  38404. * @param className defines the class name to instantiate
  38405. * @returns the new object or null if the system was not able to do the instantiation
  38406. */
  38407. static Instantiate(className: string): any;
  38408. /**
  38409. * Provides a slice function that will work even on IE
  38410. * @param data defines the array to slice
  38411. * @param start defines the start of the data (optional)
  38412. * @param end defines the end of the data (optional)
  38413. * @returns the new sliced array
  38414. */
  38415. static Slice<T>(data: T, start?: number, end?: number): T;
  38416. /**
  38417. * Polyfill for setImmediate
  38418. * @param action defines the action to execute after the current execution block
  38419. */
  38420. static SetImmediate(action: () => void): void;
  38421. /**
  38422. * Function indicating if a number is an exponent of 2
  38423. * @param value defines the value to test
  38424. * @returns true if the value is an exponent of 2
  38425. */
  38426. static IsExponentOfTwo(value: number): boolean;
  38427. private static _tmpFloatArray;
  38428. /**
  38429. * Returns the nearest 32-bit single precision float representation of a Number
  38430. * @param value A Number. If the parameter is of a different type, it will get converted
  38431. * to a number or to NaN if it cannot be converted
  38432. * @returns number
  38433. */
  38434. static FloatRound(value: number): number;
  38435. /**
  38436. * Extracts the filename from a path
  38437. * @param path defines the path to use
  38438. * @returns the filename
  38439. */
  38440. static GetFilename(path: string): string;
  38441. /**
  38442. * Extracts the "folder" part of a path (everything before the filename).
  38443. * @param uri The URI to extract the info from
  38444. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38445. * @returns The "folder" part of the path
  38446. */
  38447. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38448. /**
  38449. * Extracts text content from a DOM element hierarchy
  38450. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38451. */
  38452. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38453. /**
  38454. * Convert an angle in radians to degrees
  38455. * @param angle defines the angle to convert
  38456. * @returns the angle in degrees
  38457. */
  38458. static ToDegrees(angle: number): number;
  38459. /**
  38460. * Convert an angle in degrees to radians
  38461. * @param angle defines the angle to convert
  38462. * @returns the angle in radians
  38463. */
  38464. static ToRadians(angle: number): number;
  38465. /**
  38466. * Returns an array if obj is not an array
  38467. * @param obj defines the object to evaluate as an array
  38468. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38469. * @returns either obj directly if obj is an array or a new array containing obj
  38470. */
  38471. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38472. /**
  38473. * Gets the pointer prefix to use
  38474. * @param engine defines the engine we are finding the prefix for
  38475. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38476. */
  38477. static GetPointerPrefix(engine: Engine): string;
  38478. /**
  38479. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38480. * @param url define the url we are trying
  38481. * @param element define the dom element where to configure the cors policy
  38482. */
  38483. static SetCorsBehavior(url: string | string[], element: {
  38484. crossOrigin: string | null;
  38485. }): void;
  38486. /**
  38487. * Removes unwanted characters from an url
  38488. * @param url defines the url to clean
  38489. * @returns the cleaned url
  38490. */
  38491. static CleanUrl(url: string): string;
  38492. /**
  38493. * Gets or sets a function used to pre-process url before using them to load assets
  38494. */
  38495. static get PreprocessUrl(): (url: string) => string;
  38496. static set PreprocessUrl(processor: (url: string) => string);
  38497. /**
  38498. * Loads an image as an HTMLImageElement.
  38499. * @param input url string, ArrayBuffer, or Blob to load
  38500. * @param onLoad callback called when the image successfully loads
  38501. * @param onError callback called when the image fails to load
  38502. * @param offlineProvider offline provider for caching
  38503. * @param mimeType optional mime type
  38504. * @returns the HTMLImageElement of the loaded image
  38505. */
  38506. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38507. /**
  38508. * Loads a file from a url
  38509. * @param url url string, ArrayBuffer, or Blob to load
  38510. * @param onSuccess callback called when the file successfully loads
  38511. * @param onProgress callback called while file is loading (if the server supports this mode)
  38512. * @param offlineProvider defines the offline provider for caching
  38513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38514. * @param onError callback called when the file fails to load
  38515. * @returns a file request object
  38516. */
  38517. 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;
  38518. /**
  38519. * Loads a file from a url
  38520. * @param url the file url to load
  38521. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38522. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38523. */
  38524. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38525. /**
  38526. * Load a script (identified by an url). When the url returns, the
  38527. * content of this file is added into a new script element, attached to the DOM (body element)
  38528. * @param scriptUrl defines the url of the script to laod
  38529. * @param onSuccess defines the callback called when the script is loaded
  38530. * @param onError defines the callback to call if an error occurs
  38531. * @param scriptId defines the id of the script element
  38532. */
  38533. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38534. /**
  38535. * Load an asynchronous script (identified by an url). When the url returns, the
  38536. * content of this file is added into a new script element, attached to the DOM (body element)
  38537. * @param scriptUrl defines the url of the script to laod
  38538. * @param scriptId defines the id of the script element
  38539. * @returns a promise request object
  38540. */
  38541. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38542. /**
  38543. * Loads a file from a blob
  38544. * @param fileToLoad defines the blob to use
  38545. * @param callback defines the callback to call when data is loaded
  38546. * @param progressCallback defines the callback to call during loading process
  38547. * @returns a file request object
  38548. */
  38549. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38550. /**
  38551. * Reads a file from a File object
  38552. * @param file defines the file to load
  38553. * @param onSuccess defines the callback to call when data is loaded
  38554. * @param onProgress defines the callback to call during loading process
  38555. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38556. * @param onError defines the callback to call when an error occurs
  38557. * @returns a file request object
  38558. */
  38559. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38560. /**
  38561. * Creates a data url from a given string content
  38562. * @param content defines the content to convert
  38563. * @returns the new data url link
  38564. */
  38565. static FileAsURL(content: string): string;
  38566. /**
  38567. * Format the given number to a specific decimal format
  38568. * @param value defines the number to format
  38569. * @param decimals defines the number of decimals to use
  38570. * @returns the formatted string
  38571. */
  38572. static Format(value: number, decimals?: number): string;
  38573. /**
  38574. * Tries to copy an object by duplicating every property
  38575. * @param source defines the source object
  38576. * @param destination defines the target object
  38577. * @param doNotCopyList defines a list of properties to avoid
  38578. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38579. */
  38580. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38581. /**
  38582. * Gets a boolean indicating if the given object has no own property
  38583. * @param obj defines the object to test
  38584. * @returns true if object has no own property
  38585. */
  38586. static IsEmpty(obj: any): boolean;
  38587. /**
  38588. * Function used to register events at window level
  38589. * @param windowElement defines the Window object to use
  38590. * @param events defines the events to register
  38591. */
  38592. static RegisterTopRootEvents(windowElement: Window, events: {
  38593. name: string;
  38594. handler: Nullable<(e: FocusEvent) => any>;
  38595. }[]): void;
  38596. /**
  38597. * Function used to unregister events from window level
  38598. * @param windowElement defines the Window object to use
  38599. * @param events defines the events to unregister
  38600. */
  38601. static UnregisterTopRootEvents(windowElement: Window, events: {
  38602. name: string;
  38603. handler: Nullable<(e: FocusEvent) => any>;
  38604. }[]): void;
  38605. /**
  38606. * @ignore
  38607. */
  38608. static _ScreenshotCanvas: HTMLCanvasElement;
  38609. /**
  38610. * Dumps the current bound framebuffer
  38611. * @param width defines the rendering width
  38612. * @param height defines the rendering height
  38613. * @param engine defines the hosting engine
  38614. * @param successCallback defines the callback triggered once the data are available
  38615. * @param mimeType defines the mime type of the result
  38616. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38617. */
  38618. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38619. /**
  38620. * Converts the canvas data to blob.
  38621. * This acts as a polyfill for browsers not supporting the to blob function.
  38622. * @param canvas Defines the canvas to extract the data from
  38623. * @param successCallback Defines the callback triggered once the data are available
  38624. * @param mimeType Defines the mime type of the result
  38625. */
  38626. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38627. /**
  38628. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38629. * @param successCallback defines the callback triggered once the data are available
  38630. * @param mimeType defines the mime type of the result
  38631. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38632. */
  38633. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38634. /**
  38635. * Downloads a blob in the browser
  38636. * @param blob defines the blob to download
  38637. * @param fileName defines the name of the downloaded file
  38638. */
  38639. static Download(blob: Blob, fileName: string): void;
  38640. /**
  38641. * Captures a screenshot of the current rendering
  38642. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38643. * @param engine defines the rendering engine
  38644. * @param camera defines the source camera
  38645. * @param size This parameter can be set to a single number or to an object with the
  38646. * following (optional) properties: precision, width, height. If a single number is passed,
  38647. * it will be used for both width and height. If an object is passed, the screenshot size
  38648. * will be derived from the parameters. The precision property is a multiplier allowing
  38649. * rendering at a higher or lower resolution
  38650. * @param successCallback defines the callback receives a single parameter which contains the
  38651. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38652. * src parameter of an <img> to display it
  38653. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38654. * Check your browser for supported MIME types
  38655. */
  38656. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38657. /**
  38658. * Captures a screenshot of the current rendering
  38659. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38660. * @param engine defines the rendering engine
  38661. * @param camera defines the source camera
  38662. * @param size This parameter can be set to a single number or to an object with the
  38663. * following (optional) properties: precision, width, height. If a single number is passed,
  38664. * it will be used for both width and height. If an object is passed, the screenshot size
  38665. * will be derived from the parameters. The precision property is a multiplier allowing
  38666. * rendering at a higher or lower resolution
  38667. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38668. * Check your browser for supported MIME types
  38669. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38670. * to the src parameter of an <img> to display it
  38671. */
  38672. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38673. /**
  38674. * Generates an image screenshot from the specified camera.
  38675. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38676. * @param engine The engine to use for rendering
  38677. * @param camera The camera to use for rendering
  38678. * @param size This parameter can be set to a single number or to an object with the
  38679. * following (optional) properties: precision, width, height. If a single number is passed,
  38680. * it will be used for both width and height. If an object is passed, the screenshot size
  38681. * will be derived from the parameters. The precision property is a multiplier allowing
  38682. * rendering at a higher or lower resolution
  38683. * @param successCallback The callback receives a single parameter which contains the
  38684. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38685. * src parameter of an <img> to display it
  38686. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38687. * Check your browser for supported MIME types
  38688. * @param samples Texture samples (default: 1)
  38689. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38690. * @param fileName A name for for the downloaded file.
  38691. */
  38692. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38693. /**
  38694. * Generates an image screenshot from the specified camera.
  38695. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38696. * @param engine The engine to use for rendering
  38697. * @param camera The camera to use for rendering
  38698. * @param size This parameter can be set to a single number or to an object with the
  38699. * following (optional) properties: precision, width, height. If a single number is passed,
  38700. * it will be used for both width and height. If an object is passed, the screenshot size
  38701. * will be derived from the parameters. The precision property is a multiplier allowing
  38702. * rendering at a higher or lower resolution
  38703. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38704. * Check your browser for supported MIME types
  38705. * @param samples Texture samples (default: 1)
  38706. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38707. * @param fileName A name for for the downloaded file.
  38708. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38709. * to the src parameter of an <img> to display it
  38710. */
  38711. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38712. /**
  38713. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38714. * Be aware Math.random() could cause collisions, but:
  38715. * "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"
  38716. * @returns a pseudo random id
  38717. */
  38718. static RandomId(): string;
  38719. /**
  38720. * Test if the given uri is a base64 string
  38721. * @param uri The uri to test
  38722. * @return True if the uri is a base64 string or false otherwise
  38723. */
  38724. static IsBase64(uri: string): boolean;
  38725. /**
  38726. * Decode the given base64 uri.
  38727. * @param uri The uri to decode
  38728. * @return The decoded base64 data.
  38729. */
  38730. static DecodeBase64(uri: string): ArrayBuffer;
  38731. /**
  38732. * Gets the absolute url.
  38733. * @param url the input url
  38734. * @return the absolute url
  38735. */
  38736. static GetAbsoluteUrl(url: string): string;
  38737. /**
  38738. * No log
  38739. */
  38740. static readonly NoneLogLevel: number;
  38741. /**
  38742. * Only message logs
  38743. */
  38744. static readonly MessageLogLevel: number;
  38745. /**
  38746. * Only warning logs
  38747. */
  38748. static readonly WarningLogLevel: number;
  38749. /**
  38750. * Only error logs
  38751. */
  38752. static readonly ErrorLogLevel: number;
  38753. /**
  38754. * All logs
  38755. */
  38756. static readonly AllLogLevel: number;
  38757. /**
  38758. * Gets a value indicating the number of loading errors
  38759. * @ignorenaming
  38760. */
  38761. static get errorsCount(): number;
  38762. /**
  38763. * Callback called when a new log is added
  38764. */
  38765. static OnNewCacheEntry: (entry: string) => void;
  38766. /**
  38767. * Log a message to the console
  38768. * @param message defines the message to log
  38769. */
  38770. static Log(message: string): void;
  38771. /**
  38772. * Write a warning message to the console
  38773. * @param message defines the message to log
  38774. */
  38775. static Warn(message: string): void;
  38776. /**
  38777. * Write an error message to the console
  38778. * @param message defines the message to log
  38779. */
  38780. static Error(message: string): void;
  38781. /**
  38782. * Gets current log cache (list of logs)
  38783. */
  38784. static get LogCache(): string;
  38785. /**
  38786. * Clears the log cache
  38787. */
  38788. static ClearLogCache(): void;
  38789. /**
  38790. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38791. */
  38792. static set LogLevels(level: number);
  38793. /**
  38794. * Checks if the window object exists
  38795. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38796. */
  38797. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38798. /**
  38799. * No performance log
  38800. */
  38801. static readonly PerformanceNoneLogLevel: number;
  38802. /**
  38803. * Use user marks to log performance
  38804. */
  38805. static readonly PerformanceUserMarkLogLevel: number;
  38806. /**
  38807. * Log performance to the console
  38808. */
  38809. static readonly PerformanceConsoleLogLevel: number;
  38810. private static _performance;
  38811. /**
  38812. * Sets the current performance log level
  38813. */
  38814. static set PerformanceLogLevel(level: number);
  38815. private static _StartPerformanceCounterDisabled;
  38816. private static _EndPerformanceCounterDisabled;
  38817. private static _StartUserMark;
  38818. private static _EndUserMark;
  38819. private static _StartPerformanceConsole;
  38820. private static _EndPerformanceConsole;
  38821. /**
  38822. * Starts a performance counter
  38823. */
  38824. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38825. /**
  38826. * Ends a specific performance coutner
  38827. */
  38828. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38829. /**
  38830. * Gets either window.performance.now() if supported or Date.now() else
  38831. */
  38832. static get Now(): number;
  38833. /**
  38834. * This method will return the name of the class used to create the instance of the given object.
  38835. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38836. * @param object the object to get the class name from
  38837. * @param isType defines if the object is actually a type
  38838. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38839. */
  38840. static GetClassName(object: any, isType?: boolean): string;
  38841. /**
  38842. * Gets the first element of an array satisfying a given predicate
  38843. * @param array defines the array to browse
  38844. * @param predicate defines the predicate to use
  38845. * @returns null if not found or the element
  38846. */
  38847. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38848. /**
  38849. * This method will return the name of the full name of the class, including its owning module (if any).
  38850. * 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).
  38851. * @param object the object to get the class name from
  38852. * @param isType defines if the object is actually a type
  38853. * @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.
  38854. * @ignorenaming
  38855. */
  38856. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38857. /**
  38858. * Returns a promise that resolves after the given amount of time.
  38859. * @param delay Number of milliseconds to delay
  38860. * @returns Promise that resolves after the given amount of time
  38861. */
  38862. static DelayAsync(delay: number): Promise<void>;
  38863. /**
  38864. * Utility function to detect if the current user agent is Safari
  38865. * @returns whether or not the current user agent is safari
  38866. */
  38867. static IsSafari(): boolean;
  38868. }
  38869. /**
  38870. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38871. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38872. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38873. * @param name The name of the class, case should be preserved
  38874. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38875. */
  38876. export function className(name: string, module?: string): (target: Object) => void;
  38877. /**
  38878. * An implementation of a loop for asynchronous functions.
  38879. */
  38880. export class AsyncLoop {
  38881. /**
  38882. * Defines the number of iterations for the loop
  38883. */
  38884. iterations: number;
  38885. /**
  38886. * Defines the current index of the loop.
  38887. */
  38888. index: number;
  38889. private _done;
  38890. private _fn;
  38891. private _successCallback;
  38892. /**
  38893. * Constructor.
  38894. * @param iterations the number of iterations.
  38895. * @param func the function to run each iteration
  38896. * @param successCallback the callback that will be called upon succesful execution
  38897. * @param offset starting offset.
  38898. */
  38899. constructor(
  38900. /**
  38901. * Defines the number of iterations for the loop
  38902. */
  38903. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38904. /**
  38905. * Execute the next iteration. Must be called after the last iteration was finished.
  38906. */
  38907. executeNext(): void;
  38908. /**
  38909. * Break the loop and run the success callback.
  38910. */
  38911. breakLoop(): void;
  38912. /**
  38913. * Create and run an async loop.
  38914. * @param iterations the number of iterations.
  38915. * @param fn the function to run each iteration
  38916. * @param successCallback the callback that will be called upon succesful execution
  38917. * @param offset starting offset.
  38918. * @returns the created async loop object
  38919. */
  38920. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38921. /**
  38922. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38923. * @param iterations total number of iterations
  38924. * @param syncedIterations number of synchronous iterations in each async iteration.
  38925. * @param fn the function to call each iteration.
  38926. * @param callback a success call back that will be called when iterating stops.
  38927. * @param breakFunction a break condition (optional)
  38928. * @param timeout timeout settings for the setTimeout function. default - 0.
  38929. * @returns the created async loop object
  38930. */
  38931. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38932. }
  38933. }
  38934. declare module "babylonjs/Misc/stringDictionary" {
  38935. import { Nullable } from "babylonjs/types";
  38936. /**
  38937. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38938. * The underlying implementation relies on an associative array to ensure the best performances.
  38939. * The value can be anything including 'null' but except 'undefined'
  38940. */
  38941. export class StringDictionary<T> {
  38942. /**
  38943. * This will clear this dictionary and copy the content from the 'source' one.
  38944. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38945. * @param source the dictionary to take the content from and copy to this dictionary
  38946. */
  38947. copyFrom(source: StringDictionary<T>): void;
  38948. /**
  38949. * Get a value based from its key
  38950. * @param key the given key to get the matching value from
  38951. * @return the value if found, otherwise undefined is returned
  38952. */
  38953. get(key: string): T | undefined;
  38954. /**
  38955. * Get a value from its key or add it if it doesn't exist.
  38956. * This method will ensure you that a given key/data will be present in the dictionary.
  38957. * @param key the given key to get the matching value from
  38958. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38959. * The factory will only be invoked if there's no data for the given key.
  38960. * @return the value corresponding to the key.
  38961. */
  38962. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38963. /**
  38964. * Get a value from its key if present in the dictionary otherwise add it
  38965. * @param key the key to get the value from
  38966. * @param val if there's no such key/value pair in the dictionary add it with this value
  38967. * @return the value corresponding to the key
  38968. */
  38969. getOrAdd(key: string, val: T): T;
  38970. /**
  38971. * Check if there's a given key in the dictionary
  38972. * @param key the key to check for
  38973. * @return true if the key is present, false otherwise
  38974. */
  38975. contains(key: string): boolean;
  38976. /**
  38977. * Add a new key and its corresponding value
  38978. * @param key the key to add
  38979. * @param value the value corresponding to the key
  38980. * @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
  38981. */
  38982. add(key: string, value: T): boolean;
  38983. /**
  38984. * Update a specific value associated to a key
  38985. * @param key defines the key to use
  38986. * @param value defines the value to store
  38987. * @returns true if the value was updated (or false if the key was not found)
  38988. */
  38989. set(key: string, value: T): boolean;
  38990. /**
  38991. * Get the element of the given key and remove it from the dictionary
  38992. * @param key defines the key to search
  38993. * @returns the value associated with the key or null if not found
  38994. */
  38995. getAndRemove(key: string): Nullable<T>;
  38996. /**
  38997. * Remove a key/value from the dictionary.
  38998. * @param key the key to remove
  38999. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39000. */
  39001. remove(key: string): boolean;
  39002. /**
  39003. * Clear the whole content of the dictionary
  39004. */
  39005. clear(): void;
  39006. /**
  39007. * Gets the current count
  39008. */
  39009. get count(): number;
  39010. /**
  39011. * Execute a callback on each key/val of the dictionary.
  39012. * Note that you can remove any element in this dictionary in the callback implementation
  39013. * @param callback the callback to execute on a given key/value pair
  39014. */
  39015. forEach(callback: (key: string, val: T) => void): void;
  39016. /**
  39017. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39018. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39019. * Note that you can remove any element in this dictionary in the callback implementation
  39020. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39021. * @returns the first item
  39022. */
  39023. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39024. private _count;
  39025. private _data;
  39026. }
  39027. }
  39028. declare module "babylonjs/Collisions/collisionCoordinator" {
  39029. import { Nullable } from "babylonjs/types";
  39030. import { Scene } from "babylonjs/scene";
  39031. import { Vector3 } from "babylonjs/Maths/math.vector";
  39032. import { Collider } from "babylonjs/Collisions/collider";
  39033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39034. /** @hidden */
  39035. export interface ICollisionCoordinator {
  39036. createCollider(): Collider;
  39037. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39038. init(scene: Scene): void;
  39039. }
  39040. /** @hidden */
  39041. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39042. private _scene;
  39043. private _scaledPosition;
  39044. private _scaledVelocity;
  39045. private _finalPosition;
  39046. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39047. createCollider(): Collider;
  39048. init(scene: Scene): void;
  39049. private _collideWithWorld;
  39050. }
  39051. }
  39052. declare module "babylonjs/Inputs/scene.inputManager" {
  39053. import { Nullable } from "babylonjs/types";
  39054. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39055. import { Vector2 } from "babylonjs/Maths/math.vector";
  39056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39057. import { Scene } from "babylonjs/scene";
  39058. /**
  39059. * Class used to manage all inputs for the scene.
  39060. */
  39061. export class InputManager {
  39062. /** The distance in pixel that you have to move to prevent some events */
  39063. static DragMovementThreshold: number;
  39064. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39065. static LongPressDelay: number;
  39066. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39067. static DoubleClickDelay: number;
  39068. /** If you need to check double click without raising a single click at first click, enable this flag */
  39069. static ExclusiveDoubleClickMode: boolean;
  39070. private _wheelEventName;
  39071. private _onPointerMove;
  39072. private _onPointerDown;
  39073. private _onPointerUp;
  39074. private _initClickEvent;
  39075. private _initActionManager;
  39076. private _delayedSimpleClick;
  39077. private _delayedSimpleClickTimeout;
  39078. private _previousDelayedSimpleClickTimeout;
  39079. private _meshPickProceed;
  39080. private _previousButtonPressed;
  39081. private _currentPickResult;
  39082. private _previousPickResult;
  39083. private _totalPointersPressed;
  39084. private _doubleClickOccured;
  39085. private _pointerOverMesh;
  39086. private _pickedDownMesh;
  39087. private _pickedUpMesh;
  39088. private _pointerX;
  39089. private _pointerY;
  39090. private _unTranslatedPointerX;
  39091. private _unTranslatedPointerY;
  39092. private _startingPointerPosition;
  39093. private _previousStartingPointerPosition;
  39094. private _startingPointerTime;
  39095. private _previousStartingPointerTime;
  39096. private _pointerCaptures;
  39097. private _onKeyDown;
  39098. private _onKeyUp;
  39099. private _onCanvasFocusObserver;
  39100. private _onCanvasBlurObserver;
  39101. private _scene;
  39102. /**
  39103. * Creates a new InputManager
  39104. * @param scene defines the hosting scene
  39105. */
  39106. constructor(scene: Scene);
  39107. /**
  39108. * Gets the mesh that is currently under the pointer
  39109. */
  39110. get meshUnderPointer(): Nullable<AbstractMesh>;
  39111. /**
  39112. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39113. */
  39114. get unTranslatedPointer(): Vector2;
  39115. /**
  39116. * Gets or sets the current on-screen X position of the pointer
  39117. */
  39118. get pointerX(): number;
  39119. set pointerX(value: number);
  39120. /**
  39121. * Gets or sets the current on-screen Y position of the pointer
  39122. */
  39123. get pointerY(): number;
  39124. set pointerY(value: number);
  39125. private _updatePointerPosition;
  39126. private _processPointerMove;
  39127. private _setRayOnPointerInfo;
  39128. private _checkPrePointerObservable;
  39129. /**
  39130. * Use this method to simulate a pointer move on a mesh
  39131. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39132. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39133. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39134. */
  39135. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39136. /**
  39137. * Use this method to simulate a pointer down on a mesh
  39138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39141. */
  39142. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39143. private _processPointerDown;
  39144. /** @hidden */
  39145. _isPointerSwiping(): boolean;
  39146. /**
  39147. * Use this method to simulate a pointer up on a mesh
  39148. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39149. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39150. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39151. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39152. */
  39153. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39154. private _processPointerUp;
  39155. /**
  39156. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39157. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39158. * @returns true if the pointer was captured
  39159. */
  39160. isPointerCaptured(pointerId?: number): boolean;
  39161. /**
  39162. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39163. * @param attachUp defines if you want to attach events to pointerup
  39164. * @param attachDown defines if you want to attach events to pointerdown
  39165. * @param attachMove defines if you want to attach events to pointermove
  39166. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39167. */
  39168. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39169. /**
  39170. * Detaches all event handlers
  39171. */
  39172. detachControl(): void;
  39173. /**
  39174. * Force the value of meshUnderPointer
  39175. * @param mesh defines the mesh to use
  39176. */
  39177. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39178. /**
  39179. * Gets the mesh under the pointer
  39180. * @returns a Mesh or null if no mesh is under the pointer
  39181. */
  39182. getPointerOverMesh(): Nullable<AbstractMesh>;
  39183. }
  39184. }
  39185. declare module "babylonjs/Animations/animationGroup" {
  39186. import { Animatable } from "babylonjs/Animations/animatable";
  39187. import { Animation } from "babylonjs/Animations/animation";
  39188. import { Scene, IDisposable } from "babylonjs/scene";
  39189. import { Observable } from "babylonjs/Misc/observable";
  39190. import { Nullable } from "babylonjs/types";
  39191. import "babylonjs/Animations/animatable";
  39192. /**
  39193. * This class defines the direct association between an animation and a target
  39194. */
  39195. export class TargetedAnimation {
  39196. /**
  39197. * Animation to perform
  39198. */
  39199. animation: Animation;
  39200. /**
  39201. * Target to animate
  39202. */
  39203. target: any;
  39204. /**
  39205. * Returns the string "TargetedAnimation"
  39206. * @returns "TargetedAnimation"
  39207. */
  39208. getClassName(): string;
  39209. /**
  39210. * Serialize the object
  39211. * @returns the JSON object representing the current entity
  39212. */
  39213. serialize(): any;
  39214. }
  39215. /**
  39216. * Use this class to create coordinated animations on multiple targets
  39217. */
  39218. export class AnimationGroup implements IDisposable {
  39219. /** The name of the animation group */
  39220. name: string;
  39221. private _scene;
  39222. private _targetedAnimations;
  39223. private _animatables;
  39224. private _from;
  39225. private _to;
  39226. private _isStarted;
  39227. private _isPaused;
  39228. private _speedRatio;
  39229. private _loopAnimation;
  39230. private _isAdditive;
  39231. /**
  39232. * Gets or sets the unique id of the node
  39233. */
  39234. uniqueId: number;
  39235. /**
  39236. * This observable will notify when one animation have ended
  39237. */
  39238. onAnimationEndObservable: Observable<TargetedAnimation>;
  39239. /**
  39240. * Observer raised when one animation loops
  39241. */
  39242. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39243. /**
  39244. * Observer raised when all animations have looped
  39245. */
  39246. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39247. /**
  39248. * This observable will notify when all animations have ended.
  39249. */
  39250. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39251. /**
  39252. * This observable will notify when all animations have paused.
  39253. */
  39254. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39255. /**
  39256. * This observable will notify when all animations are playing.
  39257. */
  39258. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39259. /**
  39260. * Gets the first frame
  39261. */
  39262. get from(): number;
  39263. /**
  39264. * Gets the last frame
  39265. */
  39266. get to(): number;
  39267. /**
  39268. * Define if the animations are started
  39269. */
  39270. get isStarted(): boolean;
  39271. /**
  39272. * Gets a value indicating that the current group is playing
  39273. */
  39274. get isPlaying(): boolean;
  39275. /**
  39276. * Gets or sets the speed ratio to use for all animations
  39277. */
  39278. get speedRatio(): number;
  39279. /**
  39280. * Gets or sets the speed ratio to use for all animations
  39281. */
  39282. set speedRatio(value: number);
  39283. /**
  39284. * Gets or sets if all animations should loop or not
  39285. */
  39286. get loopAnimation(): boolean;
  39287. set loopAnimation(value: boolean);
  39288. /**
  39289. * Gets or sets if all animations should be evaluated additively
  39290. */
  39291. get isAdditive(): boolean;
  39292. set isAdditive(value: boolean);
  39293. /**
  39294. * Gets the targeted animations for this animation group
  39295. */
  39296. get targetedAnimations(): Array<TargetedAnimation>;
  39297. /**
  39298. * returning the list of animatables controlled by this animation group.
  39299. */
  39300. get animatables(): Array<Animatable>;
  39301. /**
  39302. * Gets the list of target animations
  39303. */
  39304. get children(): TargetedAnimation[];
  39305. /**
  39306. * Instantiates a new Animation Group.
  39307. * This helps managing several animations at once.
  39308. * @see http://doc.babylonjs.com/how_to/group
  39309. * @param name Defines the name of the group
  39310. * @param scene Defines the scene the group belongs to
  39311. */
  39312. constructor(
  39313. /** The name of the animation group */
  39314. name: string, scene?: Nullable<Scene>);
  39315. /**
  39316. * Add an animation (with its target) in the group
  39317. * @param animation defines the animation we want to add
  39318. * @param target defines the target of the animation
  39319. * @returns the TargetedAnimation object
  39320. */
  39321. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39322. /**
  39323. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39324. * It can add constant keys at begin or end
  39325. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39326. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39327. * @returns the animation group
  39328. */
  39329. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39330. private _animationLoopCount;
  39331. private _animationLoopFlags;
  39332. private _processLoop;
  39333. /**
  39334. * Start all animations on given targets
  39335. * @param loop defines if animations must loop
  39336. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39337. * @param from defines the from key (optional)
  39338. * @param to defines the to key (optional)
  39339. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39340. * @returns the current animation group
  39341. */
  39342. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39343. /**
  39344. * Pause all animations
  39345. * @returns the animation group
  39346. */
  39347. pause(): AnimationGroup;
  39348. /**
  39349. * Play all animations to initial state
  39350. * This function will start() the animations if they were not started or will restart() them if they were paused
  39351. * @param loop defines if animations must loop
  39352. * @returns the animation group
  39353. */
  39354. play(loop?: boolean): AnimationGroup;
  39355. /**
  39356. * Reset all animations to initial state
  39357. * @returns the animation group
  39358. */
  39359. reset(): AnimationGroup;
  39360. /**
  39361. * Restart animations from key 0
  39362. * @returns the animation group
  39363. */
  39364. restart(): AnimationGroup;
  39365. /**
  39366. * Stop all animations
  39367. * @returns the animation group
  39368. */
  39369. stop(): AnimationGroup;
  39370. /**
  39371. * Set animation weight for all animatables
  39372. * @param weight defines the weight to use
  39373. * @return the animationGroup
  39374. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39375. */
  39376. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39377. /**
  39378. * Synchronize and normalize all animatables with a source animatable
  39379. * @param root defines the root animatable to synchronize with
  39380. * @return the animationGroup
  39381. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39382. */
  39383. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39384. /**
  39385. * Goes to a specific frame in this animation group
  39386. * @param frame the frame number to go to
  39387. * @return the animationGroup
  39388. */
  39389. goToFrame(frame: number): AnimationGroup;
  39390. /**
  39391. * Dispose all associated resources
  39392. */
  39393. dispose(): void;
  39394. private _checkAnimationGroupEnded;
  39395. /**
  39396. * Clone the current animation group and returns a copy
  39397. * @param newName defines the name of the new group
  39398. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39399. * @returns the new aniamtion group
  39400. */
  39401. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39402. /**
  39403. * Serializes the animationGroup to an object
  39404. * @returns Serialized object
  39405. */
  39406. serialize(): any;
  39407. /**
  39408. * Returns a new AnimationGroup object parsed from the source provided.
  39409. * @param parsedAnimationGroup defines the source
  39410. * @param scene defines the scene that will receive the animationGroup
  39411. * @returns a new AnimationGroup
  39412. */
  39413. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39414. /**
  39415. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39416. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39417. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39418. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39419. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39420. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39421. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39422. */
  39423. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39424. /**
  39425. * Returns the string "AnimationGroup"
  39426. * @returns "AnimationGroup"
  39427. */
  39428. getClassName(): string;
  39429. /**
  39430. * Creates a detailled string about the object
  39431. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39432. * @returns a string representing the object
  39433. */
  39434. toString(fullDetails?: boolean): string;
  39435. }
  39436. }
  39437. declare module "babylonjs/scene" {
  39438. import { Nullable } from "babylonjs/types";
  39439. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39440. import { Observable } from "babylonjs/Misc/observable";
  39441. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39442. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39443. import { Geometry } from "babylonjs/Meshes/geometry";
  39444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39447. import { Mesh } from "babylonjs/Meshes/mesh";
  39448. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39449. import { Bone } from "babylonjs/Bones/bone";
  39450. import { Skeleton } from "babylonjs/Bones/skeleton";
  39451. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39452. import { Camera } from "babylonjs/Cameras/camera";
  39453. import { AbstractScene } from "babylonjs/abstractScene";
  39454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39455. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39456. import { Material } from "babylonjs/Materials/material";
  39457. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39458. import { Effect } from "babylonjs/Materials/effect";
  39459. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39460. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39461. import { Light } from "babylonjs/Lights/light";
  39462. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39463. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39464. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39465. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39466. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39467. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39468. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39469. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39470. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39471. import { Engine } from "babylonjs/Engines/engine";
  39472. import { Node } from "babylonjs/node";
  39473. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39474. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39475. import { WebRequest } from "babylonjs/Misc/webRequest";
  39476. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39477. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39479. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39480. import { Plane } from "babylonjs/Maths/math.plane";
  39481. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39482. import { Ray } from "babylonjs/Culling/ray";
  39483. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39484. import { Animation } from "babylonjs/Animations/animation";
  39485. import { Animatable } from "babylonjs/Animations/animatable";
  39486. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39487. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39488. import { Collider } from "babylonjs/Collisions/collider";
  39489. /**
  39490. * Define an interface for all classes that will hold resources
  39491. */
  39492. export interface IDisposable {
  39493. /**
  39494. * Releases all held resources
  39495. */
  39496. dispose(): void;
  39497. }
  39498. /** Interface defining initialization parameters for Scene class */
  39499. export interface SceneOptions {
  39500. /**
  39501. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39502. * It will improve performance when the number of geometries becomes important.
  39503. */
  39504. useGeometryUniqueIdsMap?: boolean;
  39505. /**
  39506. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39507. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39508. */
  39509. useMaterialMeshMap?: boolean;
  39510. /**
  39511. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39512. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39513. */
  39514. useClonedMeshMap?: boolean;
  39515. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39516. virtual?: boolean;
  39517. }
  39518. /**
  39519. * Represents a scene to be rendered by the engine.
  39520. * @see http://doc.babylonjs.com/features/scene
  39521. */
  39522. export class Scene extends AbstractScene implements IAnimatable {
  39523. /** The fog is deactivated */
  39524. static readonly FOGMODE_NONE: number;
  39525. /** The fog density is following an exponential function */
  39526. static readonly FOGMODE_EXP: number;
  39527. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39528. static readonly FOGMODE_EXP2: number;
  39529. /** The fog density is following a linear function. */
  39530. static readonly FOGMODE_LINEAR: number;
  39531. /**
  39532. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39534. */
  39535. static MinDeltaTime: number;
  39536. /**
  39537. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39539. */
  39540. static MaxDeltaTime: number;
  39541. /**
  39542. * Factory used to create the default material.
  39543. * @param name The name of the material to create
  39544. * @param scene The scene to create the material for
  39545. * @returns The default material
  39546. */
  39547. static DefaultMaterialFactory(scene: Scene): Material;
  39548. /**
  39549. * Factory used to create the a collision coordinator.
  39550. * @returns The collision coordinator
  39551. */
  39552. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39553. /** @hidden */
  39554. _inputManager: InputManager;
  39555. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39556. cameraToUseForPointers: Nullable<Camera>;
  39557. /** @hidden */
  39558. readonly _isScene: boolean;
  39559. /** @hidden */
  39560. _blockEntityCollection: boolean;
  39561. /**
  39562. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39563. */
  39564. autoClear: boolean;
  39565. /**
  39566. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39567. */
  39568. autoClearDepthAndStencil: boolean;
  39569. /**
  39570. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39571. */
  39572. clearColor: Color4;
  39573. /**
  39574. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39575. */
  39576. ambientColor: Color3;
  39577. /**
  39578. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39579. * It should only be one of the following (if not the default embedded one):
  39580. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39581. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39582. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39583. * The material properties need to be setup according to the type of texture in use.
  39584. */
  39585. environmentBRDFTexture: BaseTexture;
  39586. /** @hidden */
  39587. protected _environmentTexture: Nullable<BaseTexture>;
  39588. /**
  39589. * Texture used in all pbr material as the reflection texture.
  39590. * As in the majority of the scene they are the same (exception for multi room and so on),
  39591. * this is easier to reference from here than from all the materials.
  39592. */
  39593. get environmentTexture(): Nullable<BaseTexture>;
  39594. /**
  39595. * Texture used in all pbr material as the reflection texture.
  39596. * As in the majority of the scene they are the same (exception for multi room and so on),
  39597. * this is easier to set here than in all the materials.
  39598. */
  39599. set environmentTexture(value: Nullable<BaseTexture>);
  39600. /** @hidden */
  39601. protected _environmentIntensity: number;
  39602. /**
  39603. * Intensity of the environment in all pbr material.
  39604. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39605. * As in the majority of the scene they are the same (exception for multi room and so on),
  39606. * this is easier to reference from here than from all the materials.
  39607. */
  39608. get environmentIntensity(): number;
  39609. /**
  39610. * Intensity of the environment in all pbr material.
  39611. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39612. * As in the majority of the scene they are the same (exception for multi room and so on),
  39613. * this is easier to set here than in all the materials.
  39614. */
  39615. set environmentIntensity(value: number);
  39616. /** @hidden */
  39617. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39618. /**
  39619. * Default image processing configuration used either in the rendering
  39620. * Forward main pass or through the imageProcessingPostProcess if present.
  39621. * As in the majority of the scene they are the same (exception for multi camera),
  39622. * this is easier to reference from here than from all the materials and post process.
  39623. *
  39624. * No setter as we it is a shared configuration, you can set the values instead.
  39625. */
  39626. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39627. private _forceWireframe;
  39628. /**
  39629. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39630. */
  39631. set forceWireframe(value: boolean);
  39632. get forceWireframe(): boolean;
  39633. private _skipFrustumClipping;
  39634. /**
  39635. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39636. */
  39637. set skipFrustumClipping(value: boolean);
  39638. get skipFrustumClipping(): boolean;
  39639. private _forcePointsCloud;
  39640. /**
  39641. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39642. */
  39643. set forcePointsCloud(value: boolean);
  39644. get forcePointsCloud(): boolean;
  39645. /**
  39646. * Gets or sets the active clipplane 1
  39647. */
  39648. clipPlane: Nullable<Plane>;
  39649. /**
  39650. * Gets or sets the active clipplane 2
  39651. */
  39652. clipPlane2: Nullable<Plane>;
  39653. /**
  39654. * Gets or sets the active clipplane 3
  39655. */
  39656. clipPlane3: Nullable<Plane>;
  39657. /**
  39658. * Gets or sets the active clipplane 4
  39659. */
  39660. clipPlane4: Nullable<Plane>;
  39661. /**
  39662. * Gets or sets the active clipplane 5
  39663. */
  39664. clipPlane5: Nullable<Plane>;
  39665. /**
  39666. * Gets or sets the active clipplane 6
  39667. */
  39668. clipPlane6: Nullable<Plane>;
  39669. /**
  39670. * Gets or sets a boolean indicating if animations are enabled
  39671. */
  39672. animationsEnabled: boolean;
  39673. private _animationPropertiesOverride;
  39674. /**
  39675. * Gets or sets the animation properties override
  39676. */
  39677. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39678. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39679. /**
  39680. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39681. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39682. */
  39683. useConstantAnimationDeltaTime: boolean;
  39684. /**
  39685. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39686. * Please note that it requires to run a ray cast through the scene on every frame
  39687. */
  39688. constantlyUpdateMeshUnderPointer: boolean;
  39689. /**
  39690. * Defines the HTML cursor to use when hovering over interactive elements
  39691. */
  39692. hoverCursor: string;
  39693. /**
  39694. * Defines the HTML default cursor to use (empty by default)
  39695. */
  39696. defaultCursor: string;
  39697. /**
  39698. * Defines whether cursors are handled by the scene.
  39699. */
  39700. doNotHandleCursors: boolean;
  39701. /**
  39702. * This is used to call preventDefault() on pointer down
  39703. * in order to block unwanted artifacts like system double clicks
  39704. */
  39705. preventDefaultOnPointerDown: boolean;
  39706. /**
  39707. * This is used to call preventDefault() on pointer up
  39708. * in order to block unwanted artifacts like system double clicks
  39709. */
  39710. preventDefaultOnPointerUp: boolean;
  39711. /**
  39712. * Gets or sets user defined metadata
  39713. */
  39714. metadata: any;
  39715. /**
  39716. * For internal use only. Please do not use.
  39717. */
  39718. reservedDataStore: any;
  39719. /**
  39720. * Gets the name of the plugin used to load this scene (null by default)
  39721. */
  39722. loadingPluginName: string;
  39723. /**
  39724. * Use this array to add regular expressions used to disable offline support for specific urls
  39725. */
  39726. disableOfflineSupportExceptionRules: RegExp[];
  39727. /**
  39728. * An event triggered when the scene is disposed.
  39729. */
  39730. onDisposeObservable: Observable<Scene>;
  39731. private _onDisposeObserver;
  39732. /** Sets a function to be executed when this scene is disposed. */
  39733. set onDispose(callback: () => void);
  39734. /**
  39735. * An event triggered before rendering the scene (right after animations and physics)
  39736. */
  39737. onBeforeRenderObservable: Observable<Scene>;
  39738. private _onBeforeRenderObserver;
  39739. /** Sets a function to be executed before rendering this scene */
  39740. set beforeRender(callback: Nullable<() => void>);
  39741. /**
  39742. * An event triggered after rendering the scene
  39743. */
  39744. onAfterRenderObservable: Observable<Scene>;
  39745. /**
  39746. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39747. */
  39748. onAfterRenderCameraObservable: Observable<Camera>;
  39749. private _onAfterRenderObserver;
  39750. /** Sets a function to be executed after rendering this scene */
  39751. set afterRender(callback: Nullable<() => void>);
  39752. /**
  39753. * An event triggered before animating the scene
  39754. */
  39755. onBeforeAnimationsObservable: Observable<Scene>;
  39756. /**
  39757. * An event triggered after animations processing
  39758. */
  39759. onAfterAnimationsObservable: Observable<Scene>;
  39760. /**
  39761. * An event triggered before draw calls are ready to be sent
  39762. */
  39763. onBeforeDrawPhaseObservable: Observable<Scene>;
  39764. /**
  39765. * An event triggered after draw calls have been sent
  39766. */
  39767. onAfterDrawPhaseObservable: Observable<Scene>;
  39768. /**
  39769. * An event triggered when the scene is ready
  39770. */
  39771. onReadyObservable: Observable<Scene>;
  39772. /**
  39773. * An event triggered before rendering a camera
  39774. */
  39775. onBeforeCameraRenderObservable: Observable<Camera>;
  39776. private _onBeforeCameraRenderObserver;
  39777. /** Sets a function to be executed before rendering a camera*/
  39778. set beforeCameraRender(callback: () => void);
  39779. /**
  39780. * An event triggered after rendering a camera
  39781. */
  39782. onAfterCameraRenderObservable: Observable<Camera>;
  39783. private _onAfterCameraRenderObserver;
  39784. /** Sets a function to be executed after rendering a camera*/
  39785. set afterCameraRender(callback: () => void);
  39786. /**
  39787. * An event triggered when active meshes evaluation is about to start
  39788. */
  39789. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39790. /**
  39791. * An event triggered when active meshes evaluation is done
  39792. */
  39793. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39794. /**
  39795. * An event triggered when particles rendering is about to start
  39796. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39797. */
  39798. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39799. /**
  39800. * An event triggered when particles rendering is done
  39801. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39802. */
  39803. onAfterParticlesRenderingObservable: Observable<Scene>;
  39804. /**
  39805. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39806. */
  39807. onDataLoadedObservable: Observable<Scene>;
  39808. /**
  39809. * An event triggered when a camera is created
  39810. */
  39811. onNewCameraAddedObservable: Observable<Camera>;
  39812. /**
  39813. * An event triggered when a camera is removed
  39814. */
  39815. onCameraRemovedObservable: Observable<Camera>;
  39816. /**
  39817. * An event triggered when a light is created
  39818. */
  39819. onNewLightAddedObservable: Observable<Light>;
  39820. /**
  39821. * An event triggered when a light is removed
  39822. */
  39823. onLightRemovedObservable: Observable<Light>;
  39824. /**
  39825. * An event triggered when a geometry is created
  39826. */
  39827. onNewGeometryAddedObservable: Observable<Geometry>;
  39828. /**
  39829. * An event triggered when a geometry is removed
  39830. */
  39831. onGeometryRemovedObservable: Observable<Geometry>;
  39832. /**
  39833. * An event triggered when a transform node is created
  39834. */
  39835. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39836. /**
  39837. * An event triggered when a transform node is removed
  39838. */
  39839. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39840. /**
  39841. * An event triggered when a mesh is created
  39842. */
  39843. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39844. /**
  39845. * An event triggered when a mesh is removed
  39846. */
  39847. onMeshRemovedObservable: Observable<AbstractMesh>;
  39848. /**
  39849. * An event triggered when a skeleton is created
  39850. */
  39851. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39852. /**
  39853. * An event triggered when a skeleton is removed
  39854. */
  39855. onSkeletonRemovedObservable: Observable<Skeleton>;
  39856. /**
  39857. * An event triggered when a material is created
  39858. */
  39859. onNewMaterialAddedObservable: Observable<Material>;
  39860. /**
  39861. * An event triggered when a material is removed
  39862. */
  39863. onMaterialRemovedObservable: Observable<Material>;
  39864. /**
  39865. * An event triggered when a texture is created
  39866. */
  39867. onNewTextureAddedObservable: Observable<BaseTexture>;
  39868. /**
  39869. * An event triggered when a texture is removed
  39870. */
  39871. onTextureRemovedObservable: Observable<BaseTexture>;
  39872. /**
  39873. * An event triggered when render targets are about to be rendered
  39874. * Can happen multiple times per frame.
  39875. */
  39876. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39877. /**
  39878. * An event triggered when render targets were rendered.
  39879. * Can happen multiple times per frame.
  39880. */
  39881. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39882. /**
  39883. * An event triggered before calculating deterministic simulation step
  39884. */
  39885. onBeforeStepObservable: Observable<Scene>;
  39886. /**
  39887. * An event triggered after calculating deterministic simulation step
  39888. */
  39889. onAfterStepObservable: Observable<Scene>;
  39890. /**
  39891. * An event triggered when the activeCamera property is updated
  39892. */
  39893. onActiveCameraChanged: Observable<Scene>;
  39894. /**
  39895. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39896. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39897. * 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)
  39898. */
  39899. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39900. /**
  39901. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39902. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39903. * 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)
  39904. */
  39905. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39906. /**
  39907. * This Observable will when a mesh has been imported into the scene.
  39908. */
  39909. onMeshImportedObservable: Observable<AbstractMesh>;
  39910. /**
  39911. * This Observable will when an animation file has been imported into the scene.
  39912. */
  39913. onAnimationFileImportedObservable: Observable<Scene>;
  39914. /**
  39915. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39916. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39917. */
  39918. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39919. /** @hidden */
  39920. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39921. /**
  39922. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39923. */
  39924. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39925. /**
  39926. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39927. */
  39928. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39929. /**
  39930. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39931. */
  39932. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39933. /** Callback called when a pointer move is detected */
  39934. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39935. /** Callback called when a pointer down is detected */
  39936. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39937. /** Callback called when a pointer up is detected */
  39938. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39939. /** Callback called when a pointer pick is detected */
  39940. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39941. /**
  39942. * 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).
  39943. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39944. */
  39945. onPrePointerObservable: Observable<PointerInfoPre>;
  39946. /**
  39947. * Observable event triggered each time an input event is received from the rendering canvas
  39948. */
  39949. onPointerObservable: Observable<PointerInfo>;
  39950. /**
  39951. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39952. */
  39953. get unTranslatedPointer(): Vector2;
  39954. /**
  39955. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39956. */
  39957. static get DragMovementThreshold(): number;
  39958. static set DragMovementThreshold(value: number);
  39959. /**
  39960. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39961. */
  39962. static get LongPressDelay(): number;
  39963. static set LongPressDelay(value: number);
  39964. /**
  39965. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39966. */
  39967. static get DoubleClickDelay(): number;
  39968. static set DoubleClickDelay(value: number);
  39969. /** If you need to check double click without raising a single click at first click, enable this flag */
  39970. static get ExclusiveDoubleClickMode(): boolean;
  39971. static set ExclusiveDoubleClickMode(value: boolean);
  39972. /** @hidden */
  39973. _mirroredCameraPosition: Nullable<Vector3>;
  39974. /**
  39975. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39976. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39977. */
  39978. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39979. /**
  39980. * Observable event triggered each time an keyboard event is received from the hosting window
  39981. */
  39982. onKeyboardObservable: Observable<KeyboardInfo>;
  39983. private _useRightHandedSystem;
  39984. /**
  39985. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39986. */
  39987. set useRightHandedSystem(value: boolean);
  39988. get useRightHandedSystem(): boolean;
  39989. private _timeAccumulator;
  39990. private _currentStepId;
  39991. private _currentInternalStep;
  39992. /**
  39993. * Sets the step Id used by deterministic lock step
  39994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39995. * @param newStepId defines the step Id
  39996. */
  39997. setStepId(newStepId: number): void;
  39998. /**
  39999. * Gets the step Id used by deterministic lock step
  40000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40001. * @returns the step Id
  40002. */
  40003. getStepId(): number;
  40004. /**
  40005. * Gets the internal step used by deterministic lock step
  40006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40007. * @returns the internal step
  40008. */
  40009. getInternalStep(): number;
  40010. private _fogEnabled;
  40011. /**
  40012. * Gets or sets a boolean indicating if fog is enabled on this scene
  40013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40014. * (Default is true)
  40015. */
  40016. set fogEnabled(value: boolean);
  40017. get fogEnabled(): boolean;
  40018. private _fogMode;
  40019. /**
  40020. * Gets or sets the fog mode to use
  40021. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40022. * | mode | value |
  40023. * | --- | --- |
  40024. * | FOGMODE_NONE | 0 |
  40025. * | FOGMODE_EXP | 1 |
  40026. * | FOGMODE_EXP2 | 2 |
  40027. * | FOGMODE_LINEAR | 3 |
  40028. */
  40029. set fogMode(value: number);
  40030. get fogMode(): number;
  40031. /**
  40032. * Gets or sets the fog color to use
  40033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40034. * (Default is Color3(0.2, 0.2, 0.3))
  40035. */
  40036. fogColor: Color3;
  40037. /**
  40038. * Gets or sets the fog density to use
  40039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40040. * (Default is 0.1)
  40041. */
  40042. fogDensity: number;
  40043. /**
  40044. * Gets or sets the fog start distance to use
  40045. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40046. * (Default is 0)
  40047. */
  40048. fogStart: number;
  40049. /**
  40050. * Gets or sets the fog end distance to use
  40051. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40052. * (Default is 1000)
  40053. */
  40054. fogEnd: number;
  40055. private _shadowsEnabled;
  40056. /**
  40057. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40058. */
  40059. set shadowsEnabled(value: boolean);
  40060. get shadowsEnabled(): boolean;
  40061. private _lightsEnabled;
  40062. /**
  40063. * Gets or sets a boolean indicating if lights are enabled on this scene
  40064. */
  40065. set lightsEnabled(value: boolean);
  40066. get lightsEnabled(): boolean;
  40067. /** All of the active cameras added to this scene. */
  40068. activeCameras: Camera[];
  40069. /** @hidden */
  40070. _activeCamera: Nullable<Camera>;
  40071. /** Gets or sets the current active camera */
  40072. get activeCamera(): Nullable<Camera>;
  40073. set activeCamera(value: Nullable<Camera>);
  40074. private _defaultMaterial;
  40075. /** The default material used on meshes when no material is affected */
  40076. get defaultMaterial(): Material;
  40077. /** The default material used on meshes when no material is affected */
  40078. set defaultMaterial(value: Material);
  40079. private _texturesEnabled;
  40080. /**
  40081. * Gets or sets a boolean indicating if textures are enabled on this scene
  40082. */
  40083. set texturesEnabled(value: boolean);
  40084. get texturesEnabled(): boolean;
  40085. /**
  40086. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40087. */
  40088. physicsEnabled: boolean;
  40089. /**
  40090. * Gets or sets a boolean indicating if particles are enabled on this scene
  40091. */
  40092. particlesEnabled: boolean;
  40093. /**
  40094. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40095. */
  40096. spritesEnabled: boolean;
  40097. private _skeletonsEnabled;
  40098. /**
  40099. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40100. */
  40101. set skeletonsEnabled(value: boolean);
  40102. get skeletonsEnabled(): boolean;
  40103. /**
  40104. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40105. */
  40106. lensFlaresEnabled: boolean;
  40107. /**
  40108. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40109. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40110. */
  40111. collisionsEnabled: boolean;
  40112. private _collisionCoordinator;
  40113. /** @hidden */
  40114. get collisionCoordinator(): ICollisionCoordinator;
  40115. /**
  40116. * Defines the gravity applied to this scene (used only for collisions)
  40117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40118. */
  40119. gravity: Vector3;
  40120. /**
  40121. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40122. */
  40123. postProcessesEnabled: boolean;
  40124. /**
  40125. * The list of postprocesses added to the scene
  40126. */
  40127. postProcesses: PostProcess[];
  40128. /**
  40129. * Gets the current postprocess manager
  40130. */
  40131. postProcessManager: PostProcessManager;
  40132. /**
  40133. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40134. */
  40135. renderTargetsEnabled: boolean;
  40136. /**
  40137. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40138. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40139. */
  40140. dumpNextRenderTargets: boolean;
  40141. /**
  40142. * The list of user defined render targets added to the scene
  40143. */
  40144. customRenderTargets: RenderTargetTexture[];
  40145. /**
  40146. * Defines if texture loading must be delayed
  40147. * If true, textures will only be loaded when they need to be rendered
  40148. */
  40149. useDelayedTextureLoading: boolean;
  40150. /**
  40151. * Gets the list of meshes imported to the scene through SceneLoader
  40152. */
  40153. importedMeshesFiles: String[];
  40154. /**
  40155. * Gets or sets a boolean indicating if probes are enabled on this scene
  40156. */
  40157. probesEnabled: boolean;
  40158. /**
  40159. * Gets or sets the current offline provider to use to store scene data
  40160. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40161. */
  40162. offlineProvider: IOfflineProvider;
  40163. /**
  40164. * Gets or sets the action manager associated with the scene
  40165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40166. */
  40167. actionManager: AbstractActionManager;
  40168. private _meshesForIntersections;
  40169. /**
  40170. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40171. */
  40172. proceduralTexturesEnabled: boolean;
  40173. private _engine;
  40174. private _totalVertices;
  40175. /** @hidden */
  40176. _activeIndices: PerfCounter;
  40177. /** @hidden */
  40178. _activeParticles: PerfCounter;
  40179. /** @hidden */
  40180. _activeBones: PerfCounter;
  40181. private _animationRatio;
  40182. /** @hidden */
  40183. _animationTimeLast: number;
  40184. /** @hidden */
  40185. _animationTime: number;
  40186. /**
  40187. * Gets or sets a general scale for animation speed
  40188. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40189. */
  40190. animationTimeScale: number;
  40191. /** @hidden */
  40192. _cachedMaterial: Nullable<Material>;
  40193. /** @hidden */
  40194. _cachedEffect: Nullable<Effect>;
  40195. /** @hidden */
  40196. _cachedVisibility: Nullable<number>;
  40197. private _renderId;
  40198. private _frameId;
  40199. private _executeWhenReadyTimeoutId;
  40200. private _intermediateRendering;
  40201. private _viewUpdateFlag;
  40202. private _projectionUpdateFlag;
  40203. /** @hidden */
  40204. _toBeDisposed: Nullable<IDisposable>[];
  40205. private _activeRequests;
  40206. /** @hidden */
  40207. _pendingData: any[];
  40208. private _isDisposed;
  40209. /**
  40210. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40211. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40212. */
  40213. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40214. private _activeMeshes;
  40215. private _processedMaterials;
  40216. private _renderTargets;
  40217. /** @hidden */
  40218. _activeParticleSystems: SmartArray<IParticleSystem>;
  40219. private _activeSkeletons;
  40220. private _softwareSkinnedMeshes;
  40221. private _renderingManager;
  40222. /** @hidden */
  40223. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40224. private _transformMatrix;
  40225. private _sceneUbo;
  40226. /** @hidden */
  40227. _viewMatrix: Matrix;
  40228. private _projectionMatrix;
  40229. /** @hidden */
  40230. _forcedViewPosition: Nullable<Vector3>;
  40231. /** @hidden */
  40232. _frustumPlanes: Plane[];
  40233. /**
  40234. * Gets the list of frustum planes (built from the active camera)
  40235. */
  40236. get frustumPlanes(): Plane[];
  40237. /**
  40238. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40239. * This is useful if there are more lights that the maximum simulteanous authorized
  40240. */
  40241. requireLightSorting: boolean;
  40242. /** @hidden */
  40243. readonly useMaterialMeshMap: boolean;
  40244. /** @hidden */
  40245. readonly useClonedMeshMap: boolean;
  40246. private _externalData;
  40247. private _uid;
  40248. /**
  40249. * @hidden
  40250. * Backing store of defined scene components.
  40251. */
  40252. _components: ISceneComponent[];
  40253. /**
  40254. * @hidden
  40255. * Backing store of defined scene components.
  40256. */
  40257. _serializableComponents: ISceneSerializableComponent[];
  40258. /**
  40259. * List of components to register on the next registration step.
  40260. */
  40261. private _transientComponents;
  40262. /**
  40263. * Registers the transient components if needed.
  40264. */
  40265. private _registerTransientComponents;
  40266. /**
  40267. * @hidden
  40268. * Add a component to the scene.
  40269. * Note that the ccomponent could be registered on th next frame if this is called after
  40270. * the register component stage.
  40271. * @param component Defines the component to add to the scene
  40272. */
  40273. _addComponent(component: ISceneComponent): void;
  40274. /**
  40275. * @hidden
  40276. * Gets a component from the scene.
  40277. * @param name defines the name of the component to retrieve
  40278. * @returns the component or null if not present
  40279. */
  40280. _getComponent(name: string): Nullable<ISceneComponent>;
  40281. /**
  40282. * @hidden
  40283. * Defines the actions happening before camera updates.
  40284. */
  40285. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40286. /**
  40287. * @hidden
  40288. * Defines the actions happening before clear the canvas.
  40289. */
  40290. _beforeClearStage: Stage<SimpleStageAction>;
  40291. /**
  40292. * @hidden
  40293. * Defines the actions when collecting render targets for the frame.
  40294. */
  40295. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40296. /**
  40297. * @hidden
  40298. * Defines the actions happening for one camera in the frame.
  40299. */
  40300. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40301. /**
  40302. * @hidden
  40303. * Defines the actions happening during the per mesh ready checks.
  40304. */
  40305. _isReadyForMeshStage: Stage<MeshStageAction>;
  40306. /**
  40307. * @hidden
  40308. * Defines the actions happening before evaluate active mesh checks.
  40309. */
  40310. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40311. /**
  40312. * @hidden
  40313. * Defines the actions happening during the evaluate sub mesh checks.
  40314. */
  40315. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40316. /**
  40317. * @hidden
  40318. * Defines the actions happening during the active mesh stage.
  40319. */
  40320. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40321. /**
  40322. * @hidden
  40323. * Defines the actions happening during the per camera render target step.
  40324. */
  40325. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40326. /**
  40327. * @hidden
  40328. * Defines the actions happening just before the active camera is drawing.
  40329. */
  40330. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40331. /**
  40332. * @hidden
  40333. * Defines the actions happening just before a render target is drawing.
  40334. */
  40335. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40336. /**
  40337. * @hidden
  40338. * Defines the actions happening just before a rendering group is drawing.
  40339. */
  40340. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40341. /**
  40342. * @hidden
  40343. * Defines the actions happening just before a mesh is drawing.
  40344. */
  40345. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40346. /**
  40347. * @hidden
  40348. * Defines the actions happening just after a mesh has been drawn.
  40349. */
  40350. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40351. /**
  40352. * @hidden
  40353. * Defines the actions happening just after a rendering group has been drawn.
  40354. */
  40355. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40356. /**
  40357. * @hidden
  40358. * Defines the actions happening just after the active camera has been drawn.
  40359. */
  40360. _afterCameraDrawStage: Stage<CameraStageAction>;
  40361. /**
  40362. * @hidden
  40363. * Defines the actions happening just after a render target has been drawn.
  40364. */
  40365. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40366. /**
  40367. * @hidden
  40368. * Defines the actions happening just after rendering all cameras and computing intersections.
  40369. */
  40370. _afterRenderStage: Stage<SimpleStageAction>;
  40371. /**
  40372. * @hidden
  40373. * Defines the actions happening when a pointer move event happens.
  40374. */
  40375. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40376. /**
  40377. * @hidden
  40378. * Defines the actions happening when a pointer down event happens.
  40379. */
  40380. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40381. /**
  40382. * @hidden
  40383. * Defines the actions happening when a pointer up event happens.
  40384. */
  40385. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40386. /**
  40387. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40388. */
  40389. private geometriesByUniqueId;
  40390. /**
  40391. * Creates a new Scene
  40392. * @param engine defines the engine to use to render this scene
  40393. * @param options defines the scene options
  40394. */
  40395. constructor(engine: Engine, options?: SceneOptions);
  40396. /**
  40397. * Gets a string idenfifying the name of the class
  40398. * @returns "Scene" string
  40399. */
  40400. getClassName(): string;
  40401. private _defaultMeshCandidates;
  40402. /**
  40403. * @hidden
  40404. */
  40405. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40406. private _defaultSubMeshCandidates;
  40407. /**
  40408. * @hidden
  40409. */
  40410. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40411. /**
  40412. * Sets the default candidate providers for the scene.
  40413. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40414. * and getCollidingSubMeshCandidates to their default function
  40415. */
  40416. setDefaultCandidateProviders(): void;
  40417. /**
  40418. * Gets the mesh that is currently under the pointer
  40419. */
  40420. get meshUnderPointer(): Nullable<AbstractMesh>;
  40421. /**
  40422. * Gets or sets the current on-screen X position of the pointer
  40423. */
  40424. get pointerX(): number;
  40425. set pointerX(value: number);
  40426. /**
  40427. * Gets or sets the current on-screen Y position of the pointer
  40428. */
  40429. get pointerY(): number;
  40430. set pointerY(value: number);
  40431. /**
  40432. * Gets the cached material (ie. the latest rendered one)
  40433. * @returns the cached material
  40434. */
  40435. getCachedMaterial(): Nullable<Material>;
  40436. /**
  40437. * Gets the cached effect (ie. the latest rendered one)
  40438. * @returns the cached effect
  40439. */
  40440. getCachedEffect(): Nullable<Effect>;
  40441. /**
  40442. * Gets the cached visibility state (ie. the latest rendered one)
  40443. * @returns the cached visibility state
  40444. */
  40445. getCachedVisibility(): Nullable<number>;
  40446. /**
  40447. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40448. * @param material defines the current material
  40449. * @param effect defines the current effect
  40450. * @param visibility defines the current visibility state
  40451. * @returns true if one parameter is not cached
  40452. */
  40453. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40454. /**
  40455. * Gets the engine associated with the scene
  40456. * @returns an Engine
  40457. */
  40458. getEngine(): Engine;
  40459. /**
  40460. * Gets the total number of vertices rendered per frame
  40461. * @returns the total number of vertices rendered per frame
  40462. */
  40463. getTotalVertices(): number;
  40464. /**
  40465. * Gets the performance counter for total vertices
  40466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40467. */
  40468. get totalVerticesPerfCounter(): PerfCounter;
  40469. /**
  40470. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40471. * @returns the total number of active indices rendered per frame
  40472. */
  40473. getActiveIndices(): number;
  40474. /**
  40475. * Gets the performance counter for active indices
  40476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40477. */
  40478. get totalActiveIndicesPerfCounter(): PerfCounter;
  40479. /**
  40480. * Gets the total number of active particles rendered per frame
  40481. * @returns the total number of active particles rendered per frame
  40482. */
  40483. getActiveParticles(): number;
  40484. /**
  40485. * Gets the performance counter for active particles
  40486. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40487. */
  40488. get activeParticlesPerfCounter(): PerfCounter;
  40489. /**
  40490. * Gets the total number of active bones rendered per frame
  40491. * @returns the total number of active bones rendered per frame
  40492. */
  40493. getActiveBones(): number;
  40494. /**
  40495. * Gets the performance counter for active bones
  40496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40497. */
  40498. get activeBonesPerfCounter(): PerfCounter;
  40499. /**
  40500. * Gets the array of active meshes
  40501. * @returns an array of AbstractMesh
  40502. */
  40503. getActiveMeshes(): SmartArray<AbstractMesh>;
  40504. /**
  40505. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40506. * @returns a number
  40507. */
  40508. getAnimationRatio(): number;
  40509. /**
  40510. * Gets an unique Id for the current render phase
  40511. * @returns a number
  40512. */
  40513. getRenderId(): number;
  40514. /**
  40515. * Gets an unique Id for the current frame
  40516. * @returns a number
  40517. */
  40518. getFrameId(): number;
  40519. /** Call this function if you want to manually increment the render Id*/
  40520. incrementRenderId(): void;
  40521. private _createUbo;
  40522. /**
  40523. * Use this method to simulate a pointer move on a mesh
  40524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40527. * @returns the current scene
  40528. */
  40529. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40530. /**
  40531. * Use this method to simulate a pointer down on a mesh
  40532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40535. * @returns the current scene
  40536. */
  40537. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40538. /**
  40539. * Use this method to simulate a pointer up on a mesh
  40540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40543. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40544. * @returns the current scene
  40545. */
  40546. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40547. /**
  40548. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40549. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40550. * @returns true if the pointer was captured
  40551. */
  40552. isPointerCaptured(pointerId?: number): boolean;
  40553. /**
  40554. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40555. * @param attachUp defines if you want to attach events to pointerup
  40556. * @param attachDown defines if you want to attach events to pointerdown
  40557. * @param attachMove defines if you want to attach events to pointermove
  40558. */
  40559. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40560. /** Detaches all event handlers*/
  40561. detachControl(): void;
  40562. /**
  40563. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40564. * Delay loaded resources are not taking in account
  40565. * @return true if all required resources are ready
  40566. */
  40567. isReady(): boolean;
  40568. /** Resets all cached information relative to material (including effect and visibility) */
  40569. resetCachedMaterial(): void;
  40570. /**
  40571. * Registers a function to be called before every frame render
  40572. * @param func defines the function to register
  40573. */
  40574. registerBeforeRender(func: () => void): void;
  40575. /**
  40576. * Unregisters a function called before every frame render
  40577. * @param func defines the function to unregister
  40578. */
  40579. unregisterBeforeRender(func: () => void): void;
  40580. /**
  40581. * Registers a function to be called after every frame render
  40582. * @param func defines the function to register
  40583. */
  40584. registerAfterRender(func: () => void): void;
  40585. /**
  40586. * Unregisters a function called after every frame render
  40587. * @param func defines the function to unregister
  40588. */
  40589. unregisterAfterRender(func: () => void): void;
  40590. private _executeOnceBeforeRender;
  40591. /**
  40592. * The provided function will run before render once and will be disposed afterwards.
  40593. * A timeout delay can be provided so that the function will be executed in N ms.
  40594. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40595. * @param func The function to be executed.
  40596. * @param timeout optional delay in ms
  40597. */
  40598. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40599. /** @hidden */
  40600. _addPendingData(data: any): void;
  40601. /** @hidden */
  40602. _removePendingData(data: any): void;
  40603. /**
  40604. * Returns the number of items waiting to be loaded
  40605. * @returns the number of items waiting to be loaded
  40606. */
  40607. getWaitingItemsCount(): number;
  40608. /**
  40609. * Returns a boolean indicating if the scene is still loading data
  40610. */
  40611. get isLoading(): boolean;
  40612. /**
  40613. * Registers a function to be executed when the scene is ready
  40614. * @param {Function} func - the function to be executed
  40615. */
  40616. executeWhenReady(func: () => void): void;
  40617. /**
  40618. * Returns a promise that resolves when the scene is ready
  40619. * @returns A promise that resolves when the scene is ready
  40620. */
  40621. whenReadyAsync(): Promise<void>;
  40622. /** @hidden */
  40623. _checkIsReady(): void;
  40624. /**
  40625. * Gets all animatable attached to the scene
  40626. */
  40627. get animatables(): Animatable[];
  40628. /**
  40629. * Resets the last animation time frame.
  40630. * Useful to override when animations start running when loading a scene for the first time.
  40631. */
  40632. resetLastAnimationTimeFrame(): void;
  40633. /**
  40634. * Gets the current view matrix
  40635. * @returns a Matrix
  40636. */
  40637. getViewMatrix(): Matrix;
  40638. /**
  40639. * Gets the current projection matrix
  40640. * @returns a Matrix
  40641. */
  40642. getProjectionMatrix(): Matrix;
  40643. /**
  40644. * Gets the current transform matrix
  40645. * @returns a Matrix made of View * Projection
  40646. */
  40647. getTransformMatrix(): Matrix;
  40648. /**
  40649. * Sets the current transform matrix
  40650. * @param viewL defines the View matrix to use
  40651. * @param projectionL defines the Projection matrix to use
  40652. * @param viewR defines the right View matrix to use (if provided)
  40653. * @param projectionR defines the right Projection matrix to use (if provided)
  40654. */
  40655. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40656. /**
  40657. * Gets the uniform buffer used to store scene data
  40658. * @returns a UniformBuffer
  40659. */
  40660. getSceneUniformBuffer(): UniformBuffer;
  40661. /**
  40662. * Gets an unique (relatively to the current scene) Id
  40663. * @returns an unique number for the scene
  40664. */
  40665. getUniqueId(): number;
  40666. /**
  40667. * Add a mesh to the list of scene's meshes
  40668. * @param newMesh defines the mesh to add
  40669. * @param recursive if all child meshes should also be added to the scene
  40670. */
  40671. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40672. /**
  40673. * Remove a mesh for the list of scene's meshes
  40674. * @param toRemove defines the mesh to remove
  40675. * @param recursive if all child meshes should also be removed from the scene
  40676. * @returns the index where the mesh was in the mesh list
  40677. */
  40678. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40679. /**
  40680. * Add a transform node to the list of scene's transform nodes
  40681. * @param newTransformNode defines the transform node to add
  40682. */
  40683. addTransformNode(newTransformNode: TransformNode): void;
  40684. /**
  40685. * Remove a transform node for the list of scene's transform nodes
  40686. * @param toRemove defines the transform node to remove
  40687. * @returns the index where the transform node was in the transform node list
  40688. */
  40689. removeTransformNode(toRemove: TransformNode): number;
  40690. /**
  40691. * Remove a skeleton for the list of scene's skeletons
  40692. * @param toRemove defines the skeleton to remove
  40693. * @returns the index where the skeleton was in the skeleton list
  40694. */
  40695. removeSkeleton(toRemove: Skeleton): number;
  40696. /**
  40697. * Remove a morph target for the list of scene's morph targets
  40698. * @param toRemove defines the morph target to remove
  40699. * @returns the index where the morph target was in the morph target list
  40700. */
  40701. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40702. /**
  40703. * Remove a light for the list of scene's lights
  40704. * @param toRemove defines the light to remove
  40705. * @returns the index where the light was in the light list
  40706. */
  40707. removeLight(toRemove: Light): number;
  40708. /**
  40709. * Remove a camera for the list of scene's cameras
  40710. * @param toRemove defines the camera to remove
  40711. * @returns the index where the camera was in the camera list
  40712. */
  40713. removeCamera(toRemove: Camera): number;
  40714. /**
  40715. * Remove a particle system for the list of scene's particle systems
  40716. * @param toRemove defines the particle system to remove
  40717. * @returns the index where the particle system was in the particle system list
  40718. */
  40719. removeParticleSystem(toRemove: IParticleSystem): number;
  40720. /**
  40721. * Remove a animation for the list of scene's animations
  40722. * @param toRemove defines the animation to remove
  40723. * @returns the index where the animation was in the animation list
  40724. */
  40725. removeAnimation(toRemove: Animation): number;
  40726. /**
  40727. * Will stop the animation of the given target
  40728. * @param target - the target
  40729. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40730. * @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)
  40731. */
  40732. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40733. /**
  40734. * Removes the given animation group from this scene.
  40735. * @param toRemove The animation group to remove
  40736. * @returns The index of the removed animation group
  40737. */
  40738. removeAnimationGroup(toRemove: AnimationGroup): number;
  40739. /**
  40740. * Removes the given multi-material from this scene.
  40741. * @param toRemove The multi-material to remove
  40742. * @returns The index of the removed multi-material
  40743. */
  40744. removeMultiMaterial(toRemove: MultiMaterial): number;
  40745. /**
  40746. * Removes the given material from this scene.
  40747. * @param toRemove The material to remove
  40748. * @returns The index of the removed material
  40749. */
  40750. removeMaterial(toRemove: Material): number;
  40751. /**
  40752. * Removes the given action manager from this scene.
  40753. * @param toRemove The action manager to remove
  40754. * @returns The index of the removed action manager
  40755. */
  40756. removeActionManager(toRemove: AbstractActionManager): number;
  40757. /**
  40758. * Removes the given texture from this scene.
  40759. * @param toRemove The texture to remove
  40760. * @returns The index of the removed texture
  40761. */
  40762. removeTexture(toRemove: BaseTexture): number;
  40763. /**
  40764. * Adds the given light to this scene
  40765. * @param newLight The light to add
  40766. */
  40767. addLight(newLight: Light): void;
  40768. /**
  40769. * Sorts the list list based on light priorities
  40770. */
  40771. sortLightsByPriority(): void;
  40772. /**
  40773. * Adds the given camera to this scene
  40774. * @param newCamera The camera to add
  40775. */
  40776. addCamera(newCamera: Camera): void;
  40777. /**
  40778. * Adds the given skeleton to this scene
  40779. * @param newSkeleton The skeleton to add
  40780. */
  40781. addSkeleton(newSkeleton: Skeleton): void;
  40782. /**
  40783. * Adds the given particle system to this scene
  40784. * @param newParticleSystem The particle system to add
  40785. */
  40786. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40787. /**
  40788. * Adds the given animation to this scene
  40789. * @param newAnimation The animation to add
  40790. */
  40791. addAnimation(newAnimation: Animation): void;
  40792. /**
  40793. * Adds the given animation group to this scene.
  40794. * @param newAnimationGroup The animation group to add
  40795. */
  40796. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40797. /**
  40798. * Adds the given multi-material to this scene
  40799. * @param newMultiMaterial The multi-material to add
  40800. */
  40801. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40802. /**
  40803. * Adds the given material to this scene
  40804. * @param newMaterial The material to add
  40805. */
  40806. addMaterial(newMaterial: Material): void;
  40807. /**
  40808. * Adds the given morph target to this scene
  40809. * @param newMorphTargetManager The morph target to add
  40810. */
  40811. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40812. /**
  40813. * Adds the given geometry to this scene
  40814. * @param newGeometry The geometry to add
  40815. */
  40816. addGeometry(newGeometry: Geometry): void;
  40817. /**
  40818. * Adds the given action manager to this scene
  40819. * @param newActionManager The action manager to add
  40820. */
  40821. addActionManager(newActionManager: AbstractActionManager): void;
  40822. /**
  40823. * Adds the given texture to this scene.
  40824. * @param newTexture The texture to add
  40825. */
  40826. addTexture(newTexture: BaseTexture): void;
  40827. /**
  40828. * Switch active camera
  40829. * @param newCamera defines the new active camera
  40830. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40831. */
  40832. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40833. /**
  40834. * sets the active camera of the scene using its ID
  40835. * @param id defines the camera's ID
  40836. * @return the new active camera or null if none found.
  40837. */
  40838. setActiveCameraByID(id: string): Nullable<Camera>;
  40839. /**
  40840. * sets the active camera of the scene using its name
  40841. * @param name defines the camera's name
  40842. * @returns the new active camera or null if none found.
  40843. */
  40844. setActiveCameraByName(name: string): Nullable<Camera>;
  40845. /**
  40846. * get an animation group using its name
  40847. * @param name defines the material's name
  40848. * @return the animation group or null if none found.
  40849. */
  40850. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40851. /**
  40852. * Get a material using its unique id
  40853. * @param uniqueId defines the material's unique id
  40854. * @return the material or null if none found.
  40855. */
  40856. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40857. /**
  40858. * get a material using its id
  40859. * @param id defines the material's ID
  40860. * @return the material or null if none found.
  40861. */
  40862. getMaterialByID(id: string): Nullable<Material>;
  40863. /**
  40864. * Gets a the last added material using a given id
  40865. * @param id defines the material's ID
  40866. * @return the last material with the given id or null if none found.
  40867. */
  40868. getLastMaterialByID(id: string): Nullable<Material>;
  40869. /**
  40870. * Gets a material using its name
  40871. * @param name defines the material's name
  40872. * @return the material or null if none found.
  40873. */
  40874. getMaterialByName(name: string): Nullable<Material>;
  40875. /**
  40876. * Get a texture using its unique id
  40877. * @param uniqueId defines the texture's unique id
  40878. * @return the texture or null if none found.
  40879. */
  40880. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40881. /**
  40882. * Gets a camera using its id
  40883. * @param id defines the id to look for
  40884. * @returns the camera or null if not found
  40885. */
  40886. getCameraByID(id: string): Nullable<Camera>;
  40887. /**
  40888. * Gets a camera using its unique id
  40889. * @param uniqueId defines the unique id to look for
  40890. * @returns the camera or null if not found
  40891. */
  40892. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40893. /**
  40894. * Gets a camera using its name
  40895. * @param name defines the camera's name
  40896. * @return the camera or null if none found.
  40897. */
  40898. getCameraByName(name: string): Nullable<Camera>;
  40899. /**
  40900. * Gets a bone using its id
  40901. * @param id defines the bone's id
  40902. * @return the bone or null if not found
  40903. */
  40904. getBoneByID(id: string): Nullable<Bone>;
  40905. /**
  40906. * Gets a bone using its id
  40907. * @param name defines the bone's name
  40908. * @return the bone or null if not found
  40909. */
  40910. getBoneByName(name: string): Nullable<Bone>;
  40911. /**
  40912. * Gets a light node using its name
  40913. * @param name defines the the light's name
  40914. * @return the light or null if none found.
  40915. */
  40916. getLightByName(name: string): Nullable<Light>;
  40917. /**
  40918. * Gets a light node using its id
  40919. * @param id defines the light's id
  40920. * @return the light or null if none found.
  40921. */
  40922. getLightByID(id: string): Nullable<Light>;
  40923. /**
  40924. * Gets a light node using its scene-generated unique ID
  40925. * @param uniqueId defines the light's unique id
  40926. * @return the light or null if none found.
  40927. */
  40928. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40929. /**
  40930. * Gets a particle system by id
  40931. * @param id defines the particle system id
  40932. * @return the corresponding system or null if none found
  40933. */
  40934. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40935. /**
  40936. * Gets a geometry using its ID
  40937. * @param id defines the geometry's id
  40938. * @return the geometry or null if none found.
  40939. */
  40940. getGeometryByID(id: string): Nullable<Geometry>;
  40941. private _getGeometryByUniqueID;
  40942. /**
  40943. * Add a new geometry to this scene
  40944. * @param geometry defines the geometry to be added to the scene.
  40945. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40946. * @return a boolean defining if the geometry was added or not
  40947. */
  40948. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40949. /**
  40950. * Removes an existing geometry
  40951. * @param geometry defines the geometry to be removed from the scene
  40952. * @return a boolean defining if the geometry was removed or not
  40953. */
  40954. removeGeometry(geometry: Geometry): boolean;
  40955. /**
  40956. * Gets the list of geometries attached to the scene
  40957. * @returns an array of Geometry
  40958. */
  40959. getGeometries(): Geometry[];
  40960. /**
  40961. * Gets the first added mesh found of a given ID
  40962. * @param id defines the id to search for
  40963. * @return the mesh found or null if not found at all
  40964. */
  40965. getMeshByID(id: string): Nullable<AbstractMesh>;
  40966. /**
  40967. * Gets a list of meshes using their id
  40968. * @param id defines the id to search for
  40969. * @returns a list of meshes
  40970. */
  40971. getMeshesByID(id: string): Array<AbstractMesh>;
  40972. /**
  40973. * Gets the first added transform node found of a given ID
  40974. * @param id defines the id to search for
  40975. * @return the found transform node or null if not found at all.
  40976. */
  40977. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40978. /**
  40979. * Gets a transform node with its auto-generated unique id
  40980. * @param uniqueId efines the unique id to search for
  40981. * @return the found transform node or null if not found at all.
  40982. */
  40983. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40984. /**
  40985. * Gets a list of transform nodes using their id
  40986. * @param id defines the id to search for
  40987. * @returns a list of transform nodes
  40988. */
  40989. getTransformNodesByID(id: string): Array<TransformNode>;
  40990. /**
  40991. * Gets a mesh with its auto-generated unique id
  40992. * @param uniqueId defines the unique id to search for
  40993. * @return the found mesh or null if not found at all.
  40994. */
  40995. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40996. /**
  40997. * Gets a the last added mesh using a given id
  40998. * @param id defines the id to search for
  40999. * @return the found mesh or null if not found at all.
  41000. */
  41001. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41002. /**
  41003. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41004. * @param id defines the id to search for
  41005. * @return the found node or null if not found at all
  41006. */
  41007. getLastEntryByID(id: string): Nullable<Node>;
  41008. /**
  41009. * Gets a node (Mesh, Camera, Light) using a given id
  41010. * @param id defines the id to search for
  41011. * @return the found node or null if not found at all
  41012. */
  41013. getNodeByID(id: string): Nullable<Node>;
  41014. /**
  41015. * Gets a node (Mesh, Camera, Light) using a given name
  41016. * @param name defines the name to search for
  41017. * @return the found node or null if not found at all.
  41018. */
  41019. getNodeByName(name: string): Nullable<Node>;
  41020. /**
  41021. * Gets a mesh using a given name
  41022. * @param name defines the name to search for
  41023. * @return the found mesh or null if not found at all.
  41024. */
  41025. getMeshByName(name: string): Nullable<AbstractMesh>;
  41026. /**
  41027. * Gets a transform node using a given name
  41028. * @param name defines the name to search for
  41029. * @return the found transform node or null if not found at all.
  41030. */
  41031. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41032. /**
  41033. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41034. * @param id defines the id to search for
  41035. * @return the found skeleton or null if not found at all.
  41036. */
  41037. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41038. /**
  41039. * Gets a skeleton using a given auto generated unique id
  41040. * @param uniqueId defines the unique id to search for
  41041. * @return the found skeleton or null if not found at all.
  41042. */
  41043. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41044. /**
  41045. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41046. * @param id defines the id to search for
  41047. * @return the found skeleton or null if not found at all.
  41048. */
  41049. getSkeletonById(id: string): Nullable<Skeleton>;
  41050. /**
  41051. * Gets a skeleton using a given name
  41052. * @param name defines the name to search for
  41053. * @return the found skeleton or null if not found at all.
  41054. */
  41055. getSkeletonByName(name: string): Nullable<Skeleton>;
  41056. /**
  41057. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41058. * @param id defines the id to search for
  41059. * @return the found morph target manager or null if not found at all.
  41060. */
  41061. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41062. /**
  41063. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41064. * @param id defines the id to search for
  41065. * @return the found morph target or null if not found at all.
  41066. */
  41067. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41068. /**
  41069. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41070. * @param name defines the name to search for
  41071. * @return the found morph target or null if not found at all.
  41072. */
  41073. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41074. /**
  41075. * Gets a boolean indicating if the given mesh is active
  41076. * @param mesh defines the mesh to look for
  41077. * @returns true if the mesh is in the active list
  41078. */
  41079. isActiveMesh(mesh: AbstractMesh): boolean;
  41080. /**
  41081. * Return a unique id as a string which can serve as an identifier for the scene
  41082. */
  41083. get uid(): string;
  41084. /**
  41085. * Add an externaly attached data from its key.
  41086. * This method call will fail and return false, if such key already exists.
  41087. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41088. * @param key the unique key that identifies the data
  41089. * @param data the data object to associate to the key for this Engine instance
  41090. * @return true if no such key were already present and the data was added successfully, false otherwise
  41091. */
  41092. addExternalData<T>(key: string, data: T): boolean;
  41093. /**
  41094. * Get an externaly attached data from its key
  41095. * @param key the unique key that identifies the data
  41096. * @return the associated data, if present (can be null), or undefined if not present
  41097. */
  41098. getExternalData<T>(key: string): Nullable<T>;
  41099. /**
  41100. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41101. * @param key the unique key that identifies the data
  41102. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41103. * @return the associated data, can be null if the factory returned null.
  41104. */
  41105. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41106. /**
  41107. * Remove an externaly attached data from the Engine instance
  41108. * @param key the unique key that identifies the data
  41109. * @return true if the data was successfully removed, false if it doesn't exist
  41110. */
  41111. removeExternalData(key: string): boolean;
  41112. private _evaluateSubMesh;
  41113. /**
  41114. * Clear the processed materials smart array preventing retention point in material dispose.
  41115. */
  41116. freeProcessedMaterials(): void;
  41117. private _preventFreeActiveMeshesAndRenderingGroups;
  41118. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41119. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41120. * when disposing several meshes in a row or a hierarchy of meshes.
  41121. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41122. */
  41123. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41124. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41125. /**
  41126. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41127. */
  41128. freeActiveMeshes(): void;
  41129. /**
  41130. * Clear the info related to rendering groups preventing retention points during dispose.
  41131. */
  41132. freeRenderingGroups(): void;
  41133. /** @hidden */
  41134. _isInIntermediateRendering(): boolean;
  41135. /**
  41136. * Lambda returning the list of potentially active meshes.
  41137. */
  41138. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41139. /**
  41140. * Lambda returning the list of potentially active sub meshes.
  41141. */
  41142. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41143. /**
  41144. * Lambda returning the list of potentially intersecting sub meshes.
  41145. */
  41146. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41147. /**
  41148. * Lambda returning the list of potentially colliding sub meshes.
  41149. */
  41150. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41151. private _activeMeshesFrozen;
  41152. private _skipEvaluateActiveMeshesCompletely;
  41153. /**
  41154. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41155. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41156. * @returns the current scene
  41157. */
  41158. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41159. /**
  41160. * Use this function to restart evaluating active meshes on every frame
  41161. * @returns the current scene
  41162. */
  41163. unfreezeActiveMeshes(): Scene;
  41164. private _evaluateActiveMeshes;
  41165. private _activeMesh;
  41166. /**
  41167. * Update the transform matrix to update from the current active camera
  41168. * @param force defines a boolean used to force the update even if cache is up to date
  41169. */
  41170. updateTransformMatrix(force?: boolean): void;
  41171. private _bindFrameBuffer;
  41172. /** @hidden */
  41173. _allowPostProcessClearColor: boolean;
  41174. /** @hidden */
  41175. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41176. private _processSubCameras;
  41177. private _checkIntersections;
  41178. /** @hidden */
  41179. _advancePhysicsEngineStep(step: number): void;
  41180. /**
  41181. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41182. */
  41183. getDeterministicFrameTime: () => number;
  41184. /** @hidden */
  41185. _animate(): void;
  41186. /** Execute all animations (for a frame) */
  41187. animate(): void;
  41188. /**
  41189. * Render the scene
  41190. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41191. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41192. */
  41193. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41194. /**
  41195. * Freeze all materials
  41196. * A frozen material will not be updatable but should be faster to render
  41197. */
  41198. freezeMaterials(): void;
  41199. /**
  41200. * Unfreeze all materials
  41201. * A frozen material will not be updatable but should be faster to render
  41202. */
  41203. unfreezeMaterials(): void;
  41204. /**
  41205. * Releases all held ressources
  41206. */
  41207. dispose(): void;
  41208. /**
  41209. * Gets if the scene is already disposed
  41210. */
  41211. get isDisposed(): boolean;
  41212. /**
  41213. * Call this function to reduce memory footprint of the scene.
  41214. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41215. */
  41216. clearCachedVertexData(): void;
  41217. /**
  41218. * This function will remove the local cached buffer data from texture.
  41219. * It will save memory but will prevent the texture from being rebuilt
  41220. */
  41221. cleanCachedTextureBuffer(): void;
  41222. /**
  41223. * Get the world extend vectors with an optional filter
  41224. *
  41225. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41226. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41227. */
  41228. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41229. min: Vector3;
  41230. max: Vector3;
  41231. };
  41232. /**
  41233. * Creates a ray that can be used to pick in the scene
  41234. * @param x defines the x coordinate of the origin (on-screen)
  41235. * @param y defines the y coordinate of the origin (on-screen)
  41236. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41237. * @param camera defines the camera to use for the picking
  41238. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41239. * @returns a Ray
  41240. */
  41241. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41242. /**
  41243. * Creates a ray that can be used to pick in the scene
  41244. * @param x defines the x coordinate of the origin (on-screen)
  41245. * @param y defines the y coordinate of the origin (on-screen)
  41246. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41247. * @param result defines the ray where to store the picking ray
  41248. * @param camera defines the camera to use for the picking
  41249. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41250. * @returns the current scene
  41251. */
  41252. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41253. /**
  41254. * Creates a ray that can be used to pick in the scene
  41255. * @param x defines the x coordinate of the origin (on-screen)
  41256. * @param y defines the y coordinate of the origin (on-screen)
  41257. * @param camera defines the camera to use for the picking
  41258. * @returns a Ray
  41259. */
  41260. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41261. /**
  41262. * Creates a ray that can be used to pick in the scene
  41263. * @param x defines the x coordinate of the origin (on-screen)
  41264. * @param y defines the y coordinate of the origin (on-screen)
  41265. * @param result defines the ray where to store the picking ray
  41266. * @param camera defines the camera to use for the picking
  41267. * @returns the current scene
  41268. */
  41269. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41270. /** Launch a ray to try to pick a mesh in the scene
  41271. * @param x position on screen
  41272. * @param y position on screen
  41273. * @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
  41274. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41275. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41276. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41277. * @returns a PickingInfo
  41278. */
  41279. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41280. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41281. * @param x position on screen
  41282. * @param y position on screen
  41283. * @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
  41284. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41285. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41286. * @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)
  41287. */
  41288. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41289. /** Use the given ray to pick a mesh in the scene
  41290. * @param ray The ray to use to pick meshes
  41291. * @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
  41292. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41293. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41294. * @returns a PickingInfo
  41295. */
  41296. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41297. /**
  41298. * Launch a ray to try to pick a mesh in the scene
  41299. * @param x X position on screen
  41300. * @param y Y position on screen
  41301. * @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
  41302. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41303. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41304. * @returns an array of PickingInfo
  41305. */
  41306. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41307. /**
  41308. * Launch a ray to try to pick a mesh in the scene
  41309. * @param ray Ray to use
  41310. * @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
  41311. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41312. * @returns an array of PickingInfo
  41313. */
  41314. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41315. /**
  41316. * Force the value of meshUnderPointer
  41317. * @param mesh defines the mesh to use
  41318. */
  41319. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41320. /**
  41321. * Gets the mesh under the pointer
  41322. * @returns a Mesh or null if no mesh is under the pointer
  41323. */
  41324. getPointerOverMesh(): Nullable<AbstractMesh>;
  41325. /** @hidden */
  41326. _rebuildGeometries(): void;
  41327. /** @hidden */
  41328. _rebuildTextures(): void;
  41329. private _getByTags;
  41330. /**
  41331. * Get a list of meshes by tags
  41332. * @param tagsQuery defines the tags query to use
  41333. * @param forEach defines a predicate used to filter results
  41334. * @returns an array of Mesh
  41335. */
  41336. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41337. /**
  41338. * Get a list of cameras by tags
  41339. * @param tagsQuery defines the tags query to use
  41340. * @param forEach defines a predicate used to filter results
  41341. * @returns an array of Camera
  41342. */
  41343. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41344. /**
  41345. * Get a list of lights by tags
  41346. * @param tagsQuery defines the tags query to use
  41347. * @param forEach defines a predicate used to filter results
  41348. * @returns an array of Light
  41349. */
  41350. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41351. /**
  41352. * Get a list of materials by tags
  41353. * @param tagsQuery defines the tags query to use
  41354. * @param forEach defines a predicate used to filter results
  41355. * @returns an array of Material
  41356. */
  41357. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41358. /**
  41359. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41360. * This allowed control for front to back rendering or reversly depending of the special needs.
  41361. *
  41362. * @param renderingGroupId The rendering group id corresponding to its index
  41363. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41364. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41365. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41366. */
  41367. 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;
  41368. /**
  41369. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41370. *
  41371. * @param renderingGroupId The rendering group id corresponding to its index
  41372. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41373. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41374. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41375. */
  41376. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41377. /**
  41378. * Gets the current auto clear configuration for one rendering group of the rendering
  41379. * manager.
  41380. * @param index the rendering group index to get the information for
  41381. * @returns The auto clear setup for the requested rendering group
  41382. */
  41383. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41384. private _blockMaterialDirtyMechanism;
  41385. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41386. get blockMaterialDirtyMechanism(): boolean;
  41387. set blockMaterialDirtyMechanism(value: boolean);
  41388. /**
  41389. * Will flag all materials as dirty to trigger new shader compilation
  41390. * @param flag defines the flag used to specify which material part must be marked as dirty
  41391. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41392. */
  41393. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41394. /** @hidden */
  41395. _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;
  41396. /** @hidden */
  41397. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41398. /** @hidden */
  41399. _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;
  41400. /** @hidden */
  41401. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41402. /** @hidden */
  41403. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41404. /** @hidden */
  41405. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41406. }
  41407. }
  41408. declare module "babylonjs/assetContainer" {
  41409. import { AbstractScene } from "babylonjs/abstractScene";
  41410. import { Scene } from "babylonjs/scene";
  41411. import { Mesh } from "babylonjs/Meshes/mesh";
  41412. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41413. import { Skeleton } from "babylonjs/Bones/skeleton";
  41414. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41415. import { Animatable } from "babylonjs/Animations/animatable";
  41416. import { Nullable } from "babylonjs/types";
  41417. import { Node } from "babylonjs/node";
  41418. /**
  41419. * Set of assets to keep when moving a scene into an asset container.
  41420. */
  41421. export class KeepAssets extends AbstractScene {
  41422. }
  41423. /**
  41424. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41425. */
  41426. export class InstantiatedEntries {
  41427. /**
  41428. * List of new root nodes (eg. nodes with no parent)
  41429. */
  41430. rootNodes: TransformNode[];
  41431. /**
  41432. * List of new skeletons
  41433. */
  41434. skeletons: Skeleton[];
  41435. /**
  41436. * List of new animation groups
  41437. */
  41438. animationGroups: AnimationGroup[];
  41439. }
  41440. /**
  41441. * Container with a set of assets that can be added or removed from a scene.
  41442. */
  41443. export class AssetContainer extends AbstractScene {
  41444. private _wasAddedToScene;
  41445. /**
  41446. * The scene the AssetContainer belongs to.
  41447. */
  41448. scene: Scene;
  41449. /**
  41450. * Instantiates an AssetContainer.
  41451. * @param scene The scene the AssetContainer belongs to.
  41452. */
  41453. constructor(scene: Scene);
  41454. /**
  41455. * Instantiate or clone all meshes and add the new ones to the scene.
  41456. * Skeletons and animation groups will all be cloned
  41457. * @param nameFunction defines an optional function used to get new names for clones
  41458. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41459. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41460. */
  41461. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41462. /**
  41463. * Adds all the assets from the container to the scene.
  41464. */
  41465. addAllToScene(): void;
  41466. /**
  41467. * Removes all the assets in the container from the scene
  41468. */
  41469. removeAllFromScene(): void;
  41470. /**
  41471. * Disposes all the assets in the container
  41472. */
  41473. dispose(): void;
  41474. private _moveAssets;
  41475. /**
  41476. * Removes all the assets contained in the scene and adds them to the container.
  41477. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41478. */
  41479. moveAllFromScene(keepAssets?: KeepAssets): void;
  41480. /**
  41481. * 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.
  41482. * @returns the root mesh
  41483. */
  41484. createRootMesh(): Mesh;
  41485. /**
  41486. * Merge animations (direct and animation groups) from this asset container into a scene
  41487. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41488. * @param animatables set of animatables to retarget to a node from the scene
  41489. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41490. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41491. */
  41492. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41493. }
  41494. }
  41495. declare module "babylonjs/abstractScene" {
  41496. import { Scene } from "babylonjs/scene";
  41497. import { Nullable } from "babylonjs/types";
  41498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41499. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41500. import { Geometry } from "babylonjs/Meshes/geometry";
  41501. import { Skeleton } from "babylonjs/Bones/skeleton";
  41502. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41503. import { AssetContainer } from "babylonjs/assetContainer";
  41504. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41505. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41507. import { Material } from "babylonjs/Materials/material";
  41508. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41509. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41510. import { Camera } from "babylonjs/Cameras/camera";
  41511. import { Light } from "babylonjs/Lights/light";
  41512. import { Node } from "babylonjs/node";
  41513. import { Animation } from "babylonjs/Animations/animation";
  41514. /**
  41515. * Defines how the parser contract is defined.
  41516. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41517. */
  41518. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41519. /**
  41520. * Defines how the individual parser contract is defined.
  41521. * These parser can parse an individual asset
  41522. */
  41523. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41524. /**
  41525. * Base class of the scene acting as a container for the different elements composing a scene.
  41526. * This class is dynamically extended by the different components of the scene increasing
  41527. * flexibility and reducing coupling
  41528. */
  41529. export abstract class AbstractScene {
  41530. /**
  41531. * Stores the list of available parsers in the application.
  41532. */
  41533. private static _BabylonFileParsers;
  41534. /**
  41535. * Stores the list of available individual parsers in the application.
  41536. */
  41537. private static _IndividualBabylonFileParsers;
  41538. /**
  41539. * Adds a parser in the list of available ones
  41540. * @param name Defines the name of the parser
  41541. * @param parser Defines the parser to add
  41542. */
  41543. static AddParser(name: string, parser: BabylonFileParser): void;
  41544. /**
  41545. * Gets a general parser from the list of avaialble ones
  41546. * @param name Defines the name of the parser
  41547. * @returns the requested parser or null
  41548. */
  41549. static GetParser(name: string): Nullable<BabylonFileParser>;
  41550. /**
  41551. * Adds n individual parser in the list of available ones
  41552. * @param name Defines the name of the parser
  41553. * @param parser Defines the parser to add
  41554. */
  41555. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41556. /**
  41557. * Gets an individual parser from the list of avaialble ones
  41558. * @param name Defines the name of the parser
  41559. * @returns the requested parser or null
  41560. */
  41561. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41562. /**
  41563. * Parser json data and populate both a scene and its associated container object
  41564. * @param jsonData Defines the data to parse
  41565. * @param scene Defines the scene to parse the data for
  41566. * @param container Defines the container attached to the parsing sequence
  41567. * @param rootUrl Defines the root url of the data
  41568. */
  41569. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41570. /**
  41571. * Gets the list of root nodes (ie. nodes with no parent)
  41572. */
  41573. rootNodes: Node[];
  41574. /** All of the cameras added to this scene
  41575. * @see http://doc.babylonjs.com/babylon101/cameras
  41576. */
  41577. cameras: Camera[];
  41578. /**
  41579. * All of the lights added to this scene
  41580. * @see http://doc.babylonjs.com/babylon101/lights
  41581. */
  41582. lights: Light[];
  41583. /**
  41584. * All of the (abstract) meshes added to this scene
  41585. */
  41586. meshes: AbstractMesh[];
  41587. /**
  41588. * The list of skeletons added to the scene
  41589. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41590. */
  41591. skeletons: Skeleton[];
  41592. /**
  41593. * All of the particle systems added to this scene
  41594. * @see http://doc.babylonjs.com/babylon101/particles
  41595. */
  41596. particleSystems: IParticleSystem[];
  41597. /**
  41598. * Gets a list of Animations associated with the scene
  41599. */
  41600. animations: Animation[];
  41601. /**
  41602. * All of the animation groups added to this scene
  41603. * @see http://doc.babylonjs.com/how_to/group
  41604. */
  41605. animationGroups: AnimationGroup[];
  41606. /**
  41607. * All of the multi-materials added to this scene
  41608. * @see http://doc.babylonjs.com/how_to/multi_materials
  41609. */
  41610. multiMaterials: MultiMaterial[];
  41611. /**
  41612. * All of the materials added to this scene
  41613. * In the context of a Scene, it is not supposed to be modified manually.
  41614. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41615. * Note also that the order of the Material within the array is not significant and might change.
  41616. * @see http://doc.babylonjs.com/babylon101/materials
  41617. */
  41618. materials: Material[];
  41619. /**
  41620. * The list of morph target managers added to the scene
  41621. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41622. */
  41623. morphTargetManagers: MorphTargetManager[];
  41624. /**
  41625. * The list of geometries used in the scene.
  41626. */
  41627. geometries: Geometry[];
  41628. /**
  41629. * All of the tranform nodes added to this scene
  41630. * In the context of a Scene, it is not supposed to be modified manually.
  41631. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41632. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41633. * @see http://doc.babylonjs.com/how_to/transformnode
  41634. */
  41635. transformNodes: TransformNode[];
  41636. /**
  41637. * ActionManagers available on the scene.
  41638. */
  41639. actionManagers: AbstractActionManager[];
  41640. /**
  41641. * Textures to keep.
  41642. */
  41643. textures: BaseTexture[];
  41644. /**
  41645. * Environment texture for the scene
  41646. */
  41647. environmentTexture: Nullable<BaseTexture>;
  41648. /**
  41649. * @returns all meshes, lights, cameras, transformNodes and bones
  41650. */
  41651. getNodes(): Array<Node>;
  41652. }
  41653. }
  41654. declare module "babylonjs/Audio/sound" {
  41655. import { Observable } from "babylonjs/Misc/observable";
  41656. import { Vector3 } from "babylonjs/Maths/math.vector";
  41657. import { Nullable } from "babylonjs/types";
  41658. import { Scene } from "babylonjs/scene";
  41659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41660. /**
  41661. * Interface used to define options for Sound class
  41662. */
  41663. export interface ISoundOptions {
  41664. /**
  41665. * Does the sound autoplay once loaded.
  41666. */
  41667. autoplay?: boolean;
  41668. /**
  41669. * Does the sound loop after it finishes playing once.
  41670. */
  41671. loop?: boolean;
  41672. /**
  41673. * Sound's volume
  41674. */
  41675. volume?: number;
  41676. /**
  41677. * Is it a spatial sound?
  41678. */
  41679. spatialSound?: boolean;
  41680. /**
  41681. * Maximum distance to hear that sound
  41682. */
  41683. maxDistance?: number;
  41684. /**
  41685. * Uses user defined attenuation function
  41686. */
  41687. useCustomAttenuation?: boolean;
  41688. /**
  41689. * Define the roll off factor of spatial sounds.
  41690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41691. */
  41692. rolloffFactor?: number;
  41693. /**
  41694. * Define the reference distance the sound should be heard perfectly.
  41695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41696. */
  41697. refDistance?: number;
  41698. /**
  41699. * Define the distance attenuation model the sound will follow.
  41700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41701. */
  41702. distanceModel?: string;
  41703. /**
  41704. * Defines the playback speed (1 by default)
  41705. */
  41706. playbackRate?: number;
  41707. /**
  41708. * Defines if the sound is from a streaming source
  41709. */
  41710. streaming?: boolean;
  41711. /**
  41712. * Defines an optional length (in seconds) inside the sound file
  41713. */
  41714. length?: number;
  41715. /**
  41716. * Defines an optional offset (in seconds) inside the sound file
  41717. */
  41718. offset?: number;
  41719. /**
  41720. * If true, URLs will not be required to state the audio file codec to use.
  41721. */
  41722. skipCodecCheck?: boolean;
  41723. }
  41724. /**
  41725. * Defines a sound that can be played in the application.
  41726. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41728. */
  41729. export class Sound {
  41730. /**
  41731. * The name of the sound in the scene.
  41732. */
  41733. name: string;
  41734. /**
  41735. * Does the sound autoplay once loaded.
  41736. */
  41737. autoplay: boolean;
  41738. /**
  41739. * Does the sound loop after it finishes playing once.
  41740. */
  41741. loop: boolean;
  41742. /**
  41743. * Does the sound use a custom attenuation curve to simulate the falloff
  41744. * happening when the source gets further away from the camera.
  41745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41746. */
  41747. useCustomAttenuation: boolean;
  41748. /**
  41749. * The sound track id this sound belongs to.
  41750. */
  41751. soundTrackId: number;
  41752. /**
  41753. * Is this sound currently played.
  41754. */
  41755. isPlaying: boolean;
  41756. /**
  41757. * Is this sound currently paused.
  41758. */
  41759. isPaused: boolean;
  41760. /**
  41761. * Does this sound enables spatial sound.
  41762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41763. */
  41764. spatialSound: boolean;
  41765. /**
  41766. * Define the reference distance the sound should be heard perfectly.
  41767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41768. */
  41769. refDistance: number;
  41770. /**
  41771. * Define the roll off factor of spatial sounds.
  41772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41773. */
  41774. rolloffFactor: number;
  41775. /**
  41776. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41778. */
  41779. maxDistance: number;
  41780. /**
  41781. * Define the distance attenuation model the sound will follow.
  41782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41783. */
  41784. distanceModel: string;
  41785. /**
  41786. * @hidden
  41787. * Back Compat
  41788. **/
  41789. onended: () => any;
  41790. /**
  41791. * Gets or sets an object used to store user defined information for the sound.
  41792. */
  41793. metadata: any;
  41794. /**
  41795. * Observable event when the current playing sound finishes.
  41796. */
  41797. onEndedObservable: Observable<Sound>;
  41798. private _panningModel;
  41799. private _playbackRate;
  41800. private _streaming;
  41801. private _startTime;
  41802. private _startOffset;
  41803. private _position;
  41804. /** @hidden */
  41805. _positionInEmitterSpace: boolean;
  41806. private _localDirection;
  41807. private _volume;
  41808. private _isReadyToPlay;
  41809. private _isDirectional;
  41810. private _readyToPlayCallback;
  41811. private _audioBuffer;
  41812. private _soundSource;
  41813. private _streamingSource;
  41814. private _soundPanner;
  41815. private _soundGain;
  41816. private _inputAudioNode;
  41817. private _outputAudioNode;
  41818. private _coneInnerAngle;
  41819. private _coneOuterAngle;
  41820. private _coneOuterGain;
  41821. private _scene;
  41822. private _connectedTransformNode;
  41823. private _customAttenuationFunction;
  41824. private _registerFunc;
  41825. private _isOutputConnected;
  41826. private _htmlAudioElement;
  41827. private _urlType;
  41828. private _length?;
  41829. private _offset?;
  41830. /** @hidden */
  41831. static _SceneComponentInitialization: (scene: Scene) => void;
  41832. /**
  41833. * Create a sound and attach it to a scene
  41834. * @param name Name of your sound
  41835. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41836. * @param scene defines the scene the sound belongs to
  41837. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41838. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41839. */
  41840. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41841. /**
  41842. * Release the sound and its associated resources
  41843. */
  41844. dispose(): void;
  41845. /**
  41846. * Gets if the sounds is ready to be played or not.
  41847. * @returns true if ready, otherwise false
  41848. */
  41849. isReady(): boolean;
  41850. private _soundLoaded;
  41851. /**
  41852. * Sets the data of the sound from an audiobuffer
  41853. * @param audioBuffer The audioBuffer containing the data
  41854. */
  41855. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41856. /**
  41857. * Updates the current sounds options such as maxdistance, loop...
  41858. * @param options A JSON object containing values named as the object properties
  41859. */
  41860. updateOptions(options: ISoundOptions): void;
  41861. private _createSpatialParameters;
  41862. private _updateSpatialParameters;
  41863. /**
  41864. * Switch the panning model to HRTF:
  41865. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41867. */
  41868. switchPanningModelToHRTF(): void;
  41869. /**
  41870. * Switch the panning model to Equal Power:
  41871. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41873. */
  41874. switchPanningModelToEqualPower(): void;
  41875. private _switchPanningModel;
  41876. /**
  41877. * Connect this sound to a sound track audio node like gain...
  41878. * @param soundTrackAudioNode the sound track audio node to connect to
  41879. */
  41880. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41881. /**
  41882. * Transform this sound into a directional source
  41883. * @param coneInnerAngle Size of the inner cone in degree
  41884. * @param coneOuterAngle Size of the outer cone in degree
  41885. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41886. */
  41887. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41888. /**
  41889. * Gets or sets the inner angle for the directional cone.
  41890. */
  41891. get directionalConeInnerAngle(): number;
  41892. /**
  41893. * Gets or sets the inner angle for the directional cone.
  41894. */
  41895. set directionalConeInnerAngle(value: number);
  41896. /**
  41897. * Gets or sets the outer angle for the directional cone.
  41898. */
  41899. get directionalConeOuterAngle(): number;
  41900. /**
  41901. * Gets or sets the outer angle for the directional cone.
  41902. */
  41903. set directionalConeOuterAngle(value: number);
  41904. /**
  41905. * Sets the position of the emitter if spatial sound is enabled
  41906. * @param newPosition Defines the new posisiton
  41907. */
  41908. setPosition(newPosition: Vector3): void;
  41909. /**
  41910. * Sets the local direction of the emitter if spatial sound is enabled
  41911. * @param newLocalDirection Defines the new local direction
  41912. */
  41913. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41914. private _updateDirection;
  41915. /** @hidden */
  41916. updateDistanceFromListener(): void;
  41917. /**
  41918. * Sets a new custom attenuation function for the sound.
  41919. * @param callback Defines the function used for the attenuation
  41920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41921. */
  41922. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41923. /**
  41924. * Play the sound
  41925. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41926. * @param offset (optional) Start the sound at a specific time in seconds
  41927. * @param length (optional) Sound duration (in seconds)
  41928. */
  41929. play(time?: number, offset?: number, length?: number): void;
  41930. private _onended;
  41931. /**
  41932. * Stop the sound
  41933. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41934. */
  41935. stop(time?: number): void;
  41936. /**
  41937. * Put the sound in pause
  41938. */
  41939. pause(): void;
  41940. /**
  41941. * Sets a dedicated volume for this sounds
  41942. * @param newVolume Define the new volume of the sound
  41943. * @param time Define time for gradual change to new volume
  41944. */
  41945. setVolume(newVolume: number, time?: number): void;
  41946. /**
  41947. * Set the sound play back rate
  41948. * @param newPlaybackRate Define the playback rate the sound should be played at
  41949. */
  41950. setPlaybackRate(newPlaybackRate: number): void;
  41951. /**
  41952. * Gets the volume of the sound.
  41953. * @returns the volume of the sound
  41954. */
  41955. getVolume(): number;
  41956. /**
  41957. * Attach the sound to a dedicated mesh
  41958. * @param transformNode The transform node to connect the sound with
  41959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41960. */
  41961. attachToMesh(transformNode: TransformNode): void;
  41962. /**
  41963. * Detach the sound from the previously attached mesh
  41964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41965. */
  41966. detachFromMesh(): void;
  41967. private _onRegisterAfterWorldMatrixUpdate;
  41968. /**
  41969. * Clone the current sound in the scene.
  41970. * @returns the new sound clone
  41971. */
  41972. clone(): Nullable<Sound>;
  41973. /**
  41974. * Gets the current underlying audio buffer containing the data
  41975. * @returns the audio buffer
  41976. */
  41977. getAudioBuffer(): Nullable<AudioBuffer>;
  41978. /**
  41979. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41980. * @returns the source node
  41981. */
  41982. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41983. /**
  41984. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41985. * @returns the gain node
  41986. */
  41987. getSoundGain(): Nullable<GainNode>;
  41988. /**
  41989. * Serializes the Sound in a JSON representation
  41990. * @returns the JSON representation of the sound
  41991. */
  41992. serialize(): any;
  41993. /**
  41994. * Parse a JSON representation of a sound to innstantiate in a given scene
  41995. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41996. * @param scene Define the scene the new parsed sound should be created in
  41997. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41998. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41999. * @returns the newly parsed sound
  42000. */
  42001. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42002. }
  42003. }
  42004. declare module "babylonjs/Actions/directAudioActions" {
  42005. import { Action } from "babylonjs/Actions/action";
  42006. import { Condition } from "babylonjs/Actions/condition";
  42007. import { Sound } from "babylonjs/Audio/sound";
  42008. /**
  42009. * This defines an action helpful to play a defined sound on a triggered action.
  42010. */
  42011. export class PlaySoundAction extends Action {
  42012. private _sound;
  42013. /**
  42014. * Instantiate the action
  42015. * @param triggerOptions defines the trigger options
  42016. * @param sound defines the sound to play
  42017. * @param condition defines the trigger related conditions
  42018. */
  42019. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42020. /** @hidden */
  42021. _prepare(): void;
  42022. /**
  42023. * Execute the action and play the sound.
  42024. */
  42025. execute(): void;
  42026. /**
  42027. * Serializes the actions and its related information.
  42028. * @param parent defines the object to serialize in
  42029. * @returns the serialized object
  42030. */
  42031. serialize(parent: any): any;
  42032. }
  42033. /**
  42034. * This defines an action helpful to stop a defined sound on a triggered action.
  42035. */
  42036. export class StopSoundAction extends Action {
  42037. private _sound;
  42038. /**
  42039. * Instantiate the action
  42040. * @param triggerOptions defines the trigger options
  42041. * @param sound defines the sound to stop
  42042. * @param condition defines the trigger related conditions
  42043. */
  42044. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42045. /** @hidden */
  42046. _prepare(): void;
  42047. /**
  42048. * Execute the action and stop the sound.
  42049. */
  42050. execute(): void;
  42051. /**
  42052. * Serializes the actions and its related information.
  42053. * @param parent defines the object to serialize in
  42054. * @returns the serialized object
  42055. */
  42056. serialize(parent: any): any;
  42057. }
  42058. }
  42059. declare module "babylonjs/Actions/interpolateValueAction" {
  42060. import { Action } from "babylonjs/Actions/action";
  42061. import { Condition } from "babylonjs/Actions/condition";
  42062. import { Observable } from "babylonjs/Misc/observable";
  42063. /**
  42064. * This defines an action responsible to change the value of a property
  42065. * by interpolating between its current value and the newly set one once triggered.
  42066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  42067. */
  42068. export class InterpolateValueAction extends Action {
  42069. /**
  42070. * Defines the path of the property where the value should be interpolated
  42071. */
  42072. propertyPath: string;
  42073. /**
  42074. * Defines the target value at the end of the interpolation.
  42075. */
  42076. value: any;
  42077. /**
  42078. * Defines the time it will take for the property to interpolate to the value.
  42079. */
  42080. duration: number;
  42081. /**
  42082. * Defines if the other scene animations should be stopped when the action has been triggered
  42083. */
  42084. stopOtherAnimations?: boolean;
  42085. /**
  42086. * Defines a callback raised once the interpolation animation has been done.
  42087. */
  42088. onInterpolationDone?: () => void;
  42089. /**
  42090. * Observable triggered once the interpolation animation has been done.
  42091. */
  42092. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42093. private _target;
  42094. private _effectiveTarget;
  42095. private _property;
  42096. /**
  42097. * Instantiate the action
  42098. * @param triggerOptions defines the trigger options
  42099. * @param target defines the object containing the value to interpolate
  42100. * @param propertyPath defines the path to the property in the target object
  42101. * @param value defines the target value at the end of the interpolation
  42102. * @param duration deines the time it will take for the property to interpolate to the value.
  42103. * @param condition defines the trigger related conditions
  42104. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42105. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42106. */
  42107. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42108. /** @hidden */
  42109. _prepare(): void;
  42110. /**
  42111. * Execute the action starts the value interpolation.
  42112. */
  42113. execute(): void;
  42114. /**
  42115. * Serializes the actions and its related information.
  42116. * @param parent defines the object to serialize in
  42117. * @returns the serialized object
  42118. */
  42119. serialize(parent: any): any;
  42120. }
  42121. }
  42122. declare module "babylonjs/Actions/index" {
  42123. export * from "babylonjs/Actions/abstractActionManager";
  42124. export * from "babylonjs/Actions/action";
  42125. export * from "babylonjs/Actions/actionEvent";
  42126. export * from "babylonjs/Actions/actionManager";
  42127. export * from "babylonjs/Actions/condition";
  42128. export * from "babylonjs/Actions/directActions";
  42129. export * from "babylonjs/Actions/directAudioActions";
  42130. export * from "babylonjs/Actions/interpolateValueAction";
  42131. }
  42132. declare module "babylonjs/Animations/index" {
  42133. export * from "babylonjs/Animations/animatable";
  42134. export * from "babylonjs/Animations/animation";
  42135. export * from "babylonjs/Animations/animationGroup";
  42136. export * from "babylonjs/Animations/animationPropertiesOverride";
  42137. export * from "babylonjs/Animations/easing";
  42138. export * from "babylonjs/Animations/runtimeAnimation";
  42139. export * from "babylonjs/Animations/animationEvent";
  42140. export * from "babylonjs/Animations/animationGroup";
  42141. export * from "babylonjs/Animations/animationKey";
  42142. export * from "babylonjs/Animations/animationRange";
  42143. export * from "babylonjs/Animations/animatable.interface";
  42144. }
  42145. declare module "babylonjs/Audio/soundTrack" {
  42146. import { Sound } from "babylonjs/Audio/sound";
  42147. import { Analyser } from "babylonjs/Audio/analyser";
  42148. import { Scene } from "babylonjs/scene";
  42149. /**
  42150. * Options allowed during the creation of a sound track.
  42151. */
  42152. export interface ISoundTrackOptions {
  42153. /**
  42154. * The volume the sound track should take during creation
  42155. */
  42156. volume?: number;
  42157. /**
  42158. * Define if the sound track is the main sound track of the scene
  42159. */
  42160. mainTrack?: boolean;
  42161. }
  42162. /**
  42163. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42164. * It will be also used in a future release to apply effects on a specific track.
  42165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42166. */
  42167. export class SoundTrack {
  42168. /**
  42169. * The unique identifier of the sound track in the scene.
  42170. */
  42171. id: number;
  42172. /**
  42173. * The list of sounds included in the sound track.
  42174. */
  42175. soundCollection: Array<Sound>;
  42176. private _outputAudioNode;
  42177. private _scene;
  42178. private _connectedAnalyser;
  42179. private _options;
  42180. private _isInitialized;
  42181. /**
  42182. * Creates a new sound track.
  42183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42184. * @param scene Define the scene the sound track belongs to
  42185. * @param options
  42186. */
  42187. constructor(scene: Scene, options?: ISoundTrackOptions);
  42188. private _initializeSoundTrackAudioGraph;
  42189. /**
  42190. * Release the sound track and its associated resources
  42191. */
  42192. dispose(): void;
  42193. /**
  42194. * Adds a sound to this sound track
  42195. * @param sound define the cound to add
  42196. * @ignoreNaming
  42197. */
  42198. AddSound(sound: Sound): void;
  42199. /**
  42200. * Removes a sound to this sound track
  42201. * @param sound define the cound to remove
  42202. * @ignoreNaming
  42203. */
  42204. RemoveSound(sound: Sound): void;
  42205. /**
  42206. * Set a global volume for the full sound track.
  42207. * @param newVolume Define the new volume of the sound track
  42208. */
  42209. setVolume(newVolume: number): void;
  42210. /**
  42211. * Switch the panning model to HRTF:
  42212. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42214. */
  42215. switchPanningModelToHRTF(): void;
  42216. /**
  42217. * Switch the panning model to Equal Power:
  42218. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42220. */
  42221. switchPanningModelToEqualPower(): void;
  42222. /**
  42223. * Connect the sound track to an audio analyser allowing some amazing
  42224. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42226. * @param analyser The analyser to connect to the engine
  42227. */
  42228. connectToAnalyser(analyser: Analyser): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Audio/audioSceneComponent" {
  42232. import { Sound } from "babylonjs/Audio/sound";
  42233. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42234. import { Nullable } from "babylonjs/types";
  42235. import { Vector3 } from "babylonjs/Maths/math.vector";
  42236. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42237. import { Scene } from "babylonjs/scene";
  42238. import { AbstractScene } from "babylonjs/abstractScene";
  42239. import "babylonjs/Audio/audioEngine";
  42240. module "babylonjs/abstractScene" {
  42241. interface AbstractScene {
  42242. /**
  42243. * The list of sounds used in the scene.
  42244. */
  42245. sounds: Nullable<Array<Sound>>;
  42246. }
  42247. }
  42248. module "babylonjs/scene" {
  42249. interface Scene {
  42250. /**
  42251. * @hidden
  42252. * Backing field
  42253. */
  42254. _mainSoundTrack: SoundTrack;
  42255. /**
  42256. * The main sound track played by the scene.
  42257. * It cotains your primary collection of sounds.
  42258. */
  42259. mainSoundTrack: SoundTrack;
  42260. /**
  42261. * The list of sound tracks added to the scene
  42262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42263. */
  42264. soundTracks: Nullable<Array<SoundTrack>>;
  42265. /**
  42266. * Gets a sound using a given name
  42267. * @param name defines the name to search for
  42268. * @return the found sound or null if not found at all.
  42269. */
  42270. getSoundByName(name: string): Nullable<Sound>;
  42271. /**
  42272. * Gets or sets if audio support is enabled
  42273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42274. */
  42275. audioEnabled: boolean;
  42276. /**
  42277. * Gets or sets if audio will be output to headphones
  42278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42279. */
  42280. headphone: boolean;
  42281. /**
  42282. * Gets or sets custom audio listener position provider
  42283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42284. */
  42285. audioListenerPositionProvider: Nullable<() => Vector3>;
  42286. /**
  42287. * Gets or sets a refresh rate when using 3D audio positioning
  42288. */
  42289. audioPositioningRefreshRate: number;
  42290. }
  42291. }
  42292. /**
  42293. * Defines the sound scene component responsible to manage any sounds
  42294. * in a given scene.
  42295. */
  42296. export class AudioSceneComponent implements ISceneSerializableComponent {
  42297. /**
  42298. * The component name helpfull to identify the component in the list of scene components.
  42299. */
  42300. readonly name: string;
  42301. /**
  42302. * The scene the component belongs to.
  42303. */
  42304. scene: Scene;
  42305. private _audioEnabled;
  42306. /**
  42307. * Gets whether audio is enabled or not.
  42308. * Please use related enable/disable method to switch state.
  42309. */
  42310. get audioEnabled(): boolean;
  42311. private _headphone;
  42312. /**
  42313. * Gets whether audio is outputing to headphone or not.
  42314. * Please use the according Switch methods to change output.
  42315. */
  42316. get headphone(): boolean;
  42317. /**
  42318. * Gets or sets a refresh rate when using 3D audio positioning
  42319. */
  42320. audioPositioningRefreshRate: number;
  42321. private _audioListenerPositionProvider;
  42322. /**
  42323. * Gets the current audio listener position provider
  42324. */
  42325. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42326. /**
  42327. * Sets a custom listener position for all sounds in the scene
  42328. * By default, this is the position of the first active camera
  42329. */
  42330. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42331. /**
  42332. * Creates a new instance of the component for the given scene
  42333. * @param scene Defines the scene to register the component in
  42334. */
  42335. constructor(scene: Scene);
  42336. /**
  42337. * Registers the component in a given scene
  42338. */
  42339. register(): void;
  42340. /**
  42341. * Rebuilds the elements related to this component in case of
  42342. * context lost for instance.
  42343. */
  42344. rebuild(): void;
  42345. /**
  42346. * Serializes the component data to the specified json object
  42347. * @param serializationObject The object to serialize to
  42348. */
  42349. serialize(serializationObject: any): void;
  42350. /**
  42351. * Adds all the elements from the container to the scene
  42352. * @param container the container holding the elements
  42353. */
  42354. addFromContainer(container: AbstractScene): void;
  42355. /**
  42356. * Removes all the elements in the container from the scene
  42357. * @param container contains the elements to remove
  42358. * @param dispose if the removed element should be disposed (default: false)
  42359. */
  42360. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42361. /**
  42362. * Disposes the component and the associated ressources.
  42363. */
  42364. dispose(): void;
  42365. /**
  42366. * Disables audio in the associated scene.
  42367. */
  42368. disableAudio(): void;
  42369. /**
  42370. * Enables audio in the associated scene.
  42371. */
  42372. enableAudio(): void;
  42373. /**
  42374. * Switch audio to headphone output.
  42375. */
  42376. switchAudioModeForHeadphones(): void;
  42377. /**
  42378. * Switch audio to normal speakers.
  42379. */
  42380. switchAudioModeForNormalSpeakers(): void;
  42381. private _cachedCameraDirection;
  42382. private _cachedCameraPosition;
  42383. private _lastCheck;
  42384. private _afterRender;
  42385. }
  42386. }
  42387. declare module "babylonjs/Audio/weightedsound" {
  42388. import { Sound } from "babylonjs/Audio/sound";
  42389. /**
  42390. * Wraps one or more Sound objects and selects one with random weight for playback.
  42391. */
  42392. export class WeightedSound {
  42393. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42394. loop: boolean;
  42395. private _coneInnerAngle;
  42396. private _coneOuterAngle;
  42397. private _volume;
  42398. /** A Sound is currently playing. */
  42399. isPlaying: boolean;
  42400. /** A Sound is currently paused. */
  42401. isPaused: boolean;
  42402. private _sounds;
  42403. private _weights;
  42404. private _currentIndex?;
  42405. /**
  42406. * Creates a new WeightedSound from the list of sounds given.
  42407. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42408. * @param sounds Array of Sounds that will be selected from.
  42409. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42410. */
  42411. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42412. /**
  42413. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42414. */
  42415. get directionalConeInnerAngle(): number;
  42416. /**
  42417. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42418. */
  42419. set directionalConeInnerAngle(value: number);
  42420. /**
  42421. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42422. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42423. */
  42424. get directionalConeOuterAngle(): number;
  42425. /**
  42426. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42427. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42428. */
  42429. set directionalConeOuterAngle(value: number);
  42430. /**
  42431. * Playback volume.
  42432. */
  42433. get volume(): number;
  42434. /**
  42435. * Playback volume.
  42436. */
  42437. set volume(value: number);
  42438. private _onended;
  42439. /**
  42440. * Suspend playback
  42441. */
  42442. pause(): void;
  42443. /**
  42444. * Stop playback
  42445. */
  42446. stop(): void;
  42447. /**
  42448. * Start playback.
  42449. * @param startOffset Position the clip head at a specific time in seconds.
  42450. */
  42451. play(startOffset?: number): void;
  42452. }
  42453. }
  42454. declare module "babylonjs/Audio/index" {
  42455. export * from "babylonjs/Audio/analyser";
  42456. export * from "babylonjs/Audio/audioEngine";
  42457. export * from "babylonjs/Audio/audioSceneComponent";
  42458. export * from "babylonjs/Audio/sound";
  42459. export * from "babylonjs/Audio/soundTrack";
  42460. export * from "babylonjs/Audio/weightedsound";
  42461. }
  42462. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42463. import { Behavior } from "babylonjs/Behaviors/behavior";
  42464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42465. import { BackEase } from "babylonjs/Animations/easing";
  42466. /**
  42467. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42468. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42469. */
  42470. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42471. /**
  42472. * Gets the name of the behavior.
  42473. */
  42474. get name(): string;
  42475. /**
  42476. * The easing function used by animations
  42477. */
  42478. static EasingFunction: BackEase;
  42479. /**
  42480. * The easing mode used by animations
  42481. */
  42482. static EasingMode: number;
  42483. /**
  42484. * The duration of the animation, in milliseconds
  42485. */
  42486. transitionDuration: number;
  42487. /**
  42488. * Length of the distance animated by the transition when lower radius is reached
  42489. */
  42490. lowerRadiusTransitionRange: number;
  42491. /**
  42492. * Length of the distance animated by the transition when upper radius is reached
  42493. */
  42494. upperRadiusTransitionRange: number;
  42495. private _autoTransitionRange;
  42496. /**
  42497. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42498. */
  42499. get autoTransitionRange(): boolean;
  42500. /**
  42501. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42502. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42503. */
  42504. set autoTransitionRange(value: boolean);
  42505. private _attachedCamera;
  42506. private _onAfterCheckInputsObserver;
  42507. private _onMeshTargetChangedObserver;
  42508. /**
  42509. * Initializes the behavior.
  42510. */
  42511. init(): void;
  42512. /**
  42513. * Attaches the behavior to its arc rotate camera.
  42514. * @param camera Defines the camera to attach the behavior to
  42515. */
  42516. attach(camera: ArcRotateCamera): void;
  42517. /**
  42518. * Detaches the behavior from its current arc rotate camera.
  42519. */
  42520. detach(): void;
  42521. private _radiusIsAnimating;
  42522. private _radiusBounceTransition;
  42523. private _animatables;
  42524. private _cachedWheelPrecision;
  42525. /**
  42526. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42527. * @param radiusLimit The limit to check against.
  42528. * @return Bool to indicate if at limit.
  42529. */
  42530. private _isRadiusAtLimit;
  42531. /**
  42532. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42533. * @param radiusDelta The delta by which to animate to. Can be negative.
  42534. */
  42535. private _applyBoundRadiusAnimation;
  42536. /**
  42537. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42538. */
  42539. protected _clearAnimationLocks(): void;
  42540. /**
  42541. * Stops and removes all animations that have been applied to the camera
  42542. */
  42543. stopAllAnimations(): void;
  42544. }
  42545. }
  42546. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42547. import { Behavior } from "babylonjs/Behaviors/behavior";
  42548. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42549. import { ExponentialEase } from "babylonjs/Animations/easing";
  42550. import { Nullable } from "babylonjs/types";
  42551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42552. import { Vector3 } from "babylonjs/Maths/math.vector";
  42553. /**
  42554. * 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.
  42555. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42556. */
  42557. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42558. /**
  42559. * Gets the name of the behavior.
  42560. */
  42561. get name(): string;
  42562. private _mode;
  42563. private _radiusScale;
  42564. private _positionScale;
  42565. private _defaultElevation;
  42566. private _elevationReturnTime;
  42567. private _elevationReturnWaitTime;
  42568. private _zoomStopsAnimation;
  42569. private _framingTime;
  42570. /**
  42571. * The easing function used by animations
  42572. */
  42573. static EasingFunction: ExponentialEase;
  42574. /**
  42575. * The easing mode used by animations
  42576. */
  42577. static EasingMode: number;
  42578. /**
  42579. * Sets the current mode used by the behavior
  42580. */
  42581. set mode(mode: number);
  42582. /**
  42583. * Gets current mode used by the behavior.
  42584. */
  42585. get mode(): number;
  42586. /**
  42587. * Sets the scale applied to the radius (1 by default)
  42588. */
  42589. set radiusScale(radius: number);
  42590. /**
  42591. * Gets the scale applied to the radius
  42592. */
  42593. get radiusScale(): number;
  42594. /**
  42595. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42596. */
  42597. set positionScale(scale: number);
  42598. /**
  42599. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42600. */
  42601. get positionScale(): number;
  42602. /**
  42603. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42604. * behaviour is triggered, in radians.
  42605. */
  42606. set defaultElevation(elevation: number);
  42607. /**
  42608. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42609. * behaviour is triggered, in radians.
  42610. */
  42611. get defaultElevation(): number;
  42612. /**
  42613. * Sets the time (in milliseconds) taken to return to the default beta position.
  42614. * Negative value indicates camera should not return to default.
  42615. */
  42616. set elevationReturnTime(speed: number);
  42617. /**
  42618. * Gets the time (in milliseconds) taken to return to the default beta position.
  42619. * Negative value indicates camera should not return to default.
  42620. */
  42621. get elevationReturnTime(): number;
  42622. /**
  42623. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42624. */
  42625. set elevationReturnWaitTime(time: number);
  42626. /**
  42627. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42628. */
  42629. get elevationReturnWaitTime(): number;
  42630. /**
  42631. * Sets the flag that indicates if user zooming should stop animation.
  42632. */
  42633. set zoomStopsAnimation(flag: boolean);
  42634. /**
  42635. * Gets the flag that indicates if user zooming should stop animation.
  42636. */
  42637. get zoomStopsAnimation(): boolean;
  42638. /**
  42639. * Sets the transition time when framing the mesh, in milliseconds
  42640. */
  42641. set framingTime(time: number);
  42642. /**
  42643. * Gets the transition time when framing the mesh, in milliseconds
  42644. */
  42645. get framingTime(): number;
  42646. /**
  42647. * Define if the behavior should automatically change the configured
  42648. * camera limits and sensibilities.
  42649. */
  42650. autoCorrectCameraLimitsAndSensibility: boolean;
  42651. private _onPrePointerObservableObserver;
  42652. private _onAfterCheckInputsObserver;
  42653. private _onMeshTargetChangedObserver;
  42654. private _attachedCamera;
  42655. private _isPointerDown;
  42656. private _lastInteractionTime;
  42657. /**
  42658. * Initializes the behavior.
  42659. */
  42660. init(): void;
  42661. /**
  42662. * Attaches the behavior to its arc rotate camera.
  42663. * @param camera Defines the camera to attach the behavior to
  42664. */
  42665. attach(camera: ArcRotateCamera): void;
  42666. /**
  42667. * Detaches the behavior from its current arc rotate camera.
  42668. */
  42669. detach(): void;
  42670. private _animatables;
  42671. private _betaIsAnimating;
  42672. private _betaTransition;
  42673. private _radiusTransition;
  42674. private _vectorTransition;
  42675. /**
  42676. * Targets the given mesh and updates zoom level accordingly.
  42677. * @param mesh The mesh to target.
  42678. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42679. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42680. */
  42681. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42682. /**
  42683. * Targets the given mesh with its children and updates zoom level accordingly.
  42684. * @param mesh The mesh to target.
  42685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42687. */
  42688. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42689. /**
  42690. * Targets the given meshes with their children and updates zoom level accordingly.
  42691. * @param meshes The mesh to target.
  42692. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42693. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42694. */
  42695. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42696. /**
  42697. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42698. * @param minimumWorld Determines the smaller position of the bounding box extend
  42699. * @param maximumWorld Determines the bigger position of the bounding box extend
  42700. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42701. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42702. */
  42703. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42704. /**
  42705. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42706. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42707. * frustum width.
  42708. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42709. * to fully enclose the mesh in the viewing frustum.
  42710. */
  42711. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42712. /**
  42713. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42714. * is automatically returned to its default position (expected to be above ground plane).
  42715. */
  42716. private _maintainCameraAboveGround;
  42717. /**
  42718. * Returns the frustum slope based on the canvas ratio and camera FOV
  42719. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42720. */
  42721. private _getFrustumSlope;
  42722. /**
  42723. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42724. */
  42725. private _clearAnimationLocks;
  42726. /**
  42727. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42728. */
  42729. private _applyUserInteraction;
  42730. /**
  42731. * Stops and removes all animations that have been applied to the camera
  42732. */
  42733. stopAllAnimations(): void;
  42734. /**
  42735. * Gets a value indicating if the user is moving the camera
  42736. */
  42737. get isUserIsMoving(): boolean;
  42738. /**
  42739. * The camera can move all the way towards the mesh.
  42740. */
  42741. static IgnoreBoundsSizeMode: number;
  42742. /**
  42743. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42744. */
  42745. static FitFrustumSidesMode: number;
  42746. }
  42747. }
  42748. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42749. import { Nullable } from "babylonjs/types";
  42750. import { Camera } from "babylonjs/Cameras/camera";
  42751. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42752. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42753. /**
  42754. * Base class for Camera Pointer Inputs.
  42755. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42756. * for example usage.
  42757. */
  42758. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42759. /**
  42760. * Defines the camera the input is attached to.
  42761. */
  42762. abstract camera: Camera;
  42763. /**
  42764. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42765. */
  42766. protected _altKey: boolean;
  42767. protected _ctrlKey: boolean;
  42768. protected _metaKey: boolean;
  42769. protected _shiftKey: boolean;
  42770. /**
  42771. * Which mouse buttons were pressed at time of last mouse event.
  42772. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42773. */
  42774. protected _buttonsPressed: number;
  42775. /**
  42776. * Defines the buttons associated with the input to handle camera move.
  42777. */
  42778. buttons: number[];
  42779. /**
  42780. * Attach the input controls to a specific dom element to get the input from.
  42781. * @param element Defines the element the controls should be listened from
  42782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42783. */
  42784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42785. /**
  42786. * Detach the current controls from the specified dom element.
  42787. * @param element Defines the element to stop listening the inputs from
  42788. */
  42789. detachControl(element: Nullable<HTMLElement>): void;
  42790. /**
  42791. * Gets the class name of the current input.
  42792. * @returns the class name
  42793. */
  42794. getClassName(): string;
  42795. /**
  42796. * Get the friendly name associated with the input class.
  42797. * @returns the input friendly name
  42798. */
  42799. getSimpleName(): string;
  42800. /**
  42801. * Called on pointer POINTERDOUBLETAP event.
  42802. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42803. */
  42804. protected onDoubleTap(type: string): void;
  42805. /**
  42806. * Called on pointer POINTERMOVE event if only a single touch is active.
  42807. * Override this method to provide functionality.
  42808. */
  42809. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42810. /**
  42811. * Called on pointer POINTERMOVE event if multiple touches are active.
  42812. * Override this method to provide functionality.
  42813. */
  42814. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42815. /**
  42816. * Called on JS contextmenu event.
  42817. * Override this method to provide functionality.
  42818. */
  42819. protected onContextMenu(evt: PointerEvent): void;
  42820. /**
  42821. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42822. * press.
  42823. * Override this method to provide functionality.
  42824. */
  42825. protected onButtonDown(evt: PointerEvent): void;
  42826. /**
  42827. * Called each time a new POINTERUP event occurs. Ie, for each button
  42828. * release.
  42829. * Override this method to provide functionality.
  42830. */
  42831. protected onButtonUp(evt: PointerEvent): void;
  42832. /**
  42833. * Called when window becomes inactive.
  42834. * Override this method to provide functionality.
  42835. */
  42836. protected onLostFocus(): void;
  42837. private _pointerInput;
  42838. private _observer;
  42839. private _onLostFocus;
  42840. private pointA;
  42841. private pointB;
  42842. }
  42843. }
  42844. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42845. import { Nullable } from "babylonjs/types";
  42846. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42847. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42848. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42849. /**
  42850. * Manage the pointers inputs to control an arc rotate camera.
  42851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42852. */
  42853. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42854. /**
  42855. * Defines the camera the input is attached to.
  42856. */
  42857. camera: ArcRotateCamera;
  42858. /**
  42859. * Gets the class name of the current input.
  42860. * @returns the class name
  42861. */
  42862. getClassName(): string;
  42863. /**
  42864. * Defines the buttons associated with the input to handle camera move.
  42865. */
  42866. buttons: number[];
  42867. /**
  42868. * Defines the pointer angular sensibility along the X axis or how fast is
  42869. * the camera rotating.
  42870. */
  42871. angularSensibilityX: number;
  42872. /**
  42873. * Defines the pointer angular sensibility along the Y axis or how fast is
  42874. * the camera rotating.
  42875. */
  42876. angularSensibilityY: number;
  42877. /**
  42878. * Defines the pointer pinch precision or how fast is the camera zooming.
  42879. */
  42880. pinchPrecision: number;
  42881. /**
  42882. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42883. * from 0.
  42884. * It defines the percentage of current camera.radius to use as delta when
  42885. * pinch zoom is used.
  42886. */
  42887. pinchDeltaPercentage: number;
  42888. /**
  42889. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42890. * that any object in the plane at the camera's target point will scale
  42891. * perfectly with finger motion.
  42892. * Overrides pinchDeltaPercentage and pinchPrecision.
  42893. */
  42894. useNaturalPinchZoom: boolean;
  42895. /**
  42896. * Defines the pointer panning sensibility or how fast is the camera moving.
  42897. */
  42898. panningSensibility: number;
  42899. /**
  42900. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42901. */
  42902. multiTouchPanning: boolean;
  42903. /**
  42904. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42905. * zoom (pinch) through multitouch.
  42906. */
  42907. multiTouchPanAndZoom: boolean;
  42908. /**
  42909. * Revers pinch action direction.
  42910. */
  42911. pinchInwards: boolean;
  42912. private _isPanClick;
  42913. private _twoFingerActivityCount;
  42914. private _isPinching;
  42915. /**
  42916. * Called on pointer POINTERMOVE event if only a single touch is active.
  42917. */
  42918. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42919. /**
  42920. * Called on pointer POINTERDOUBLETAP event.
  42921. */
  42922. protected onDoubleTap(type: string): void;
  42923. /**
  42924. * Called on pointer POINTERMOVE event if multiple touches are active.
  42925. */
  42926. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42927. /**
  42928. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42929. * press.
  42930. */
  42931. protected onButtonDown(evt: PointerEvent): void;
  42932. /**
  42933. * Called each time a new POINTERUP event occurs. Ie, for each button
  42934. * release.
  42935. */
  42936. protected onButtonUp(evt: PointerEvent): void;
  42937. /**
  42938. * Called when window becomes inactive.
  42939. */
  42940. protected onLostFocus(): void;
  42941. }
  42942. }
  42943. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  42944. import { Nullable } from "babylonjs/types";
  42945. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42946. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42947. /**
  42948. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42950. */
  42951. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42952. /**
  42953. * Defines the camera the input is attached to.
  42954. */
  42955. camera: ArcRotateCamera;
  42956. /**
  42957. * Defines the list of key codes associated with the up action (increase alpha)
  42958. */
  42959. keysUp: number[];
  42960. /**
  42961. * Defines the list of key codes associated with the down action (decrease alpha)
  42962. */
  42963. keysDown: number[];
  42964. /**
  42965. * Defines the list of key codes associated with the left action (increase beta)
  42966. */
  42967. keysLeft: number[];
  42968. /**
  42969. * Defines the list of key codes associated with the right action (decrease beta)
  42970. */
  42971. keysRight: number[];
  42972. /**
  42973. * Defines the list of key codes associated with the reset action.
  42974. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42975. */
  42976. keysReset: number[];
  42977. /**
  42978. * Defines the panning sensibility of the inputs.
  42979. * (How fast is the camera panning)
  42980. */
  42981. panningSensibility: number;
  42982. /**
  42983. * Defines the zooming sensibility of the inputs.
  42984. * (How fast is the camera zooming)
  42985. */
  42986. zoomingSensibility: number;
  42987. /**
  42988. * Defines whether maintaining the alt key down switch the movement mode from
  42989. * orientation to zoom.
  42990. */
  42991. useAltToZoom: boolean;
  42992. /**
  42993. * Rotation speed of the camera
  42994. */
  42995. angularSpeed: number;
  42996. private _keys;
  42997. private _ctrlPressed;
  42998. private _altPressed;
  42999. private _onCanvasBlurObserver;
  43000. private _onKeyboardObserver;
  43001. private _engine;
  43002. private _scene;
  43003. /**
  43004. * Attach the input controls to a specific dom element to get the input from.
  43005. * @param element Defines the element the controls should be listened from
  43006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43007. */
  43008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43009. /**
  43010. * Detach the current controls from the specified dom element.
  43011. * @param element Defines the element to stop listening the inputs from
  43012. */
  43013. detachControl(element: Nullable<HTMLElement>): void;
  43014. /**
  43015. * Update the current camera state depending on the inputs that have been used this frame.
  43016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43017. */
  43018. checkInputs(): void;
  43019. /**
  43020. * Gets the class name of the current intput.
  43021. * @returns the class name
  43022. */
  43023. getClassName(): string;
  43024. /**
  43025. * Get the friendly name associated with the input class.
  43026. * @returns the input friendly name
  43027. */
  43028. getSimpleName(): string;
  43029. }
  43030. }
  43031. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43032. import { Nullable } from "babylonjs/types";
  43033. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43035. /**
  43036. * Manage the mouse wheel inputs to control an arc rotate camera.
  43037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43038. */
  43039. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43040. /**
  43041. * Defines the camera the input is attached to.
  43042. */
  43043. camera: ArcRotateCamera;
  43044. /**
  43045. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43046. */
  43047. wheelPrecision: number;
  43048. /**
  43049. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43050. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43051. */
  43052. wheelDeltaPercentage: number;
  43053. private _wheel;
  43054. private _observer;
  43055. private computeDeltaFromMouseWheelLegacyEvent;
  43056. /**
  43057. * Attach the input controls to a specific dom element to get the input from.
  43058. * @param element Defines the element the controls should be listened from
  43059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43060. */
  43061. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43062. /**
  43063. * Detach the current controls from the specified dom element.
  43064. * @param element Defines the element to stop listening the inputs from
  43065. */
  43066. detachControl(element: Nullable<HTMLElement>): void;
  43067. /**
  43068. * Gets the class name of the current intput.
  43069. * @returns the class name
  43070. */
  43071. getClassName(): string;
  43072. /**
  43073. * Get the friendly name associated with the input class.
  43074. * @returns the input friendly name
  43075. */
  43076. getSimpleName(): string;
  43077. }
  43078. }
  43079. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43080. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43081. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43082. /**
  43083. * Default Inputs manager for the ArcRotateCamera.
  43084. * It groups all the default supported inputs for ease of use.
  43085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43086. */
  43087. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43088. /**
  43089. * Instantiates a new ArcRotateCameraInputsManager.
  43090. * @param camera Defines the camera the inputs belong to
  43091. */
  43092. constructor(camera: ArcRotateCamera);
  43093. /**
  43094. * Add mouse wheel input support to the input manager.
  43095. * @returns the current input manager
  43096. */
  43097. addMouseWheel(): ArcRotateCameraInputsManager;
  43098. /**
  43099. * Add pointers input support to the input manager.
  43100. * @returns the current input manager
  43101. */
  43102. addPointers(): ArcRotateCameraInputsManager;
  43103. /**
  43104. * Add keyboard input support to the input manager.
  43105. * @returns the current input manager
  43106. */
  43107. addKeyboard(): ArcRotateCameraInputsManager;
  43108. }
  43109. }
  43110. declare module "babylonjs/Cameras/arcRotateCamera" {
  43111. import { Observable } from "babylonjs/Misc/observable";
  43112. import { Nullable } from "babylonjs/types";
  43113. import { Scene } from "babylonjs/scene";
  43114. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43116. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43117. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43118. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43119. import { Camera } from "babylonjs/Cameras/camera";
  43120. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43121. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43122. import { Collider } from "babylonjs/Collisions/collider";
  43123. /**
  43124. * This represents an orbital type of camera.
  43125. *
  43126. * 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.
  43127. * 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.
  43128. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43129. */
  43130. export class ArcRotateCamera extends TargetCamera {
  43131. /**
  43132. * Defines the rotation angle of the camera along the longitudinal axis.
  43133. */
  43134. alpha: number;
  43135. /**
  43136. * Defines the rotation angle of the camera along the latitudinal axis.
  43137. */
  43138. beta: number;
  43139. /**
  43140. * Defines the radius of the camera from it s target point.
  43141. */
  43142. radius: number;
  43143. protected _target: Vector3;
  43144. protected _targetHost: Nullable<AbstractMesh>;
  43145. /**
  43146. * Defines the target point of the camera.
  43147. * The camera looks towards it form the radius distance.
  43148. */
  43149. get target(): Vector3;
  43150. set target(value: Vector3);
  43151. /**
  43152. * Define the current local position of the camera in the scene
  43153. */
  43154. get position(): Vector3;
  43155. set position(newPosition: Vector3);
  43156. protected _upVector: Vector3;
  43157. protected _upToYMatrix: Matrix;
  43158. protected _YToUpMatrix: Matrix;
  43159. /**
  43160. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43161. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43162. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43163. */
  43164. set upVector(vec: Vector3);
  43165. get upVector(): Vector3;
  43166. /**
  43167. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43168. */
  43169. setMatUp(): void;
  43170. /**
  43171. * Current inertia value on the longitudinal axis.
  43172. * The bigger this number the longer it will take for the camera to stop.
  43173. */
  43174. inertialAlphaOffset: number;
  43175. /**
  43176. * Current inertia value on the latitudinal axis.
  43177. * The bigger this number the longer it will take for the camera to stop.
  43178. */
  43179. inertialBetaOffset: number;
  43180. /**
  43181. * Current inertia value on the radius axis.
  43182. * The bigger this number the longer it will take for the camera to stop.
  43183. */
  43184. inertialRadiusOffset: number;
  43185. /**
  43186. * Minimum allowed angle on the longitudinal axis.
  43187. * This can help limiting how the Camera is able to move in the scene.
  43188. */
  43189. lowerAlphaLimit: Nullable<number>;
  43190. /**
  43191. * Maximum allowed angle on the longitudinal axis.
  43192. * This can help limiting how the Camera is able to move in the scene.
  43193. */
  43194. upperAlphaLimit: Nullable<number>;
  43195. /**
  43196. * Minimum allowed angle on the latitudinal axis.
  43197. * This can help limiting how the Camera is able to move in the scene.
  43198. */
  43199. lowerBetaLimit: number;
  43200. /**
  43201. * Maximum allowed angle on the latitudinal axis.
  43202. * This can help limiting how the Camera is able to move in the scene.
  43203. */
  43204. upperBetaLimit: number;
  43205. /**
  43206. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43207. * This can help limiting how the Camera is able to move in the scene.
  43208. */
  43209. lowerRadiusLimit: Nullable<number>;
  43210. /**
  43211. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43212. * This can help limiting how the Camera is able to move in the scene.
  43213. */
  43214. upperRadiusLimit: Nullable<number>;
  43215. /**
  43216. * Defines the current inertia value used during panning of the camera along the X axis.
  43217. */
  43218. inertialPanningX: number;
  43219. /**
  43220. * Defines the current inertia value used during panning of the camera along the Y axis.
  43221. */
  43222. inertialPanningY: number;
  43223. /**
  43224. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43225. * Basically if your fingers moves away from more than this distance you will be considered
  43226. * in pinch mode.
  43227. */
  43228. pinchToPanMaxDistance: number;
  43229. /**
  43230. * Defines the maximum distance the camera can pan.
  43231. * This could help keeping the cammera always in your scene.
  43232. */
  43233. panningDistanceLimit: Nullable<number>;
  43234. /**
  43235. * Defines the target of the camera before paning.
  43236. */
  43237. panningOriginTarget: Vector3;
  43238. /**
  43239. * Defines the value of the inertia used during panning.
  43240. * 0 would mean stop inertia and one would mean no decelleration at all.
  43241. */
  43242. panningInertia: number;
  43243. /**
  43244. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43245. */
  43246. get angularSensibilityX(): number;
  43247. set angularSensibilityX(value: number);
  43248. /**
  43249. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43250. */
  43251. get angularSensibilityY(): number;
  43252. set angularSensibilityY(value: number);
  43253. /**
  43254. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43255. */
  43256. get pinchPrecision(): number;
  43257. set pinchPrecision(value: number);
  43258. /**
  43259. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43260. * It will be used instead of pinchDeltaPrecision if different from 0.
  43261. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43262. */
  43263. get pinchDeltaPercentage(): number;
  43264. set pinchDeltaPercentage(value: number);
  43265. /**
  43266. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43267. * and pinch delta percentage.
  43268. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43269. * that any object in the plane at the camera's target point will scale
  43270. * perfectly with finger motion.
  43271. */
  43272. get useNaturalPinchZoom(): boolean;
  43273. set useNaturalPinchZoom(value: boolean);
  43274. /**
  43275. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43276. */
  43277. get panningSensibility(): number;
  43278. set panningSensibility(value: number);
  43279. /**
  43280. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43281. */
  43282. get keysUp(): number[];
  43283. set keysUp(value: number[]);
  43284. /**
  43285. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43286. */
  43287. get keysDown(): number[];
  43288. set keysDown(value: number[]);
  43289. /**
  43290. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43291. */
  43292. get keysLeft(): number[];
  43293. set keysLeft(value: number[]);
  43294. /**
  43295. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43296. */
  43297. get keysRight(): number[];
  43298. set keysRight(value: number[]);
  43299. /**
  43300. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43301. */
  43302. get wheelPrecision(): number;
  43303. set wheelPrecision(value: number);
  43304. /**
  43305. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43306. * It will be used instead of pinchDeltaPrecision if different from 0.
  43307. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43308. */
  43309. get wheelDeltaPercentage(): number;
  43310. set wheelDeltaPercentage(value: number);
  43311. /**
  43312. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43313. */
  43314. zoomOnFactor: number;
  43315. /**
  43316. * Defines a screen offset for the camera position.
  43317. */
  43318. targetScreenOffset: Vector2;
  43319. /**
  43320. * Allows the camera to be completely reversed.
  43321. * If false the camera can not arrive upside down.
  43322. */
  43323. allowUpsideDown: boolean;
  43324. /**
  43325. * Define if double tap/click is used to restore the previously saved state of the camera.
  43326. */
  43327. useInputToRestoreState: boolean;
  43328. /** @hidden */
  43329. _viewMatrix: Matrix;
  43330. /** @hidden */
  43331. _useCtrlForPanning: boolean;
  43332. /** @hidden */
  43333. _panningMouseButton: number;
  43334. /**
  43335. * Defines the input associated to the camera.
  43336. */
  43337. inputs: ArcRotateCameraInputsManager;
  43338. /** @hidden */
  43339. _reset: () => void;
  43340. /**
  43341. * Defines the allowed panning axis.
  43342. */
  43343. panningAxis: Vector3;
  43344. protected _localDirection: Vector3;
  43345. protected _transformedDirection: Vector3;
  43346. private _bouncingBehavior;
  43347. /**
  43348. * Gets the bouncing behavior of the camera if it has been enabled.
  43349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43350. */
  43351. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43352. /**
  43353. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43355. */
  43356. get useBouncingBehavior(): boolean;
  43357. set useBouncingBehavior(value: boolean);
  43358. private _framingBehavior;
  43359. /**
  43360. * Gets the framing behavior of the camera if it has been enabled.
  43361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43362. */
  43363. get framingBehavior(): Nullable<FramingBehavior>;
  43364. /**
  43365. * Defines if the framing behavior of the camera is enabled on the camera.
  43366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43367. */
  43368. get useFramingBehavior(): boolean;
  43369. set useFramingBehavior(value: boolean);
  43370. private _autoRotationBehavior;
  43371. /**
  43372. * Gets the auto rotation behavior of the camera if it has been enabled.
  43373. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43374. */
  43375. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43376. /**
  43377. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43379. */
  43380. get useAutoRotationBehavior(): boolean;
  43381. set useAutoRotationBehavior(value: boolean);
  43382. /**
  43383. * Observable triggered when the mesh target has been changed on the camera.
  43384. */
  43385. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43386. /**
  43387. * Event raised when the camera is colliding with a mesh.
  43388. */
  43389. onCollide: (collidedMesh: AbstractMesh) => void;
  43390. /**
  43391. * Defines whether the camera should check collision with the objects oh the scene.
  43392. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43393. */
  43394. checkCollisions: boolean;
  43395. /**
  43396. * Defines the collision radius of the camera.
  43397. * This simulates a sphere around the camera.
  43398. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43399. */
  43400. collisionRadius: Vector3;
  43401. protected _collider: Collider;
  43402. protected _previousPosition: Vector3;
  43403. protected _collisionVelocity: Vector3;
  43404. protected _newPosition: Vector3;
  43405. protected _previousAlpha: number;
  43406. protected _previousBeta: number;
  43407. protected _previousRadius: number;
  43408. protected _collisionTriggered: boolean;
  43409. protected _targetBoundingCenter: Nullable<Vector3>;
  43410. private _computationVector;
  43411. /**
  43412. * Instantiates a new ArcRotateCamera in a given scene
  43413. * @param name Defines the name of the camera
  43414. * @param alpha Defines the camera rotation along the logitudinal axis
  43415. * @param beta Defines the camera rotation along the latitudinal axis
  43416. * @param radius Defines the camera distance from its target
  43417. * @param target Defines the camera target
  43418. * @param scene Defines the scene the camera belongs to
  43419. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43420. */
  43421. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43422. /** @hidden */
  43423. _initCache(): void;
  43424. /** @hidden */
  43425. _updateCache(ignoreParentClass?: boolean): void;
  43426. protected _getTargetPosition(): Vector3;
  43427. private _storedAlpha;
  43428. private _storedBeta;
  43429. private _storedRadius;
  43430. private _storedTarget;
  43431. private _storedTargetScreenOffset;
  43432. /**
  43433. * Stores the current state of the camera (alpha, beta, radius and target)
  43434. * @returns the camera itself
  43435. */
  43436. storeState(): Camera;
  43437. /**
  43438. * @hidden
  43439. * Restored camera state. You must call storeState() first
  43440. */
  43441. _restoreStateValues(): boolean;
  43442. /** @hidden */
  43443. _isSynchronizedViewMatrix(): boolean;
  43444. /**
  43445. * Attached controls to the current camera.
  43446. * @param element Defines the element the controls should be listened from
  43447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43448. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43449. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43450. */
  43451. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43452. /**
  43453. * Detach the current controls from the camera.
  43454. * The camera will stop reacting to inputs.
  43455. * @param element Defines the element to stop listening the inputs from
  43456. */
  43457. detachControl(element: HTMLElement): void;
  43458. /** @hidden */
  43459. _checkInputs(): void;
  43460. protected _checkLimits(): void;
  43461. /**
  43462. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43463. */
  43464. rebuildAnglesAndRadius(): void;
  43465. /**
  43466. * Use a position to define the current camera related information like alpha, beta and radius
  43467. * @param position Defines the position to set the camera at
  43468. */
  43469. setPosition(position: Vector3): void;
  43470. /**
  43471. * Defines the target the camera should look at.
  43472. * This will automatically adapt alpha beta and radius to fit within the new target.
  43473. * @param target Defines the new target as a Vector or a mesh
  43474. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43475. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43476. */
  43477. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43478. /** @hidden */
  43479. _getViewMatrix(): Matrix;
  43480. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43481. /**
  43482. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43483. * @param meshes Defines the mesh to zoom on
  43484. * @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)
  43485. */
  43486. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43487. /**
  43488. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43489. * The target will be changed but the radius
  43490. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43491. * @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)
  43492. */
  43493. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43494. min: Vector3;
  43495. max: Vector3;
  43496. distance: number;
  43497. }, doNotUpdateMaxZ?: boolean): void;
  43498. /**
  43499. * @override
  43500. * Override Camera.createRigCamera
  43501. */
  43502. createRigCamera(name: string, cameraIndex: number): Camera;
  43503. /**
  43504. * @hidden
  43505. * @override
  43506. * Override Camera._updateRigCameras
  43507. */
  43508. _updateRigCameras(): void;
  43509. /**
  43510. * Destroy the camera and release the current resources hold by it.
  43511. */
  43512. dispose(): void;
  43513. /**
  43514. * Gets the current object class name.
  43515. * @return the class name
  43516. */
  43517. getClassName(): string;
  43518. }
  43519. }
  43520. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43521. import { Behavior } from "babylonjs/Behaviors/behavior";
  43522. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43523. /**
  43524. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43525. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43526. */
  43527. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43528. /**
  43529. * Gets the name of the behavior.
  43530. */
  43531. get name(): string;
  43532. private _zoomStopsAnimation;
  43533. private _idleRotationSpeed;
  43534. private _idleRotationWaitTime;
  43535. private _idleRotationSpinupTime;
  43536. /**
  43537. * Sets the flag that indicates if user zooming should stop animation.
  43538. */
  43539. set zoomStopsAnimation(flag: boolean);
  43540. /**
  43541. * Gets the flag that indicates if user zooming should stop animation.
  43542. */
  43543. get zoomStopsAnimation(): boolean;
  43544. /**
  43545. * Sets the default speed at which the camera rotates around the model.
  43546. */
  43547. set idleRotationSpeed(speed: number);
  43548. /**
  43549. * Gets the default speed at which the camera rotates around the model.
  43550. */
  43551. get idleRotationSpeed(): number;
  43552. /**
  43553. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43554. */
  43555. set idleRotationWaitTime(time: number);
  43556. /**
  43557. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43558. */
  43559. get idleRotationWaitTime(): number;
  43560. /**
  43561. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43562. */
  43563. set idleRotationSpinupTime(time: number);
  43564. /**
  43565. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43566. */
  43567. get idleRotationSpinupTime(): number;
  43568. /**
  43569. * Gets a value indicating if the camera is currently rotating because of this behavior
  43570. */
  43571. get rotationInProgress(): boolean;
  43572. private _onPrePointerObservableObserver;
  43573. private _onAfterCheckInputsObserver;
  43574. private _attachedCamera;
  43575. private _isPointerDown;
  43576. private _lastFrameTime;
  43577. private _lastInteractionTime;
  43578. private _cameraRotationSpeed;
  43579. /**
  43580. * Initializes the behavior.
  43581. */
  43582. init(): void;
  43583. /**
  43584. * Attaches the behavior to its arc rotate camera.
  43585. * @param camera Defines the camera to attach the behavior to
  43586. */
  43587. attach(camera: ArcRotateCamera): void;
  43588. /**
  43589. * Detaches the behavior from its current arc rotate camera.
  43590. */
  43591. detach(): void;
  43592. /**
  43593. * Returns true if user is scrolling.
  43594. * @return true if user is scrolling.
  43595. */
  43596. private _userIsZooming;
  43597. private _lastFrameRadius;
  43598. private _shouldAnimationStopForInteraction;
  43599. /**
  43600. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43601. */
  43602. private _applyUserInteraction;
  43603. private _userIsMoving;
  43604. }
  43605. }
  43606. declare module "babylonjs/Behaviors/Cameras/index" {
  43607. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43608. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43609. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43610. }
  43611. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43612. import { Mesh } from "babylonjs/Meshes/mesh";
  43613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43614. import { Behavior } from "babylonjs/Behaviors/behavior";
  43615. /**
  43616. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43617. */
  43618. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43619. private ui;
  43620. /**
  43621. * The name of the behavior
  43622. */
  43623. name: string;
  43624. /**
  43625. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43626. */
  43627. distanceAwayFromFace: number;
  43628. /**
  43629. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43630. */
  43631. distanceAwayFromBottomOfFace: number;
  43632. private _faceVectors;
  43633. private _target;
  43634. private _scene;
  43635. private _onRenderObserver;
  43636. private _tmpMatrix;
  43637. private _tmpVector;
  43638. /**
  43639. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43640. * @param ui The transform node that should be attched to the mesh
  43641. */
  43642. constructor(ui: TransformNode);
  43643. /**
  43644. * Initializes the behavior
  43645. */
  43646. init(): void;
  43647. private _closestFace;
  43648. private _zeroVector;
  43649. private _lookAtTmpMatrix;
  43650. private _lookAtToRef;
  43651. /**
  43652. * Attaches the AttachToBoxBehavior to the passed in mesh
  43653. * @param target The mesh that the specified node will be attached to
  43654. */
  43655. attach(target: Mesh): void;
  43656. /**
  43657. * Detaches the behavior from the mesh
  43658. */
  43659. detach(): void;
  43660. }
  43661. }
  43662. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43663. import { Behavior } from "babylonjs/Behaviors/behavior";
  43664. import { Mesh } from "babylonjs/Meshes/mesh";
  43665. /**
  43666. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43667. */
  43668. export class FadeInOutBehavior implements Behavior<Mesh> {
  43669. /**
  43670. * Time in milliseconds to delay before fading in (Default: 0)
  43671. */
  43672. delay: number;
  43673. /**
  43674. * Time in milliseconds for the mesh to fade in (Default: 300)
  43675. */
  43676. fadeInTime: number;
  43677. private _millisecondsPerFrame;
  43678. private _hovered;
  43679. private _hoverValue;
  43680. private _ownerNode;
  43681. /**
  43682. * Instatiates the FadeInOutBehavior
  43683. */
  43684. constructor();
  43685. /**
  43686. * The name of the behavior
  43687. */
  43688. get name(): string;
  43689. /**
  43690. * Initializes the behavior
  43691. */
  43692. init(): void;
  43693. /**
  43694. * Attaches the fade behavior on the passed in mesh
  43695. * @param ownerNode The mesh that will be faded in/out once attached
  43696. */
  43697. attach(ownerNode: Mesh): void;
  43698. /**
  43699. * Detaches the behavior from the mesh
  43700. */
  43701. detach(): void;
  43702. /**
  43703. * Triggers the mesh to begin fading in or out
  43704. * @param value if the object should fade in or out (true to fade in)
  43705. */
  43706. fadeIn(value: boolean): void;
  43707. private _update;
  43708. private _setAllVisibility;
  43709. }
  43710. }
  43711. declare module "babylonjs/Misc/pivotTools" {
  43712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43713. /**
  43714. * Class containing a set of static utilities functions for managing Pivots
  43715. * @hidden
  43716. */
  43717. export class PivotTools {
  43718. private static _PivotCached;
  43719. private static _OldPivotPoint;
  43720. private static _PivotTranslation;
  43721. private static _PivotTmpVector;
  43722. /** @hidden */
  43723. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43724. /** @hidden */
  43725. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43726. }
  43727. }
  43728. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43729. import { Scene } from "babylonjs/scene";
  43730. import { Vector4 } from "babylonjs/Maths/math.vector";
  43731. import { Mesh } from "babylonjs/Meshes/mesh";
  43732. import { Nullable } from "babylonjs/types";
  43733. import { Plane } from "babylonjs/Maths/math.plane";
  43734. /**
  43735. * Class containing static functions to help procedurally build meshes
  43736. */
  43737. export class PlaneBuilder {
  43738. /**
  43739. * Creates a plane mesh
  43740. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43741. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43742. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43746. * @param name defines the name of the mesh
  43747. * @param options defines the options used to create the mesh
  43748. * @param scene defines the hosting scene
  43749. * @returns the plane mesh
  43750. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43751. */
  43752. static CreatePlane(name: string, options: {
  43753. size?: number;
  43754. width?: number;
  43755. height?: number;
  43756. sideOrientation?: number;
  43757. frontUVs?: Vector4;
  43758. backUVs?: Vector4;
  43759. updatable?: boolean;
  43760. sourcePlane?: Plane;
  43761. }, scene?: Nullable<Scene>): Mesh;
  43762. }
  43763. }
  43764. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43765. import { Behavior } from "babylonjs/Behaviors/behavior";
  43766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43767. import { Observable } from "babylonjs/Misc/observable";
  43768. import { Vector3 } from "babylonjs/Maths/math.vector";
  43769. import { Ray } from "babylonjs/Culling/ray";
  43770. import "babylonjs/Meshes/Builders/planeBuilder";
  43771. /**
  43772. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43773. */
  43774. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43775. private static _AnyMouseID;
  43776. /**
  43777. * Abstract mesh the behavior is set on
  43778. */
  43779. attachedNode: AbstractMesh;
  43780. private _dragPlane;
  43781. private _scene;
  43782. private _pointerObserver;
  43783. private _beforeRenderObserver;
  43784. private static _planeScene;
  43785. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43786. /**
  43787. * 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)
  43788. */
  43789. maxDragAngle: number;
  43790. /**
  43791. * @hidden
  43792. */
  43793. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43794. /**
  43795. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43796. */
  43797. currentDraggingPointerID: number;
  43798. /**
  43799. * The last position where the pointer hit the drag plane in world space
  43800. */
  43801. lastDragPosition: Vector3;
  43802. /**
  43803. * If the behavior is currently in a dragging state
  43804. */
  43805. dragging: boolean;
  43806. /**
  43807. * 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)
  43808. */
  43809. dragDeltaRatio: number;
  43810. /**
  43811. * If the drag plane orientation should be updated during the dragging (Default: true)
  43812. */
  43813. updateDragPlane: boolean;
  43814. private _debugMode;
  43815. private _moving;
  43816. /**
  43817. * Fires each time the attached mesh is dragged with the pointer
  43818. * * delta between last drag position and current drag position in world space
  43819. * * dragDistance along the drag axis
  43820. * * dragPlaneNormal normal of the current drag plane used during the drag
  43821. * * dragPlanePoint in world space where the drag intersects the drag plane
  43822. */
  43823. onDragObservable: Observable<{
  43824. delta: Vector3;
  43825. dragPlanePoint: Vector3;
  43826. dragPlaneNormal: Vector3;
  43827. dragDistance: number;
  43828. pointerId: number;
  43829. }>;
  43830. /**
  43831. * Fires each time a drag begins (eg. mouse down on mesh)
  43832. */
  43833. onDragStartObservable: Observable<{
  43834. dragPlanePoint: Vector3;
  43835. pointerId: number;
  43836. }>;
  43837. /**
  43838. * Fires each time a drag ends (eg. mouse release after drag)
  43839. */
  43840. onDragEndObservable: Observable<{
  43841. dragPlanePoint: Vector3;
  43842. pointerId: number;
  43843. }>;
  43844. /**
  43845. * If the attached mesh should be moved when dragged
  43846. */
  43847. moveAttached: boolean;
  43848. /**
  43849. * If the drag behavior will react to drag events (Default: true)
  43850. */
  43851. enabled: boolean;
  43852. /**
  43853. * If pointer events should start and release the drag (Default: true)
  43854. */
  43855. startAndReleaseDragOnPointerEvents: boolean;
  43856. /**
  43857. * If camera controls should be detached during the drag
  43858. */
  43859. detachCameraControls: boolean;
  43860. /**
  43861. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43862. */
  43863. useObjectOrientationForDragging: boolean;
  43864. private _options;
  43865. /**
  43866. * Gets the options used by the behavior
  43867. */
  43868. get options(): {
  43869. dragAxis?: Vector3;
  43870. dragPlaneNormal?: Vector3;
  43871. };
  43872. /**
  43873. * Sets the options used by the behavior
  43874. */
  43875. set options(options: {
  43876. dragAxis?: Vector3;
  43877. dragPlaneNormal?: Vector3;
  43878. });
  43879. /**
  43880. * Creates a pointer drag behavior that can be attached to a mesh
  43881. * @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)
  43882. */
  43883. constructor(options?: {
  43884. dragAxis?: Vector3;
  43885. dragPlaneNormal?: Vector3;
  43886. });
  43887. /**
  43888. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43889. */
  43890. validateDrag: (targetPosition: Vector3) => boolean;
  43891. /**
  43892. * The name of the behavior
  43893. */
  43894. get name(): string;
  43895. /**
  43896. * Initializes the behavior
  43897. */
  43898. init(): void;
  43899. private _tmpVector;
  43900. private _alternatePickedPoint;
  43901. private _worldDragAxis;
  43902. private _targetPosition;
  43903. private _attachedElement;
  43904. /**
  43905. * Attaches the drag behavior the passed in mesh
  43906. * @param ownerNode The mesh that will be dragged around once attached
  43907. * @param predicate Predicate to use for pick filtering
  43908. */
  43909. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43910. /**
  43911. * Force relase the drag action by code.
  43912. */
  43913. releaseDrag(): void;
  43914. private _startDragRay;
  43915. private _lastPointerRay;
  43916. /**
  43917. * Simulates the start of a pointer drag event on the behavior
  43918. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43919. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43920. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43921. */
  43922. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43923. private _startDrag;
  43924. private _dragDelta;
  43925. private _moveDrag;
  43926. private _pickWithRayOnDragPlane;
  43927. private _pointA;
  43928. private _pointB;
  43929. private _pointC;
  43930. private _lineA;
  43931. private _lineB;
  43932. private _localAxis;
  43933. private _lookAt;
  43934. private _updateDragPlanePosition;
  43935. /**
  43936. * Detaches the behavior from the mesh
  43937. */
  43938. detach(): void;
  43939. }
  43940. }
  43941. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  43942. import { Mesh } from "babylonjs/Meshes/mesh";
  43943. import { Behavior } from "babylonjs/Behaviors/behavior";
  43944. /**
  43945. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43946. */
  43947. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43948. private _dragBehaviorA;
  43949. private _dragBehaviorB;
  43950. private _startDistance;
  43951. private _initialScale;
  43952. private _targetScale;
  43953. private _ownerNode;
  43954. private _sceneRenderObserver;
  43955. /**
  43956. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43957. */
  43958. constructor();
  43959. /**
  43960. * The name of the behavior
  43961. */
  43962. get name(): string;
  43963. /**
  43964. * Initializes the behavior
  43965. */
  43966. init(): void;
  43967. private _getCurrentDistance;
  43968. /**
  43969. * Attaches the scale behavior the passed in mesh
  43970. * @param ownerNode The mesh that will be scaled around once attached
  43971. */
  43972. attach(ownerNode: Mesh): void;
  43973. /**
  43974. * Detaches the behavior from the mesh
  43975. */
  43976. detach(): void;
  43977. }
  43978. }
  43979. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  43980. import { Behavior } from "babylonjs/Behaviors/behavior";
  43981. import { Mesh } from "babylonjs/Meshes/mesh";
  43982. import { Observable } from "babylonjs/Misc/observable";
  43983. /**
  43984. * 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
  43985. */
  43986. export class SixDofDragBehavior implements Behavior<Mesh> {
  43987. private static _virtualScene;
  43988. private _ownerNode;
  43989. private _sceneRenderObserver;
  43990. private _scene;
  43991. private _targetPosition;
  43992. private _virtualOriginMesh;
  43993. private _virtualDragMesh;
  43994. private _pointerObserver;
  43995. private _moving;
  43996. private _startingOrientation;
  43997. private _attachedElement;
  43998. /**
  43999. * 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)
  44000. */
  44001. private zDragFactor;
  44002. /**
  44003. * If the object should rotate to face the drag origin
  44004. */
  44005. rotateDraggedObject: boolean;
  44006. /**
  44007. * If the behavior is currently in a dragging state
  44008. */
  44009. dragging: boolean;
  44010. /**
  44011. * 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)
  44012. */
  44013. dragDeltaRatio: number;
  44014. /**
  44015. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44016. */
  44017. currentDraggingPointerID: number;
  44018. /**
  44019. * If camera controls should be detached during the drag
  44020. */
  44021. detachCameraControls: boolean;
  44022. /**
  44023. * Fires each time a drag starts
  44024. */
  44025. onDragStartObservable: Observable<{}>;
  44026. /**
  44027. * Fires each time a drag ends (eg. mouse release after drag)
  44028. */
  44029. onDragEndObservable: Observable<{}>;
  44030. /**
  44031. * 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
  44032. */
  44033. constructor();
  44034. /**
  44035. * The name of the behavior
  44036. */
  44037. get name(): string;
  44038. /**
  44039. * Initializes the behavior
  44040. */
  44041. init(): void;
  44042. /**
  44043. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44044. */
  44045. private get _pointerCamera();
  44046. /**
  44047. * Attaches the scale behavior the passed in mesh
  44048. * @param ownerNode The mesh that will be scaled around once attached
  44049. */
  44050. attach(ownerNode: Mesh): void;
  44051. /**
  44052. * Detaches the behavior from the mesh
  44053. */
  44054. detach(): void;
  44055. }
  44056. }
  44057. declare module "babylonjs/Behaviors/Meshes/index" {
  44058. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44059. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44060. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44061. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44062. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44063. }
  44064. declare module "babylonjs/Behaviors/index" {
  44065. export * from "babylonjs/Behaviors/behavior";
  44066. export * from "babylonjs/Behaviors/Cameras/index";
  44067. export * from "babylonjs/Behaviors/Meshes/index";
  44068. }
  44069. declare module "babylonjs/Bones/boneIKController" {
  44070. import { Bone } from "babylonjs/Bones/bone";
  44071. import { Vector3 } from "babylonjs/Maths/math.vector";
  44072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44073. import { Nullable } from "babylonjs/types";
  44074. /**
  44075. * Class used to apply inverse kinematics to bones
  44076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44077. */
  44078. export class BoneIKController {
  44079. private static _tmpVecs;
  44080. private static _tmpQuat;
  44081. private static _tmpMats;
  44082. /**
  44083. * Gets or sets the target mesh
  44084. */
  44085. targetMesh: AbstractMesh;
  44086. /** Gets or sets the mesh used as pole */
  44087. poleTargetMesh: AbstractMesh;
  44088. /**
  44089. * Gets or sets the bone used as pole
  44090. */
  44091. poleTargetBone: Nullable<Bone>;
  44092. /**
  44093. * Gets or sets the target position
  44094. */
  44095. targetPosition: Vector3;
  44096. /**
  44097. * Gets or sets the pole target position
  44098. */
  44099. poleTargetPosition: Vector3;
  44100. /**
  44101. * Gets or sets the pole target local offset
  44102. */
  44103. poleTargetLocalOffset: Vector3;
  44104. /**
  44105. * Gets or sets the pole angle
  44106. */
  44107. poleAngle: number;
  44108. /**
  44109. * Gets or sets the mesh associated with the controller
  44110. */
  44111. mesh: AbstractMesh;
  44112. /**
  44113. * 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)
  44114. */
  44115. slerpAmount: number;
  44116. private _bone1Quat;
  44117. private _bone1Mat;
  44118. private _bone2Ang;
  44119. private _bone1;
  44120. private _bone2;
  44121. private _bone1Length;
  44122. private _bone2Length;
  44123. private _maxAngle;
  44124. private _maxReach;
  44125. private _rightHandedSystem;
  44126. private _bendAxis;
  44127. private _slerping;
  44128. private _adjustRoll;
  44129. /**
  44130. * Gets or sets maximum allowed angle
  44131. */
  44132. get maxAngle(): number;
  44133. set maxAngle(value: number);
  44134. /**
  44135. * Creates a new BoneIKController
  44136. * @param mesh defines the mesh to control
  44137. * @param bone defines the bone to control
  44138. * @param options defines options to set up the controller
  44139. */
  44140. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44141. targetMesh?: AbstractMesh;
  44142. poleTargetMesh?: AbstractMesh;
  44143. poleTargetBone?: Bone;
  44144. poleTargetLocalOffset?: Vector3;
  44145. poleAngle?: number;
  44146. bendAxis?: Vector3;
  44147. maxAngle?: number;
  44148. slerpAmount?: number;
  44149. });
  44150. private _setMaxAngle;
  44151. /**
  44152. * Force the controller to update the bones
  44153. */
  44154. update(): void;
  44155. }
  44156. }
  44157. declare module "babylonjs/Bones/boneLookController" {
  44158. import { Vector3 } from "babylonjs/Maths/math.vector";
  44159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44160. import { Bone } from "babylonjs/Bones/bone";
  44161. import { Space } from "babylonjs/Maths/math.axis";
  44162. /**
  44163. * Class used to make a bone look toward a point in space
  44164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44165. */
  44166. export class BoneLookController {
  44167. private static _tmpVecs;
  44168. private static _tmpQuat;
  44169. private static _tmpMats;
  44170. /**
  44171. * The target Vector3 that the bone will look at
  44172. */
  44173. target: Vector3;
  44174. /**
  44175. * The mesh that the bone is attached to
  44176. */
  44177. mesh: AbstractMesh;
  44178. /**
  44179. * The bone that will be looking to the target
  44180. */
  44181. bone: Bone;
  44182. /**
  44183. * The up axis of the coordinate system that is used when the bone is rotated
  44184. */
  44185. upAxis: Vector3;
  44186. /**
  44187. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44188. */
  44189. upAxisSpace: Space;
  44190. /**
  44191. * Used to make an adjustment to the yaw of the bone
  44192. */
  44193. adjustYaw: number;
  44194. /**
  44195. * Used to make an adjustment to the pitch of the bone
  44196. */
  44197. adjustPitch: number;
  44198. /**
  44199. * Used to make an adjustment to the roll of the bone
  44200. */
  44201. adjustRoll: number;
  44202. /**
  44203. * 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)
  44204. */
  44205. slerpAmount: number;
  44206. private _minYaw;
  44207. private _maxYaw;
  44208. private _minPitch;
  44209. private _maxPitch;
  44210. private _minYawSin;
  44211. private _minYawCos;
  44212. private _maxYawSin;
  44213. private _maxYawCos;
  44214. private _midYawConstraint;
  44215. private _minPitchTan;
  44216. private _maxPitchTan;
  44217. private _boneQuat;
  44218. private _slerping;
  44219. private _transformYawPitch;
  44220. private _transformYawPitchInv;
  44221. private _firstFrameSkipped;
  44222. private _yawRange;
  44223. private _fowardAxis;
  44224. /**
  44225. * Gets or sets the minimum yaw angle that the bone can look to
  44226. */
  44227. get minYaw(): number;
  44228. set minYaw(value: number);
  44229. /**
  44230. * Gets or sets the maximum yaw angle that the bone can look to
  44231. */
  44232. get maxYaw(): number;
  44233. set maxYaw(value: number);
  44234. /**
  44235. * Gets or sets the minimum pitch angle that the bone can look to
  44236. */
  44237. get minPitch(): number;
  44238. set minPitch(value: number);
  44239. /**
  44240. * Gets or sets the maximum pitch angle that the bone can look to
  44241. */
  44242. get maxPitch(): number;
  44243. set maxPitch(value: number);
  44244. /**
  44245. * Create a BoneLookController
  44246. * @param mesh the mesh that the bone belongs to
  44247. * @param bone the bone that will be looking to the target
  44248. * @param target the target Vector3 to look at
  44249. * @param options optional settings:
  44250. * * maxYaw: the maximum angle the bone will yaw to
  44251. * * minYaw: the minimum angle the bone will yaw to
  44252. * * maxPitch: the maximum angle the bone will pitch to
  44253. * * minPitch: the minimum angle the bone will yaw to
  44254. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44255. * * upAxis: the up axis of the coordinate system
  44256. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44257. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44258. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44259. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44260. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44261. * * adjustRoll: used to make an adjustment to the roll of the bone
  44262. **/
  44263. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44264. maxYaw?: number;
  44265. minYaw?: number;
  44266. maxPitch?: number;
  44267. minPitch?: number;
  44268. slerpAmount?: number;
  44269. upAxis?: Vector3;
  44270. upAxisSpace?: Space;
  44271. yawAxis?: Vector3;
  44272. pitchAxis?: Vector3;
  44273. adjustYaw?: number;
  44274. adjustPitch?: number;
  44275. adjustRoll?: number;
  44276. });
  44277. /**
  44278. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44279. */
  44280. update(): void;
  44281. private _getAngleDiff;
  44282. private _getAngleBetween;
  44283. private _isAngleBetween;
  44284. }
  44285. }
  44286. declare module "babylonjs/Bones/index" {
  44287. export * from "babylonjs/Bones/bone";
  44288. export * from "babylonjs/Bones/boneIKController";
  44289. export * from "babylonjs/Bones/boneLookController";
  44290. export * from "babylonjs/Bones/skeleton";
  44291. }
  44292. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44293. import { Nullable } from "babylonjs/types";
  44294. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44295. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44296. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44297. /**
  44298. * Manage the gamepad inputs to control an arc rotate camera.
  44299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44300. */
  44301. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44302. /**
  44303. * Defines the camera the input is attached to.
  44304. */
  44305. camera: ArcRotateCamera;
  44306. /**
  44307. * Defines the gamepad the input is gathering event from.
  44308. */
  44309. gamepad: Nullable<Gamepad>;
  44310. /**
  44311. * Defines the gamepad rotation sensiblity.
  44312. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44313. */
  44314. gamepadRotationSensibility: number;
  44315. /**
  44316. * Defines the gamepad move sensiblity.
  44317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44318. */
  44319. gamepadMoveSensibility: number;
  44320. private _yAxisScale;
  44321. /**
  44322. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44323. */
  44324. get invertYAxis(): boolean;
  44325. set invertYAxis(value: boolean);
  44326. private _onGamepadConnectedObserver;
  44327. private _onGamepadDisconnectedObserver;
  44328. /**
  44329. * Attach the input controls to a specific dom element to get the input from.
  44330. * @param element Defines the element the controls should be listened from
  44331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44332. */
  44333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44334. /**
  44335. * Detach the current controls from the specified dom element.
  44336. * @param element Defines the element to stop listening the inputs from
  44337. */
  44338. detachControl(element: Nullable<HTMLElement>): void;
  44339. /**
  44340. * Update the current camera state depending on the inputs that have been used this frame.
  44341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44342. */
  44343. checkInputs(): void;
  44344. /**
  44345. * Gets the class name of the current intput.
  44346. * @returns the class name
  44347. */
  44348. getClassName(): string;
  44349. /**
  44350. * Get the friendly name associated with the input class.
  44351. * @returns the input friendly name
  44352. */
  44353. getSimpleName(): string;
  44354. }
  44355. }
  44356. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44357. import { Nullable } from "babylonjs/types";
  44358. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44359. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44360. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44361. interface ArcRotateCameraInputsManager {
  44362. /**
  44363. * Add orientation input support to the input manager.
  44364. * @returns the current input manager
  44365. */
  44366. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44367. }
  44368. }
  44369. /**
  44370. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44371. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44372. */
  44373. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44374. /**
  44375. * Defines the camera the input is attached to.
  44376. */
  44377. camera: ArcRotateCamera;
  44378. /**
  44379. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44380. */
  44381. alphaCorrection: number;
  44382. /**
  44383. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44384. */
  44385. gammaCorrection: number;
  44386. private _alpha;
  44387. private _gamma;
  44388. private _dirty;
  44389. private _deviceOrientationHandler;
  44390. /**
  44391. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44392. */
  44393. constructor();
  44394. /**
  44395. * Attach the input controls to a specific dom element to get the input from.
  44396. * @param element Defines the element the controls should be listened from
  44397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44398. */
  44399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44400. /** @hidden */
  44401. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44402. /**
  44403. * Update the current camera state depending on the inputs that have been used this frame.
  44404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44405. */
  44406. checkInputs(): void;
  44407. /**
  44408. * Detach the current controls from the specified dom element.
  44409. * @param element Defines the element to stop listening the inputs from
  44410. */
  44411. detachControl(element: Nullable<HTMLElement>): void;
  44412. /**
  44413. * Gets the class name of the current intput.
  44414. * @returns the class name
  44415. */
  44416. getClassName(): string;
  44417. /**
  44418. * Get the friendly name associated with the input class.
  44419. * @returns the input friendly name
  44420. */
  44421. getSimpleName(): string;
  44422. }
  44423. }
  44424. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44425. import { Nullable } from "babylonjs/types";
  44426. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44427. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44428. /**
  44429. * Listen to mouse events to control the camera.
  44430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44431. */
  44432. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44433. /**
  44434. * Defines the camera the input is attached to.
  44435. */
  44436. camera: FlyCamera;
  44437. /**
  44438. * Defines if touch is enabled. (Default is true.)
  44439. */
  44440. touchEnabled: boolean;
  44441. /**
  44442. * Defines the buttons associated with the input to handle camera rotation.
  44443. */
  44444. buttons: number[];
  44445. /**
  44446. * Assign buttons for Yaw control.
  44447. */
  44448. buttonsYaw: number[];
  44449. /**
  44450. * Assign buttons for Pitch control.
  44451. */
  44452. buttonsPitch: number[];
  44453. /**
  44454. * Assign buttons for Roll control.
  44455. */
  44456. buttonsRoll: number[];
  44457. /**
  44458. * Detect if any button is being pressed while mouse is moved.
  44459. * -1 = Mouse locked.
  44460. * 0 = Left button.
  44461. * 1 = Middle Button.
  44462. * 2 = Right Button.
  44463. */
  44464. activeButton: number;
  44465. /**
  44466. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44467. * Higher values reduce its sensitivity.
  44468. */
  44469. angularSensibility: number;
  44470. private _mousemoveCallback;
  44471. private _observer;
  44472. private _rollObserver;
  44473. private previousPosition;
  44474. private noPreventDefault;
  44475. private element;
  44476. /**
  44477. * Listen to mouse events to control the camera.
  44478. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44480. */
  44481. constructor(touchEnabled?: boolean);
  44482. /**
  44483. * Attach the mouse control to the HTML DOM element.
  44484. * @param element Defines the element that listens to the input events.
  44485. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44486. */
  44487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44488. /**
  44489. * Detach the current controls from the specified dom element.
  44490. * @param element Defines the element to stop listening the inputs from
  44491. */
  44492. detachControl(element: Nullable<HTMLElement>): void;
  44493. /**
  44494. * Gets the class name of the current input.
  44495. * @returns the class name.
  44496. */
  44497. getClassName(): string;
  44498. /**
  44499. * Get the friendly name associated with the input class.
  44500. * @returns the input's friendly name.
  44501. */
  44502. getSimpleName(): string;
  44503. private _pointerInput;
  44504. private _onMouseMove;
  44505. /**
  44506. * Rotate camera by mouse offset.
  44507. */
  44508. private rotateCamera;
  44509. }
  44510. }
  44511. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44512. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44513. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44514. /**
  44515. * Default Inputs manager for the FlyCamera.
  44516. * It groups all the default supported inputs for ease of use.
  44517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44518. */
  44519. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44520. /**
  44521. * Instantiates a new FlyCameraInputsManager.
  44522. * @param camera Defines the camera the inputs belong to.
  44523. */
  44524. constructor(camera: FlyCamera);
  44525. /**
  44526. * Add keyboard input support to the input manager.
  44527. * @returns the new FlyCameraKeyboardMoveInput().
  44528. */
  44529. addKeyboard(): FlyCameraInputsManager;
  44530. /**
  44531. * Add mouse input support to the input manager.
  44532. * @param touchEnabled Enable touch screen support.
  44533. * @returns the new FlyCameraMouseInput().
  44534. */
  44535. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44536. }
  44537. }
  44538. declare module "babylonjs/Cameras/flyCamera" {
  44539. import { Scene } from "babylonjs/scene";
  44540. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44542. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44543. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44544. /**
  44545. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44546. * such as in a 3D Space Shooter or a Flight Simulator.
  44547. */
  44548. export class FlyCamera extends TargetCamera {
  44549. /**
  44550. * Define the collision ellipsoid of the camera.
  44551. * This is helpful for simulating a camera body, like a player's body.
  44552. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44553. */
  44554. ellipsoid: Vector3;
  44555. /**
  44556. * Define an offset for the position of the ellipsoid around the camera.
  44557. * This can be helpful if the camera is attached away from the player's body center,
  44558. * such as at its head.
  44559. */
  44560. ellipsoidOffset: Vector3;
  44561. /**
  44562. * Enable or disable collisions of the camera with the rest of the scene objects.
  44563. */
  44564. checkCollisions: boolean;
  44565. /**
  44566. * Enable or disable gravity on the camera.
  44567. */
  44568. applyGravity: boolean;
  44569. /**
  44570. * Define the current direction the camera is moving to.
  44571. */
  44572. cameraDirection: Vector3;
  44573. /**
  44574. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44575. * This overrides and empties cameraRotation.
  44576. */
  44577. rotationQuaternion: Quaternion;
  44578. /**
  44579. * Track Roll to maintain the wanted Rolling when looking around.
  44580. */
  44581. _trackRoll: number;
  44582. /**
  44583. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44584. */
  44585. rollCorrect: number;
  44586. /**
  44587. * Mimic a banked turn, Rolling the camera when Yawing.
  44588. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44589. */
  44590. bankedTurn: boolean;
  44591. /**
  44592. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44593. */
  44594. bankedTurnLimit: number;
  44595. /**
  44596. * Value of 0 disables the banked Roll.
  44597. * Value of 1 is equal to the Yaw angle in radians.
  44598. */
  44599. bankedTurnMultiplier: number;
  44600. /**
  44601. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44602. */
  44603. inputs: FlyCameraInputsManager;
  44604. /**
  44605. * Gets the input sensibility for mouse input.
  44606. * Higher values reduce sensitivity.
  44607. */
  44608. get angularSensibility(): number;
  44609. /**
  44610. * Sets the input sensibility for a mouse input.
  44611. * Higher values reduce sensitivity.
  44612. */
  44613. set angularSensibility(value: number);
  44614. /**
  44615. * Get the keys for camera movement forward.
  44616. */
  44617. get keysForward(): number[];
  44618. /**
  44619. * Set the keys for camera movement forward.
  44620. */
  44621. set keysForward(value: number[]);
  44622. /**
  44623. * Get the keys for camera movement backward.
  44624. */
  44625. get keysBackward(): number[];
  44626. set keysBackward(value: number[]);
  44627. /**
  44628. * Get the keys for camera movement up.
  44629. */
  44630. get keysUp(): number[];
  44631. /**
  44632. * Set the keys for camera movement up.
  44633. */
  44634. set keysUp(value: number[]);
  44635. /**
  44636. * Get the keys for camera movement down.
  44637. */
  44638. get keysDown(): number[];
  44639. /**
  44640. * Set the keys for camera movement down.
  44641. */
  44642. set keysDown(value: number[]);
  44643. /**
  44644. * Get the keys for camera movement left.
  44645. */
  44646. get keysLeft(): number[];
  44647. /**
  44648. * Set the keys for camera movement left.
  44649. */
  44650. set keysLeft(value: number[]);
  44651. /**
  44652. * Set the keys for camera movement right.
  44653. */
  44654. get keysRight(): number[];
  44655. /**
  44656. * Set the keys for camera movement right.
  44657. */
  44658. set keysRight(value: number[]);
  44659. /**
  44660. * Event raised when the camera collides with a mesh in the scene.
  44661. */
  44662. onCollide: (collidedMesh: AbstractMesh) => void;
  44663. private _collider;
  44664. private _needMoveForGravity;
  44665. private _oldPosition;
  44666. private _diffPosition;
  44667. private _newPosition;
  44668. /** @hidden */
  44669. _localDirection: Vector3;
  44670. /** @hidden */
  44671. _transformedDirection: Vector3;
  44672. /**
  44673. * Instantiates a FlyCamera.
  44674. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44675. * such as in a 3D Space Shooter or a Flight Simulator.
  44676. * @param name Define the name of the camera in the scene.
  44677. * @param position Define the starting position of the camera in the scene.
  44678. * @param scene Define the scene the camera belongs to.
  44679. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44680. */
  44681. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44682. /**
  44683. * Attach a control to the HTML DOM element.
  44684. * @param element Defines the element that listens to the input events.
  44685. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44686. */
  44687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44688. /**
  44689. * Detach a control from the HTML DOM element.
  44690. * The camera will stop reacting to that input.
  44691. * @param element Defines the element that listens to the input events.
  44692. */
  44693. detachControl(element: HTMLElement): void;
  44694. private _collisionMask;
  44695. /**
  44696. * Get the mask that the camera ignores in collision events.
  44697. */
  44698. get collisionMask(): number;
  44699. /**
  44700. * Set the mask that the camera ignores in collision events.
  44701. */
  44702. set collisionMask(mask: number);
  44703. /** @hidden */
  44704. _collideWithWorld(displacement: Vector3): void;
  44705. /** @hidden */
  44706. private _onCollisionPositionChange;
  44707. /** @hidden */
  44708. _checkInputs(): void;
  44709. /** @hidden */
  44710. _decideIfNeedsToMove(): boolean;
  44711. /** @hidden */
  44712. _updatePosition(): void;
  44713. /**
  44714. * Restore the Roll to its target value at the rate specified.
  44715. * @param rate - Higher means slower restoring.
  44716. * @hidden
  44717. */
  44718. restoreRoll(rate: number): void;
  44719. /**
  44720. * Destroy the camera and release the current resources held by it.
  44721. */
  44722. dispose(): void;
  44723. /**
  44724. * Get the current object class name.
  44725. * @returns the class name.
  44726. */
  44727. getClassName(): string;
  44728. }
  44729. }
  44730. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44731. import { Nullable } from "babylonjs/types";
  44732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44733. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44734. /**
  44735. * Listen to keyboard events to control the camera.
  44736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44737. */
  44738. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44739. /**
  44740. * Defines the camera the input is attached to.
  44741. */
  44742. camera: FlyCamera;
  44743. /**
  44744. * The list of keyboard keys used to control the forward move of the camera.
  44745. */
  44746. keysForward: number[];
  44747. /**
  44748. * The list of keyboard keys used to control the backward move of the camera.
  44749. */
  44750. keysBackward: number[];
  44751. /**
  44752. * The list of keyboard keys used to control the forward move of the camera.
  44753. */
  44754. keysUp: number[];
  44755. /**
  44756. * The list of keyboard keys used to control the backward move of the camera.
  44757. */
  44758. keysDown: number[];
  44759. /**
  44760. * The list of keyboard keys used to control the right strafe move of the camera.
  44761. */
  44762. keysRight: number[];
  44763. /**
  44764. * The list of keyboard keys used to control the left strafe move of the camera.
  44765. */
  44766. keysLeft: number[];
  44767. private _keys;
  44768. private _onCanvasBlurObserver;
  44769. private _onKeyboardObserver;
  44770. private _engine;
  44771. private _scene;
  44772. /**
  44773. * Attach the input controls to a specific dom element to get the input from.
  44774. * @param element Defines the element the controls should be listened from
  44775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44776. */
  44777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44778. /**
  44779. * Detach the current controls from the specified dom element.
  44780. * @param element Defines the element to stop listening the inputs from
  44781. */
  44782. detachControl(element: Nullable<HTMLElement>): void;
  44783. /**
  44784. * Gets the class name of the current intput.
  44785. * @returns the class name
  44786. */
  44787. getClassName(): string;
  44788. /** @hidden */
  44789. _onLostFocus(e: FocusEvent): void;
  44790. /**
  44791. * Get the friendly name associated with the input class.
  44792. * @returns the input friendly name
  44793. */
  44794. getSimpleName(): string;
  44795. /**
  44796. * Update the current camera state depending on the inputs that have been used this frame.
  44797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44798. */
  44799. checkInputs(): void;
  44800. }
  44801. }
  44802. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44803. import { Nullable } from "babylonjs/types";
  44804. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44805. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44806. /**
  44807. * Manage the mouse wheel inputs to control a follow camera.
  44808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44809. */
  44810. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44811. /**
  44812. * Defines the camera the input is attached to.
  44813. */
  44814. camera: FollowCamera;
  44815. /**
  44816. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44817. */
  44818. axisControlRadius: boolean;
  44819. /**
  44820. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44821. */
  44822. axisControlHeight: boolean;
  44823. /**
  44824. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44825. */
  44826. axisControlRotation: boolean;
  44827. /**
  44828. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44829. * relation to mouseWheel events.
  44830. */
  44831. wheelPrecision: number;
  44832. /**
  44833. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44834. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44835. */
  44836. wheelDeltaPercentage: number;
  44837. private _wheel;
  44838. private _observer;
  44839. /**
  44840. * Attach the input controls to a specific dom element to get the input from.
  44841. * @param element Defines the element the controls should be listened from
  44842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44843. */
  44844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44845. /**
  44846. * Detach the current controls from the specified dom element.
  44847. * @param element Defines the element to stop listening the inputs from
  44848. */
  44849. detachControl(element: Nullable<HTMLElement>): void;
  44850. /**
  44851. * Gets the class name of the current intput.
  44852. * @returns the class name
  44853. */
  44854. getClassName(): string;
  44855. /**
  44856. * Get the friendly name associated with the input class.
  44857. * @returns the input friendly name
  44858. */
  44859. getSimpleName(): string;
  44860. }
  44861. }
  44862. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44863. import { Nullable } from "babylonjs/types";
  44864. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44865. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44866. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44867. /**
  44868. * Manage the pointers inputs to control an follow camera.
  44869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44870. */
  44871. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44872. /**
  44873. * Defines the camera the input is attached to.
  44874. */
  44875. camera: FollowCamera;
  44876. /**
  44877. * Gets the class name of the current input.
  44878. * @returns the class name
  44879. */
  44880. getClassName(): string;
  44881. /**
  44882. * Defines the pointer angular sensibility along the X axis or how fast is
  44883. * the camera rotating.
  44884. * A negative number will reverse the axis direction.
  44885. */
  44886. angularSensibilityX: number;
  44887. /**
  44888. * Defines the pointer angular sensibility along the Y axis or how fast is
  44889. * the camera rotating.
  44890. * A negative number will reverse the axis direction.
  44891. */
  44892. angularSensibilityY: number;
  44893. /**
  44894. * Defines the pointer pinch precision or how fast is the camera zooming.
  44895. * A negative number will reverse the axis direction.
  44896. */
  44897. pinchPrecision: number;
  44898. /**
  44899. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44900. * from 0.
  44901. * It defines the percentage of current camera.radius to use as delta when
  44902. * pinch zoom is used.
  44903. */
  44904. pinchDeltaPercentage: number;
  44905. /**
  44906. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44907. */
  44908. axisXControlRadius: boolean;
  44909. /**
  44910. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44911. */
  44912. axisXControlHeight: boolean;
  44913. /**
  44914. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44915. */
  44916. axisXControlRotation: boolean;
  44917. /**
  44918. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44919. */
  44920. axisYControlRadius: boolean;
  44921. /**
  44922. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44923. */
  44924. axisYControlHeight: boolean;
  44925. /**
  44926. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44927. */
  44928. axisYControlRotation: boolean;
  44929. /**
  44930. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44931. */
  44932. axisPinchControlRadius: boolean;
  44933. /**
  44934. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44935. */
  44936. axisPinchControlHeight: boolean;
  44937. /**
  44938. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44939. */
  44940. axisPinchControlRotation: boolean;
  44941. /**
  44942. * Log error messages if basic misconfiguration has occurred.
  44943. */
  44944. warningEnable: boolean;
  44945. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44946. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44947. private _warningCounter;
  44948. private _warning;
  44949. }
  44950. }
  44951. declare module "babylonjs/Cameras/followCameraInputsManager" {
  44952. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44953. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44954. /**
  44955. * Default Inputs manager for the FollowCamera.
  44956. * It groups all the default supported inputs for ease of use.
  44957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44958. */
  44959. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44960. /**
  44961. * Instantiates a new FollowCameraInputsManager.
  44962. * @param camera Defines the camera the inputs belong to
  44963. */
  44964. constructor(camera: FollowCamera);
  44965. /**
  44966. * Add keyboard input support to the input manager.
  44967. * @returns the current input manager
  44968. */
  44969. addKeyboard(): FollowCameraInputsManager;
  44970. /**
  44971. * Add mouse wheel input support to the input manager.
  44972. * @returns the current input manager
  44973. */
  44974. addMouseWheel(): FollowCameraInputsManager;
  44975. /**
  44976. * Add pointers input support to the input manager.
  44977. * @returns the current input manager
  44978. */
  44979. addPointers(): FollowCameraInputsManager;
  44980. /**
  44981. * Add orientation input support to the input manager.
  44982. * @returns the current input manager
  44983. */
  44984. addVRDeviceOrientation(): FollowCameraInputsManager;
  44985. }
  44986. }
  44987. declare module "babylonjs/Cameras/followCamera" {
  44988. import { Nullable } from "babylonjs/types";
  44989. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44990. import { Scene } from "babylonjs/scene";
  44991. import { Vector3 } from "babylonjs/Maths/math.vector";
  44992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44993. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  44994. /**
  44995. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44996. * an arc rotate version arcFollowCamera are available.
  44997. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  44998. */
  44999. export class FollowCamera extends TargetCamera {
  45000. /**
  45001. * Distance the follow camera should follow an object at
  45002. */
  45003. radius: number;
  45004. /**
  45005. * Minimum allowed distance of the camera to the axis of rotation
  45006. * (The camera can not get closer).
  45007. * This can help limiting how the Camera is able to move in the scene.
  45008. */
  45009. lowerRadiusLimit: Nullable<number>;
  45010. /**
  45011. * Maximum allowed distance of the camera to the axis of rotation
  45012. * (The camera can not get further).
  45013. * This can help limiting how the Camera is able to move in the scene.
  45014. */
  45015. upperRadiusLimit: Nullable<number>;
  45016. /**
  45017. * Define a rotation offset between the camera and the object it follows
  45018. */
  45019. rotationOffset: number;
  45020. /**
  45021. * Minimum allowed angle to camera position relative to target object.
  45022. * This can help limiting how the Camera is able to move in the scene.
  45023. */
  45024. lowerRotationOffsetLimit: Nullable<number>;
  45025. /**
  45026. * Maximum allowed angle to camera position relative to target object.
  45027. * This can help limiting how the Camera is able to move in the scene.
  45028. */
  45029. upperRotationOffsetLimit: Nullable<number>;
  45030. /**
  45031. * Define a height offset between the camera and the object it follows.
  45032. * It can help following an object from the top (like a car chaing a plane)
  45033. */
  45034. heightOffset: number;
  45035. /**
  45036. * Minimum allowed height of camera position relative to target object.
  45037. * This can help limiting how the Camera is able to move in the scene.
  45038. */
  45039. lowerHeightOffsetLimit: Nullable<number>;
  45040. /**
  45041. * Maximum allowed height of camera position relative to target object.
  45042. * This can help limiting how the Camera is able to move in the scene.
  45043. */
  45044. upperHeightOffsetLimit: Nullable<number>;
  45045. /**
  45046. * Define how fast the camera can accelerate to follow it s target.
  45047. */
  45048. cameraAcceleration: number;
  45049. /**
  45050. * Define the speed limit of the camera following an object.
  45051. */
  45052. maxCameraSpeed: number;
  45053. /**
  45054. * Define the target of the camera.
  45055. */
  45056. lockedTarget: Nullable<AbstractMesh>;
  45057. /**
  45058. * Defines the input associated with the camera.
  45059. */
  45060. inputs: FollowCameraInputsManager;
  45061. /**
  45062. * Instantiates the follow camera.
  45063. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45064. * @param name Define the name of the camera in the scene
  45065. * @param position Define the position of the camera
  45066. * @param scene Define the scene the camera belong to
  45067. * @param lockedTarget Define the target of the camera
  45068. */
  45069. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45070. private _follow;
  45071. /**
  45072. * Attached controls to the current camera.
  45073. * @param element Defines the element the controls should be listened from
  45074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45075. */
  45076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45077. /**
  45078. * Detach the current controls from the camera.
  45079. * The camera will stop reacting to inputs.
  45080. * @param element Defines the element to stop listening the inputs from
  45081. */
  45082. detachControl(element: HTMLElement): void;
  45083. /** @hidden */
  45084. _checkInputs(): void;
  45085. private _checkLimits;
  45086. /**
  45087. * Gets the camera class name.
  45088. * @returns the class name
  45089. */
  45090. getClassName(): string;
  45091. }
  45092. /**
  45093. * Arc Rotate version of the follow camera.
  45094. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45095. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45096. */
  45097. export class ArcFollowCamera extends TargetCamera {
  45098. /** The longitudinal angle of the camera */
  45099. alpha: number;
  45100. /** The latitudinal angle of the camera */
  45101. beta: number;
  45102. /** The radius of the camera from its target */
  45103. radius: number;
  45104. /** Define the camera target (the mesh it should follow) */
  45105. target: Nullable<AbstractMesh>;
  45106. private _cartesianCoordinates;
  45107. /**
  45108. * Instantiates a new ArcFollowCamera
  45109. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45110. * @param name Define the name of the camera
  45111. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45112. * @param beta Define the rotation angle of the camera around the elevation axis
  45113. * @param radius Define the radius of the camera from its target point
  45114. * @param target Define the target of the camera
  45115. * @param scene Define the scene the camera belongs to
  45116. */
  45117. constructor(name: string,
  45118. /** The longitudinal angle of the camera */
  45119. alpha: number,
  45120. /** The latitudinal angle of the camera */
  45121. beta: number,
  45122. /** The radius of the camera from its target */
  45123. radius: number,
  45124. /** Define the camera target (the mesh it should follow) */
  45125. target: Nullable<AbstractMesh>, scene: Scene);
  45126. private _follow;
  45127. /** @hidden */
  45128. _checkInputs(): void;
  45129. /**
  45130. * Returns the class name of the object.
  45131. * It is mostly used internally for serialization purposes.
  45132. */
  45133. getClassName(): string;
  45134. }
  45135. }
  45136. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45137. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45138. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45139. import { Nullable } from "babylonjs/types";
  45140. /**
  45141. * Manage the keyboard inputs to control the movement of a follow camera.
  45142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45143. */
  45144. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45145. /**
  45146. * Defines the camera the input is attached to.
  45147. */
  45148. camera: FollowCamera;
  45149. /**
  45150. * Defines the list of key codes associated with the up action (increase heightOffset)
  45151. */
  45152. keysHeightOffsetIncr: number[];
  45153. /**
  45154. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45155. */
  45156. keysHeightOffsetDecr: number[];
  45157. /**
  45158. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45159. */
  45160. keysHeightOffsetModifierAlt: boolean;
  45161. /**
  45162. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45163. */
  45164. keysHeightOffsetModifierCtrl: boolean;
  45165. /**
  45166. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45167. */
  45168. keysHeightOffsetModifierShift: boolean;
  45169. /**
  45170. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45171. */
  45172. keysRotationOffsetIncr: number[];
  45173. /**
  45174. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45175. */
  45176. keysRotationOffsetDecr: number[];
  45177. /**
  45178. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45179. */
  45180. keysRotationOffsetModifierAlt: boolean;
  45181. /**
  45182. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45183. */
  45184. keysRotationOffsetModifierCtrl: boolean;
  45185. /**
  45186. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45187. */
  45188. keysRotationOffsetModifierShift: boolean;
  45189. /**
  45190. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45191. */
  45192. keysRadiusIncr: number[];
  45193. /**
  45194. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45195. */
  45196. keysRadiusDecr: number[];
  45197. /**
  45198. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45199. */
  45200. keysRadiusModifierAlt: boolean;
  45201. /**
  45202. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45203. */
  45204. keysRadiusModifierCtrl: boolean;
  45205. /**
  45206. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45207. */
  45208. keysRadiusModifierShift: boolean;
  45209. /**
  45210. * Defines the rate of change of heightOffset.
  45211. */
  45212. heightSensibility: number;
  45213. /**
  45214. * Defines the rate of change of rotationOffset.
  45215. */
  45216. rotationSensibility: number;
  45217. /**
  45218. * Defines the rate of change of radius.
  45219. */
  45220. radiusSensibility: number;
  45221. private _keys;
  45222. private _ctrlPressed;
  45223. private _altPressed;
  45224. private _shiftPressed;
  45225. private _onCanvasBlurObserver;
  45226. private _onKeyboardObserver;
  45227. private _engine;
  45228. private _scene;
  45229. /**
  45230. * Attach the input controls to a specific dom element to get the input from.
  45231. * @param element Defines the element the controls should be listened from
  45232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45233. */
  45234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45235. /**
  45236. * Detach the current controls from the specified dom element.
  45237. * @param element Defines the element to stop listening the inputs from
  45238. */
  45239. detachControl(element: Nullable<HTMLElement>): void;
  45240. /**
  45241. * Update the current camera state depending on the inputs that have been used this frame.
  45242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45243. */
  45244. checkInputs(): void;
  45245. /**
  45246. * Gets the class name of the current input.
  45247. * @returns the class name
  45248. */
  45249. getClassName(): string;
  45250. /**
  45251. * Get the friendly name associated with the input class.
  45252. * @returns the input friendly name
  45253. */
  45254. getSimpleName(): string;
  45255. /**
  45256. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45257. * allow modification of the heightOffset value.
  45258. */
  45259. private _modifierHeightOffset;
  45260. /**
  45261. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45262. * allow modification of the rotationOffset value.
  45263. */
  45264. private _modifierRotationOffset;
  45265. /**
  45266. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45267. * allow modification of the radius value.
  45268. */
  45269. private _modifierRadius;
  45270. }
  45271. }
  45272. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45273. import { Nullable } from "babylonjs/types";
  45274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45276. import { Observable } from "babylonjs/Misc/observable";
  45277. module "babylonjs/Cameras/freeCameraInputsManager" {
  45278. interface FreeCameraInputsManager {
  45279. /**
  45280. * @hidden
  45281. */
  45282. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45283. /**
  45284. * Add orientation input support to the input manager.
  45285. * @returns the current input manager
  45286. */
  45287. addDeviceOrientation(): FreeCameraInputsManager;
  45288. }
  45289. }
  45290. /**
  45291. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45292. * Screen rotation is taken into account.
  45293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45294. */
  45295. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45296. private _camera;
  45297. private _screenOrientationAngle;
  45298. private _constantTranform;
  45299. private _screenQuaternion;
  45300. private _alpha;
  45301. private _beta;
  45302. private _gamma;
  45303. /**
  45304. * Can be used to detect if a device orientation sensor is available on a device
  45305. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45306. * @returns a promise that will resolve on orientation change
  45307. */
  45308. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45309. /**
  45310. * @hidden
  45311. */
  45312. _onDeviceOrientationChangedObservable: Observable<void>;
  45313. /**
  45314. * Instantiates a new input
  45315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45316. */
  45317. constructor();
  45318. /**
  45319. * Define the camera controlled by the input.
  45320. */
  45321. get camera(): FreeCamera;
  45322. set camera(camera: FreeCamera);
  45323. /**
  45324. * Attach the input controls to a specific dom element to get the input from.
  45325. * @param element Defines the element the controls should be listened from
  45326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45327. */
  45328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45329. private _orientationChanged;
  45330. private _deviceOrientation;
  45331. /**
  45332. * Detach the current controls from the specified dom element.
  45333. * @param element Defines the element to stop listening the inputs from
  45334. */
  45335. detachControl(element: Nullable<HTMLElement>): void;
  45336. /**
  45337. * Update the current camera state depending on the inputs that have been used this frame.
  45338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45339. */
  45340. checkInputs(): void;
  45341. /**
  45342. * Gets the class name of the current intput.
  45343. * @returns the class name
  45344. */
  45345. getClassName(): string;
  45346. /**
  45347. * Get the friendly name associated with the input class.
  45348. * @returns the input friendly name
  45349. */
  45350. getSimpleName(): string;
  45351. }
  45352. }
  45353. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45354. import { Nullable } from "babylonjs/types";
  45355. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45356. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45357. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45358. /**
  45359. * Manage the gamepad inputs to control a free camera.
  45360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45361. */
  45362. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45363. /**
  45364. * Define the camera the input is attached to.
  45365. */
  45366. camera: FreeCamera;
  45367. /**
  45368. * Define the Gamepad controlling the input
  45369. */
  45370. gamepad: Nullable<Gamepad>;
  45371. /**
  45372. * Defines the gamepad rotation sensiblity.
  45373. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45374. */
  45375. gamepadAngularSensibility: number;
  45376. /**
  45377. * Defines the gamepad move sensiblity.
  45378. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45379. */
  45380. gamepadMoveSensibility: number;
  45381. private _yAxisScale;
  45382. /**
  45383. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45384. */
  45385. get invertYAxis(): boolean;
  45386. set invertYAxis(value: boolean);
  45387. private _onGamepadConnectedObserver;
  45388. private _onGamepadDisconnectedObserver;
  45389. private _cameraTransform;
  45390. private _deltaTransform;
  45391. private _vector3;
  45392. private _vector2;
  45393. /**
  45394. * Attach the input controls to a specific dom element to get the input from.
  45395. * @param element Defines the element the controls should be listened from
  45396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45397. */
  45398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45399. /**
  45400. * Detach the current controls from the specified dom element.
  45401. * @param element Defines the element to stop listening the inputs from
  45402. */
  45403. detachControl(element: Nullable<HTMLElement>): void;
  45404. /**
  45405. * Update the current camera state depending on the inputs that have been used this frame.
  45406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45407. */
  45408. checkInputs(): void;
  45409. /**
  45410. * Gets the class name of the current intput.
  45411. * @returns the class name
  45412. */
  45413. getClassName(): string;
  45414. /**
  45415. * Get the friendly name associated with the input class.
  45416. * @returns the input friendly name
  45417. */
  45418. getSimpleName(): string;
  45419. }
  45420. }
  45421. declare module "babylonjs/Misc/virtualJoystick" {
  45422. import { Nullable } from "babylonjs/types";
  45423. import { Vector3 } from "babylonjs/Maths/math.vector";
  45424. /**
  45425. * Defines the potential axis of a Joystick
  45426. */
  45427. export enum JoystickAxis {
  45428. /** X axis */
  45429. X = 0,
  45430. /** Y axis */
  45431. Y = 1,
  45432. /** Z axis */
  45433. Z = 2
  45434. }
  45435. /**
  45436. * Class used to define virtual joystick (used in touch mode)
  45437. */
  45438. export class VirtualJoystick {
  45439. /**
  45440. * Gets or sets a boolean indicating that left and right values must be inverted
  45441. */
  45442. reverseLeftRight: boolean;
  45443. /**
  45444. * Gets or sets a boolean indicating that up and down values must be inverted
  45445. */
  45446. reverseUpDown: boolean;
  45447. /**
  45448. * Gets the offset value for the position (ie. the change of the position value)
  45449. */
  45450. deltaPosition: Vector3;
  45451. /**
  45452. * Gets a boolean indicating if the virtual joystick was pressed
  45453. */
  45454. pressed: boolean;
  45455. /**
  45456. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45457. */
  45458. static Canvas: Nullable<HTMLCanvasElement>;
  45459. private static _globalJoystickIndex;
  45460. private static vjCanvasContext;
  45461. private static vjCanvasWidth;
  45462. private static vjCanvasHeight;
  45463. private static halfWidth;
  45464. private _action;
  45465. private _axisTargetedByLeftAndRight;
  45466. private _axisTargetedByUpAndDown;
  45467. private _joystickSensibility;
  45468. private _inversedSensibility;
  45469. private _joystickPointerID;
  45470. private _joystickColor;
  45471. private _joystickPointerPos;
  45472. private _joystickPreviousPointerPos;
  45473. private _joystickPointerStartPos;
  45474. private _deltaJoystickVector;
  45475. private _leftJoystick;
  45476. private _touches;
  45477. private _onPointerDownHandlerRef;
  45478. private _onPointerMoveHandlerRef;
  45479. private _onPointerUpHandlerRef;
  45480. private _onResize;
  45481. /**
  45482. * Creates a new virtual joystick
  45483. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45484. */
  45485. constructor(leftJoystick?: boolean);
  45486. /**
  45487. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45488. * @param newJoystickSensibility defines the new sensibility
  45489. */
  45490. setJoystickSensibility(newJoystickSensibility: number): void;
  45491. private _onPointerDown;
  45492. private _onPointerMove;
  45493. private _onPointerUp;
  45494. /**
  45495. * Change the color of the virtual joystick
  45496. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45497. */
  45498. setJoystickColor(newColor: string): void;
  45499. /**
  45500. * Defines a callback to call when the joystick is touched
  45501. * @param action defines the callback
  45502. */
  45503. setActionOnTouch(action: () => any): void;
  45504. /**
  45505. * Defines which axis you'd like to control for left & right
  45506. * @param axis defines the axis to use
  45507. */
  45508. setAxisForLeftRight(axis: JoystickAxis): void;
  45509. /**
  45510. * Defines which axis you'd like to control for up & down
  45511. * @param axis defines the axis to use
  45512. */
  45513. setAxisForUpDown(axis: JoystickAxis): void;
  45514. private _drawVirtualJoystick;
  45515. /**
  45516. * Release internal HTML canvas
  45517. */
  45518. releaseCanvas(): void;
  45519. }
  45520. }
  45521. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45522. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45523. import { Nullable } from "babylonjs/types";
  45524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45526. module "babylonjs/Cameras/freeCameraInputsManager" {
  45527. interface FreeCameraInputsManager {
  45528. /**
  45529. * Add virtual joystick input support to the input manager.
  45530. * @returns the current input manager
  45531. */
  45532. addVirtualJoystick(): FreeCameraInputsManager;
  45533. }
  45534. }
  45535. /**
  45536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45538. */
  45539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45540. /**
  45541. * Defines the camera the input is attached to.
  45542. */
  45543. camera: FreeCamera;
  45544. private _leftjoystick;
  45545. private _rightjoystick;
  45546. /**
  45547. * Gets the left stick of the virtual joystick.
  45548. * @returns The virtual Joystick
  45549. */
  45550. getLeftJoystick(): VirtualJoystick;
  45551. /**
  45552. * Gets the right stick of the virtual joystick.
  45553. * @returns The virtual Joystick
  45554. */
  45555. getRightJoystick(): VirtualJoystick;
  45556. /**
  45557. * Update the current camera state depending on the inputs that have been used this frame.
  45558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45559. */
  45560. checkInputs(): void;
  45561. /**
  45562. * Attach the input controls to a specific dom element to get the input from.
  45563. * @param element Defines the element the controls should be listened from
  45564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45565. */
  45566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45567. /**
  45568. * Detach the current controls from the specified dom element.
  45569. * @param element Defines the element to stop listening the inputs from
  45570. */
  45571. detachControl(element: Nullable<HTMLElement>): void;
  45572. /**
  45573. * Gets the class name of the current intput.
  45574. * @returns the class name
  45575. */
  45576. getClassName(): string;
  45577. /**
  45578. * Get the friendly name associated with the input class.
  45579. * @returns the input friendly name
  45580. */
  45581. getSimpleName(): string;
  45582. }
  45583. }
  45584. declare module "babylonjs/Cameras/Inputs/index" {
  45585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45587. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45588. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45589. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45590. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45591. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45592. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45593. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45594. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45595. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45596. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45597. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45598. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45599. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45600. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45601. }
  45602. declare module "babylonjs/Cameras/touchCamera" {
  45603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45604. import { Scene } from "babylonjs/scene";
  45605. import { Vector3 } from "babylonjs/Maths/math.vector";
  45606. /**
  45607. * This represents a FPS type of camera controlled by touch.
  45608. * This is like a universal camera minus the Gamepad controls.
  45609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45610. */
  45611. export class TouchCamera extends FreeCamera {
  45612. /**
  45613. * Defines the touch sensibility for rotation.
  45614. * The higher the faster.
  45615. */
  45616. get touchAngularSensibility(): number;
  45617. set touchAngularSensibility(value: number);
  45618. /**
  45619. * Defines the touch sensibility for move.
  45620. * The higher the faster.
  45621. */
  45622. get touchMoveSensibility(): number;
  45623. set touchMoveSensibility(value: number);
  45624. /**
  45625. * Instantiates a new touch camera.
  45626. * This represents a FPS type of camera controlled by touch.
  45627. * This is like a universal camera minus the Gamepad controls.
  45628. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45629. * @param name Define the name of the camera in the scene
  45630. * @param position Define the start position of the camera in the scene
  45631. * @param scene Define the scene the camera belongs to
  45632. */
  45633. constructor(name: string, position: Vector3, scene: Scene);
  45634. /**
  45635. * Gets the current object class name.
  45636. * @return the class name
  45637. */
  45638. getClassName(): string;
  45639. /** @hidden */
  45640. _setupInputs(): void;
  45641. }
  45642. }
  45643. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45644. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45645. import { Scene } from "babylonjs/scene";
  45646. import { Vector3 } from "babylonjs/Maths/math.vector";
  45647. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45648. import { Axis } from "babylonjs/Maths/math.axis";
  45649. /**
  45650. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45651. * being tilted forward or back and left or right.
  45652. */
  45653. export class DeviceOrientationCamera extends FreeCamera {
  45654. private _initialQuaternion;
  45655. private _quaternionCache;
  45656. private _tmpDragQuaternion;
  45657. private _disablePointerInputWhenUsingDeviceOrientation;
  45658. /**
  45659. * Creates a new device orientation camera
  45660. * @param name The name of the camera
  45661. * @param position The start position camera
  45662. * @param scene The scene the camera belongs to
  45663. */
  45664. constructor(name: string, position: Vector3, scene: Scene);
  45665. /**
  45666. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45667. */
  45668. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45669. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45670. private _dragFactor;
  45671. /**
  45672. * Enabled turning on the y axis when the orientation sensor is active
  45673. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45674. */
  45675. enableHorizontalDragging(dragFactor?: number): void;
  45676. /**
  45677. * Gets the current instance class name ("DeviceOrientationCamera").
  45678. * This helps avoiding instanceof at run time.
  45679. * @returns the class name
  45680. */
  45681. getClassName(): string;
  45682. /**
  45683. * @hidden
  45684. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45685. */
  45686. _checkInputs(): void;
  45687. /**
  45688. * Reset the camera to its default orientation on the specified axis only.
  45689. * @param axis The axis to reset
  45690. */
  45691. resetToCurrentRotation(axis?: Axis): void;
  45692. }
  45693. }
  45694. declare module "babylonjs/Gamepads/xboxGamepad" {
  45695. import { Observable } from "babylonjs/Misc/observable";
  45696. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45697. /**
  45698. * Defines supported buttons for XBox360 compatible gamepads
  45699. */
  45700. export enum Xbox360Button {
  45701. /** A */
  45702. A = 0,
  45703. /** B */
  45704. B = 1,
  45705. /** X */
  45706. X = 2,
  45707. /** Y */
  45708. Y = 3,
  45709. /** Left button */
  45710. LB = 4,
  45711. /** Right button */
  45712. RB = 5,
  45713. /** Back */
  45714. Back = 8,
  45715. /** Start */
  45716. Start = 9,
  45717. /** Left stick */
  45718. LeftStick = 10,
  45719. /** Right stick */
  45720. RightStick = 11
  45721. }
  45722. /** Defines values for XBox360 DPad */
  45723. export enum Xbox360Dpad {
  45724. /** Up */
  45725. Up = 12,
  45726. /** Down */
  45727. Down = 13,
  45728. /** Left */
  45729. Left = 14,
  45730. /** Right */
  45731. Right = 15
  45732. }
  45733. /**
  45734. * Defines a XBox360 gamepad
  45735. */
  45736. export class Xbox360Pad extends Gamepad {
  45737. private _leftTrigger;
  45738. private _rightTrigger;
  45739. private _onlefttriggerchanged;
  45740. private _onrighttriggerchanged;
  45741. private _onbuttondown;
  45742. private _onbuttonup;
  45743. private _ondpaddown;
  45744. private _ondpadup;
  45745. /** Observable raised when a button is pressed */
  45746. onButtonDownObservable: Observable<Xbox360Button>;
  45747. /** Observable raised when a button is released */
  45748. onButtonUpObservable: Observable<Xbox360Button>;
  45749. /** Observable raised when a pad is pressed */
  45750. onPadDownObservable: Observable<Xbox360Dpad>;
  45751. /** Observable raised when a pad is released */
  45752. onPadUpObservable: Observable<Xbox360Dpad>;
  45753. private _buttonA;
  45754. private _buttonB;
  45755. private _buttonX;
  45756. private _buttonY;
  45757. private _buttonBack;
  45758. private _buttonStart;
  45759. private _buttonLB;
  45760. private _buttonRB;
  45761. private _buttonLeftStick;
  45762. private _buttonRightStick;
  45763. private _dPadUp;
  45764. private _dPadDown;
  45765. private _dPadLeft;
  45766. private _dPadRight;
  45767. private _isXboxOnePad;
  45768. /**
  45769. * Creates a new XBox360 gamepad object
  45770. * @param id defines the id of this gamepad
  45771. * @param index defines its index
  45772. * @param gamepad defines the internal HTML gamepad object
  45773. * @param xboxOne defines if it is a XBox One gamepad
  45774. */
  45775. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45776. /**
  45777. * Defines the callback to call when left trigger is pressed
  45778. * @param callback defines the callback to use
  45779. */
  45780. onlefttriggerchanged(callback: (value: number) => void): void;
  45781. /**
  45782. * Defines the callback to call when right trigger is pressed
  45783. * @param callback defines the callback to use
  45784. */
  45785. onrighttriggerchanged(callback: (value: number) => void): void;
  45786. /**
  45787. * Gets the left trigger value
  45788. */
  45789. get leftTrigger(): number;
  45790. /**
  45791. * Sets the left trigger value
  45792. */
  45793. set leftTrigger(newValue: number);
  45794. /**
  45795. * Gets the right trigger value
  45796. */
  45797. get rightTrigger(): number;
  45798. /**
  45799. * Sets the right trigger value
  45800. */
  45801. set rightTrigger(newValue: number);
  45802. /**
  45803. * Defines the callback to call when a button is pressed
  45804. * @param callback defines the callback to use
  45805. */
  45806. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45807. /**
  45808. * Defines the callback to call when a button is released
  45809. * @param callback defines the callback to use
  45810. */
  45811. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45812. /**
  45813. * Defines the callback to call when a pad is pressed
  45814. * @param callback defines the callback to use
  45815. */
  45816. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45817. /**
  45818. * Defines the callback to call when a pad is released
  45819. * @param callback defines the callback to use
  45820. */
  45821. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45822. private _setButtonValue;
  45823. private _setDPadValue;
  45824. /**
  45825. * Gets the value of the `A` button
  45826. */
  45827. get buttonA(): number;
  45828. /**
  45829. * Sets the value of the `A` button
  45830. */
  45831. set buttonA(value: number);
  45832. /**
  45833. * Gets the value of the `B` button
  45834. */
  45835. get buttonB(): number;
  45836. /**
  45837. * Sets the value of the `B` button
  45838. */
  45839. set buttonB(value: number);
  45840. /**
  45841. * Gets the value of the `X` button
  45842. */
  45843. get buttonX(): number;
  45844. /**
  45845. * Sets the value of the `X` button
  45846. */
  45847. set buttonX(value: number);
  45848. /**
  45849. * Gets the value of the `Y` button
  45850. */
  45851. get buttonY(): number;
  45852. /**
  45853. * Sets the value of the `Y` button
  45854. */
  45855. set buttonY(value: number);
  45856. /**
  45857. * Gets the value of the `Start` button
  45858. */
  45859. get buttonStart(): number;
  45860. /**
  45861. * Sets the value of the `Start` button
  45862. */
  45863. set buttonStart(value: number);
  45864. /**
  45865. * Gets the value of the `Back` button
  45866. */
  45867. get buttonBack(): number;
  45868. /**
  45869. * Sets the value of the `Back` button
  45870. */
  45871. set buttonBack(value: number);
  45872. /**
  45873. * Gets the value of the `Left` button
  45874. */
  45875. get buttonLB(): number;
  45876. /**
  45877. * Sets the value of the `Left` button
  45878. */
  45879. set buttonLB(value: number);
  45880. /**
  45881. * Gets the value of the `Right` button
  45882. */
  45883. get buttonRB(): number;
  45884. /**
  45885. * Sets the value of the `Right` button
  45886. */
  45887. set buttonRB(value: number);
  45888. /**
  45889. * Gets the value of the Left joystick
  45890. */
  45891. get buttonLeftStick(): number;
  45892. /**
  45893. * Sets the value of the Left joystick
  45894. */
  45895. set buttonLeftStick(value: number);
  45896. /**
  45897. * Gets the value of the Right joystick
  45898. */
  45899. get buttonRightStick(): number;
  45900. /**
  45901. * Sets the value of the Right joystick
  45902. */
  45903. set buttonRightStick(value: number);
  45904. /**
  45905. * Gets the value of D-pad up
  45906. */
  45907. get dPadUp(): number;
  45908. /**
  45909. * Sets the value of D-pad up
  45910. */
  45911. set dPadUp(value: number);
  45912. /**
  45913. * Gets the value of D-pad down
  45914. */
  45915. get dPadDown(): number;
  45916. /**
  45917. * Sets the value of D-pad down
  45918. */
  45919. set dPadDown(value: number);
  45920. /**
  45921. * Gets the value of D-pad left
  45922. */
  45923. get dPadLeft(): number;
  45924. /**
  45925. * Sets the value of D-pad left
  45926. */
  45927. set dPadLeft(value: number);
  45928. /**
  45929. * Gets the value of D-pad right
  45930. */
  45931. get dPadRight(): number;
  45932. /**
  45933. * Sets the value of D-pad right
  45934. */
  45935. set dPadRight(value: number);
  45936. /**
  45937. * Force the gamepad to synchronize with device values
  45938. */
  45939. update(): void;
  45940. /**
  45941. * Disposes the gamepad
  45942. */
  45943. dispose(): void;
  45944. }
  45945. }
  45946. declare module "babylonjs/Gamepads/dualShockGamepad" {
  45947. import { Observable } from "babylonjs/Misc/observable";
  45948. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45949. /**
  45950. * Defines supported buttons for DualShock compatible gamepads
  45951. */
  45952. export enum DualShockButton {
  45953. /** Cross */
  45954. Cross = 0,
  45955. /** Circle */
  45956. Circle = 1,
  45957. /** Square */
  45958. Square = 2,
  45959. /** Triangle */
  45960. Triangle = 3,
  45961. /** L1 */
  45962. L1 = 4,
  45963. /** R1 */
  45964. R1 = 5,
  45965. /** Share */
  45966. Share = 8,
  45967. /** Options */
  45968. Options = 9,
  45969. /** Left stick */
  45970. LeftStick = 10,
  45971. /** Right stick */
  45972. RightStick = 11
  45973. }
  45974. /** Defines values for DualShock DPad */
  45975. export enum DualShockDpad {
  45976. /** Up */
  45977. Up = 12,
  45978. /** Down */
  45979. Down = 13,
  45980. /** Left */
  45981. Left = 14,
  45982. /** Right */
  45983. Right = 15
  45984. }
  45985. /**
  45986. * Defines a DualShock gamepad
  45987. */
  45988. export class DualShockPad extends Gamepad {
  45989. private _leftTrigger;
  45990. private _rightTrigger;
  45991. private _onlefttriggerchanged;
  45992. private _onrighttriggerchanged;
  45993. private _onbuttondown;
  45994. private _onbuttonup;
  45995. private _ondpaddown;
  45996. private _ondpadup;
  45997. /** Observable raised when a button is pressed */
  45998. onButtonDownObservable: Observable<DualShockButton>;
  45999. /** Observable raised when a button is released */
  46000. onButtonUpObservable: Observable<DualShockButton>;
  46001. /** Observable raised when a pad is pressed */
  46002. onPadDownObservable: Observable<DualShockDpad>;
  46003. /** Observable raised when a pad is released */
  46004. onPadUpObservable: Observable<DualShockDpad>;
  46005. private _buttonCross;
  46006. private _buttonCircle;
  46007. private _buttonSquare;
  46008. private _buttonTriangle;
  46009. private _buttonShare;
  46010. private _buttonOptions;
  46011. private _buttonL1;
  46012. private _buttonR1;
  46013. private _buttonLeftStick;
  46014. private _buttonRightStick;
  46015. private _dPadUp;
  46016. private _dPadDown;
  46017. private _dPadLeft;
  46018. private _dPadRight;
  46019. /**
  46020. * Creates a new DualShock gamepad object
  46021. * @param id defines the id of this gamepad
  46022. * @param index defines its index
  46023. * @param gamepad defines the internal HTML gamepad object
  46024. */
  46025. constructor(id: string, index: number, gamepad: any);
  46026. /**
  46027. * Defines the callback to call when left trigger is pressed
  46028. * @param callback defines the callback to use
  46029. */
  46030. onlefttriggerchanged(callback: (value: number) => void): void;
  46031. /**
  46032. * Defines the callback to call when right trigger is pressed
  46033. * @param callback defines the callback to use
  46034. */
  46035. onrighttriggerchanged(callback: (value: number) => void): void;
  46036. /**
  46037. * Gets the left trigger value
  46038. */
  46039. get leftTrigger(): number;
  46040. /**
  46041. * Sets the left trigger value
  46042. */
  46043. set leftTrigger(newValue: number);
  46044. /**
  46045. * Gets the right trigger value
  46046. */
  46047. get rightTrigger(): number;
  46048. /**
  46049. * Sets the right trigger value
  46050. */
  46051. set rightTrigger(newValue: number);
  46052. /**
  46053. * Defines the callback to call when a button is pressed
  46054. * @param callback defines the callback to use
  46055. */
  46056. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46057. /**
  46058. * Defines the callback to call when a button is released
  46059. * @param callback defines the callback to use
  46060. */
  46061. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46062. /**
  46063. * Defines the callback to call when a pad is pressed
  46064. * @param callback defines the callback to use
  46065. */
  46066. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46067. /**
  46068. * Defines the callback to call when a pad is released
  46069. * @param callback defines the callback to use
  46070. */
  46071. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46072. private _setButtonValue;
  46073. private _setDPadValue;
  46074. /**
  46075. * Gets the value of the `Cross` button
  46076. */
  46077. get buttonCross(): number;
  46078. /**
  46079. * Sets the value of the `Cross` button
  46080. */
  46081. set buttonCross(value: number);
  46082. /**
  46083. * Gets the value of the `Circle` button
  46084. */
  46085. get buttonCircle(): number;
  46086. /**
  46087. * Sets the value of the `Circle` button
  46088. */
  46089. set buttonCircle(value: number);
  46090. /**
  46091. * Gets the value of the `Square` button
  46092. */
  46093. get buttonSquare(): number;
  46094. /**
  46095. * Sets the value of the `Square` button
  46096. */
  46097. set buttonSquare(value: number);
  46098. /**
  46099. * Gets the value of the `Triangle` button
  46100. */
  46101. get buttonTriangle(): number;
  46102. /**
  46103. * Sets the value of the `Triangle` button
  46104. */
  46105. set buttonTriangle(value: number);
  46106. /**
  46107. * Gets the value of the `Options` button
  46108. */
  46109. get buttonOptions(): number;
  46110. /**
  46111. * Sets the value of the `Options` button
  46112. */
  46113. set buttonOptions(value: number);
  46114. /**
  46115. * Gets the value of the `Share` button
  46116. */
  46117. get buttonShare(): number;
  46118. /**
  46119. * Sets the value of the `Share` button
  46120. */
  46121. set buttonShare(value: number);
  46122. /**
  46123. * Gets the value of the `L1` button
  46124. */
  46125. get buttonL1(): number;
  46126. /**
  46127. * Sets the value of the `L1` button
  46128. */
  46129. set buttonL1(value: number);
  46130. /**
  46131. * Gets the value of the `R1` button
  46132. */
  46133. get buttonR1(): number;
  46134. /**
  46135. * Sets the value of the `R1` button
  46136. */
  46137. set buttonR1(value: number);
  46138. /**
  46139. * Gets the value of the Left joystick
  46140. */
  46141. get buttonLeftStick(): number;
  46142. /**
  46143. * Sets the value of the Left joystick
  46144. */
  46145. set buttonLeftStick(value: number);
  46146. /**
  46147. * Gets the value of the Right joystick
  46148. */
  46149. get buttonRightStick(): number;
  46150. /**
  46151. * Sets the value of the Right joystick
  46152. */
  46153. set buttonRightStick(value: number);
  46154. /**
  46155. * Gets the value of D-pad up
  46156. */
  46157. get dPadUp(): number;
  46158. /**
  46159. * Sets the value of D-pad up
  46160. */
  46161. set dPadUp(value: number);
  46162. /**
  46163. * Gets the value of D-pad down
  46164. */
  46165. get dPadDown(): number;
  46166. /**
  46167. * Sets the value of D-pad down
  46168. */
  46169. set dPadDown(value: number);
  46170. /**
  46171. * Gets the value of D-pad left
  46172. */
  46173. get dPadLeft(): number;
  46174. /**
  46175. * Sets the value of D-pad left
  46176. */
  46177. set dPadLeft(value: number);
  46178. /**
  46179. * Gets the value of D-pad right
  46180. */
  46181. get dPadRight(): number;
  46182. /**
  46183. * Sets the value of D-pad right
  46184. */
  46185. set dPadRight(value: number);
  46186. /**
  46187. * Force the gamepad to synchronize with device values
  46188. */
  46189. update(): void;
  46190. /**
  46191. * Disposes the gamepad
  46192. */
  46193. dispose(): void;
  46194. }
  46195. }
  46196. declare module "babylonjs/Gamepads/gamepadManager" {
  46197. import { Observable } from "babylonjs/Misc/observable";
  46198. import { Nullable } from "babylonjs/types";
  46199. import { Scene } from "babylonjs/scene";
  46200. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46201. /**
  46202. * Manager for handling gamepads
  46203. */
  46204. export class GamepadManager {
  46205. private _scene?;
  46206. private _babylonGamepads;
  46207. private _oneGamepadConnected;
  46208. /** @hidden */
  46209. _isMonitoring: boolean;
  46210. private _gamepadEventSupported;
  46211. private _gamepadSupport?;
  46212. /**
  46213. * observable to be triggered when the gamepad controller has been connected
  46214. */
  46215. onGamepadConnectedObservable: Observable<Gamepad>;
  46216. /**
  46217. * observable to be triggered when the gamepad controller has been disconnected
  46218. */
  46219. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46220. private _onGamepadConnectedEvent;
  46221. private _onGamepadDisconnectedEvent;
  46222. /**
  46223. * Initializes the gamepad manager
  46224. * @param _scene BabylonJS scene
  46225. */
  46226. constructor(_scene?: Scene | undefined);
  46227. /**
  46228. * The gamepads in the game pad manager
  46229. */
  46230. get gamepads(): Gamepad[];
  46231. /**
  46232. * Get the gamepad controllers based on type
  46233. * @param type The type of gamepad controller
  46234. * @returns Nullable gamepad
  46235. */
  46236. getGamepadByType(type?: number): Nullable<Gamepad>;
  46237. /**
  46238. * Disposes the gamepad manager
  46239. */
  46240. dispose(): void;
  46241. private _addNewGamepad;
  46242. private _startMonitoringGamepads;
  46243. private _stopMonitoringGamepads;
  46244. /** @hidden */
  46245. _checkGamepadsStatus(): void;
  46246. private _updateGamepadObjects;
  46247. }
  46248. }
  46249. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46250. import { Nullable } from "babylonjs/types";
  46251. import { Scene } from "babylonjs/scene";
  46252. import { ISceneComponent } from "babylonjs/sceneComponent";
  46253. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46254. module "babylonjs/scene" {
  46255. interface Scene {
  46256. /** @hidden */
  46257. _gamepadManager: Nullable<GamepadManager>;
  46258. /**
  46259. * Gets the gamepad manager associated with the scene
  46260. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46261. */
  46262. gamepadManager: GamepadManager;
  46263. }
  46264. }
  46265. module "babylonjs/Cameras/freeCameraInputsManager" {
  46266. /**
  46267. * Interface representing a free camera inputs manager
  46268. */
  46269. interface FreeCameraInputsManager {
  46270. /**
  46271. * Adds gamepad input support to the FreeCameraInputsManager.
  46272. * @returns the FreeCameraInputsManager
  46273. */
  46274. addGamepad(): FreeCameraInputsManager;
  46275. }
  46276. }
  46277. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46278. /**
  46279. * Interface representing an arc rotate camera inputs manager
  46280. */
  46281. interface ArcRotateCameraInputsManager {
  46282. /**
  46283. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46284. * @returns the camera inputs manager
  46285. */
  46286. addGamepad(): ArcRotateCameraInputsManager;
  46287. }
  46288. }
  46289. /**
  46290. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46291. */
  46292. export class GamepadSystemSceneComponent implements ISceneComponent {
  46293. /**
  46294. * The component name helpfull to identify the component in the list of scene components.
  46295. */
  46296. readonly name: string;
  46297. /**
  46298. * The scene the component belongs to.
  46299. */
  46300. scene: Scene;
  46301. /**
  46302. * Creates a new instance of the component for the given scene
  46303. * @param scene Defines the scene to register the component in
  46304. */
  46305. constructor(scene: Scene);
  46306. /**
  46307. * Registers the component in a given scene
  46308. */
  46309. register(): void;
  46310. /**
  46311. * Rebuilds the elements related to this component in case of
  46312. * context lost for instance.
  46313. */
  46314. rebuild(): void;
  46315. /**
  46316. * Disposes the component and the associated ressources
  46317. */
  46318. dispose(): void;
  46319. private _beforeCameraUpdate;
  46320. }
  46321. }
  46322. declare module "babylonjs/Cameras/universalCamera" {
  46323. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46324. import { Scene } from "babylonjs/scene";
  46325. import { Vector3 } from "babylonjs/Maths/math.vector";
  46326. import "babylonjs/Gamepads/gamepadSceneComponent";
  46327. /**
  46328. * 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,
  46329. * which still works and will still be found in many Playgrounds.
  46330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46331. */
  46332. export class UniversalCamera extends TouchCamera {
  46333. /**
  46334. * Defines the gamepad rotation sensiblity.
  46335. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46336. */
  46337. get gamepadAngularSensibility(): number;
  46338. set gamepadAngularSensibility(value: number);
  46339. /**
  46340. * Defines the gamepad move sensiblity.
  46341. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46342. */
  46343. get gamepadMoveSensibility(): number;
  46344. set gamepadMoveSensibility(value: number);
  46345. /**
  46346. * 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,
  46347. * which still works and will still be found in many Playgrounds.
  46348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46349. * @param name Define the name of the camera in the scene
  46350. * @param position Define the start position of the camera in the scene
  46351. * @param scene Define the scene the camera belongs to
  46352. */
  46353. constructor(name: string, position: Vector3, scene: Scene);
  46354. /**
  46355. * Gets the current object class name.
  46356. * @return the class name
  46357. */
  46358. getClassName(): string;
  46359. }
  46360. }
  46361. declare module "babylonjs/Cameras/gamepadCamera" {
  46362. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46363. import { Scene } from "babylonjs/scene";
  46364. import { Vector3 } from "babylonjs/Maths/math.vector";
  46365. /**
  46366. * This represents a FPS type of camera. This is only here for back compat purpose.
  46367. * Please use the UniversalCamera instead as both are identical.
  46368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46369. */
  46370. export class GamepadCamera extends UniversalCamera {
  46371. /**
  46372. * Instantiates a new Gamepad Camera
  46373. * This represents a FPS type of camera. This is only here for back compat purpose.
  46374. * Please use the UniversalCamera instead as both are identical.
  46375. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46376. * @param name Define the name of the camera in the scene
  46377. * @param position Define the start position of the camera in the scene
  46378. * @param scene Define the scene the camera belongs to
  46379. */
  46380. constructor(name: string, position: Vector3, scene: Scene);
  46381. /**
  46382. * Gets the current object class name.
  46383. * @return the class name
  46384. */
  46385. getClassName(): string;
  46386. }
  46387. }
  46388. declare module "babylonjs/Shaders/pass.fragment" {
  46389. /** @hidden */
  46390. export var passPixelShader: {
  46391. name: string;
  46392. shader: string;
  46393. };
  46394. }
  46395. declare module "babylonjs/Shaders/passCube.fragment" {
  46396. /** @hidden */
  46397. export var passCubePixelShader: {
  46398. name: string;
  46399. shader: string;
  46400. };
  46401. }
  46402. declare module "babylonjs/PostProcesses/passPostProcess" {
  46403. import { Nullable } from "babylonjs/types";
  46404. import { Camera } from "babylonjs/Cameras/camera";
  46405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46406. import { Engine } from "babylonjs/Engines/engine";
  46407. import "babylonjs/Shaders/pass.fragment";
  46408. import "babylonjs/Shaders/passCube.fragment";
  46409. /**
  46410. * PassPostProcess which produces an output the same as it's input
  46411. */
  46412. export class PassPostProcess extends PostProcess {
  46413. /**
  46414. * Creates the PassPostProcess
  46415. * @param name The name of the effect.
  46416. * @param options The required width/height ratio to downsize to before computing the render pass.
  46417. * @param camera The camera to apply the render pass to.
  46418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46419. * @param engine The engine which the post process will be applied. (default: current engine)
  46420. * @param reusable If the post process can be reused on the same frame. (default: false)
  46421. * @param textureType The type of texture to be used when performing the post processing.
  46422. * @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)
  46423. */
  46424. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46425. }
  46426. /**
  46427. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46428. */
  46429. export class PassCubePostProcess extends PostProcess {
  46430. private _face;
  46431. /**
  46432. * Gets or sets the cube face to display.
  46433. * * 0 is +X
  46434. * * 1 is -X
  46435. * * 2 is +Y
  46436. * * 3 is -Y
  46437. * * 4 is +Z
  46438. * * 5 is -Z
  46439. */
  46440. get face(): number;
  46441. set face(value: number);
  46442. /**
  46443. * Creates the PassCubePostProcess
  46444. * @param name The name of the effect.
  46445. * @param options The required width/height ratio to downsize to before computing the render pass.
  46446. * @param camera The camera to apply the render pass to.
  46447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46448. * @param engine The engine which the post process will be applied. (default: current engine)
  46449. * @param reusable If the post process can be reused on the same frame. (default: false)
  46450. * @param textureType The type of texture to be used when performing the post processing.
  46451. * @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)
  46452. */
  46453. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46454. }
  46455. }
  46456. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46457. /** @hidden */
  46458. export var anaglyphPixelShader: {
  46459. name: string;
  46460. shader: string;
  46461. };
  46462. }
  46463. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46464. import { Engine } from "babylonjs/Engines/engine";
  46465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46466. import { Camera } from "babylonjs/Cameras/camera";
  46467. import "babylonjs/Shaders/anaglyph.fragment";
  46468. /**
  46469. * Postprocess used to generate anaglyphic rendering
  46470. */
  46471. export class AnaglyphPostProcess extends PostProcess {
  46472. private _passedProcess;
  46473. /**
  46474. * Creates a new AnaglyphPostProcess
  46475. * @param name defines postprocess name
  46476. * @param options defines creation options or target ratio scale
  46477. * @param rigCameras defines cameras using this postprocess
  46478. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46479. * @param engine defines hosting engine
  46480. * @param reusable defines if the postprocess will be reused multiple times per frame
  46481. */
  46482. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46483. }
  46484. }
  46485. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46486. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46487. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46488. import { Scene } from "babylonjs/scene";
  46489. import { Vector3 } from "babylonjs/Maths/math.vector";
  46490. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46491. /**
  46492. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46493. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46494. */
  46495. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46496. /**
  46497. * Creates a new AnaglyphArcRotateCamera
  46498. * @param name defines camera name
  46499. * @param alpha defines alpha angle (in radians)
  46500. * @param beta defines beta angle (in radians)
  46501. * @param radius defines radius
  46502. * @param target defines camera target
  46503. * @param interaxialDistance defines distance between each color axis
  46504. * @param scene defines the hosting scene
  46505. */
  46506. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46507. /**
  46508. * Gets camera class name
  46509. * @returns AnaglyphArcRotateCamera
  46510. */
  46511. getClassName(): string;
  46512. }
  46513. }
  46514. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46516. import { Scene } from "babylonjs/scene";
  46517. import { Vector3 } from "babylonjs/Maths/math.vector";
  46518. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46519. /**
  46520. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46521. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46522. */
  46523. export class AnaglyphFreeCamera extends FreeCamera {
  46524. /**
  46525. * Creates a new AnaglyphFreeCamera
  46526. * @param name defines camera name
  46527. * @param position defines initial position
  46528. * @param interaxialDistance defines distance between each color axis
  46529. * @param scene defines the hosting scene
  46530. */
  46531. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46532. /**
  46533. * Gets camera class name
  46534. * @returns AnaglyphFreeCamera
  46535. */
  46536. getClassName(): string;
  46537. }
  46538. }
  46539. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46540. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46541. import { Scene } from "babylonjs/scene";
  46542. import { Vector3 } from "babylonjs/Maths/math.vector";
  46543. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46544. /**
  46545. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46546. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46547. */
  46548. export class AnaglyphGamepadCamera extends GamepadCamera {
  46549. /**
  46550. * Creates a new AnaglyphGamepadCamera
  46551. * @param name defines camera name
  46552. * @param position defines initial position
  46553. * @param interaxialDistance defines distance between each color axis
  46554. * @param scene defines the hosting scene
  46555. */
  46556. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46557. /**
  46558. * Gets camera class name
  46559. * @returns AnaglyphGamepadCamera
  46560. */
  46561. getClassName(): string;
  46562. }
  46563. }
  46564. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46565. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46566. import { Scene } from "babylonjs/scene";
  46567. import { Vector3 } from "babylonjs/Maths/math.vector";
  46568. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46569. /**
  46570. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46571. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46572. */
  46573. export class AnaglyphUniversalCamera extends UniversalCamera {
  46574. /**
  46575. * Creates a new AnaglyphUniversalCamera
  46576. * @param name defines camera name
  46577. * @param position defines initial position
  46578. * @param interaxialDistance defines distance between each color axis
  46579. * @param scene defines the hosting scene
  46580. */
  46581. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46582. /**
  46583. * Gets camera class name
  46584. * @returns AnaglyphUniversalCamera
  46585. */
  46586. getClassName(): string;
  46587. }
  46588. }
  46589. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46590. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46591. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46592. import { Scene } from "babylonjs/scene";
  46593. import { Vector3 } from "babylonjs/Maths/math.vector";
  46594. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46595. /**
  46596. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46597. * @see http://doc.babylonjs.com/features/cameras
  46598. */
  46599. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46600. /**
  46601. * Creates a new StereoscopicArcRotateCamera
  46602. * @param name defines camera name
  46603. * @param alpha defines alpha angle (in radians)
  46604. * @param beta defines beta angle (in radians)
  46605. * @param radius defines radius
  46606. * @param target defines camera target
  46607. * @param interaxialDistance defines distance between each color axis
  46608. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46609. * @param scene defines the hosting scene
  46610. */
  46611. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46612. /**
  46613. * Gets camera class name
  46614. * @returns StereoscopicArcRotateCamera
  46615. */
  46616. getClassName(): string;
  46617. }
  46618. }
  46619. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46620. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46621. import { Scene } from "babylonjs/scene";
  46622. import { Vector3 } from "babylonjs/Maths/math.vector";
  46623. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46624. /**
  46625. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46626. * @see http://doc.babylonjs.com/features/cameras
  46627. */
  46628. export class StereoscopicFreeCamera extends FreeCamera {
  46629. /**
  46630. * Creates a new StereoscopicFreeCamera
  46631. * @param name defines camera name
  46632. * @param position defines initial position
  46633. * @param interaxialDistance defines distance between each color axis
  46634. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46635. * @param scene defines the hosting scene
  46636. */
  46637. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46638. /**
  46639. * Gets camera class name
  46640. * @returns StereoscopicFreeCamera
  46641. */
  46642. getClassName(): string;
  46643. }
  46644. }
  46645. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46646. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46647. import { Scene } from "babylonjs/scene";
  46648. import { Vector3 } from "babylonjs/Maths/math.vector";
  46649. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46650. /**
  46651. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46652. * @see http://doc.babylonjs.com/features/cameras
  46653. */
  46654. export class StereoscopicGamepadCamera extends GamepadCamera {
  46655. /**
  46656. * Creates a new StereoscopicGamepadCamera
  46657. * @param name defines camera name
  46658. * @param position defines initial position
  46659. * @param interaxialDistance defines distance between each color axis
  46660. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46661. * @param scene defines the hosting scene
  46662. */
  46663. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46664. /**
  46665. * Gets camera class name
  46666. * @returns StereoscopicGamepadCamera
  46667. */
  46668. getClassName(): string;
  46669. }
  46670. }
  46671. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46672. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46673. import { Scene } from "babylonjs/scene";
  46674. import { Vector3 } from "babylonjs/Maths/math.vector";
  46675. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46676. /**
  46677. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46678. * @see http://doc.babylonjs.com/features/cameras
  46679. */
  46680. export class StereoscopicUniversalCamera extends UniversalCamera {
  46681. /**
  46682. * Creates a new StereoscopicUniversalCamera
  46683. * @param name defines camera name
  46684. * @param position defines initial position
  46685. * @param interaxialDistance defines distance between each color axis
  46686. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46687. * @param scene defines the hosting scene
  46688. */
  46689. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46690. /**
  46691. * Gets camera class name
  46692. * @returns StereoscopicUniversalCamera
  46693. */
  46694. getClassName(): string;
  46695. }
  46696. }
  46697. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46698. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46699. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46700. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46701. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46702. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46703. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46704. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46705. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46706. }
  46707. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46708. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46709. import { Scene } from "babylonjs/scene";
  46710. import { Vector3 } from "babylonjs/Maths/math.vector";
  46711. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46712. /**
  46713. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46714. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46715. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46716. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46717. */
  46718. export class VirtualJoysticksCamera extends FreeCamera {
  46719. /**
  46720. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46721. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46722. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46723. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46724. * @param name Define the name of the camera in the scene
  46725. * @param position Define the start position of the camera in the scene
  46726. * @param scene Define the scene the camera belongs to
  46727. */
  46728. constructor(name: string, position: Vector3, scene: Scene);
  46729. /**
  46730. * Gets the current object class name.
  46731. * @return the class name
  46732. */
  46733. getClassName(): string;
  46734. }
  46735. }
  46736. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46737. import { Matrix } from "babylonjs/Maths/math.vector";
  46738. /**
  46739. * This represents all the required metrics to create a VR camera.
  46740. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46741. */
  46742. export class VRCameraMetrics {
  46743. /**
  46744. * Define the horizontal resolution off the screen.
  46745. */
  46746. hResolution: number;
  46747. /**
  46748. * Define the vertical resolution off the screen.
  46749. */
  46750. vResolution: number;
  46751. /**
  46752. * Define the horizontal screen size.
  46753. */
  46754. hScreenSize: number;
  46755. /**
  46756. * Define the vertical screen size.
  46757. */
  46758. vScreenSize: number;
  46759. /**
  46760. * Define the vertical screen center position.
  46761. */
  46762. vScreenCenter: number;
  46763. /**
  46764. * Define the distance of the eyes to the screen.
  46765. */
  46766. eyeToScreenDistance: number;
  46767. /**
  46768. * Define the distance between both lenses
  46769. */
  46770. lensSeparationDistance: number;
  46771. /**
  46772. * Define the distance between both viewer's eyes.
  46773. */
  46774. interpupillaryDistance: number;
  46775. /**
  46776. * Define the distortion factor of the VR postprocess.
  46777. * Please, touch with care.
  46778. */
  46779. distortionK: number[];
  46780. /**
  46781. * Define the chromatic aberration correction factors for the VR post process.
  46782. */
  46783. chromaAbCorrection: number[];
  46784. /**
  46785. * Define the scale factor of the post process.
  46786. * The smaller the better but the slower.
  46787. */
  46788. postProcessScaleFactor: number;
  46789. /**
  46790. * Define an offset for the lens center.
  46791. */
  46792. lensCenterOffset: number;
  46793. /**
  46794. * Define if the current vr camera should compensate the distortion of the lense or not.
  46795. */
  46796. compensateDistortion: boolean;
  46797. /**
  46798. * Defines if multiview should be enabled when rendering (Default: false)
  46799. */
  46800. multiviewEnabled: boolean;
  46801. /**
  46802. * Gets the rendering aspect ratio based on the provided resolutions.
  46803. */
  46804. get aspectRatio(): number;
  46805. /**
  46806. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46807. */
  46808. get aspectRatioFov(): number;
  46809. /**
  46810. * @hidden
  46811. */
  46812. get leftHMatrix(): Matrix;
  46813. /**
  46814. * @hidden
  46815. */
  46816. get rightHMatrix(): Matrix;
  46817. /**
  46818. * @hidden
  46819. */
  46820. get leftPreViewMatrix(): Matrix;
  46821. /**
  46822. * @hidden
  46823. */
  46824. get rightPreViewMatrix(): Matrix;
  46825. /**
  46826. * Get the default VRMetrics based on the most generic setup.
  46827. * @returns the default vr metrics
  46828. */
  46829. static GetDefault(): VRCameraMetrics;
  46830. }
  46831. }
  46832. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46833. /** @hidden */
  46834. export var vrDistortionCorrectionPixelShader: {
  46835. name: string;
  46836. shader: string;
  46837. };
  46838. }
  46839. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46840. import { Camera } from "babylonjs/Cameras/camera";
  46841. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46842. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46843. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46844. /**
  46845. * VRDistortionCorrectionPostProcess used for mobile VR
  46846. */
  46847. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46848. private _isRightEye;
  46849. private _distortionFactors;
  46850. private _postProcessScaleFactor;
  46851. private _lensCenterOffset;
  46852. private _scaleIn;
  46853. private _scaleFactor;
  46854. private _lensCenter;
  46855. /**
  46856. * Initializes the VRDistortionCorrectionPostProcess
  46857. * @param name The name of the effect.
  46858. * @param camera The camera to apply the render pass to.
  46859. * @param isRightEye If this is for the right eye distortion
  46860. * @param vrMetrics All the required metrics for the VR camera
  46861. */
  46862. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46863. }
  46864. }
  46865. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46866. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46867. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46868. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46869. import { Scene } from "babylonjs/scene";
  46870. import { Vector3 } from "babylonjs/Maths/math.vector";
  46871. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46872. import "babylonjs/Cameras/RigModes/vrRigMode";
  46873. /**
  46874. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46875. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46876. */
  46877. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46878. /**
  46879. * Creates a new VRDeviceOrientationArcRotateCamera
  46880. * @param name defines camera name
  46881. * @param alpha defines the camera rotation along the logitudinal axis
  46882. * @param beta defines the camera rotation along the latitudinal axis
  46883. * @param radius defines the camera distance from its target
  46884. * @param target defines the camera target
  46885. * @param scene defines the scene the camera belongs to
  46886. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46887. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46888. */
  46889. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46890. /**
  46891. * Gets camera class name
  46892. * @returns VRDeviceOrientationArcRotateCamera
  46893. */
  46894. getClassName(): string;
  46895. }
  46896. }
  46897. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46898. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46899. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46900. import { Scene } from "babylonjs/scene";
  46901. import { Vector3 } from "babylonjs/Maths/math.vector";
  46902. import "babylonjs/Cameras/RigModes/vrRigMode";
  46903. /**
  46904. * Camera used to simulate VR rendering (based on FreeCamera)
  46905. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46906. */
  46907. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46908. /**
  46909. * Creates a new VRDeviceOrientationFreeCamera
  46910. * @param name defines camera name
  46911. * @param position defines the start position of the camera
  46912. * @param scene defines the scene the camera belongs to
  46913. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46914. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46915. */
  46916. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46917. /**
  46918. * Gets camera class name
  46919. * @returns VRDeviceOrientationFreeCamera
  46920. */
  46921. getClassName(): string;
  46922. }
  46923. }
  46924. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  46925. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46926. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46927. import { Scene } from "babylonjs/scene";
  46928. import { Vector3 } from "babylonjs/Maths/math.vector";
  46929. import "babylonjs/Gamepads/gamepadSceneComponent";
  46930. /**
  46931. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46932. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46933. */
  46934. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46935. /**
  46936. * Creates a new VRDeviceOrientationGamepadCamera
  46937. * @param name defines camera name
  46938. * @param position defines the start position of the camera
  46939. * @param scene defines the scene the camera belongs to
  46940. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46941. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46942. */
  46943. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46944. /**
  46945. * Gets camera class name
  46946. * @returns VRDeviceOrientationGamepadCamera
  46947. */
  46948. getClassName(): string;
  46949. }
  46950. }
  46951. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  46952. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46953. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46954. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46955. /** @hidden */
  46956. export var imageProcessingPixelShader: {
  46957. name: string;
  46958. shader: string;
  46959. };
  46960. }
  46961. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  46962. import { Nullable } from "babylonjs/types";
  46963. import { Color4 } from "babylonjs/Maths/math.color";
  46964. import { Camera } from "babylonjs/Cameras/camera";
  46965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46966. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46967. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46969. import { Engine } from "babylonjs/Engines/engine";
  46970. import "babylonjs/Shaders/imageProcessing.fragment";
  46971. import "babylonjs/Shaders/postprocess.vertex";
  46972. /**
  46973. * ImageProcessingPostProcess
  46974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  46975. */
  46976. export class ImageProcessingPostProcess extends PostProcess {
  46977. /**
  46978. * Default configuration related to image processing available in the PBR Material.
  46979. */
  46980. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46981. /**
  46982. * Gets the image processing configuration used either in this material.
  46983. */
  46984. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46985. /**
  46986. * Sets the Default image processing configuration used either in the this material.
  46987. *
  46988. * If sets to null, the scene one is in use.
  46989. */
  46990. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  46991. /**
  46992. * Keep track of the image processing observer to allow dispose and replace.
  46993. */
  46994. private _imageProcessingObserver;
  46995. /**
  46996. * Attaches a new image processing configuration to the PBR Material.
  46997. * @param configuration
  46998. */
  46999. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47000. /**
  47001. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47002. */
  47003. get colorCurves(): Nullable<ColorCurves>;
  47004. /**
  47005. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47006. */
  47007. set colorCurves(value: Nullable<ColorCurves>);
  47008. /**
  47009. * Gets wether the color curves effect is enabled.
  47010. */
  47011. get colorCurvesEnabled(): boolean;
  47012. /**
  47013. * Sets wether the color curves effect is enabled.
  47014. */
  47015. set colorCurvesEnabled(value: boolean);
  47016. /**
  47017. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47018. */
  47019. get colorGradingTexture(): Nullable<BaseTexture>;
  47020. /**
  47021. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47022. */
  47023. set colorGradingTexture(value: Nullable<BaseTexture>);
  47024. /**
  47025. * Gets wether the color grading effect is enabled.
  47026. */
  47027. get colorGradingEnabled(): boolean;
  47028. /**
  47029. * Gets wether the color grading effect is enabled.
  47030. */
  47031. set colorGradingEnabled(value: boolean);
  47032. /**
  47033. * Gets exposure used in the effect.
  47034. */
  47035. get exposure(): number;
  47036. /**
  47037. * Sets exposure used in the effect.
  47038. */
  47039. set exposure(value: number);
  47040. /**
  47041. * Gets wether tonemapping is enabled or not.
  47042. */
  47043. get toneMappingEnabled(): boolean;
  47044. /**
  47045. * Sets wether tonemapping is enabled or not
  47046. */
  47047. set toneMappingEnabled(value: boolean);
  47048. /**
  47049. * Gets the type of tone mapping effect.
  47050. */
  47051. get toneMappingType(): number;
  47052. /**
  47053. * Sets the type of tone mapping effect.
  47054. */
  47055. set toneMappingType(value: number);
  47056. /**
  47057. * Gets contrast used in the effect.
  47058. */
  47059. get contrast(): number;
  47060. /**
  47061. * Sets contrast used in the effect.
  47062. */
  47063. set contrast(value: number);
  47064. /**
  47065. * Gets Vignette stretch size.
  47066. */
  47067. get vignetteStretch(): number;
  47068. /**
  47069. * Sets Vignette stretch size.
  47070. */
  47071. set vignetteStretch(value: number);
  47072. /**
  47073. * Gets Vignette centre X Offset.
  47074. */
  47075. get vignetteCentreX(): number;
  47076. /**
  47077. * Sets Vignette centre X Offset.
  47078. */
  47079. set vignetteCentreX(value: number);
  47080. /**
  47081. * Gets Vignette centre Y Offset.
  47082. */
  47083. get vignetteCentreY(): number;
  47084. /**
  47085. * Sets Vignette centre Y Offset.
  47086. */
  47087. set vignetteCentreY(value: number);
  47088. /**
  47089. * Gets Vignette weight or intensity of the vignette effect.
  47090. */
  47091. get vignetteWeight(): number;
  47092. /**
  47093. * Sets Vignette weight or intensity of the vignette effect.
  47094. */
  47095. set vignetteWeight(value: number);
  47096. /**
  47097. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47098. * if vignetteEnabled is set to true.
  47099. */
  47100. get vignetteColor(): Color4;
  47101. /**
  47102. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47103. * if vignetteEnabled is set to true.
  47104. */
  47105. set vignetteColor(value: Color4);
  47106. /**
  47107. * Gets Camera field of view used by the Vignette effect.
  47108. */
  47109. get vignetteCameraFov(): number;
  47110. /**
  47111. * Sets Camera field of view used by the Vignette effect.
  47112. */
  47113. set vignetteCameraFov(value: number);
  47114. /**
  47115. * Gets the vignette blend mode allowing different kind of effect.
  47116. */
  47117. get vignetteBlendMode(): number;
  47118. /**
  47119. * Sets the vignette blend mode allowing different kind of effect.
  47120. */
  47121. set vignetteBlendMode(value: number);
  47122. /**
  47123. * Gets wether the vignette effect is enabled.
  47124. */
  47125. get vignetteEnabled(): boolean;
  47126. /**
  47127. * Sets wether the vignette effect is enabled.
  47128. */
  47129. set vignetteEnabled(value: boolean);
  47130. private _fromLinearSpace;
  47131. /**
  47132. * Gets wether the input of the processing is in Gamma or Linear Space.
  47133. */
  47134. get fromLinearSpace(): boolean;
  47135. /**
  47136. * Sets wether the input of the processing is in Gamma or Linear Space.
  47137. */
  47138. set fromLinearSpace(value: boolean);
  47139. /**
  47140. * Defines cache preventing GC.
  47141. */
  47142. private _defines;
  47143. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47144. /**
  47145. * "ImageProcessingPostProcess"
  47146. * @returns "ImageProcessingPostProcess"
  47147. */
  47148. getClassName(): string;
  47149. protected _updateParameters(): void;
  47150. dispose(camera?: Camera): void;
  47151. }
  47152. }
  47153. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47154. import { Scene } from "babylonjs/scene";
  47155. import { Color3 } from "babylonjs/Maths/math.color";
  47156. import { Mesh } from "babylonjs/Meshes/mesh";
  47157. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47158. import { Nullable } from "babylonjs/types";
  47159. /**
  47160. * Class containing static functions to help procedurally build meshes
  47161. */
  47162. export class GroundBuilder {
  47163. /**
  47164. * Creates a ground mesh
  47165. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47166. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47168. * @param name defines the name of the mesh
  47169. * @param options defines the options used to create the mesh
  47170. * @param scene defines the hosting scene
  47171. * @returns the ground mesh
  47172. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47173. */
  47174. static CreateGround(name: string, options: {
  47175. width?: number;
  47176. height?: number;
  47177. subdivisions?: number;
  47178. subdivisionsX?: number;
  47179. subdivisionsY?: number;
  47180. updatable?: boolean;
  47181. }, scene: any): Mesh;
  47182. /**
  47183. * Creates a tiled ground mesh
  47184. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47185. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47186. * * 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
  47187. * * 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
  47188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47189. * @param name defines the name of the mesh
  47190. * @param options defines the options used to create the mesh
  47191. * @param scene defines the hosting scene
  47192. * @returns the tiled ground mesh
  47193. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47194. */
  47195. static CreateTiledGround(name: string, options: {
  47196. xmin: number;
  47197. zmin: number;
  47198. xmax: number;
  47199. zmax: number;
  47200. subdivisions?: {
  47201. w: number;
  47202. h: number;
  47203. };
  47204. precision?: {
  47205. w: number;
  47206. h: number;
  47207. };
  47208. updatable?: boolean;
  47209. }, scene?: Nullable<Scene>): Mesh;
  47210. /**
  47211. * Creates a ground mesh from a height map
  47212. * * The parameter `url` sets the URL of the height map image resource.
  47213. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47214. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47215. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47216. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47217. * * 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.
  47218. * * 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).
  47219. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47221. * @param name defines the name of the mesh
  47222. * @param url defines the url to the height map
  47223. * @param options defines the options used to create the mesh
  47224. * @param scene defines the hosting scene
  47225. * @returns the ground mesh
  47226. * @see https://doc.babylonjs.com/babylon101/height_map
  47227. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47228. */
  47229. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47230. width?: number;
  47231. height?: number;
  47232. subdivisions?: number;
  47233. minHeight?: number;
  47234. maxHeight?: number;
  47235. colorFilter?: Color3;
  47236. alphaFilter?: number;
  47237. updatable?: boolean;
  47238. onReady?: (mesh: GroundMesh) => void;
  47239. }, scene?: Nullable<Scene>): GroundMesh;
  47240. }
  47241. }
  47242. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47243. import { Vector4 } from "babylonjs/Maths/math.vector";
  47244. import { Mesh } from "babylonjs/Meshes/mesh";
  47245. /**
  47246. * Class containing static functions to help procedurally build meshes
  47247. */
  47248. export class TorusBuilder {
  47249. /**
  47250. * Creates a torus mesh
  47251. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47252. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47253. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47257. * @param name defines the name of the mesh
  47258. * @param options defines the options used to create the mesh
  47259. * @param scene defines the hosting scene
  47260. * @returns the torus mesh
  47261. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47262. */
  47263. static CreateTorus(name: string, options: {
  47264. diameter?: number;
  47265. thickness?: number;
  47266. tessellation?: number;
  47267. updatable?: boolean;
  47268. sideOrientation?: number;
  47269. frontUVs?: Vector4;
  47270. backUVs?: Vector4;
  47271. }, scene: any): Mesh;
  47272. }
  47273. }
  47274. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47275. import { Vector4 } from "babylonjs/Maths/math.vector";
  47276. import { Color4 } from "babylonjs/Maths/math.color";
  47277. import { Mesh } from "babylonjs/Meshes/mesh";
  47278. /**
  47279. * Class containing static functions to help procedurally build meshes
  47280. */
  47281. export class CylinderBuilder {
  47282. /**
  47283. * Creates a cylinder or a cone mesh
  47284. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47285. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47286. * * 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.
  47287. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47288. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47289. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47290. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47291. * * 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).
  47292. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47293. * * 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).
  47294. * * 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
  47295. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47296. * * 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
  47297. * * 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.
  47298. * * If `enclose` is false, a ring surface is one element.
  47299. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47300. * * 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
  47301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47304. * @param name defines the name of the mesh
  47305. * @param options defines the options used to create the mesh
  47306. * @param scene defines the hosting scene
  47307. * @returns the cylinder mesh
  47308. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47309. */
  47310. static CreateCylinder(name: string, options: {
  47311. height?: number;
  47312. diameterTop?: number;
  47313. diameterBottom?: number;
  47314. diameter?: number;
  47315. tessellation?: number;
  47316. subdivisions?: number;
  47317. arc?: number;
  47318. faceColors?: Color4[];
  47319. faceUV?: Vector4[];
  47320. updatable?: boolean;
  47321. hasRings?: boolean;
  47322. enclose?: boolean;
  47323. cap?: number;
  47324. sideOrientation?: number;
  47325. frontUVs?: Vector4;
  47326. backUVs?: Vector4;
  47327. }, scene: any): Mesh;
  47328. }
  47329. }
  47330. declare module "babylonjs/XR/webXRTypes" {
  47331. import { Nullable } from "babylonjs/types";
  47332. import { IDisposable } from "babylonjs/scene";
  47333. /**
  47334. * States of the webXR experience
  47335. */
  47336. export enum WebXRState {
  47337. /**
  47338. * Transitioning to being in XR mode
  47339. */
  47340. ENTERING_XR = 0,
  47341. /**
  47342. * Transitioning to non XR mode
  47343. */
  47344. EXITING_XR = 1,
  47345. /**
  47346. * In XR mode and presenting
  47347. */
  47348. IN_XR = 2,
  47349. /**
  47350. * Not entered XR mode
  47351. */
  47352. NOT_IN_XR = 3
  47353. }
  47354. /**
  47355. * Abstraction of the XR render target
  47356. */
  47357. export interface WebXRRenderTarget extends IDisposable {
  47358. /**
  47359. * xrpresent context of the canvas which can be used to display/mirror xr content
  47360. */
  47361. canvasContext: WebGLRenderingContext;
  47362. /**
  47363. * xr layer for the canvas
  47364. */
  47365. xrLayer: Nullable<XRWebGLLayer>;
  47366. /**
  47367. * Initializes the xr layer for the session
  47368. * @param xrSession xr session
  47369. * @returns a promise that will resolve once the XR Layer has been created
  47370. */
  47371. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47372. }
  47373. }
  47374. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47375. import { Nullable } from "babylonjs/types";
  47376. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47377. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47378. /**
  47379. * COnfiguration object for WebXR output canvas
  47380. */
  47381. export class WebXRManagedOutputCanvasOptions {
  47382. /**
  47383. * An optional canvas in case you wish to create it yourself and provide it here.
  47384. * If not provided, a new canvas will be created
  47385. */
  47386. canvasElement?: HTMLCanvasElement;
  47387. /**
  47388. * Options for this XR Layer output
  47389. */
  47390. canvasOptions?: XRWebGLLayerOptions;
  47391. /**
  47392. * CSS styling for a newly created canvas (if not provided)
  47393. */
  47394. newCanvasCssStyle?: string;
  47395. /**
  47396. * Get the default values of the configuration object
  47397. * @returns default values of this configuration object
  47398. */
  47399. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47400. }
  47401. /**
  47402. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47403. */
  47404. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47405. private _options;
  47406. private _canvas;
  47407. private _engine;
  47408. /**
  47409. * Rendering context of the canvas which can be used to display/mirror xr content
  47410. */
  47411. canvasContext: WebGLRenderingContext;
  47412. /**
  47413. * xr layer for the canvas
  47414. */
  47415. xrLayer: Nullable<XRWebGLLayer>;
  47416. /**
  47417. * Initializes the canvas to be added/removed upon entering/exiting xr
  47418. * @param _xrSessionManager The XR Session manager
  47419. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47420. */
  47421. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47422. /**
  47423. * Disposes of the object
  47424. */
  47425. dispose(): void;
  47426. /**
  47427. * Initializes the xr layer for the session
  47428. * @param xrSession xr session
  47429. * @returns a promise that will resolve once the XR Layer has been created
  47430. */
  47431. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47432. private _addCanvas;
  47433. private _removeCanvas;
  47434. private _setManagedOutputCanvas;
  47435. }
  47436. }
  47437. declare module "babylonjs/XR/webXRSessionManager" {
  47438. import { Observable } from "babylonjs/Misc/observable";
  47439. import { Nullable } from "babylonjs/types";
  47440. import { IDisposable, Scene } from "babylonjs/scene";
  47441. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47442. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47443. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47444. /**
  47445. * Manages an XRSession to work with Babylon's engine
  47446. * @see https://doc.babylonjs.com/how_to/webxr
  47447. */
  47448. export class WebXRSessionManager implements IDisposable {
  47449. /** The scene which the session should be created for */
  47450. scene: Scene;
  47451. private _referenceSpace;
  47452. private _rttProvider;
  47453. private _sessionEnded;
  47454. private _xrNavigator;
  47455. private baseLayer;
  47456. /**
  47457. * The base reference space from which the session started. good if you want to reset your
  47458. * reference space
  47459. */
  47460. baseReferenceSpace: XRReferenceSpace;
  47461. /**
  47462. * Current XR frame
  47463. */
  47464. currentFrame: Nullable<XRFrame>;
  47465. /** WebXR timestamp updated every frame */
  47466. currentTimestamp: number;
  47467. /**
  47468. * Used just in case of a failure to initialize an immersive session.
  47469. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47470. */
  47471. defaultHeightCompensation: number;
  47472. /**
  47473. * Fires every time a new xrFrame arrives which can be used to update the camera
  47474. */
  47475. onXRFrameObservable: Observable<XRFrame>;
  47476. /**
  47477. * Fires when the reference space changed
  47478. */
  47479. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47480. /**
  47481. * Fires when the xr session is ended either by the device or manually done
  47482. */
  47483. onXRSessionEnded: Observable<any>;
  47484. /**
  47485. * Fires when the xr session is ended either by the device or manually done
  47486. */
  47487. onXRSessionInit: Observable<XRSession>;
  47488. /**
  47489. * Underlying xr session
  47490. */
  47491. session: XRSession;
  47492. /**
  47493. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47494. * or get the offset the player is currently at.
  47495. */
  47496. viewerReferenceSpace: XRReferenceSpace;
  47497. /**
  47498. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47499. * @param scene The scene which the session should be created for
  47500. */
  47501. constructor(
  47502. /** The scene which the session should be created for */
  47503. scene: Scene);
  47504. /**
  47505. * The current reference space used in this session. This reference space can constantly change!
  47506. * It is mainly used to offset the camera's position.
  47507. */
  47508. get referenceSpace(): XRReferenceSpace;
  47509. /**
  47510. * Set a new reference space and triggers the observable
  47511. */
  47512. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47513. /**
  47514. * Disposes of the session manager
  47515. */
  47516. dispose(): void;
  47517. /**
  47518. * Stops the xrSession and restores the render loop
  47519. * @returns Promise which resolves after it exits XR
  47520. */
  47521. exitXRAsync(): Promise<void>;
  47522. /**
  47523. * Gets the correct render target texture to be rendered this frame for this eye
  47524. * @param eye the eye for which to get the render target
  47525. * @returns the render target for the specified eye
  47526. */
  47527. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47528. /**
  47529. * Creates a WebXRRenderTarget object for the XR session
  47530. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47531. * @param options optional options to provide when creating a new render target
  47532. * @returns a WebXR render target to which the session can render
  47533. */
  47534. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47535. /**
  47536. * Initializes the manager
  47537. * After initialization enterXR can be called to start an XR session
  47538. * @returns Promise which resolves after it is initialized
  47539. */
  47540. initializeAsync(): Promise<void>;
  47541. /**
  47542. * Initializes an xr session
  47543. * @param xrSessionMode mode to initialize
  47544. * @param xrSessionInit defines optional and required values to pass to the session builder
  47545. * @returns a promise which will resolve once the session has been initialized
  47546. */
  47547. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47548. /**
  47549. * Checks if a session would be supported for the creation options specified
  47550. * @param sessionMode session mode to check if supported eg. immersive-vr
  47551. * @returns A Promise that resolves to true if supported and false if not
  47552. */
  47553. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47554. /**
  47555. * Resets the reference space to the one started the session
  47556. */
  47557. resetReferenceSpace(): void;
  47558. /**
  47559. * Starts rendering to the xr layer
  47560. */
  47561. runXRRenderLoop(): void;
  47562. /**
  47563. * Sets the reference space on the xr session
  47564. * @param referenceSpaceType space to set
  47565. * @returns a promise that will resolve once the reference space has been set
  47566. */
  47567. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47568. /**
  47569. * Updates the render state of the session
  47570. * @param state state to set
  47571. * @returns a promise that resolves once the render state has been updated
  47572. */
  47573. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47574. /**
  47575. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47576. * @param sessionMode defines the session to test
  47577. * @returns a promise with boolean as final value
  47578. */
  47579. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47580. private _createRenderTargetTexture;
  47581. }
  47582. }
  47583. declare module "babylonjs/XR/webXRCamera" {
  47584. import { Matrix } from "babylonjs/Maths/math.vector";
  47585. import { Scene } from "babylonjs/scene";
  47586. import { Camera } from "babylonjs/Cameras/camera";
  47587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47588. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47589. /**
  47590. * WebXR Camera which holds the views for the xrSession
  47591. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47592. */
  47593. export class WebXRCamera extends FreeCamera {
  47594. private _xrSessionManager;
  47595. private _firstFrame;
  47596. private _referenceQuaternion;
  47597. private _referencedPosition;
  47598. private _xrInvPositionCache;
  47599. private _xrInvQuaternionCache;
  47600. /**
  47601. * Should position compensation execute on first frame.
  47602. * This is used when copying the position from a native (non XR) camera
  47603. */
  47604. compensateOnFirstFrame: boolean;
  47605. /**
  47606. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47607. * @param name the name of the camera
  47608. * @param scene the scene to add the camera to
  47609. * @param _xrSessionManager a constructed xr session manager
  47610. */
  47611. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47612. /**
  47613. * Return the user's height, unrelated to the current ground.
  47614. * This will be the y position of this camera, when ground level is 0.
  47615. */
  47616. get realWorldHeight(): number;
  47617. /** @hidden */
  47618. _updateForDualEyeDebugging(): void;
  47619. /**
  47620. * Sets this camera's transformation based on a non-vr camera
  47621. * @param otherCamera the non-vr camera to copy the transformation from
  47622. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47623. */
  47624. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47625. /**
  47626. * Gets the current instance class name ("WebXRCamera").
  47627. * @returns the class name
  47628. */
  47629. getClassName(): string;
  47630. /**
  47631. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47632. */
  47633. _getViewMatrix(): Matrix;
  47634. private _updateFromXRSession;
  47635. private _updateNumberOfRigCameras;
  47636. private _updateReferenceSpace;
  47637. private _updateReferenceSpaceOffset;
  47638. }
  47639. }
  47640. declare module "babylonjs/XR/webXRFeaturesManager" {
  47641. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47642. import { IDisposable } from "babylonjs/scene";
  47643. /**
  47644. * Defining the interface required for a (webxr) feature
  47645. */
  47646. export interface IWebXRFeature extends IDisposable {
  47647. /**
  47648. * Is this feature attached
  47649. */
  47650. attached: boolean;
  47651. /**
  47652. * Should auto-attach be disabled?
  47653. */
  47654. disableAutoAttach: boolean;
  47655. /**
  47656. * Attach the feature to the session
  47657. * Will usually be called by the features manager
  47658. *
  47659. * @param force should attachment be forced (even when already attached)
  47660. * @returns true if successful.
  47661. */
  47662. attach(force?: boolean): boolean;
  47663. /**
  47664. * Detach the feature from the session
  47665. * Will usually be called by the features manager
  47666. *
  47667. * @returns true if successful.
  47668. */
  47669. detach(): boolean;
  47670. }
  47671. /**
  47672. * A list of the currently available features without referencing them
  47673. */
  47674. export class WebXRFeatureName {
  47675. /**
  47676. * The name of the anchor system feature
  47677. */
  47678. static ANCHOR_SYSTEM: string;
  47679. /**
  47680. * The name of the background remover feature
  47681. */
  47682. static BACKGROUND_REMOVER: string;
  47683. /**
  47684. * The name of the hit test feature
  47685. */
  47686. static HIT_TEST: string;
  47687. /**
  47688. * physics impostors for xr controllers feature
  47689. */
  47690. static PHYSICS_CONTROLLERS: string;
  47691. /**
  47692. * The name of the plane detection feature
  47693. */
  47694. static PLANE_DETECTION: string;
  47695. /**
  47696. * The name of the pointer selection feature
  47697. */
  47698. static POINTER_SELECTION: string;
  47699. /**
  47700. * The name of the teleportation feature
  47701. */
  47702. static TELEPORTATION: string;
  47703. }
  47704. /**
  47705. * Defining the constructor of a feature. Used to register the modules.
  47706. */
  47707. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47708. /**
  47709. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47710. * It is mainly used in AR sessions.
  47711. *
  47712. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47713. */
  47714. export class WebXRFeaturesManager implements IDisposable {
  47715. private _xrSessionManager;
  47716. private static readonly _AvailableFeatures;
  47717. private _features;
  47718. /**
  47719. * constructs a new features manages.
  47720. *
  47721. * @param _xrSessionManager an instance of WebXRSessionManager
  47722. */
  47723. constructor(_xrSessionManager: WebXRSessionManager);
  47724. /**
  47725. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47726. * Mainly used internally.
  47727. *
  47728. * @param featureName the name of the feature to register
  47729. * @param constructorFunction the function used to construct the module
  47730. * @param version the (babylon) version of the module
  47731. * @param stable is that a stable version of this module
  47732. */
  47733. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47734. /**
  47735. * Returns a constructor of a specific feature.
  47736. *
  47737. * @param featureName the name of the feature to construct
  47738. * @param version the version of the feature to load
  47739. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47740. * @param options optional options provided to the module.
  47741. * @returns a function that, when called, will return a new instance of this feature
  47742. */
  47743. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47744. /**
  47745. * Can be used to return the list of features currently registered
  47746. *
  47747. * @returns an Array of available features
  47748. */
  47749. static GetAvailableFeatures(): string[];
  47750. /**
  47751. * Gets the versions available for a specific feature
  47752. * @param featureName the name of the feature
  47753. * @returns an array with the available versions
  47754. */
  47755. static GetAvailableVersions(featureName: string): string[];
  47756. /**
  47757. * Return the latest unstable version of this feature
  47758. * @param featureName the name of the feature to search
  47759. * @returns the version number. if not found will return -1
  47760. */
  47761. static GetLatestVersionOfFeature(featureName: string): number;
  47762. /**
  47763. * Return the latest stable version of this feature
  47764. * @param featureName the name of the feature to search
  47765. * @returns the version number. if not found will return -1
  47766. */
  47767. static GetStableVersionOfFeature(featureName: string): number;
  47768. /**
  47769. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47770. * Can be used during a session to start a feature
  47771. * @param featureName the name of feature to attach
  47772. */
  47773. attachFeature(featureName: string): void;
  47774. /**
  47775. * Can be used inside a session or when the session ends to detach a specific feature
  47776. * @param featureName the name of the feature to detach
  47777. */
  47778. detachFeature(featureName: string): void;
  47779. /**
  47780. * Used to disable an already-enabled feature
  47781. * The feature will be disposed and will be recreated once enabled.
  47782. * @param featureName the feature to disable
  47783. * @returns true if disable was successful
  47784. */
  47785. disableFeature(featureName: string | {
  47786. Name: string;
  47787. }): boolean;
  47788. /**
  47789. * dispose this features manager
  47790. */
  47791. dispose(): void;
  47792. /**
  47793. * 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.
  47794. * 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.
  47795. *
  47796. * @param featureName the name of the feature to load or the class of the feature
  47797. * @param version optional version to load. if not provided the latest version will be enabled
  47798. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47799. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47800. * @returns a new constructed feature or throws an error if feature not found.
  47801. */
  47802. enableFeature(featureName: string | {
  47803. Name: string;
  47804. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47805. /**
  47806. * get the implementation of an enabled feature.
  47807. * @param featureName the name of the feature to load
  47808. * @returns the feature class, if found
  47809. */
  47810. getEnabledFeature(featureName: string): IWebXRFeature;
  47811. /**
  47812. * Get the list of enabled features
  47813. * @returns an array of enabled features
  47814. */
  47815. getEnabledFeatures(): string[];
  47816. }
  47817. }
  47818. declare module "babylonjs/XR/webXRExperienceHelper" {
  47819. import { Observable } from "babylonjs/Misc/observable";
  47820. import { IDisposable, Scene } from "babylonjs/scene";
  47821. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47822. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  47823. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47824. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  47825. /**
  47826. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47827. * @see https://doc.babylonjs.com/how_to/webxr
  47828. */
  47829. export class WebXRExperienceHelper implements IDisposable {
  47830. private scene;
  47831. private _nonVRCamera;
  47832. private _originalSceneAutoClear;
  47833. private _supported;
  47834. /**
  47835. * Camera used to render xr content
  47836. */
  47837. camera: WebXRCamera;
  47838. /** A features manager for this xr session */
  47839. featuresManager: WebXRFeaturesManager;
  47840. /**
  47841. * Observers registered here will be triggered after the camera's initial transformation is set
  47842. * This can be used to set a different ground level or an extra rotation.
  47843. *
  47844. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47845. * to the position set after this observable is done executing.
  47846. */
  47847. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47848. /**
  47849. * Fires when the state of the experience helper has changed
  47850. */
  47851. onStateChangedObservable: Observable<WebXRState>;
  47852. /** Session manager used to keep track of xr session */
  47853. sessionManager: WebXRSessionManager;
  47854. /**
  47855. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47856. */
  47857. state: WebXRState;
  47858. /**
  47859. * Creates a WebXRExperienceHelper
  47860. * @param scene The scene the helper should be created in
  47861. */
  47862. private constructor();
  47863. /**
  47864. * Creates the experience helper
  47865. * @param scene the scene to attach the experience helper to
  47866. * @returns a promise for the experience helper
  47867. */
  47868. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47869. /**
  47870. * Disposes of the experience helper
  47871. */
  47872. dispose(): void;
  47873. /**
  47874. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47875. * @param sessionMode options for the XR session
  47876. * @param referenceSpaceType frame of reference of the XR session
  47877. * @param renderTarget the output canvas that will be used to enter XR mode
  47878. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47879. * @returns promise that resolves after xr mode has entered
  47880. */
  47881. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47882. /**
  47883. * Exits XR mode and returns the scene to its original state
  47884. * @returns promise that resolves after xr mode has exited
  47885. */
  47886. exitXRAsync(): Promise<void>;
  47887. private _nonXRToXRCamera;
  47888. private _setState;
  47889. }
  47890. }
  47891. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  47892. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  47893. import { Observable } from "babylonjs/Misc/observable";
  47894. import { IDisposable } from "babylonjs/scene";
  47895. /**
  47896. * X-Y values for axes in WebXR
  47897. */
  47898. export interface IWebXRMotionControllerAxesValue {
  47899. /**
  47900. * The value of the x axis
  47901. */
  47902. x: number;
  47903. /**
  47904. * The value of the y-axis
  47905. */
  47906. y: number;
  47907. }
  47908. /**
  47909. * changed / previous values for the values of this component
  47910. */
  47911. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47912. /**
  47913. * current (this frame) value
  47914. */
  47915. current: T;
  47916. /**
  47917. * previous (last change) value
  47918. */
  47919. previous: T;
  47920. }
  47921. /**
  47922. * Represents changes in the component between current frame and last values recorded
  47923. */
  47924. export interface IWebXRMotionControllerComponentChanges {
  47925. /**
  47926. * will be populated with previous and current values if axes changed
  47927. */
  47928. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47929. /**
  47930. * will be populated with previous and current values if pressed changed
  47931. */
  47932. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47933. /**
  47934. * will be populated with previous and current values if touched changed
  47935. */
  47936. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47937. /**
  47938. * will be populated with previous and current values if value changed
  47939. */
  47940. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47941. }
  47942. /**
  47943. * This class represents a single component (for example button or thumbstick) of a motion controller
  47944. */
  47945. export class WebXRControllerComponent implements IDisposable {
  47946. /**
  47947. * the id of this component
  47948. */
  47949. id: string;
  47950. /**
  47951. * the type of the component
  47952. */
  47953. type: MotionControllerComponentType;
  47954. private _buttonIndex;
  47955. private _axesIndices;
  47956. private _axes;
  47957. private _changes;
  47958. private _currentValue;
  47959. private _hasChanges;
  47960. private _pressed;
  47961. private _touched;
  47962. /**
  47963. * button component type
  47964. */
  47965. static BUTTON_TYPE: MotionControllerComponentType;
  47966. /**
  47967. * squeeze component type
  47968. */
  47969. static SQUEEZE_TYPE: MotionControllerComponentType;
  47970. /**
  47971. * Thumbstick component type
  47972. */
  47973. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47974. /**
  47975. * Touchpad component type
  47976. */
  47977. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47978. /**
  47979. * trigger component type
  47980. */
  47981. static TRIGGER_TYPE: MotionControllerComponentType;
  47982. /**
  47983. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47984. * the axes data changes
  47985. */
  47986. onAxisValueChangedObservable: Observable<{
  47987. x: number;
  47988. y: number;
  47989. }>;
  47990. /**
  47991. * Observers registered here will be triggered when the state of a button changes
  47992. * State change is either pressed / touched / value
  47993. */
  47994. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47995. /**
  47996. * Creates a new component for a motion controller.
  47997. * It is created by the motion controller itself
  47998. *
  47999. * @param id the id of this component
  48000. * @param type the type of the component
  48001. * @param _buttonIndex index in the buttons array of the gamepad
  48002. * @param _axesIndices indices of the values in the axes array of the gamepad
  48003. */
  48004. constructor(
  48005. /**
  48006. * the id of this component
  48007. */
  48008. id: string,
  48009. /**
  48010. * the type of the component
  48011. */
  48012. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48013. /**
  48014. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48015. */
  48016. get axes(): IWebXRMotionControllerAxesValue;
  48017. /**
  48018. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48019. */
  48020. get changes(): IWebXRMotionControllerComponentChanges;
  48021. /**
  48022. * Return whether or not the component changed the last frame
  48023. */
  48024. get hasChanges(): boolean;
  48025. /**
  48026. * is the button currently pressed
  48027. */
  48028. get pressed(): boolean;
  48029. /**
  48030. * is the button currently touched
  48031. */
  48032. get touched(): boolean;
  48033. /**
  48034. * Get the current value of this component
  48035. */
  48036. get value(): number;
  48037. /**
  48038. * Dispose this component
  48039. */
  48040. dispose(): void;
  48041. /**
  48042. * Are there axes correlating to this component
  48043. * @return true is axes data is available
  48044. */
  48045. isAxes(): boolean;
  48046. /**
  48047. * Is this component a button (hence - pressable)
  48048. * @returns true if can be pressed
  48049. */
  48050. isButton(): boolean;
  48051. /**
  48052. * update this component using the gamepad object it is in. Called on every frame
  48053. * @param nativeController the native gamepad controller object
  48054. */
  48055. update(nativeController: IMinimalMotionControllerObject): void;
  48056. }
  48057. }
  48058. declare module "babylonjs/Loading/sceneLoader" {
  48059. import { Observable } from "babylonjs/Misc/observable";
  48060. import { Nullable } from "babylonjs/types";
  48061. import { Scene } from "babylonjs/scene";
  48062. import { Engine } from "babylonjs/Engines/engine";
  48063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48064. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48065. import { AssetContainer } from "babylonjs/assetContainer";
  48066. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48067. import { Skeleton } from "babylonjs/Bones/skeleton";
  48068. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48069. import { WebRequest } from "babylonjs/Misc/webRequest";
  48070. /**
  48071. * Class used to represent data loading progression
  48072. */
  48073. export class SceneLoaderProgressEvent {
  48074. /** defines if data length to load can be evaluated */
  48075. readonly lengthComputable: boolean;
  48076. /** defines the loaded data length */
  48077. readonly loaded: number;
  48078. /** defines the data length to load */
  48079. readonly total: number;
  48080. /**
  48081. * Create a new progress event
  48082. * @param lengthComputable defines if data length to load can be evaluated
  48083. * @param loaded defines the loaded data length
  48084. * @param total defines the data length to load
  48085. */
  48086. constructor(
  48087. /** defines if data length to load can be evaluated */
  48088. lengthComputable: boolean,
  48089. /** defines the loaded data length */
  48090. loaded: number,
  48091. /** defines the data length to load */
  48092. total: number);
  48093. /**
  48094. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48095. * @param event defines the source event
  48096. * @returns a new SceneLoaderProgressEvent
  48097. */
  48098. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48099. }
  48100. /**
  48101. * Interface used by SceneLoader plugins to define supported file extensions
  48102. */
  48103. export interface ISceneLoaderPluginExtensions {
  48104. /**
  48105. * Defines the list of supported extensions
  48106. */
  48107. [extension: string]: {
  48108. isBinary: boolean;
  48109. };
  48110. }
  48111. /**
  48112. * Interface used by SceneLoader plugin factory
  48113. */
  48114. export interface ISceneLoaderPluginFactory {
  48115. /**
  48116. * Defines the name of the factory
  48117. */
  48118. name: string;
  48119. /**
  48120. * Function called to create a new plugin
  48121. * @return the new plugin
  48122. */
  48123. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48124. /**
  48125. * The callback that returns true if the data can be directly loaded.
  48126. * @param data string containing the file data
  48127. * @returns if the data can be loaded directly
  48128. */
  48129. canDirectLoad?(data: string): boolean;
  48130. }
  48131. /**
  48132. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48133. */
  48134. export interface ISceneLoaderPluginBase {
  48135. /**
  48136. * The friendly name of this plugin.
  48137. */
  48138. name: string;
  48139. /**
  48140. * The file extensions supported by this plugin.
  48141. */
  48142. extensions: string | ISceneLoaderPluginExtensions;
  48143. /**
  48144. * The callback called when loading from a url.
  48145. * @param scene scene loading this url
  48146. * @param url url to load
  48147. * @param onSuccess callback called when the file successfully loads
  48148. * @param onProgress callback called while file is loading (if the server supports this mode)
  48149. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48150. * @param onError callback called when the file fails to load
  48151. * @returns a file request object
  48152. */
  48153. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48154. /**
  48155. * The callback called when loading from a file object.
  48156. * @param scene scene loading this file
  48157. * @param file defines the file to load
  48158. * @param onSuccess defines the callback to call when data is loaded
  48159. * @param onProgress defines the callback to call during loading process
  48160. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48161. * @param onError defines the callback to call when an error occurs
  48162. * @returns a file request object
  48163. */
  48164. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48165. /**
  48166. * The callback that returns true if the data can be directly loaded.
  48167. * @param data string containing the file data
  48168. * @returns if the data can be loaded directly
  48169. */
  48170. canDirectLoad?(data: string): boolean;
  48171. /**
  48172. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48173. * @param scene scene loading this data
  48174. * @param data string containing the data
  48175. * @returns data to pass to the plugin
  48176. */
  48177. directLoad?(scene: Scene, data: string): any;
  48178. /**
  48179. * The callback that allows custom handling of the root url based on the response url.
  48180. * @param rootUrl the original root url
  48181. * @param responseURL the response url if available
  48182. * @returns the new root url
  48183. */
  48184. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48185. }
  48186. /**
  48187. * Interface used to define a SceneLoader plugin
  48188. */
  48189. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48190. /**
  48191. * Import meshes into a scene.
  48192. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48193. * @param scene The scene to import into
  48194. * @param data The data to import
  48195. * @param rootUrl The root url for scene and resources
  48196. * @param meshes The meshes array to import into
  48197. * @param particleSystems The particle systems array to import into
  48198. * @param skeletons The skeletons array to import into
  48199. * @param onError The callback when import fails
  48200. * @returns True if successful or false otherwise
  48201. */
  48202. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48203. /**
  48204. * Load into a scene.
  48205. * @param scene The scene to load into
  48206. * @param data The data to import
  48207. * @param rootUrl The root url for scene and resources
  48208. * @param onError The callback when import fails
  48209. * @returns True if successful or false otherwise
  48210. */
  48211. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48212. /**
  48213. * Load into an asset container.
  48214. * @param scene The scene to load into
  48215. * @param data The data to import
  48216. * @param rootUrl The root url for scene and resources
  48217. * @param onError The callback when import fails
  48218. * @returns The loaded asset container
  48219. */
  48220. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48221. }
  48222. /**
  48223. * Interface used to define an async SceneLoader plugin
  48224. */
  48225. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48226. /**
  48227. * Import meshes into a scene.
  48228. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48229. * @param scene The scene to import into
  48230. * @param data The data to import
  48231. * @param rootUrl The root url for scene and resources
  48232. * @param onProgress The callback when the load progresses
  48233. * @param fileName Defines the name of the file to load
  48234. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48235. */
  48236. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48237. meshes: AbstractMesh[];
  48238. particleSystems: IParticleSystem[];
  48239. skeletons: Skeleton[];
  48240. animationGroups: AnimationGroup[];
  48241. }>;
  48242. /**
  48243. * Load into a scene.
  48244. * @param scene The scene to load into
  48245. * @param data The data to import
  48246. * @param rootUrl The root url for scene and resources
  48247. * @param onProgress The callback when the load progresses
  48248. * @param fileName Defines the name of the file to load
  48249. * @returns Nothing
  48250. */
  48251. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48252. /**
  48253. * Load into an asset container.
  48254. * @param scene The scene to load into
  48255. * @param data The data to import
  48256. * @param rootUrl The root url for scene and resources
  48257. * @param onProgress The callback when the load progresses
  48258. * @param fileName Defines the name of the file to load
  48259. * @returns The loaded asset container
  48260. */
  48261. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48262. }
  48263. /**
  48264. * Mode that determines how to handle old animation groups before loading new ones.
  48265. */
  48266. export enum SceneLoaderAnimationGroupLoadingMode {
  48267. /**
  48268. * Reset all old animations to initial state then dispose them.
  48269. */
  48270. Clean = 0,
  48271. /**
  48272. * Stop all old animations.
  48273. */
  48274. Stop = 1,
  48275. /**
  48276. * Restart old animations from first frame.
  48277. */
  48278. Sync = 2,
  48279. /**
  48280. * Old animations remains untouched.
  48281. */
  48282. NoSync = 3
  48283. }
  48284. /**
  48285. * Class used to load scene from various file formats using registered plugins
  48286. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48287. */
  48288. export class SceneLoader {
  48289. /**
  48290. * No logging while loading
  48291. */
  48292. static readonly NO_LOGGING: number;
  48293. /**
  48294. * Minimal logging while loading
  48295. */
  48296. static readonly MINIMAL_LOGGING: number;
  48297. /**
  48298. * Summary logging while loading
  48299. */
  48300. static readonly SUMMARY_LOGGING: number;
  48301. /**
  48302. * Detailled logging while loading
  48303. */
  48304. static readonly DETAILED_LOGGING: number;
  48305. /**
  48306. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48307. */
  48308. static get ForceFullSceneLoadingForIncremental(): boolean;
  48309. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48310. /**
  48311. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48312. */
  48313. static get ShowLoadingScreen(): boolean;
  48314. static set ShowLoadingScreen(value: boolean);
  48315. /**
  48316. * Defines the current logging level (while loading the scene)
  48317. * @ignorenaming
  48318. */
  48319. static get loggingLevel(): number;
  48320. static set loggingLevel(value: number);
  48321. /**
  48322. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48323. */
  48324. static get CleanBoneMatrixWeights(): boolean;
  48325. static set CleanBoneMatrixWeights(value: boolean);
  48326. /**
  48327. * Event raised when a plugin is used to load a scene
  48328. */
  48329. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48330. private static _registeredPlugins;
  48331. private static _getDefaultPlugin;
  48332. private static _getPluginForExtension;
  48333. private static _getPluginForDirectLoad;
  48334. private static _getPluginForFilename;
  48335. private static _getDirectLoad;
  48336. private static _loadData;
  48337. private static _getFileInfo;
  48338. /**
  48339. * Gets a plugin that can load the given extension
  48340. * @param extension defines the extension to load
  48341. * @returns a plugin or null if none works
  48342. */
  48343. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48344. /**
  48345. * Gets a boolean indicating that the given extension can be loaded
  48346. * @param extension defines the extension to load
  48347. * @returns true if the extension is supported
  48348. */
  48349. static IsPluginForExtensionAvailable(extension: string): boolean;
  48350. /**
  48351. * Adds a new plugin to the list of registered plugins
  48352. * @param plugin defines the plugin to add
  48353. */
  48354. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48355. /**
  48356. * Import meshes into a scene
  48357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48358. * @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)
  48359. * @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)
  48360. * @param scene the instance of BABYLON.Scene to append to
  48361. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48362. * @param onProgress a callback with a progress event for each file being loaded
  48363. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48364. * @param pluginExtension the extension used to determine the plugin
  48365. * @returns The loaded plugin
  48366. */
  48367. 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>;
  48368. /**
  48369. * Import meshes into a scene
  48370. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48371. * @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)
  48372. * @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)
  48373. * @param scene the instance of BABYLON.Scene to append to
  48374. * @param onProgress a callback with a progress event for each file being loaded
  48375. * @param pluginExtension the extension used to determine the plugin
  48376. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48377. */
  48378. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48379. meshes: AbstractMesh[];
  48380. particleSystems: IParticleSystem[];
  48381. skeletons: Skeleton[];
  48382. animationGroups: AnimationGroup[];
  48383. }>;
  48384. /**
  48385. * Load a scene
  48386. * @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)
  48387. * @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)
  48388. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48389. * @param onSuccess a callback with the scene when import succeeds
  48390. * @param onProgress a callback with a progress event for each file being loaded
  48391. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48392. * @param pluginExtension the extension used to determine the plugin
  48393. * @returns The loaded plugin
  48394. */
  48395. 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>;
  48396. /**
  48397. * Load a scene
  48398. * @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)
  48399. * @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)
  48400. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48401. * @param onProgress a callback with a progress event for each file being loaded
  48402. * @param pluginExtension the extension used to determine the plugin
  48403. * @returns The loaded scene
  48404. */
  48405. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48406. /**
  48407. * Append a scene
  48408. * @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)
  48409. * @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)
  48410. * @param scene is the instance of BABYLON.Scene to append to
  48411. * @param onSuccess a callback with the scene when import succeeds
  48412. * @param onProgress a callback with a progress event for each file being loaded
  48413. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48414. * @param pluginExtension the extension used to determine the plugin
  48415. * @returns The loaded plugin
  48416. */
  48417. 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>;
  48418. /**
  48419. * Append a scene
  48420. * @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)
  48421. * @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)
  48422. * @param scene is the instance of BABYLON.Scene to append to
  48423. * @param onProgress a callback with a progress event for each file being loaded
  48424. * @param pluginExtension the extension used to determine the plugin
  48425. * @returns The given scene
  48426. */
  48427. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48428. /**
  48429. * Load a scene into an asset container
  48430. * @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)
  48431. * @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)
  48432. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48433. * @param onSuccess a callback with the scene when import succeeds
  48434. * @param onProgress a callback with a progress event for each file being loaded
  48435. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48436. * @param pluginExtension the extension used to determine the plugin
  48437. * @returns The loaded plugin
  48438. */
  48439. 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>;
  48440. /**
  48441. * Load a scene into an asset container
  48442. * @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)
  48443. * @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)
  48444. * @param scene is the instance of Scene to append to
  48445. * @param onProgress a callback with a progress event for each file being loaded
  48446. * @param pluginExtension the extension used to determine the plugin
  48447. * @returns The loaded asset container
  48448. */
  48449. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48450. /**
  48451. * Import animations from a file into a scene
  48452. * @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)
  48453. * @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)
  48454. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48455. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48456. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48457. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48458. * @param onSuccess a callback with the scene when import succeeds
  48459. * @param onProgress a callback with a progress event for each file being loaded
  48460. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48461. */
  48462. 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;
  48463. /**
  48464. * Import animations from a file into a scene
  48465. * @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)
  48466. * @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)
  48467. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48468. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48469. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48470. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48471. * @param onSuccess a callback with the scene when import succeeds
  48472. * @param onProgress a callback with a progress event for each file being loaded
  48473. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48474. * @returns the updated scene with imported animations
  48475. */
  48476. 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>;
  48477. }
  48478. }
  48479. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48480. import { IDisposable, Scene } from "babylonjs/scene";
  48481. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48482. import { Observable } from "babylonjs/Misc/observable";
  48483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48484. import { Nullable } from "babylonjs/types";
  48485. /**
  48486. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48487. */
  48488. export type MotionControllerHandedness = "none" | "left" | "right";
  48489. /**
  48490. * The type of components available in motion controllers.
  48491. * This is not the name of the component.
  48492. */
  48493. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48494. /**
  48495. * The state of a controller component
  48496. */
  48497. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48498. /**
  48499. * The schema of motion controller layout.
  48500. * No object will be initialized using this interface
  48501. * This is used just to define the profile.
  48502. */
  48503. export interface IMotionControllerLayout {
  48504. /**
  48505. * Path to load the assets. Usually relative to the base path
  48506. */
  48507. assetPath: string;
  48508. /**
  48509. * Available components (unsorted)
  48510. */
  48511. components: {
  48512. /**
  48513. * A map of component Ids
  48514. */
  48515. [componentId: string]: {
  48516. /**
  48517. * The type of input the component outputs
  48518. */
  48519. type: MotionControllerComponentType;
  48520. /**
  48521. * The indices of this component in the gamepad object
  48522. */
  48523. gamepadIndices: {
  48524. /**
  48525. * Index of button
  48526. */
  48527. button?: number;
  48528. /**
  48529. * If available, index of x-axis
  48530. */
  48531. xAxis?: number;
  48532. /**
  48533. * If available, index of y-axis
  48534. */
  48535. yAxis?: number;
  48536. };
  48537. /**
  48538. * The mesh's root node name
  48539. */
  48540. rootNodeName: string;
  48541. /**
  48542. * Animation definitions for this model
  48543. */
  48544. visualResponses: {
  48545. [stateKey: string]: {
  48546. /**
  48547. * What property will be animated
  48548. */
  48549. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48550. /**
  48551. * What states influence this visual response
  48552. */
  48553. states: MotionControllerComponentStateType[];
  48554. /**
  48555. * Type of animation - movement or visibility
  48556. */
  48557. valueNodeProperty: "transform" | "visibility";
  48558. /**
  48559. * Base node name to move. Its position will be calculated according to the min and max nodes
  48560. */
  48561. valueNodeName?: string;
  48562. /**
  48563. * Minimum movement node
  48564. */
  48565. minNodeName?: string;
  48566. /**
  48567. * Max movement node
  48568. */
  48569. maxNodeName?: string;
  48570. };
  48571. };
  48572. /**
  48573. * If touch enabled, what is the name of node to display user feedback
  48574. */
  48575. touchPointNodeName?: string;
  48576. };
  48577. };
  48578. /**
  48579. * Is it xr standard mapping or not
  48580. */
  48581. gamepadMapping: "" | "xr-standard";
  48582. /**
  48583. * Base root node of this entire model
  48584. */
  48585. rootNodeName: string;
  48586. /**
  48587. * Defines the main button component id
  48588. */
  48589. selectComponentId: string;
  48590. }
  48591. /**
  48592. * A definition for the layout map in the input profile
  48593. */
  48594. export interface IMotionControllerLayoutMap {
  48595. /**
  48596. * Layouts with handedness type as a key
  48597. */
  48598. [handedness: string]: IMotionControllerLayout;
  48599. }
  48600. /**
  48601. * The XR Input profile schema
  48602. * Profiles can be found here:
  48603. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48604. */
  48605. export interface IMotionControllerProfile {
  48606. /**
  48607. * fallback profiles for this profileId
  48608. */
  48609. fallbackProfileIds: string[];
  48610. /**
  48611. * The layout map, with handedness as key
  48612. */
  48613. layouts: IMotionControllerLayoutMap;
  48614. /**
  48615. * The id of this profile
  48616. * correlates to the profile(s) in the xrInput.profiles array
  48617. */
  48618. profileId: string;
  48619. }
  48620. /**
  48621. * A helper-interface for the 3 meshes needed for controller button animation
  48622. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48623. */
  48624. export interface IMotionControllerButtonMeshMap {
  48625. /**
  48626. * the mesh that defines the pressed value mesh position.
  48627. * This is used to find the max-position of this button
  48628. */
  48629. pressedMesh: AbstractMesh;
  48630. /**
  48631. * the mesh that defines the unpressed value mesh position.
  48632. * This is used to find the min (or initial) position of this button
  48633. */
  48634. unpressedMesh: AbstractMesh;
  48635. /**
  48636. * The mesh that will be changed when value changes
  48637. */
  48638. valueMesh: AbstractMesh;
  48639. }
  48640. /**
  48641. * A helper-interface for the 3 meshes needed for controller axis animation.
  48642. * This will be expanded when touchpad animations are fully supported
  48643. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48644. */
  48645. export interface IMotionControllerMeshMap {
  48646. /**
  48647. * the mesh that defines the maximum value mesh position.
  48648. */
  48649. maxMesh?: AbstractMesh;
  48650. /**
  48651. * the mesh that defines the minimum value mesh position.
  48652. */
  48653. minMesh?: AbstractMesh;
  48654. /**
  48655. * The mesh that will be changed when axis value changes
  48656. */
  48657. valueMesh: AbstractMesh;
  48658. }
  48659. /**
  48660. * The elements needed for change-detection of the gamepad objects in motion controllers
  48661. */
  48662. export interface IMinimalMotionControllerObject {
  48663. /**
  48664. * Available axes of this controller
  48665. */
  48666. axes: number[];
  48667. /**
  48668. * An array of available buttons
  48669. */
  48670. buttons: Array<{
  48671. /**
  48672. * Value of the button/trigger
  48673. */
  48674. value: number;
  48675. /**
  48676. * If the button/trigger is currently touched
  48677. */
  48678. touched: boolean;
  48679. /**
  48680. * If the button/trigger is currently pressed
  48681. */
  48682. pressed: boolean;
  48683. }>;
  48684. /**
  48685. * EXPERIMENTAL haptic support.
  48686. */
  48687. hapticActuators?: Array<{
  48688. pulse: (value: number, duration: number) => Promise<boolean>;
  48689. }>;
  48690. }
  48691. /**
  48692. * An Abstract Motion controller
  48693. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48694. * Each component has an observable to check for changes in value and state
  48695. */
  48696. export abstract class WebXRAbstractMotionController implements IDisposable {
  48697. protected scene: Scene;
  48698. protected layout: IMotionControllerLayout;
  48699. /**
  48700. * The gamepad object correlating to this controller
  48701. */
  48702. gamepadObject: IMinimalMotionControllerObject;
  48703. /**
  48704. * handedness (left/right/none) of this controller
  48705. */
  48706. handedness: MotionControllerHandedness;
  48707. private _initComponent;
  48708. private _modelReady;
  48709. /**
  48710. * A map of components (WebXRControllerComponent) in this motion controller
  48711. * Components have a ComponentType and can also have both button and axis definitions
  48712. */
  48713. readonly components: {
  48714. [id: string]: WebXRControllerComponent;
  48715. };
  48716. /**
  48717. * Disable the model's animation. Can be set at any time.
  48718. */
  48719. disableAnimation: boolean;
  48720. /**
  48721. * Observers registered here will be triggered when the model of this controller is done loading
  48722. */
  48723. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48724. /**
  48725. * The profile id of this motion controller
  48726. */
  48727. abstract profileId: string;
  48728. /**
  48729. * The root mesh of the model. It is null if the model was not yet initialized
  48730. */
  48731. rootMesh: Nullable<AbstractMesh>;
  48732. /**
  48733. * constructs a new abstract motion controller
  48734. * @param scene the scene to which the model of the controller will be added
  48735. * @param layout The profile layout to load
  48736. * @param gamepadObject The gamepad object correlating to this controller
  48737. * @param handedness handedness (left/right/none) of this controller
  48738. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48739. */
  48740. constructor(scene: Scene, layout: IMotionControllerLayout,
  48741. /**
  48742. * The gamepad object correlating to this controller
  48743. */
  48744. gamepadObject: IMinimalMotionControllerObject,
  48745. /**
  48746. * handedness (left/right/none) of this controller
  48747. */
  48748. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48749. /**
  48750. * Dispose this controller, the model mesh and all its components
  48751. */
  48752. dispose(): void;
  48753. /**
  48754. * Returns all components of specific type
  48755. * @param type the type to search for
  48756. * @return an array of components with this type
  48757. */
  48758. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48759. /**
  48760. * get a component based an its component id as defined in layout.components
  48761. * @param id the id of the component
  48762. * @returns the component correlates to the id or undefined if not found
  48763. */
  48764. getComponent(id: string): WebXRControllerComponent;
  48765. /**
  48766. * Get the list of components available in this motion controller
  48767. * @returns an array of strings correlating to available components
  48768. */
  48769. getComponentIds(): string[];
  48770. /**
  48771. * Get the first component of specific type
  48772. * @param type type of component to find
  48773. * @return a controller component or null if not found
  48774. */
  48775. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48776. /**
  48777. * Get the main (Select) component of this controller as defined in the layout
  48778. * @returns the main component of this controller
  48779. */
  48780. getMainComponent(): WebXRControllerComponent;
  48781. /**
  48782. * Loads the model correlating to this controller
  48783. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48784. * @returns A promise fulfilled with the result of the model loading
  48785. */
  48786. loadModel(): Promise<boolean>;
  48787. /**
  48788. * Update this model using the current XRFrame
  48789. * @param xrFrame the current xr frame to use and update the model
  48790. */
  48791. updateFromXRFrame(xrFrame: XRFrame): void;
  48792. /**
  48793. * Backwards compatibility due to a deeply-integrated typo
  48794. */
  48795. get handness(): XREye;
  48796. /**
  48797. * Pulse (vibrate) this controller
  48798. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48799. * Consecutive calls to this function will cancel the last pulse call
  48800. *
  48801. * @param value the strength of the pulse in 0.0...1.0 range
  48802. * @param duration Duration of the pulse in milliseconds
  48803. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48804. * @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
  48805. */
  48806. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48807. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48808. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48809. /**
  48810. * Moves the axis on the controller mesh based on its current state
  48811. * @param axis the index of the axis
  48812. * @param axisValue the value of the axis which determines the meshes new position
  48813. * @hidden
  48814. */
  48815. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48816. /**
  48817. * Update the model itself with the current frame data
  48818. * @param xrFrame the frame to use for updating the model mesh
  48819. */
  48820. protected updateModel(xrFrame: XRFrame): void;
  48821. /**
  48822. * Get the filename and path for this controller's model
  48823. * @returns a map of filename and path
  48824. */
  48825. protected abstract _getFilenameAndPath(): {
  48826. filename: string;
  48827. path: string;
  48828. };
  48829. /**
  48830. * This function is called before the mesh is loaded. It checks for loading constraints.
  48831. * For example, this function can check if the GLB loader is available
  48832. * If this function returns false, the generic controller will be loaded instead
  48833. * @returns Is the client ready to load the mesh
  48834. */
  48835. protected abstract _getModelLoadingConstraints(): boolean;
  48836. /**
  48837. * This function will be called after the model was successfully loaded and can be used
  48838. * for mesh transformations before it is available for the user
  48839. * @param meshes the loaded meshes
  48840. */
  48841. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48842. /**
  48843. * Set the root mesh for this controller. Important for the WebXR controller class
  48844. * @param meshes the loaded meshes
  48845. */
  48846. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48847. /**
  48848. * A function executed each frame that updates the mesh (if needed)
  48849. * @param xrFrame the current xrFrame
  48850. */
  48851. protected abstract _updateModel(xrFrame: XRFrame): void;
  48852. private _getGenericFilenameAndPath;
  48853. private _getGenericParentMesh;
  48854. }
  48855. }
  48856. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  48857. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48859. import { Scene } from "babylonjs/scene";
  48860. /**
  48861. * A generic trigger-only motion controller for WebXR
  48862. */
  48863. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48864. /**
  48865. * Static version of the profile id of this controller
  48866. */
  48867. static ProfileId: string;
  48868. profileId: string;
  48869. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48870. protected _getFilenameAndPath(): {
  48871. filename: string;
  48872. path: string;
  48873. };
  48874. protected _getModelLoadingConstraints(): boolean;
  48875. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48876. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48877. protected _updateModel(): void;
  48878. }
  48879. }
  48880. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  48881. import { Vector4 } from "babylonjs/Maths/math.vector";
  48882. import { Mesh } from "babylonjs/Meshes/mesh";
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Nullable } from "babylonjs/types";
  48885. /**
  48886. * Class containing static functions to help procedurally build meshes
  48887. */
  48888. export class SphereBuilder {
  48889. /**
  48890. * Creates a sphere mesh
  48891. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48892. * * 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`)
  48893. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48894. * * 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
  48895. * * 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)
  48896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48899. * @param name defines the name of the mesh
  48900. * @param options defines the options used to create the mesh
  48901. * @param scene defines the hosting scene
  48902. * @returns the sphere mesh
  48903. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48904. */
  48905. static CreateSphere(name: string, options: {
  48906. segments?: number;
  48907. diameter?: number;
  48908. diameterX?: number;
  48909. diameterY?: number;
  48910. diameterZ?: number;
  48911. arc?: number;
  48912. slice?: number;
  48913. sideOrientation?: number;
  48914. frontUVs?: Vector4;
  48915. backUVs?: Vector4;
  48916. updatable?: boolean;
  48917. }, scene?: Nullable<Scene>): Mesh;
  48918. }
  48919. }
  48920. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  48921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48922. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48923. import { Scene } from "babylonjs/scene";
  48924. /**
  48925. * A profiled motion controller has its profile loaded from an online repository.
  48926. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48927. */
  48928. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48929. private _repositoryUrl;
  48930. private _buttonMeshMapping;
  48931. private _touchDots;
  48932. /**
  48933. * The profile ID of this controller. Will be populated when the controller initializes.
  48934. */
  48935. profileId: string;
  48936. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48937. dispose(): void;
  48938. protected _getFilenameAndPath(): {
  48939. filename: string;
  48940. path: string;
  48941. };
  48942. protected _getModelLoadingConstraints(): boolean;
  48943. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48944. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48945. protected _updateModel(_xrFrame: XRFrame): void;
  48946. }
  48947. }
  48948. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  48949. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48950. import { Scene } from "babylonjs/scene";
  48951. /**
  48952. * A construction function type to create a new controller based on an xrInput object
  48953. */
  48954. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48955. /**
  48956. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48957. *
  48958. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48959. * it should be replaced with auto-loaded controllers.
  48960. *
  48961. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48962. */
  48963. export class WebXRMotionControllerManager {
  48964. private static _AvailableControllers;
  48965. private static _Fallbacks;
  48966. private static _ProfileLoadingPromises;
  48967. private static _ProfilesList;
  48968. /**
  48969. * The base URL of the online controller repository. Can be changed at any time.
  48970. */
  48971. static BaseRepositoryUrl: string;
  48972. /**
  48973. * Which repository gets priority - local or online
  48974. */
  48975. static PrioritizeOnlineRepository: boolean;
  48976. /**
  48977. * Use the online repository, or use only locally-defined controllers
  48978. */
  48979. static UseOnlineRepository: boolean;
  48980. /**
  48981. * Clear the cache used for profile loading and reload when requested again
  48982. */
  48983. static ClearProfilesCache(): void;
  48984. /**
  48985. * Register the default fallbacks.
  48986. * This function is called automatically when this file is imported.
  48987. */
  48988. static DefaultFallbacks(): void;
  48989. /**
  48990. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48991. * @param profileId the profile to which a fallback needs to be found
  48992. * @return an array with corresponding fallback profiles
  48993. */
  48994. static FindFallbackWithProfileId(profileId: string): string[];
  48995. /**
  48996. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48997. * The order of search:
  48998. *
  48999. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49000. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49001. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49002. * 4) return the generic trigger controller if none were found
  49003. *
  49004. * @param xrInput the xrInput to which a new controller is initialized
  49005. * @param scene the scene to which the model will be added
  49006. * @param forceProfile force a certain profile for this controller
  49007. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49008. */
  49009. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49010. /**
  49011. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49012. *
  49013. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49014. *
  49015. * @param type the profile type to register
  49016. * @param constructFunction the function to be called when loading this profile
  49017. */
  49018. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49019. /**
  49020. * Register a fallback to a specific profile.
  49021. * @param profileId the profileId that will receive the fallbacks
  49022. * @param fallbacks A list of fallback profiles
  49023. */
  49024. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49025. /**
  49026. * Will update the list of profiles available in the repository
  49027. * @return a promise that resolves to a map of profiles available online
  49028. */
  49029. static UpdateProfilesList(): Promise<{
  49030. [profile: string]: string;
  49031. }>;
  49032. private static _LoadProfileFromRepository;
  49033. private static _LoadProfilesFromAvailableControllers;
  49034. }
  49035. }
  49036. declare module "babylonjs/XR/webXRInputSource" {
  49037. import { Observable } from "babylonjs/Misc/observable";
  49038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49039. import { Ray } from "babylonjs/Culling/ray";
  49040. import { Scene } from "babylonjs/scene";
  49041. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49042. /**
  49043. * Configuration options for the WebXR controller creation
  49044. */
  49045. export interface IWebXRControllerOptions {
  49046. /**
  49047. * Should the controller mesh be animated when a user interacts with it
  49048. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49049. */
  49050. disableMotionControllerAnimation?: boolean;
  49051. /**
  49052. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49053. */
  49054. doNotLoadControllerMesh?: boolean;
  49055. /**
  49056. * Force a specific controller type for this controller.
  49057. * This can be used when creating your own profile or when testing different controllers
  49058. */
  49059. forceControllerProfile?: string;
  49060. /**
  49061. * Defines a rendering group ID for meshes that will be loaded.
  49062. * This is for the default controllers only.
  49063. */
  49064. renderingGroupId?: number;
  49065. }
  49066. /**
  49067. * Represents an XR controller
  49068. */
  49069. export class WebXRInputSource {
  49070. private _scene;
  49071. /** The underlying input source for the controller */
  49072. inputSource: XRInputSource;
  49073. private _options;
  49074. private _tmpVector;
  49075. private _uniqueId;
  49076. /**
  49077. * 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
  49078. */
  49079. grip?: AbstractMesh;
  49080. /**
  49081. * If available, this is the gamepad object related to this controller.
  49082. * Using this object it is possible to get click events and trackpad changes of the
  49083. * webxr controller that is currently being used.
  49084. */
  49085. motionController?: WebXRAbstractMotionController;
  49086. /**
  49087. * Event that fires when the controller is removed/disposed.
  49088. * The object provided as event data is this controller, after associated assets were disposed.
  49089. * uniqueId is still available.
  49090. */
  49091. onDisposeObservable: Observable<WebXRInputSource>;
  49092. /**
  49093. * Will be triggered when the mesh associated with the motion controller is done loading.
  49094. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49095. * A shortened version of controller -> motion controller -> on mesh loaded.
  49096. */
  49097. onMeshLoadedObservable: Observable<AbstractMesh>;
  49098. /**
  49099. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49100. */
  49101. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49102. /**
  49103. * Pointer which can be used to select objects or attach a visible laser to
  49104. */
  49105. pointer: AbstractMesh;
  49106. /**
  49107. * Creates the controller
  49108. * @see https://doc.babylonjs.com/how_to/webxr
  49109. * @param _scene the scene which the controller should be associated to
  49110. * @param inputSource the underlying input source for the controller
  49111. * @param _options options for this controller creation
  49112. */
  49113. constructor(_scene: Scene,
  49114. /** The underlying input source for the controller */
  49115. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49116. /**
  49117. * Get this controllers unique id
  49118. */
  49119. get uniqueId(): string;
  49120. /**
  49121. * Disposes of the object
  49122. */
  49123. dispose(): void;
  49124. /**
  49125. * Gets a world space ray coming from the pointer or grip
  49126. * @param result the resulting ray
  49127. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49128. */
  49129. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49130. /**
  49131. * Updates the controller pose based on the given XRFrame
  49132. * @param xrFrame xr frame to update the pose with
  49133. * @param referenceSpace reference space to use
  49134. */
  49135. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49136. }
  49137. }
  49138. declare module "babylonjs/XR/webXRInput" {
  49139. import { Observable } from "babylonjs/Misc/observable";
  49140. import { IDisposable } from "babylonjs/scene";
  49141. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49142. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49143. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49144. /**
  49145. * The schema for initialization options of the XR Input class
  49146. */
  49147. export interface IWebXRInputOptions {
  49148. /**
  49149. * If set to true no model will be automatically loaded
  49150. */
  49151. doNotLoadControllerMeshes?: boolean;
  49152. /**
  49153. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49154. * If not found, the xr input profile data will be used.
  49155. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49156. */
  49157. forceInputProfile?: string;
  49158. /**
  49159. * Do not send a request to the controller repository to load the profile.
  49160. *
  49161. * Instead, use the controllers available in babylon itself.
  49162. */
  49163. disableOnlineControllerRepository?: boolean;
  49164. /**
  49165. * A custom URL for the controllers repository
  49166. */
  49167. customControllersRepositoryURL?: string;
  49168. /**
  49169. * Should the controller model's components not move according to the user input
  49170. */
  49171. disableControllerAnimation?: boolean;
  49172. /**
  49173. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49174. */
  49175. controllerOptions?: IWebXRControllerOptions;
  49176. }
  49177. /**
  49178. * XR input used to track XR inputs such as controllers/rays
  49179. */
  49180. export class WebXRInput implements IDisposable {
  49181. /**
  49182. * the xr session manager for this session
  49183. */
  49184. xrSessionManager: WebXRSessionManager;
  49185. /**
  49186. * the WebXR camera for this session. Mainly used for teleportation
  49187. */
  49188. xrCamera: WebXRCamera;
  49189. private readonly options;
  49190. /**
  49191. * XR controllers being tracked
  49192. */
  49193. controllers: Array<WebXRInputSource>;
  49194. private _frameObserver;
  49195. private _sessionEndedObserver;
  49196. private _sessionInitObserver;
  49197. /**
  49198. * Event when a controller has been connected/added
  49199. */
  49200. onControllerAddedObservable: Observable<WebXRInputSource>;
  49201. /**
  49202. * Event when a controller has been removed/disconnected
  49203. */
  49204. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49205. /**
  49206. * Initializes the WebXRInput
  49207. * @param xrSessionManager the xr session manager for this session
  49208. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49209. * @param options = initialization options for this xr input
  49210. */
  49211. constructor(
  49212. /**
  49213. * the xr session manager for this session
  49214. */
  49215. xrSessionManager: WebXRSessionManager,
  49216. /**
  49217. * the WebXR camera for this session. Mainly used for teleportation
  49218. */
  49219. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49220. private _onInputSourcesChange;
  49221. private _addAndRemoveControllers;
  49222. /**
  49223. * Disposes of the object
  49224. */
  49225. dispose(): void;
  49226. }
  49227. }
  49228. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49229. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49230. import { Observable, EventState } from "babylonjs/Misc/observable";
  49231. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49232. /**
  49233. * This is the base class for all WebXR features.
  49234. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49235. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49236. */
  49237. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49238. protected _xrSessionManager: WebXRSessionManager;
  49239. private _attached;
  49240. private _removeOnDetach;
  49241. /**
  49242. * Should auto-attach be disabled?
  49243. */
  49244. disableAutoAttach: boolean;
  49245. /**
  49246. * Construct a new (abstract) WebXR feature
  49247. * @param _xrSessionManager the xr session manager for this feature
  49248. */
  49249. constructor(_xrSessionManager: WebXRSessionManager);
  49250. /**
  49251. * Is this feature attached
  49252. */
  49253. get attached(): boolean;
  49254. /**
  49255. * attach this feature
  49256. *
  49257. * @param force should attachment be forced (even when already attached)
  49258. * @returns true if successful, false is failed or already attached
  49259. */
  49260. attach(force?: boolean): boolean;
  49261. /**
  49262. * detach this feature.
  49263. *
  49264. * @returns true if successful, false if failed or already detached
  49265. */
  49266. detach(): boolean;
  49267. /**
  49268. * Dispose this feature and all of the resources attached
  49269. */
  49270. dispose(): void;
  49271. /**
  49272. * This is used to register callbacks that will automatically be removed when detach is called.
  49273. * @param observable the observable to which the observer will be attached
  49274. * @param callback the callback to register
  49275. */
  49276. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49277. /**
  49278. * Code in this function will be executed on each xrFrame received from the browser.
  49279. * This function will not execute after the feature is detached.
  49280. * @param _xrFrame the current frame
  49281. */
  49282. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49283. }
  49284. }
  49285. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49286. import { IDisposable, Scene } from "babylonjs/scene";
  49287. import { Nullable } from "babylonjs/types";
  49288. import { Observable } from "babylonjs/Misc/observable";
  49289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49290. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49291. import { Camera } from "babylonjs/Cameras/camera";
  49292. /**
  49293. * Renders a layer on top of an existing scene
  49294. */
  49295. export class UtilityLayerRenderer implements IDisposable {
  49296. /** the original scene that will be rendered on top of */
  49297. originalScene: Scene;
  49298. private _pointerCaptures;
  49299. private _lastPointerEvents;
  49300. private static _DefaultUtilityLayer;
  49301. private static _DefaultKeepDepthUtilityLayer;
  49302. private _sharedGizmoLight;
  49303. private _renderCamera;
  49304. /**
  49305. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49306. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49307. * @returns the camera that is used when rendering the utility layer
  49308. */
  49309. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49310. /**
  49311. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49312. * @param cam the camera that should be used when rendering the utility layer
  49313. */
  49314. setRenderCamera(cam: Nullable<Camera>): void;
  49315. /**
  49316. * @hidden
  49317. * Light which used by gizmos to get light shading
  49318. */
  49319. _getSharedGizmoLight(): HemisphericLight;
  49320. /**
  49321. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49322. */
  49323. pickUtilitySceneFirst: boolean;
  49324. /**
  49325. * 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)
  49326. */
  49327. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49328. /**
  49329. * 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)
  49330. */
  49331. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49332. /**
  49333. * The scene that is rendered on top of the original scene
  49334. */
  49335. utilityLayerScene: Scene;
  49336. /**
  49337. * If the utility layer should automatically be rendered on top of existing scene
  49338. */
  49339. shouldRender: boolean;
  49340. /**
  49341. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49342. */
  49343. onlyCheckPointerDownEvents: boolean;
  49344. /**
  49345. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49346. */
  49347. processAllEvents: boolean;
  49348. /**
  49349. * Observable raised when the pointer move from the utility layer scene to the main scene
  49350. */
  49351. onPointerOutObservable: Observable<number>;
  49352. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49353. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49354. private _afterRenderObserver;
  49355. private _sceneDisposeObserver;
  49356. private _originalPointerObserver;
  49357. /**
  49358. * Instantiates a UtilityLayerRenderer
  49359. * @param originalScene the original scene that will be rendered on top of
  49360. * @param handleEvents boolean indicating if the utility layer should handle events
  49361. */
  49362. constructor(
  49363. /** the original scene that will be rendered on top of */
  49364. originalScene: Scene, handleEvents?: boolean);
  49365. private _notifyObservers;
  49366. /**
  49367. * Renders the utility layers scene on top of the original scene
  49368. */
  49369. render(): void;
  49370. /**
  49371. * Disposes of the renderer
  49372. */
  49373. dispose(): void;
  49374. private _updateCamera;
  49375. }
  49376. }
  49377. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49378. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49380. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49381. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49382. import { Scene } from "babylonjs/scene";
  49383. import { Nullable } from "babylonjs/types";
  49384. import { Color3 } from "babylonjs/Maths/math.color";
  49385. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49386. /**
  49387. * Options interface for the pointer selection module
  49388. */
  49389. export interface IWebXRControllerPointerSelectionOptions {
  49390. /**
  49391. * if provided, this scene will be used to render meshes.
  49392. */
  49393. customUtilityLayerScene?: Scene;
  49394. /**
  49395. * 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)
  49396. * If not disabled, the last picked point will be used to execute a pointer up event
  49397. * If disabled, pointer up event will be triggered right after the pointer down event.
  49398. * Used in screen and gaze target ray mode only
  49399. */
  49400. disablePointerUpOnTouchOut: boolean;
  49401. /**
  49402. * For gaze mode (time to select instead of press)
  49403. */
  49404. forceGazeMode: boolean;
  49405. /**
  49406. * 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
  49407. * to start a new countdown to the pointer down event.
  49408. * Defaults to 1.
  49409. */
  49410. gazeModePointerMovedFactor?: number;
  49411. /**
  49412. * Different button type to use instead of the main component
  49413. */
  49414. overrideButtonId?: string;
  49415. /**
  49416. * use this rendering group id for the meshes (optional)
  49417. */
  49418. renderingGroupId?: number;
  49419. /**
  49420. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49421. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49422. * 3000 means 3 seconds between pointing at something and selecting it
  49423. */
  49424. timeToSelect?: number;
  49425. /**
  49426. * Should meshes created here be added to a utility layer or the main scene
  49427. */
  49428. useUtilityLayer?: boolean;
  49429. /**
  49430. * the xr input to use with this pointer selection
  49431. */
  49432. xrInput: WebXRInput;
  49433. }
  49434. /**
  49435. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49436. */
  49437. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49438. private readonly _options;
  49439. private static _idCounter;
  49440. private _attachController;
  49441. private _controllers;
  49442. private _scene;
  49443. private _tmpVectorForPickCompare;
  49444. /**
  49445. * The module's name
  49446. */
  49447. static readonly Name: string;
  49448. /**
  49449. * The (Babylon) version of this module.
  49450. * This is an integer representing the implementation version.
  49451. * This number does not correspond to the WebXR specs version
  49452. */
  49453. static readonly Version: number;
  49454. /**
  49455. * Disable lighting on the laser pointer (so it will always be visible)
  49456. */
  49457. disablePointerLighting: boolean;
  49458. /**
  49459. * Disable lighting on the selection mesh (so it will always be visible)
  49460. */
  49461. disableSelectionMeshLighting: boolean;
  49462. /**
  49463. * Should the laser pointer be displayed
  49464. */
  49465. displayLaserPointer: boolean;
  49466. /**
  49467. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49468. */
  49469. displaySelectionMesh: boolean;
  49470. /**
  49471. * This color will be set to the laser pointer when selection is triggered
  49472. */
  49473. laserPointerPickedColor: Color3;
  49474. /**
  49475. * Default color of the laser pointer
  49476. */
  49477. laserPointerDefaultColor: Color3;
  49478. /**
  49479. * default color of the selection ring
  49480. */
  49481. selectionMeshDefaultColor: Color3;
  49482. /**
  49483. * This color will be applied to the selection ring when selection is triggered
  49484. */
  49485. selectionMeshPickedColor: Color3;
  49486. /**
  49487. * Optional filter to be used for ray selection. This predicate shares behavior with
  49488. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49489. */
  49490. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49491. /**
  49492. * constructs a new background remover module
  49493. * @param _xrSessionManager the session manager for this module
  49494. * @param _options read-only options to be used in this module
  49495. */
  49496. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49497. /**
  49498. * attach this feature
  49499. * Will usually be called by the features manager
  49500. *
  49501. * @returns true if successful.
  49502. */
  49503. attach(): boolean;
  49504. /**
  49505. * detach this feature.
  49506. * Will usually be called by the features manager
  49507. *
  49508. * @returns true if successful.
  49509. */
  49510. detach(): boolean;
  49511. /**
  49512. * Will get the mesh under a specific pointer.
  49513. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49514. * @param controllerId the controllerId to check
  49515. * @returns The mesh under pointer or null if no mesh is under the pointer
  49516. */
  49517. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49518. /**
  49519. * Get the xr controller that correlates to the pointer id in the pointer event
  49520. *
  49521. * @param id the pointer id to search for
  49522. * @returns the controller that correlates to this id or null if not found
  49523. */
  49524. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49525. protected _onXRFrame(_xrFrame: XRFrame): void;
  49526. private _attachGazeMode;
  49527. private _attachScreenRayMode;
  49528. private _attachTrackedPointerRayMode;
  49529. private _convertNormalToDirectionOfRay;
  49530. private _detachController;
  49531. private _generateNewMeshPair;
  49532. private _pickingMoved;
  49533. private _updatePointerDistance;
  49534. /** @hidden */
  49535. get lasterPointerDefaultColor(): Color3;
  49536. }
  49537. }
  49538. declare module "babylonjs/XR/webXREnterExitUI" {
  49539. import { Nullable } from "babylonjs/types";
  49540. import { Observable } from "babylonjs/Misc/observable";
  49541. import { IDisposable, Scene } from "babylonjs/scene";
  49542. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49543. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49544. /**
  49545. * Button which can be used to enter a different mode of XR
  49546. */
  49547. export class WebXREnterExitUIButton {
  49548. /** button element */
  49549. element: HTMLElement;
  49550. /** XR initialization options for the button */
  49551. sessionMode: XRSessionMode;
  49552. /** Reference space type */
  49553. referenceSpaceType: XRReferenceSpaceType;
  49554. /**
  49555. * Creates a WebXREnterExitUIButton
  49556. * @param element button element
  49557. * @param sessionMode XR initialization session mode
  49558. * @param referenceSpaceType the type of reference space to be used
  49559. */
  49560. constructor(
  49561. /** button element */
  49562. element: HTMLElement,
  49563. /** XR initialization options for the button */
  49564. sessionMode: XRSessionMode,
  49565. /** Reference space type */
  49566. referenceSpaceType: XRReferenceSpaceType);
  49567. /**
  49568. * Extendable function which can be used to update the button's visuals when the state changes
  49569. * @param activeButton the current active button in the UI
  49570. */
  49571. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49572. }
  49573. /**
  49574. * Options to create the webXR UI
  49575. */
  49576. export class WebXREnterExitUIOptions {
  49577. /**
  49578. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49579. */
  49580. customButtons?: Array<WebXREnterExitUIButton>;
  49581. /**
  49582. * A reference space type to use when creating the default button.
  49583. * Default is local-floor
  49584. */
  49585. referenceSpaceType?: XRReferenceSpaceType;
  49586. /**
  49587. * Context to enter xr with
  49588. */
  49589. renderTarget?: Nullable<WebXRRenderTarget>;
  49590. /**
  49591. * A session mode to use when creating the default button.
  49592. * Default is immersive-vr
  49593. */
  49594. sessionMode?: XRSessionMode;
  49595. /**
  49596. * A list of optional features to init the session with
  49597. */
  49598. optionalFeatures?: string[];
  49599. }
  49600. /**
  49601. * UI to allow the user to enter/exit XR mode
  49602. */
  49603. export class WebXREnterExitUI implements IDisposable {
  49604. private scene;
  49605. /** version of the options passed to this UI */
  49606. options: WebXREnterExitUIOptions;
  49607. private _activeButton;
  49608. private _buttons;
  49609. private _overlay;
  49610. /**
  49611. * Fired every time the active button is changed.
  49612. *
  49613. * When xr is entered via a button that launches xr that button will be the callback parameter
  49614. *
  49615. * When exiting xr the callback parameter will be null)
  49616. */
  49617. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49618. /**
  49619. *
  49620. * @param scene babylon scene object to use
  49621. * @param options (read-only) version of the options passed to this UI
  49622. */
  49623. private constructor();
  49624. /**
  49625. * Creates UI to allow the user to enter/exit XR mode
  49626. * @param scene the scene to add the ui to
  49627. * @param helper the xr experience helper to enter/exit xr with
  49628. * @param options options to configure the UI
  49629. * @returns the created ui
  49630. */
  49631. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49632. /**
  49633. * Disposes of the XR UI component
  49634. */
  49635. dispose(): void;
  49636. private _updateButtons;
  49637. }
  49638. }
  49639. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49640. import { Vector3 } from "babylonjs/Maths/math.vector";
  49641. import { Color4 } from "babylonjs/Maths/math.color";
  49642. import { Nullable } from "babylonjs/types";
  49643. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49644. import { Scene } from "babylonjs/scene";
  49645. /**
  49646. * Class containing static functions to help procedurally build meshes
  49647. */
  49648. export class LinesBuilder {
  49649. /**
  49650. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49651. * * 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
  49652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49653. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49654. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49655. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49656. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49657. * * 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
  49658. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49661. * @param name defines the name of the new line system
  49662. * @param options defines the options used to create the line system
  49663. * @param scene defines the hosting scene
  49664. * @returns a new line system mesh
  49665. */
  49666. static CreateLineSystem(name: string, options: {
  49667. lines: Vector3[][];
  49668. updatable?: boolean;
  49669. instance?: Nullable<LinesMesh>;
  49670. colors?: Nullable<Color4[][]>;
  49671. useVertexAlpha?: boolean;
  49672. }, scene: Nullable<Scene>): LinesMesh;
  49673. /**
  49674. * Creates a line mesh
  49675. * 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
  49676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49677. * * The parameter `points` is an array successive Vector3
  49678. * * 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
  49679. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49680. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49681. * * When updating an instance, remember that only point positions can change, not the number of points
  49682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49684. * @param name defines the name of the new line system
  49685. * @param options defines the options used to create the line system
  49686. * @param scene defines the hosting scene
  49687. * @returns a new line mesh
  49688. */
  49689. static CreateLines(name: string, options: {
  49690. points: Vector3[];
  49691. updatable?: boolean;
  49692. instance?: Nullable<LinesMesh>;
  49693. colors?: Color4[];
  49694. useVertexAlpha?: boolean;
  49695. }, scene?: Nullable<Scene>): LinesMesh;
  49696. /**
  49697. * Creates a dashed line mesh
  49698. * * 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
  49699. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49700. * * The parameter `points` is an array successive Vector3
  49701. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49702. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49703. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49704. * * 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
  49705. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49706. * * When updating an instance, remember that only point positions can change, not the number of points
  49707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49708. * @param name defines the name of the mesh
  49709. * @param options defines the options used to create the mesh
  49710. * @param scene defines the hosting scene
  49711. * @returns the dashed line mesh
  49712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49713. */
  49714. static CreateDashedLines(name: string, options: {
  49715. points: Vector3[];
  49716. dashSize?: number;
  49717. gapSize?: number;
  49718. dashNb?: number;
  49719. updatable?: boolean;
  49720. instance?: LinesMesh;
  49721. useVertexAlpha?: boolean;
  49722. }, scene?: Nullable<Scene>): LinesMesh;
  49723. }
  49724. }
  49725. declare module "babylonjs/Misc/timer" {
  49726. import { Observable, Observer } from "babylonjs/Misc/observable";
  49727. import { Nullable } from "babylonjs/types";
  49728. import { IDisposable } from "babylonjs/scene";
  49729. /**
  49730. * Construction options for a timer
  49731. */
  49732. export interface ITimerOptions<T> {
  49733. /**
  49734. * Time-to-end
  49735. */
  49736. timeout: number;
  49737. /**
  49738. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49739. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49740. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49741. */
  49742. contextObservable: Observable<T>;
  49743. /**
  49744. * Optional parameters when adding an observer to the observable
  49745. */
  49746. observableParameters?: {
  49747. mask?: number;
  49748. insertFirst?: boolean;
  49749. scope?: any;
  49750. };
  49751. /**
  49752. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49753. */
  49754. breakCondition?: (data?: ITimerData<T>) => boolean;
  49755. /**
  49756. * Will be triggered when the time condition has met
  49757. */
  49758. onEnded?: (data: ITimerData<any>) => void;
  49759. /**
  49760. * Will be triggered when the break condition has met (prematurely ended)
  49761. */
  49762. onAborted?: (data: ITimerData<any>) => void;
  49763. /**
  49764. * Optional function to execute on each tick (or count)
  49765. */
  49766. onTick?: (data: ITimerData<any>) => void;
  49767. }
  49768. /**
  49769. * An interface defining the data sent by the timer
  49770. */
  49771. export interface ITimerData<T> {
  49772. /**
  49773. * When did it start
  49774. */
  49775. startTime: number;
  49776. /**
  49777. * Time now
  49778. */
  49779. currentTime: number;
  49780. /**
  49781. * Time passed since started
  49782. */
  49783. deltaTime: number;
  49784. /**
  49785. * How much is completed, in [0.0...1.0].
  49786. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49787. */
  49788. completeRate: number;
  49789. /**
  49790. * What the registered observable sent in the last count
  49791. */
  49792. payload: T;
  49793. }
  49794. /**
  49795. * The current state of the timer
  49796. */
  49797. export enum TimerState {
  49798. /**
  49799. * Timer initialized, not yet started
  49800. */
  49801. INIT = 0,
  49802. /**
  49803. * Timer started and counting
  49804. */
  49805. STARTED = 1,
  49806. /**
  49807. * Timer ended (whether aborted or time reached)
  49808. */
  49809. ENDED = 2
  49810. }
  49811. /**
  49812. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49813. *
  49814. * @param options options with which to initialize this timer
  49815. */
  49816. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49817. /**
  49818. * An advanced implementation of a timer class
  49819. */
  49820. export class AdvancedTimer<T = any> implements IDisposable {
  49821. /**
  49822. * Will notify each time the timer calculates the remaining time
  49823. */
  49824. onEachCountObservable: Observable<ITimerData<T>>;
  49825. /**
  49826. * Will trigger when the timer was aborted due to the break condition
  49827. */
  49828. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49829. /**
  49830. * Will trigger when the timer ended successfully
  49831. */
  49832. onTimerEndedObservable: Observable<ITimerData<T>>;
  49833. /**
  49834. * Will trigger when the timer state has changed
  49835. */
  49836. onStateChangedObservable: Observable<TimerState>;
  49837. private _observer;
  49838. private _contextObservable;
  49839. private _observableParameters;
  49840. private _startTime;
  49841. private _timer;
  49842. private _state;
  49843. private _breakCondition;
  49844. private _timeToEnd;
  49845. private _breakOnNextTick;
  49846. /**
  49847. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49848. * @param options construction options for this advanced timer
  49849. */
  49850. constructor(options: ITimerOptions<T>);
  49851. /**
  49852. * set a breaking condition for this timer. Default is to never break during count
  49853. * @param predicate the new break condition. Returns true to break, false otherwise
  49854. */
  49855. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49856. /**
  49857. * Reset ALL associated observables in this advanced timer
  49858. */
  49859. clearObservables(): void;
  49860. /**
  49861. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49862. *
  49863. * @param timeToEnd how much time to measure until timer ended
  49864. */
  49865. start(timeToEnd?: number): void;
  49866. /**
  49867. * Will force a stop on the next tick.
  49868. */
  49869. stop(): void;
  49870. /**
  49871. * Dispose this timer, clearing all resources
  49872. */
  49873. dispose(): void;
  49874. private _setState;
  49875. private _tick;
  49876. private _stop;
  49877. }
  49878. }
  49879. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  49880. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49881. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49882. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49884. import { Vector3 } from "babylonjs/Maths/math.vector";
  49885. import { Material } from "babylonjs/Materials/material";
  49886. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49887. import { Scene } from "babylonjs/scene";
  49888. /**
  49889. * The options container for the teleportation module
  49890. */
  49891. export interface IWebXRTeleportationOptions {
  49892. /**
  49893. * if provided, this scene will be used to render meshes.
  49894. */
  49895. customUtilityLayerScene?: Scene;
  49896. /**
  49897. * Values to configure the default target mesh
  49898. */
  49899. defaultTargetMeshOptions?: {
  49900. /**
  49901. * Fill color of the teleportation area
  49902. */
  49903. teleportationFillColor?: string;
  49904. /**
  49905. * Border color for the teleportation area
  49906. */
  49907. teleportationBorderColor?: string;
  49908. /**
  49909. * Disable the mesh's animation sequence
  49910. */
  49911. disableAnimation?: boolean;
  49912. /**
  49913. * Disable lighting on the material or the ring and arrow
  49914. */
  49915. disableLighting?: boolean;
  49916. /**
  49917. * Override the default material of the torus and arrow
  49918. */
  49919. torusArrowMaterial?: Material;
  49920. };
  49921. /**
  49922. * A list of meshes to use as floor meshes.
  49923. * Meshes can be added and removed after initializing the feature using the
  49924. * addFloorMesh and removeFloorMesh functions
  49925. * If empty, rotation will still work
  49926. */
  49927. floorMeshes?: AbstractMesh[];
  49928. /**
  49929. * use this rendering group id for the meshes (optional)
  49930. */
  49931. renderingGroupId?: number;
  49932. /**
  49933. * Should teleportation move only to snap points
  49934. */
  49935. snapPointsOnly?: boolean;
  49936. /**
  49937. * An array of points to which the teleportation will snap to.
  49938. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49939. */
  49940. snapPositions?: Vector3[];
  49941. /**
  49942. * How close should the teleportation ray be in order to snap to position.
  49943. * Default to 0.8 units (meters)
  49944. */
  49945. snapToPositionRadius?: number;
  49946. /**
  49947. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49948. * If you want to support rotation, make sure your mesh has a direction indicator.
  49949. *
  49950. * When left untouched, the default mesh will be initialized.
  49951. */
  49952. teleportationTargetMesh?: AbstractMesh;
  49953. /**
  49954. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49955. */
  49956. timeToTeleport?: number;
  49957. /**
  49958. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49959. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49960. */
  49961. useMainComponentOnly?: boolean;
  49962. /**
  49963. * Should meshes created here be added to a utility layer or the main scene
  49964. */
  49965. useUtilityLayer?: boolean;
  49966. /**
  49967. * Babylon XR Input class for controller
  49968. */
  49969. xrInput: WebXRInput;
  49970. }
  49971. /**
  49972. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49973. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49974. * the input of the attached controllers.
  49975. */
  49976. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49977. private _options;
  49978. private _controllers;
  49979. private _currentTeleportationControllerId;
  49980. private _floorMeshes;
  49981. private _quadraticBezierCurve;
  49982. private _selectionFeature;
  49983. private _snapToPositions;
  49984. private _snappedToPoint;
  49985. private _teleportationRingMaterial?;
  49986. private _tmpRay;
  49987. private _tmpVector;
  49988. /**
  49989. * The module's name
  49990. */
  49991. static readonly Name: string;
  49992. /**
  49993. * The (Babylon) version of this module.
  49994. * This is an integer representing the implementation version.
  49995. * This number does not correspond to the webxr specs version
  49996. */
  49997. static readonly Version: number;
  49998. /**
  49999. * Is movement backwards enabled
  50000. */
  50001. backwardsMovementEnabled: boolean;
  50002. /**
  50003. * Distance to travel when moving backwards
  50004. */
  50005. backwardsTeleportationDistance: number;
  50006. /**
  50007. * The distance from the user to the inspection point in the direction of the controller
  50008. * A higher number will allow the user to move further
  50009. * defaults to 5 (meters, in xr units)
  50010. */
  50011. parabolicCheckRadius: number;
  50012. /**
  50013. * Should the module support parabolic ray on top of direct ray
  50014. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50015. * Very helpful when moving between floors / different heights
  50016. */
  50017. parabolicRayEnabled: boolean;
  50018. /**
  50019. * How much rotation should be applied when rotating right and left
  50020. */
  50021. rotationAngle: number;
  50022. /**
  50023. * Is rotation enabled when moving forward?
  50024. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50025. */
  50026. rotationEnabled: boolean;
  50027. /**
  50028. * constructs a new anchor system
  50029. * @param _xrSessionManager an instance of WebXRSessionManager
  50030. * @param _options configuration object for this feature
  50031. */
  50032. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50033. /**
  50034. * Get the snapPointsOnly flag
  50035. */
  50036. get snapPointsOnly(): boolean;
  50037. /**
  50038. * Sets the snapPointsOnly flag
  50039. * @param snapToPoints should teleportation be exclusively to snap points
  50040. */
  50041. set snapPointsOnly(snapToPoints: boolean);
  50042. /**
  50043. * Add a new mesh to the floor meshes array
  50044. * @param mesh the mesh to use as floor mesh
  50045. */
  50046. addFloorMesh(mesh: AbstractMesh): void;
  50047. /**
  50048. * Add a new snap-to point to fix teleportation to this position
  50049. * @param newSnapPoint The new Snap-To point
  50050. */
  50051. addSnapPoint(newSnapPoint: Vector3): void;
  50052. attach(): boolean;
  50053. detach(): boolean;
  50054. dispose(): void;
  50055. /**
  50056. * Remove a mesh from the floor meshes array
  50057. * @param mesh the mesh to remove
  50058. */
  50059. removeFloorMesh(mesh: AbstractMesh): void;
  50060. /**
  50061. * Remove a mesh from the floor meshes array using its name
  50062. * @param name the mesh name to remove
  50063. */
  50064. removeFloorMeshByName(name: string): void;
  50065. /**
  50066. * 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
  50067. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50068. * @returns was the point found and removed or not
  50069. */
  50070. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50071. /**
  50072. * This function sets a selection feature that will be disabled when
  50073. * the forward ray is shown and will be reattached when hidden.
  50074. * This is used to remove the selection rays when moving.
  50075. * @param selectionFeature the feature to disable when forward movement is enabled
  50076. */
  50077. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50078. protected _onXRFrame(_xrFrame: XRFrame): void;
  50079. private _attachController;
  50080. private _createDefaultTargetMesh;
  50081. private _detachController;
  50082. private _findClosestSnapPointWithRadius;
  50083. private _setTargetMeshPosition;
  50084. private _setTargetMeshVisibility;
  50085. private _showParabolicPath;
  50086. private _teleportForward;
  50087. }
  50088. }
  50089. declare module "babylonjs/XR/webXRDefaultExperience" {
  50090. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50091. import { Scene } from "babylonjs/scene";
  50092. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50093. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50094. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50095. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50097. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50098. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50099. /**
  50100. * Options for the default xr helper
  50101. */
  50102. export class WebXRDefaultExperienceOptions {
  50103. /**
  50104. * Enable or disable default UI to enter XR
  50105. */
  50106. disableDefaultUI?: boolean;
  50107. /**
  50108. * Should teleportation not initialize. defaults to false.
  50109. */
  50110. disableTeleportation?: boolean;
  50111. /**
  50112. * Floor meshes that will be used for teleport
  50113. */
  50114. floorMeshes?: Array<AbstractMesh>;
  50115. /**
  50116. * If set to true, the first frame will not be used to reset position
  50117. * The first frame is mainly used when copying transformation from the old camera
  50118. * Mainly used in AR
  50119. */
  50120. ignoreNativeCameraTransformation?: boolean;
  50121. /**
  50122. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50123. */
  50124. inputOptions?: IWebXRInputOptions;
  50125. /**
  50126. * optional configuration for the output canvas
  50127. */
  50128. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50129. /**
  50130. * optional UI options. This can be used among other to change session mode and reference space type
  50131. */
  50132. uiOptions?: WebXREnterExitUIOptions;
  50133. /**
  50134. * When loading teleportation and pointer select, use stable versions instead of latest.
  50135. */
  50136. useStablePlugins?: boolean;
  50137. /**
  50138. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50139. */
  50140. renderingGroupId?: number;
  50141. /**
  50142. * A list of optional features to init the session with
  50143. * If set to true, all features we support will be added
  50144. */
  50145. optionalFeatures?: boolean | string[];
  50146. }
  50147. /**
  50148. * Default experience which provides a similar setup to the previous webVRExperience
  50149. */
  50150. export class WebXRDefaultExperience {
  50151. /**
  50152. * Base experience
  50153. */
  50154. baseExperience: WebXRExperienceHelper;
  50155. /**
  50156. * Enables ui for entering/exiting xr
  50157. */
  50158. enterExitUI: WebXREnterExitUI;
  50159. /**
  50160. * Input experience extension
  50161. */
  50162. input: WebXRInput;
  50163. /**
  50164. * Enables laser pointer and selection
  50165. */
  50166. pointerSelection: WebXRControllerPointerSelection;
  50167. /**
  50168. * Default target xr should render to
  50169. */
  50170. renderTarget: WebXRRenderTarget;
  50171. /**
  50172. * Enables teleportation
  50173. */
  50174. teleportation: WebXRMotionControllerTeleportation;
  50175. private constructor();
  50176. /**
  50177. * Creates the default xr experience
  50178. * @param scene scene
  50179. * @param options options for basic configuration
  50180. * @returns resulting WebXRDefaultExperience
  50181. */
  50182. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50183. /**
  50184. * DIsposes of the experience helper
  50185. */
  50186. dispose(): void;
  50187. }
  50188. }
  50189. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50190. import { Observable } from "babylonjs/Misc/observable";
  50191. import { Nullable } from "babylonjs/types";
  50192. import { Camera } from "babylonjs/Cameras/camera";
  50193. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50194. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50195. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50196. import { Scene } from "babylonjs/scene";
  50197. import { Vector3 } from "babylonjs/Maths/math.vector";
  50198. import { Color3 } from "babylonjs/Maths/math.color";
  50199. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50201. import { Mesh } from "babylonjs/Meshes/mesh";
  50202. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50203. import { EasingFunction } from "babylonjs/Animations/easing";
  50204. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50205. import "babylonjs/Meshes/Builders/groundBuilder";
  50206. import "babylonjs/Meshes/Builders/torusBuilder";
  50207. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50208. import "babylonjs/Gamepads/gamepadSceneComponent";
  50209. import "babylonjs/Animations/animatable";
  50210. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50211. /**
  50212. * Options to modify the vr teleportation behavior.
  50213. */
  50214. export interface VRTeleportationOptions {
  50215. /**
  50216. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50217. */
  50218. floorMeshName?: string;
  50219. /**
  50220. * A list of meshes to be used as the teleportation floor. (default: empty)
  50221. */
  50222. floorMeshes?: Mesh[];
  50223. /**
  50224. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50225. */
  50226. teleportationMode?: number;
  50227. /**
  50228. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50229. */
  50230. teleportationTime?: number;
  50231. /**
  50232. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50233. */
  50234. teleportationSpeed?: number;
  50235. /**
  50236. * The easing function used in the animation or null for Linear. (default CircleEase)
  50237. */
  50238. easingFunction?: EasingFunction;
  50239. }
  50240. /**
  50241. * Options to modify the vr experience helper's behavior.
  50242. */
  50243. export interface VRExperienceHelperOptions extends WebVROptions {
  50244. /**
  50245. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50246. */
  50247. createDeviceOrientationCamera?: boolean;
  50248. /**
  50249. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50250. */
  50251. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50252. /**
  50253. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50254. */
  50255. laserToggle?: boolean;
  50256. /**
  50257. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50258. */
  50259. floorMeshes?: Mesh[];
  50260. /**
  50261. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50262. */
  50263. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50264. /**
  50265. * Defines if WebXR should be used instead of WebVR (if available)
  50266. */
  50267. useXR?: boolean;
  50268. }
  50269. /**
  50270. * Event containing information after VR has been entered
  50271. */
  50272. export class OnAfterEnteringVRObservableEvent {
  50273. /**
  50274. * If entering vr was successful
  50275. */
  50276. success: boolean;
  50277. }
  50278. /**
  50279. * Helps to quickly add VR support to an existing scene.
  50280. * See http://doc.babylonjs.com/how_to/webvr_helper
  50281. */
  50282. export class VRExperienceHelper {
  50283. /** Options to modify the vr experience helper's behavior. */
  50284. webVROptions: VRExperienceHelperOptions;
  50285. private _scene;
  50286. private _position;
  50287. private _btnVR;
  50288. private _btnVRDisplayed;
  50289. private _webVRsupported;
  50290. private _webVRready;
  50291. private _webVRrequesting;
  50292. private _webVRpresenting;
  50293. private _hasEnteredVR;
  50294. private _fullscreenVRpresenting;
  50295. private _inputElement;
  50296. private _webVRCamera;
  50297. private _vrDeviceOrientationCamera;
  50298. private _deviceOrientationCamera;
  50299. private _existingCamera;
  50300. private _onKeyDown;
  50301. private _onVrDisplayPresentChange;
  50302. private _onVRDisplayChanged;
  50303. private _onVRRequestPresentStart;
  50304. private _onVRRequestPresentComplete;
  50305. /**
  50306. * 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)
  50307. */
  50308. enableGazeEvenWhenNoPointerLock: boolean;
  50309. /**
  50310. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50311. */
  50312. exitVROnDoubleTap: boolean;
  50313. /**
  50314. * Observable raised right before entering VR.
  50315. */
  50316. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50317. /**
  50318. * Observable raised when entering VR has completed.
  50319. */
  50320. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50321. /**
  50322. * Observable raised when exiting VR.
  50323. */
  50324. onExitingVRObservable: Observable<VRExperienceHelper>;
  50325. /**
  50326. * Observable raised when controller mesh is loaded.
  50327. */
  50328. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50329. /** Return this.onEnteringVRObservable
  50330. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50331. */
  50332. get onEnteringVR(): Observable<VRExperienceHelper>;
  50333. /** Return this.onExitingVRObservable
  50334. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50335. */
  50336. get onExitingVR(): Observable<VRExperienceHelper>;
  50337. /** Return this.onControllerMeshLoadedObservable
  50338. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50339. */
  50340. get onControllerMeshLoaded(): Observable<WebVRController>;
  50341. private _rayLength;
  50342. private _useCustomVRButton;
  50343. private _teleportationRequested;
  50344. private _teleportActive;
  50345. private _floorMeshName;
  50346. private _floorMeshesCollection;
  50347. private _teleportationMode;
  50348. private _teleportationTime;
  50349. private _teleportationSpeed;
  50350. private _teleportationEasing;
  50351. private _rotationAllowed;
  50352. private _teleportBackwardsVector;
  50353. private _teleportationTarget;
  50354. private _isDefaultTeleportationTarget;
  50355. private _postProcessMove;
  50356. private _teleportationFillColor;
  50357. private _teleportationBorderColor;
  50358. private _rotationAngle;
  50359. private _haloCenter;
  50360. private _cameraGazer;
  50361. private _padSensibilityUp;
  50362. private _padSensibilityDown;
  50363. private _leftController;
  50364. private _rightController;
  50365. private _gazeColor;
  50366. private _laserColor;
  50367. private _pickedLaserColor;
  50368. private _pickedGazeColor;
  50369. /**
  50370. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50371. */
  50372. onNewMeshSelected: Observable<AbstractMesh>;
  50373. /**
  50374. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50375. * This observable will provide the mesh and the controller used to select the mesh
  50376. */
  50377. onMeshSelectedWithController: Observable<{
  50378. mesh: AbstractMesh;
  50379. controller: WebVRController;
  50380. }>;
  50381. /**
  50382. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50383. */
  50384. onNewMeshPicked: Observable<PickingInfo>;
  50385. private _circleEase;
  50386. /**
  50387. * Observable raised before camera teleportation
  50388. */
  50389. onBeforeCameraTeleport: Observable<Vector3>;
  50390. /**
  50391. * Observable raised after camera teleportation
  50392. */
  50393. onAfterCameraTeleport: Observable<Vector3>;
  50394. /**
  50395. * Observable raised when current selected mesh gets unselected
  50396. */
  50397. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50398. private _raySelectionPredicate;
  50399. /**
  50400. * To be optionaly changed by user to define custom ray selection
  50401. */
  50402. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50403. /**
  50404. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50405. */
  50406. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50407. /**
  50408. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50409. */
  50410. teleportationEnabled: boolean;
  50411. private _defaultHeight;
  50412. private _teleportationInitialized;
  50413. private _interactionsEnabled;
  50414. private _interactionsRequested;
  50415. private _displayGaze;
  50416. private _displayLaserPointer;
  50417. /**
  50418. * The mesh used to display where the user is going to teleport.
  50419. */
  50420. get teleportationTarget(): Mesh;
  50421. /**
  50422. * Sets the mesh to be used to display where the user is going to teleport.
  50423. */
  50424. set teleportationTarget(value: Mesh);
  50425. /**
  50426. * 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
  50427. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50428. * See http://doc.babylonjs.com/resources/baking_transformations
  50429. */
  50430. get gazeTrackerMesh(): Mesh;
  50431. set gazeTrackerMesh(value: Mesh);
  50432. /**
  50433. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50434. */
  50435. updateGazeTrackerScale: boolean;
  50436. /**
  50437. * If the gaze trackers color should be updated when selecting meshes
  50438. */
  50439. updateGazeTrackerColor: boolean;
  50440. /**
  50441. * If the controller laser color should be updated when selecting meshes
  50442. */
  50443. updateControllerLaserColor: boolean;
  50444. /**
  50445. * The gaze tracking mesh corresponding to the left controller
  50446. */
  50447. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50448. /**
  50449. * The gaze tracking mesh corresponding to the right controller
  50450. */
  50451. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50452. /**
  50453. * If the ray of the gaze should be displayed.
  50454. */
  50455. get displayGaze(): boolean;
  50456. /**
  50457. * Sets if the ray of the gaze should be displayed.
  50458. */
  50459. set displayGaze(value: boolean);
  50460. /**
  50461. * If the ray of the LaserPointer should be displayed.
  50462. */
  50463. get displayLaserPointer(): boolean;
  50464. /**
  50465. * Sets if the ray of the LaserPointer should be displayed.
  50466. */
  50467. set displayLaserPointer(value: boolean);
  50468. /**
  50469. * The deviceOrientationCamera used as the camera when not in VR.
  50470. */
  50471. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50472. /**
  50473. * Based on the current WebVR support, returns the current VR camera used.
  50474. */
  50475. get currentVRCamera(): Nullable<Camera>;
  50476. /**
  50477. * The webVRCamera which is used when in VR.
  50478. */
  50479. get webVRCamera(): WebVRFreeCamera;
  50480. /**
  50481. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50482. */
  50483. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50484. /**
  50485. * The html button that is used to trigger entering into VR.
  50486. */
  50487. get vrButton(): Nullable<HTMLButtonElement>;
  50488. private get _teleportationRequestInitiated();
  50489. /**
  50490. * Defines whether or not Pointer lock should be requested when switching to
  50491. * full screen.
  50492. */
  50493. requestPointerLockOnFullScreen: boolean;
  50494. /**
  50495. * If asking to force XR, this will be populated with the default xr experience
  50496. */
  50497. xr: WebXRDefaultExperience;
  50498. /**
  50499. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50500. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50501. */
  50502. xrTestDone: boolean;
  50503. /**
  50504. * Instantiates a VRExperienceHelper.
  50505. * Helps to quickly add VR support to an existing scene.
  50506. * @param scene The scene the VRExperienceHelper belongs to.
  50507. * @param webVROptions Options to modify the vr experience helper's behavior.
  50508. */
  50509. constructor(scene: Scene,
  50510. /** Options to modify the vr experience helper's behavior. */
  50511. webVROptions?: VRExperienceHelperOptions);
  50512. private completeVRInit;
  50513. private _onDefaultMeshLoaded;
  50514. private _onResize;
  50515. private _onFullscreenChange;
  50516. /**
  50517. * Gets a value indicating if we are currently in VR mode.
  50518. */
  50519. get isInVRMode(): boolean;
  50520. private onVrDisplayPresentChange;
  50521. private onVRDisplayChanged;
  50522. private moveButtonToBottomRight;
  50523. private displayVRButton;
  50524. private updateButtonVisibility;
  50525. private _cachedAngularSensibility;
  50526. /**
  50527. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50528. * Otherwise, will use the fullscreen API.
  50529. */
  50530. enterVR(): void;
  50531. /**
  50532. * Attempt to exit VR, or fullscreen.
  50533. */
  50534. exitVR(): void;
  50535. /**
  50536. * The position of the vr experience helper.
  50537. */
  50538. get position(): Vector3;
  50539. /**
  50540. * Sets the position of the vr experience helper.
  50541. */
  50542. set position(value: Vector3);
  50543. /**
  50544. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50545. */
  50546. enableInteractions(): void;
  50547. private get _noControllerIsActive();
  50548. private beforeRender;
  50549. private _isTeleportationFloor;
  50550. /**
  50551. * Adds a floor mesh to be used for teleportation.
  50552. * @param floorMesh the mesh to be used for teleportation.
  50553. */
  50554. addFloorMesh(floorMesh: Mesh): void;
  50555. /**
  50556. * Removes a floor mesh from being used for teleportation.
  50557. * @param floorMesh the mesh to be removed.
  50558. */
  50559. removeFloorMesh(floorMesh: Mesh): void;
  50560. /**
  50561. * Enables interactions and teleportation using the VR controllers and gaze.
  50562. * @param vrTeleportationOptions options to modify teleportation behavior.
  50563. */
  50564. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50565. private _onNewGamepadConnected;
  50566. private _tryEnableInteractionOnController;
  50567. private _onNewGamepadDisconnected;
  50568. private _enableInteractionOnController;
  50569. private _checkTeleportWithRay;
  50570. private _checkRotate;
  50571. private _checkTeleportBackwards;
  50572. private _enableTeleportationOnController;
  50573. private _createTeleportationCircles;
  50574. private _displayTeleportationTarget;
  50575. private _hideTeleportationTarget;
  50576. private _rotateCamera;
  50577. private _moveTeleportationSelectorTo;
  50578. private _workingVector;
  50579. private _workingQuaternion;
  50580. private _workingMatrix;
  50581. /**
  50582. * Time Constant Teleportation Mode
  50583. */
  50584. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50585. /**
  50586. * Speed Constant Teleportation Mode
  50587. */
  50588. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50589. /**
  50590. * Teleports the users feet to the desired location
  50591. * @param location The location where the user's feet should be placed
  50592. */
  50593. teleportCamera(location: Vector3): void;
  50594. private _convertNormalToDirectionOfRay;
  50595. private _castRayAndSelectObject;
  50596. private _notifySelectedMeshUnselected;
  50597. /**
  50598. * Permanently set new colors for the laser pointer
  50599. * @param color the new laser color
  50600. * @param pickedColor the new laser color when picked mesh detected
  50601. */
  50602. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50603. /**
  50604. * Set lighting enabled / disabled on the laser pointer of both controllers
  50605. * @param enabled should the lighting be enabled on the laser pointer
  50606. */
  50607. setLaserLightingState(enabled?: boolean): void;
  50608. /**
  50609. * Permanently set new colors for the gaze pointer
  50610. * @param color the new gaze color
  50611. * @param pickedColor the new gaze color when picked mesh detected
  50612. */
  50613. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50614. /**
  50615. * Sets the color of the laser ray from the vr controllers.
  50616. * @param color new color for the ray.
  50617. */
  50618. changeLaserColor(color: Color3): void;
  50619. /**
  50620. * Sets the color of the ray from the vr headsets gaze.
  50621. * @param color new color for the ray.
  50622. */
  50623. changeGazeColor(color: Color3): void;
  50624. /**
  50625. * Exits VR and disposes of the vr experience helper
  50626. */
  50627. dispose(): void;
  50628. /**
  50629. * Gets the name of the VRExperienceHelper class
  50630. * @returns "VRExperienceHelper"
  50631. */
  50632. getClassName(): string;
  50633. }
  50634. }
  50635. declare module "babylonjs/Cameras/VR/index" {
  50636. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50637. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50638. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50639. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50640. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50641. export * from "babylonjs/Cameras/VR/webVRCamera";
  50642. }
  50643. declare module "babylonjs/Cameras/RigModes/index" {
  50644. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50645. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50646. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50647. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50648. }
  50649. declare module "babylonjs/Cameras/index" {
  50650. export * from "babylonjs/Cameras/Inputs/index";
  50651. export * from "babylonjs/Cameras/cameraInputsManager";
  50652. export * from "babylonjs/Cameras/camera";
  50653. export * from "babylonjs/Cameras/targetCamera";
  50654. export * from "babylonjs/Cameras/freeCamera";
  50655. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50656. export * from "babylonjs/Cameras/touchCamera";
  50657. export * from "babylonjs/Cameras/arcRotateCamera";
  50658. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50659. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50660. export * from "babylonjs/Cameras/flyCamera";
  50661. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50662. export * from "babylonjs/Cameras/followCamera";
  50663. export * from "babylonjs/Cameras/followCameraInputsManager";
  50664. export * from "babylonjs/Cameras/gamepadCamera";
  50665. export * from "babylonjs/Cameras/Stereoscopic/index";
  50666. export * from "babylonjs/Cameras/universalCamera";
  50667. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50668. export * from "babylonjs/Cameras/VR/index";
  50669. export * from "babylonjs/Cameras/RigModes/index";
  50670. }
  50671. declare module "babylonjs/Collisions/index" {
  50672. export * from "babylonjs/Collisions/collider";
  50673. export * from "babylonjs/Collisions/collisionCoordinator";
  50674. export * from "babylonjs/Collisions/pickingInfo";
  50675. export * from "babylonjs/Collisions/intersectionInfo";
  50676. export * from "babylonjs/Collisions/meshCollisionData";
  50677. }
  50678. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50679. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50680. import { Vector3 } from "babylonjs/Maths/math.vector";
  50681. import { Ray } from "babylonjs/Culling/ray";
  50682. import { Plane } from "babylonjs/Maths/math.plane";
  50683. /**
  50684. * Contains an array of blocks representing the octree
  50685. */
  50686. export interface IOctreeContainer<T> {
  50687. /**
  50688. * Blocks within the octree
  50689. */
  50690. blocks: Array<OctreeBlock<T>>;
  50691. }
  50692. /**
  50693. * Class used to store a cell in an octree
  50694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50695. */
  50696. export class OctreeBlock<T> {
  50697. /**
  50698. * Gets the content of the current block
  50699. */
  50700. entries: T[];
  50701. /**
  50702. * Gets the list of block children
  50703. */
  50704. blocks: Array<OctreeBlock<T>>;
  50705. private _depth;
  50706. private _maxDepth;
  50707. private _capacity;
  50708. private _minPoint;
  50709. private _maxPoint;
  50710. private _boundingVectors;
  50711. private _creationFunc;
  50712. /**
  50713. * Creates a new block
  50714. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50715. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50716. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50717. * @param depth defines the current depth of this block in the octree
  50718. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50719. * @param creationFunc defines a callback to call when an element is added to the block
  50720. */
  50721. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50722. /**
  50723. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50724. */
  50725. get capacity(): number;
  50726. /**
  50727. * Gets the minimum vector (in world space) of the block's bounding box
  50728. */
  50729. get minPoint(): Vector3;
  50730. /**
  50731. * Gets the maximum vector (in world space) of the block's bounding box
  50732. */
  50733. get maxPoint(): Vector3;
  50734. /**
  50735. * Add a new element to this block
  50736. * @param entry defines the element to add
  50737. */
  50738. addEntry(entry: T): void;
  50739. /**
  50740. * Remove an element from this block
  50741. * @param entry defines the element to remove
  50742. */
  50743. removeEntry(entry: T): void;
  50744. /**
  50745. * Add an array of elements to this block
  50746. * @param entries defines the array of elements to add
  50747. */
  50748. addEntries(entries: T[]): void;
  50749. /**
  50750. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50751. * @param frustumPlanes defines the frustum planes to test
  50752. * @param selection defines the array to store current content if selection is positive
  50753. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50754. */
  50755. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50756. /**
  50757. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50758. * @param sphereCenter defines the bounding sphere center
  50759. * @param sphereRadius defines the bounding sphere radius
  50760. * @param selection defines the array to store current content if selection is positive
  50761. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50762. */
  50763. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50764. /**
  50765. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50766. * @param ray defines the ray to test with
  50767. * @param selection defines the array to store current content if selection is positive
  50768. */
  50769. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50770. /**
  50771. * Subdivide the content into child blocks (this block will then be empty)
  50772. */
  50773. createInnerBlocks(): void;
  50774. /**
  50775. * @hidden
  50776. */
  50777. 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;
  50778. }
  50779. }
  50780. declare module "babylonjs/Culling/Octrees/octree" {
  50781. import { SmartArray } from "babylonjs/Misc/smartArray";
  50782. import { Vector3 } from "babylonjs/Maths/math.vector";
  50783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50785. import { Ray } from "babylonjs/Culling/ray";
  50786. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50787. import { Plane } from "babylonjs/Maths/math.plane";
  50788. /**
  50789. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50790. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50791. */
  50792. export class Octree<T> {
  50793. /** 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.) */
  50794. maxDepth: number;
  50795. /**
  50796. * Blocks within the octree containing objects
  50797. */
  50798. blocks: Array<OctreeBlock<T>>;
  50799. /**
  50800. * Content stored in the octree
  50801. */
  50802. dynamicContent: T[];
  50803. private _maxBlockCapacity;
  50804. private _selectionContent;
  50805. private _creationFunc;
  50806. /**
  50807. * Creates a octree
  50808. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50809. * @param creationFunc function to be used to instatiate the octree
  50810. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50811. * @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.)
  50812. */
  50813. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50814. /** 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.) */
  50815. maxDepth?: number);
  50816. /**
  50817. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50818. * @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);
  50819. * @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);
  50820. * @param entries meshes to be added to the octree blocks
  50821. */
  50822. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50823. /**
  50824. * Adds a mesh to the octree
  50825. * @param entry Mesh to add to the octree
  50826. */
  50827. addMesh(entry: T): void;
  50828. /**
  50829. * Remove an element from the octree
  50830. * @param entry defines the element to remove
  50831. */
  50832. removeMesh(entry: T): void;
  50833. /**
  50834. * Selects an array of meshes within the frustum
  50835. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50836. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50837. * @returns array of meshes within the frustum
  50838. */
  50839. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50840. /**
  50841. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50842. * @param sphereCenter defines the bounding sphere center
  50843. * @param sphereRadius defines the bounding sphere radius
  50844. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50845. * @returns an array of objects that intersect the sphere
  50846. */
  50847. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50848. /**
  50849. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50850. * @param ray defines the ray to test with
  50851. * @returns array of intersected objects
  50852. */
  50853. intersectsRay(ray: Ray): SmartArray<T>;
  50854. /**
  50855. * Adds a mesh into the octree block if it intersects the block
  50856. */
  50857. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50858. /**
  50859. * Adds a submesh into the octree block if it intersects the block
  50860. */
  50861. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50862. }
  50863. }
  50864. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  50865. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  50866. import { Scene } from "babylonjs/scene";
  50867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50869. import { Ray } from "babylonjs/Culling/ray";
  50870. import { Octree } from "babylonjs/Culling/Octrees/octree";
  50871. import { Collider } from "babylonjs/Collisions/collider";
  50872. module "babylonjs/scene" {
  50873. interface Scene {
  50874. /**
  50875. * @hidden
  50876. * Backing Filed
  50877. */
  50878. _selectionOctree: Octree<AbstractMesh>;
  50879. /**
  50880. * Gets the octree used to boost mesh selection (picking)
  50881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50882. */
  50883. selectionOctree: Octree<AbstractMesh>;
  50884. /**
  50885. * Creates or updates the octree used to boost selection (picking)
  50886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50887. * @param maxCapacity defines the maximum capacity per leaf
  50888. * @param maxDepth defines the maximum depth of the octree
  50889. * @returns an octree of AbstractMesh
  50890. */
  50891. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50892. }
  50893. }
  50894. module "babylonjs/Meshes/abstractMesh" {
  50895. interface AbstractMesh {
  50896. /**
  50897. * @hidden
  50898. * Backing Field
  50899. */
  50900. _submeshesOctree: Octree<SubMesh>;
  50901. /**
  50902. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50903. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50904. * @param maxCapacity defines the maximum size of each block (64 by default)
  50905. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50906. * @returns the new octree
  50907. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50909. */
  50910. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50911. }
  50912. }
  50913. /**
  50914. * Defines the octree scene component responsible to manage any octrees
  50915. * in a given scene.
  50916. */
  50917. export class OctreeSceneComponent {
  50918. /**
  50919. * The component name help to identify the component in the list of scene components.
  50920. */
  50921. readonly name: string;
  50922. /**
  50923. * The scene the component belongs to.
  50924. */
  50925. scene: Scene;
  50926. /**
  50927. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50928. */
  50929. readonly checksIsEnabled: boolean;
  50930. /**
  50931. * Creates a new instance of the component for the given scene
  50932. * @param scene Defines the scene to register the component in
  50933. */
  50934. constructor(scene: Scene);
  50935. /**
  50936. * Registers the component in a given scene
  50937. */
  50938. register(): void;
  50939. /**
  50940. * Return the list of active meshes
  50941. * @returns the list of active meshes
  50942. */
  50943. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50944. /**
  50945. * Return the list of active sub meshes
  50946. * @param mesh The mesh to get the candidates sub meshes from
  50947. * @returns the list of active sub meshes
  50948. */
  50949. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50950. private _tempRay;
  50951. /**
  50952. * Return the list of sub meshes intersecting with a given local ray
  50953. * @param mesh defines the mesh to find the submesh for
  50954. * @param localRay defines the ray in local space
  50955. * @returns the list of intersecting sub meshes
  50956. */
  50957. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50958. /**
  50959. * Return the list of sub meshes colliding with a collider
  50960. * @param mesh defines the mesh to find the submesh for
  50961. * @param collider defines the collider to evaluate the collision against
  50962. * @returns the list of colliding sub meshes
  50963. */
  50964. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50965. /**
  50966. * Rebuilds the elements related to this component in case of
  50967. * context lost for instance.
  50968. */
  50969. rebuild(): void;
  50970. /**
  50971. * Disposes the component and the associated ressources.
  50972. */
  50973. dispose(): void;
  50974. }
  50975. }
  50976. declare module "babylonjs/Culling/Octrees/index" {
  50977. export * from "babylonjs/Culling/Octrees/octree";
  50978. export * from "babylonjs/Culling/Octrees/octreeBlock";
  50979. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  50980. }
  50981. declare module "babylonjs/Culling/index" {
  50982. export * from "babylonjs/Culling/boundingBox";
  50983. export * from "babylonjs/Culling/boundingInfo";
  50984. export * from "babylonjs/Culling/boundingSphere";
  50985. export * from "babylonjs/Culling/Octrees/index";
  50986. export * from "babylonjs/Culling/ray";
  50987. }
  50988. declare module "babylonjs/Gizmos/gizmo" {
  50989. import { Nullable } from "babylonjs/types";
  50990. import { IDisposable } from "babylonjs/scene";
  50991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50992. import { Mesh } from "babylonjs/Meshes/mesh";
  50993. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50994. /**
  50995. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50996. */
  50997. export class Gizmo implements IDisposable {
  50998. /** The utility layer the gizmo will be added to */
  50999. gizmoLayer: UtilityLayerRenderer;
  51000. /**
  51001. * The root mesh of the gizmo
  51002. */
  51003. _rootMesh: Mesh;
  51004. private _attachedMesh;
  51005. /**
  51006. * Ratio for the scale of the gizmo (Default: 1)
  51007. */
  51008. scaleRatio: number;
  51009. /**
  51010. * If a custom mesh has been set (Default: false)
  51011. */
  51012. protected _customMeshSet: boolean;
  51013. /**
  51014. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51015. * * When set, interactions will be enabled
  51016. */
  51017. get attachedMesh(): Nullable<AbstractMesh>;
  51018. set attachedMesh(value: Nullable<AbstractMesh>);
  51019. /**
  51020. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51021. * @param mesh The mesh to replace the default mesh of the gizmo
  51022. */
  51023. setCustomMesh(mesh: Mesh): void;
  51024. /**
  51025. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51026. */
  51027. updateGizmoRotationToMatchAttachedMesh: boolean;
  51028. /**
  51029. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51030. */
  51031. updateGizmoPositionToMatchAttachedMesh: boolean;
  51032. /**
  51033. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51034. */
  51035. updateScale: boolean;
  51036. protected _interactionsEnabled: boolean;
  51037. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51038. private _beforeRenderObserver;
  51039. private _tempVector;
  51040. /**
  51041. * Creates a gizmo
  51042. * @param gizmoLayer The utility layer the gizmo will be added to
  51043. */
  51044. constructor(
  51045. /** The utility layer the gizmo will be added to */
  51046. gizmoLayer?: UtilityLayerRenderer);
  51047. /**
  51048. * Updates the gizmo to match the attached mesh's position/rotation
  51049. */
  51050. protected _update(): void;
  51051. /**
  51052. * Disposes of the gizmo
  51053. */
  51054. dispose(): void;
  51055. }
  51056. }
  51057. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51058. import { Observable } from "babylonjs/Misc/observable";
  51059. import { Nullable } from "babylonjs/types";
  51060. import { Vector3 } from "babylonjs/Maths/math.vector";
  51061. import { Color3 } from "babylonjs/Maths/math.color";
  51062. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51064. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51065. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51066. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51067. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51068. import { Scene } from "babylonjs/scene";
  51069. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51070. /**
  51071. * Single plane drag gizmo
  51072. */
  51073. export class PlaneDragGizmo extends Gizmo {
  51074. /**
  51075. * Drag behavior responsible for the gizmos dragging interactions
  51076. */
  51077. dragBehavior: PointerDragBehavior;
  51078. private _pointerObserver;
  51079. /**
  51080. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51081. */
  51082. snapDistance: number;
  51083. /**
  51084. * Event that fires each time the gizmo snaps to a new location.
  51085. * * snapDistance is the the change in distance
  51086. */
  51087. onSnapObservable: Observable<{
  51088. snapDistance: number;
  51089. }>;
  51090. private _plane;
  51091. private _coloredMaterial;
  51092. private _hoverMaterial;
  51093. private _isEnabled;
  51094. private _parent;
  51095. /** @hidden */
  51096. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51097. /** @hidden */
  51098. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51099. /**
  51100. * Creates a PlaneDragGizmo
  51101. * @param gizmoLayer The utility layer the gizmo will be added to
  51102. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51103. * @param color The color of the gizmo
  51104. */
  51105. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51106. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51107. /**
  51108. * If the gizmo is enabled
  51109. */
  51110. set isEnabled(value: boolean);
  51111. get isEnabled(): boolean;
  51112. /**
  51113. * Disposes of the gizmo
  51114. */
  51115. dispose(): void;
  51116. }
  51117. }
  51118. declare module "babylonjs/Gizmos/positionGizmo" {
  51119. import { Observable } from "babylonjs/Misc/observable";
  51120. import { Nullable } from "babylonjs/types";
  51121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51122. import { Mesh } from "babylonjs/Meshes/mesh";
  51123. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51124. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51125. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51126. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51127. /**
  51128. * Gizmo that enables dragging a mesh along 3 axis
  51129. */
  51130. export class PositionGizmo extends Gizmo {
  51131. /**
  51132. * Internal gizmo used for interactions on the x axis
  51133. */
  51134. xGizmo: AxisDragGizmo;
  51135. /**
  51136. * Internal gizmo used for interactions on the y axis
  51137. */
  51138. yGizmo: AxisDragGizmo;
  51139. /**
  51140. * Internal gizmo used for interactions on the z axis
  51141. */
  51142. zGizmo: AxisDragGizmo;
  51143. /**
  51144. * Internal gizmo used for interactions on the yz plane
  51145. */
  51146. xPlaneGizmo: PlaneDragGizmo;
  51147. /**
  51148. * Internal gizmo used for interactions on the xz plane
  51149. */
  51150. yPlaneGizmo: PlaneDragGizmo;
  51151. /**
  51152. * Internal gizmo used for interactions on the xy plane
  51153. */
  51154. zPlaneGizmo: PlaneDragGizmo;
  51155. /**
  51156. * private variables
  51157. */
  51158. private _meshAttached;
  51159. private _updateGizmoRotationToMatchAttachedMesh;
  51160. private _snapDistance;
  51161. private _scaleRatio;
  51162. /** Fires an event when any of it's sub gizmos are dragged */
  51163. onDragStartObservable: Observable<unknown>;
  51164. /** Fires an event when any of it's sub gizmos are released from dragging */
  51165. onDragEndObservable: Observable<unknown>;
  51166. /**
  51167. * If set to true, planar drag is enabled
  51168. */
  51169. private _planarGizmoEnabled;
  51170. get attachedMesh(): Nullable<AbstractMesh>;
  51171. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51172. /**
  51173. * Creates a PositionGizmo
  51174. * @param gizmoLayer The utility layer the gizmo will be added to
  51175. */
  51176. constructor(gizmoLayer?: UtilityLayerRenderer);
  51177. /**
  51178. * If the planar drag gizmo is enabled
  51179. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51180. */
  51181. set planarGizmoEnabled(value: boolean);
  51182. get planarGizmoEnabled(): boolean;
  51183. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51184. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51185. /**
  51186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51187. */
  51188. set snapDistance(value: number);
  51189. get snapDistance(): number;
  51190. /**
  51191. * Ratio for the scale of the gizmo (Default: 1)
  51192. */
  51193. set scaleRatio(value: number);
  51194. get scaleRatio(): number;
  51195. /**
  51196. * Disposes of the gizmo
  51197. */
  51198. dispose(): void;
  51199. /**
  51200. * CustomMeshes are not supported by this gizmo
  51201. * @param mesh The mesh to replace the default mesh of the gizmo
  51202. */
  51203. setCustomMesh(mesh: Mesh): void;
  51204. }
  51205. }
  51206. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51207. import { Observable } from "babylonjs/Misc/observable";
  51208. import { Nullable } from "babylonjs/types";
  51209. import { Vector3 } from "babylonjs/Maths/math.vector";
  51210. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51212. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51214. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51215. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51216. import { Scene } from "babylonjs/scene";
  51217. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51218. import { Color3 } from "babylonjs/Maths/math.color";
  51219. /**
  51220. * Single axis drag gizmo
  51221. */
  51222. export class AxisDragGizmo extends Gizmo {
  51223. /**
  51224. * Drag behavior responsible for the gizmos dragging interactions
  51225. */
  51226. dragBehavior: PointerDragBehavior;
  51227. private _pointerObserver;
  51228. /**
  51229. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51230. */
  51231. snapDistance: number;
  51232. /**
  51233. * Event that fires each time the gizmo snaps to a new location.
  51234. * * snapDistance is the the change in distance
  51235. */
  51236. onSnapObservable: Observable<{
  51237. snapDistance: number;
  51238. }>;
  51239. private _isEnabled;
  51240. private _parent;
  51241. private _arrow;
  51242. private _coloredMaterial;
  51243. private _hoverMaterial;
  51244. /** @hidden */
  51245. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51246. /** @hidden */
  51247. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51248. /**
  51249. * Creates an AxisDragGizmo
  51250. * @param gizmoLayer The utility layer the gizmo will be added to
  51251. * @param dragAxis The axis which the gizmo will be able to drag on
  51252. * @param color The color of the gizmo
  51253. */
  51254. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51255. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51256. /**
  51257. * If the gizmo is enabled
  51258. */
  51259. set isEnabled(value: boolean);
  51260. get isEnabled(): boolean;
  51261. /**
  51262. * Disposes of the gizmo
  51263. */
  51264. dispose(): void;
  51265. }
  51266. }
  51267. declare module "babylonjs/Debug/axesViewer" {
  51268. import { Vector3 } from "babylonjs/Maths/math.vector";
  51269. import { Nullable } from "babylonjs/types";
  51270. import { Scene } from "babylonjs/scene";
  51271. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51272. /**
  51273. * The Axes viewer will show 3 axes in a specific point in space
  51274. */
  51275. export class AxesViewer {
  51276. private _xAxis;
  51277. private _yAxis;
  51278. private _zAxis;
  51279. private _scaleLinesFactor;
  51280. private _instanced;
  51281. /**
  51282. * Gets the hosting scene
  51283. */
  51284. scene: Scene;
  51285. /**
  51286. * Gets or sets a number used to scale line length
  51287. */
  51288. scaleLines: number;
  51289. /** Gets the node hierarchy used to render x-axis */
  51290. get xAxis(): TransformNode;
  51291. /** Gets the node hierarchy used to render y-axis */
  51292. get yAxis(): TransformNode;
  51293. /** Gets the node hierarchy used to render z-axis */
  51294. get zAxis(): TransformNode;
  51295. /**
  51296. * Creates a new AxesViewer
  51297. * @param scene defines the hosting scene
  51298. * @param scaleLines defines a number used to scale line length (1 by default)
  51299. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51300. * @param xAxis defines the node hierarchy used to render the x-axis
  51301. * @param yAxis defines the node hierarchy used to render the y-axis
  51302. * @param zAxis defines the node hierarchy used to render the z-axis
  51303. */
  51304. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51305. /**
  51306. * Force the viewer to update
  51307. * @param position defines the position of the viewer
  51308. * @param xaxis defines the x axis of the viewer
  51309. * @param yaxis defines the y axis of the viewer
  51310. * @param zaxis defines the z axis of the viewer
  51311. */
  51312. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51313. /**
  51314. * Creates an instance of this axes viewer.
  51315. * @returns a new axes viewer with instanced meshes
  51316. */
  51317. createInstance(): AxesViewer;
  51318. /** Releases resources */
  51319. dispose(): void;
  51320. private static _SetRenderingGroupId;
  51321. }
  51322. }
  51323. declare module "babylonjs/Debug/boneAxesViewer" {
  51324. import { Nullable } from "babylonjs/types";
  51325. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51326. import { Vector3 } from "babylonjs/Maths/math.vector";
  51327. import { Mesh } from "babylonjs/Meshes/mesh";
  51328. import { Bone } from "babylonjs/Bones/bone";
  51329. import { Scene } from "babylonjs/scene";
  51330. /**
  51331. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51332. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51333. */
  51334. export class BoneAxesViewer extends AxesViewer {
  51335. /**
  51336. * Gets or sets the target mesh where to display the axes viewer
  51337. */
  51338. mesh: Nullable<Mesh>;
  51339. /**
  51340. * Gets or sets the target bone where to display the axes viewer
  51341. */
  51342. bone: Nullable<Bone>;
  51343. /** Gets current position */
  51344. pos: Vector3;
  51345. /** Gets direction of X axis */
  51346. xaxis: Vector3;
  51347. /** Gets direction of Y axis */
  51348. yaxis: Vector3;
  51349. /** Gets direction of Z axis */
  51350. zaxis: Vector3;
  51351. /**
  51352. * Creates a new BoneAxesViewer
  51353. * @param scene defines the hosting scene
  51354. * @param bone defines the target bone
  51355. * @param mesh defines the target mesh
  51356. * @param scaleLines defines a scaling factor for line length (1 by default)
  51357. */
  51358. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51359. /**
  51360. * Force the viewer to update
  51361. */
  51362. update(): void;
  51363. /** Releases resources */
  51364. dispose(): void;
  51365. }
  51366. }
  51367. declare module "babylonjs/Debug/debugLayer" {
  51368. import { Scene } from "babylonjs/scene";
  51369. /**
  51370. * Interface used to define scene explorer extensibility option
  51371. */
  51372. export interface IExplorerExtensibilityOption {
  51373. /**
  51374. * Define the option label
  51375. */
  51376. label: string;
  51377. /**
  51378. * Defines the action to execute on click
  51379. */
  51380. action: (entity: any) => void;
  51381. }
  51382. /**
  51383. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51384. */
  51385. export interface IExplorerExtensibilityGroup {
  51386. /**
  51387. * Defines a predicate to test if a given type mut be extended
  51388. */
  51389. predicate: (entity: any) => boolean;
  51390. /**
  51391. * Gets the list of options added to a type
  51392. */
  51393. entries: IExplorerExtensibilityOption[];
  51394. }
  51395. /**
  51396. * Interface used to define the options to use to create the Inspector
  51397. */
  51398. export interface IInspectorOptions {
  51399. /**
  51400. * Display in overlay mode (default: false)
  51401. */
  51402. overlay?: boolean;
  51403. /**
  51404. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51405. */
  51406. globalRoot?: HTMLElement;
  51407. /**
  51408. * Display the Scene explorer
  51409. */
  51410. showExplorer?: boolean;
  51411. /**
  51412. * Display the property inspector
  51413. */
  51414. showInspector?: boolean;
  51415. /**
  51416. * Display in embed mode (both panes on the right)
  51417. */
  51418. embedMode?: boolean;
  51419. /**
  51420. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51421. */
  51422. handleResize?: boolean;
  51423. /**
  51424. * Allow the panes to popup (default: true)
  51425. */
  51426. enablePopup?: boolean;
  51427. /**
  51428. * Allow the panes to be closed by users (default: true)
  51429. */
  51430. enableClose?: boolean;
  51431. /**
  51432. * Optional list of extensibility entries
  51433. */
  51434. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51435. /**
  51436. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51437. */
  51438. inspectorURL?: string;
  51439. /**
  51440. * Optional initial tab (default to DebugLayerTab.Properties)
  51441. */
  51442. initialTab?: DebugLayerTab;
  51443. }
  51444. module "babylonjs/scene" {
  51445. interface Scene {
  51446. /**
  51447. * @hidden
  51448. * Backing field
  51449. */
  51450. _debugLayer: DebugLayer;
  51451. /**
  51452. * Gets the debug layer (aka Inspector) associated with the scene
  51453. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51454. */
  51455. debugLayer: DebugLayer;
  51456. }
  51457. }
  51458. /**
  51459. * Enum of inspector action tab
  51460. */
  51461. export enum DebugLayerTab {
  51462. /**
  51463. * Properties tag (default)
  51464. */
  51465. Properties = 0,
  51466. /**
  51467. * Debug tab
  51468. */
  51469. Debug = 1,
  51470. /**
  51471. * Statistics tab
  51472. */
  51473. Statistics = 2,
  51474. /**
  51475. * Tools tab
  51476. */
  51477. Tools = 3,
  51478. /**
  51479. * Settings tab
  51480. */
  51481. Settings = 4
  51482. }
  51483. /**
  51484. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51485. * what is happening in your scene
  51486. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51487. */
  51488. export class DebugLayer {
  51489. /**
  51490. * Define the url to get the inspector script from.
  51491. * By default it uses the babylonjs CDN.
  51492. * @ignoreNaming
  51493. */
  51494. static InspectorURL: string;
  51495. private _scene;
  51496. private BJSINSPECTOR;
  51497. private _onPropertyChangedObservable?;
  51498. /**
  51499. * Observable triggered when a property is changed through the inspector.
  51500. */
  51501. get onPropertyChangedObservable(): any;
  51502. /**
  51503. * Instantiates a new debug layer.
  51504. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51505. * what is happening in your scene
  51506. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51507. * @param scene Defines the scene to inspect
  51508. */
  51509. constructor(scene: Scene);
  51510. /** Creates the inspector window. */
  51511. private _createInspector;
  51512. /**
  51513. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51514. * @param entity defines the entity to select
  51515. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51516. */
  51517. select(entity: any, lineContainerTitles?: string | string[]): void;
  51518. /** Get the inspector from bundle or global */
  51519. private _getGlobalInspector;
  51520. /**
  51521. * Get if the inspector is visible or not.
  51522. * @returns true if visible otherwise, false
  51523. */
  51524. isVisible(): boolean;
  51525. /**
  51526. * Hide the inspector and close its window.
  51527. */
  51528. hide(): void;
  51529. /**
  51530. * Update the scene in the inspector
  51531. */
  51532. setAsActiveScene(): void;
  51533. /**
  51534. * Launch the debugLayer.
  51535. * @param config Define the configuration of the inspector
  51536. * @return a promise fulfilled when the debug layer is visible
  51537. */
  51538. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51539. }
  51540. }
  51541. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51542. import { Nullable } from "babylonjs/types";
  51543. import { Scene } from "babylonjs/scene";
  51544. import { Vector4 } from "babylonjs/Maths/math.vector";
  51545. import { Color4 } from "babylonjs/Maths/math.color";
  51546. import { Mesh } from "babylonjs/Meshes/mesh";
  51547. /**
  51548. * Class containing static functions to help procedurally build meshes
  51549. */
  51550. export class BoxBuilder {
  51551. /**
  51552. * Creates a box mesh
  51553. * * The parameter `size` sets the size (float) of each box side (default 1)
  51554. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51555. * * 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)
  51556. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51560. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51561. * @param name defines the name of the mesh
  51562. * @param options defines the options used to create the mesh
  51563. * @param scene defines the hosting scene
  51564. * @returns the box mesh
  51565. */
  51566. static CreateBox(name: string, options: {
  51567. size?: number;
  51568. width?: number;
  51569. height?: number;
  51570. depth?: number;
  51571. faceUV?: Vector4[];
  51572. faceColors?: Color4[];
  51573. sideOrientation?: number;
  51574. frontUVs?: Vector4;
  51575. backUVs?: Vector4;
  51576. wrap?: boolean;
  51577. topBaseAt?: number;
  51578. bottomBaseAt?: number;
  51579. updatable?: boolean;
  51580. }, scene?: Nullable<Scene>): Mesh;
  51581. }
  51582. }
  51583. declare module "babylonjs/Debug/physicsViewer" {
  51584. import { Nullable } from "babylonjs/types";
  51585. import { Scene } from "babylonjs/scene";
  51586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51587. import { Mesh } from "babylonjs/Meshes/mesh";
  51588. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51589. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51590. /**
  51591. * Used to show the physics impostor around the specific mesh
  51592. */
  51593. export class PhysicsViewer {
  51594. /** @hidden */
  51595. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51596. /** @hidden */
  51597. protected _meshes: Array<Nullable<AbstractMesh>>;
  51598. /** @hidden */
  51599. protected _scene: Nullable<Scene>;
  51600. /** @hidden */
  51601. protected _numMeshes: number;
  51602. /** @hidden */
  51603. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51604. private _renderFunction;
  51605. private _utilityLayer;
  51606. private _debugBoxMesh;
  51607. private _debugSphereMesh;
  51608. private _debugCylinderMesh;
  51609. private _debugMaterial;
  51610. private _debugMeshMeshes;
  51611. /**
  51612. * Creates a new PhysicsViewer
  51613. * @param scene defines the hosting scene
  51614. */
  51615. constructor(scene: Scene);
  51616. /** @hidden */
  51617. protected _updateDebugMeshes(): void;
  51618. /**
  51619. * Renders a specified physic impostor
  51620. * @param impostor defines the impostor to render
  51621. * @param targetMesh defines the mesh represented by the impostor
  51622. * @returns the new debug mesh used to render the impostor
  51623. */
  51624. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51625. /**
  51626. * Hides a specified physic impostor
  51627. * @param impostor defines the impostor to hide
  51628. */
  51629. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51630. private _getDebugMaterial;
  51631. private _getDebugBoxMesh;
  51632. private _getDebugSphereMesh;
  51633. private _getDebugCylinderMesh;
  51634. private _getDebugMeshMesh;
  51635. private _getDebugMesh;
  51636. /** Releases all resources */
  51637. dispose(): void;
  51638. }
  51639. }
  51640. declare module "babylonjs/Debug/rayHelper" {
  51641. import { Nullable } from "babylonjs/types";
  51642. import { Ray } from "babylonjs/Culling/ray";
  51643. import { Vector3 } from "babylonjs/Maths/math.vector";
  51644. import { Color3 } from "babylonjs/Maths/math.color";
  51645. import { Scene } from "babylonjs/scene";
  51646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51647. import "babylonjs/Meshes/Builders/linesBuilder";
  51648. /**
  51649. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51650. * in order to better appreciate the issue one might have.
  51651. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51652. */
  51653. export class RayHelper {
  51654. /**
  51655. * Defines the ray we are currently tryin to visualize.
  51656. */
  51657. ray: Nullable<Ray>;
  51658. private _renderPoints;
  51659. private _renderLine;
  51660. private _renderFunction;
  51661. private _scene;
  51662. private _updateToMeshFunction;
  51663. private _attachedToMesh;
  51664. private _meshSpaceDirection;
  51665. private _meshSpaceOrigin;
  51666. /**
  51667. * Helper function to create a colored helper in a scene in one line.
  51668. * @param ray Defines the ray we are currently tryin to visualize
  51669. * @param scene Defines the scene the ray is used in
  51670. * @param color Defines the color we want to see the ray in
  51671. * @returns The newly created ray helper.
  51672. */
  51673. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51674. /**
  51675. * Instantiate a new ray helper.
  51676. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51677. * in order to better appreciate the issue one might have.
  51678. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51679. * @param ray Defines the ray we are currently tryin to visualize
  51680. */
  51681. constructor(ray: Ray);
  51682. /**
  51683. * Shows the ray we are willing to debug.
  51684. * @param scene Defines the scene the ray needs to be rendered in
  51685. * @param color Defines the color the ray needs to be rendered in
  51686. */
  51687. show(scene: Scene, color?: Color3): void;
  51688. /**
  51689. * Hides the ray we are debugging.
  51690. */
  51691. hide(): void;
  51692. private _render;
  51693. /**
  51694. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51695. * @param mesh Defines the mesh we want the helper attached to
  51696. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51697. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51698. * @param length Defines the length of the ray
  51699. */
  51700. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51701. /**
  51702. * Detach the ray helper from the mesh it has previously been attached to.
  51703. */
  51704. detachFromMesh(): void;
  51705. private _updateToMesh;
  51706. /**
  51707. * Dispose the helper and release its associated resources.
  51708. */
  51709. dispose(): void;
  51710. }
  51711. }
  51712. declare module "babylonjs/Debug/skeletonViewer" {
  51713. import { Color3 } from "babylonjs/Maths/math.color";
  51714. import { Scene } from "babylonjs/scene";
  51715. import { Nullable } from "babylonjs/types";
  51716. import { Skeleton } from "babylonjs/Bones/skeleton";
  51717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51718. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51719. /**
  51720. * Class used to render a debug view of a given skeleton
  51721. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51722. */
  51723. export class SkeletonViewer {
  51724. /** defines the skeleton to render */
  51725. skeleton: Skeleton;
  51726. /** defines the mesh attached to the skeleton */
  51727. mesh: AbstractMesh;
  51728. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51729. autoUpdateBonesMatrices: boolean;
  51730. /** defines the rendering group id to use with the viewer */
  51731. renderingGroupId: number;
  51732. /** Gets or sets the color used to render the skeleton */
  51733. color: Color3;
  51734. private _scene;
  51735. private _debugLines;
  51736. private _debugMesh;
  51737. private _isEnabled;
  51738. private _renderFunction;
  51739. private _utilityLayer;
  51740. /**
  51741. * Returns the mesh used to render the bones
  51742. */
  51743. get debugMesh(): Nullable<LinesMesh>;
  51744. /**
  51745. * Creates a new SkeletonViewer
  51746. * @param skeleton defines the skeleton to render
  51747. * @param mesh defines the mesh attached to the skeleton
  51748. * @param scene defines the hosting scene
  51749. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51750. * @param renderingGroupId defines the rendering group id to use with the viewer
  51751. */
  51752. constructor(
  51753. /** defines the skeleton to render */
  51754. skeleton: Skeleton,
  51755. /** defines the mesh attached to the skeleton */
  51756. mesh: AbstractMesh, scene: Scene,
  51757. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51758. autoUpdateBonesMatrices?: boolean,
  51759. /** defines the rendering group id to use with the viewer */
  51760. renderingGroupId?: number);
  51761. /** Gets or sets a boolean indicating if the viewer is enabled */
  51762. set isEnabled(value: boolean);
  51763. get isEnabled(): boolean;
  51764. private _getBonePosition;
  51765. private _getLinesForBonesWithLength;
  51766. private _getLinesForBonesNoLength;
  51767. /** Update the viewer to sync with current skeleton state */
  51768. update(): void;
  51769. /** Release associated resources */
  51770. dispose(): void;
  51771. }
  51772. }
  51773. declare module "babylonjs/Debug/index" {
  51774. export * from "babylonjs/Debug/axesViewer";
  51775. export * from "babylonjs/Debug/boneAxesViewer";
  51776. export * from "babylonjs/Debug/debugLayer";
  51777. export * from "babylonjs/Debug/physicsViewer";
  51778. export * from "babylonjs/Debug/rayHelper";
  51779. export * from "babylonjs/Debug/skeletonViewer";
  51780. }
  51781. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51782. /**
  51783. * Enum for Device Types
  51784. */
  51785. export enum DeviceType {
  51786. /** Generic */
  51787. Generic = 0,
  51788. /** Keyboard */
  51789. Keyboard = 1,
  51790. /** Mouse */
  51791. Mouse = 2,
  51792. /** Touch Pointers */
  51793. Touch = 3,
  51794. /** PS4 Dual Shock */
  51795. DualShock = 4,
  51796. /** Xbox */
  51797. Xbox = 5,
  51798. /** Switch Controller */
  51799. Switch = 6
  51800. }
  51801. /**
  51802. * Enum for All Pointers (Touch/Mouse)
  51803. */
  51804. export enum PointerInput {
  51805. /** Horizontal Axis */
  51806. Horizontal = 0,
  51807. /** Vertical Axis */
  51808. Vertical = 1,
  51809. /** Left Click or Touch */
  51810. LeftClick = 2,
  51811. /** Middle Click */
  51812. MiddleClick = 3,
  51813. /** Right Click */
  51814. RightClick = 4,
  51815. /** Browser Back */
  51816. BrowserBack = 5,
  51817. /** Browser Forward */
  51818. BrowserForward = 6
  51819. }
  51820. /**
  51821. * Enum for Dual Shock Gamepad
  51822. */
  51823. export enum DualShockInput {
  51824. /** Cross */
  51825. Cross = 0,
  51826. /** Circle */
  51827. Circle = 1,
  51828. /** Square */
  51829. Square = 2,
  51830. /** Triangle */
  51831. Triangle = 3,
  51832. /** L1 */
  51833. L1 = 4,
  51834. /** R1 */
  51835. R1 = 5,
  51836. /** L2 */
  51837. L2 = 6,
  51838. /** R2 */
  51839. R2 = 7,
  51840. /** Share */
  51841. Share = 8,
  51842. /** Options */
  51843. Options = 9,
  51844. /** L3 */
  51845. L3 = 10,
  51846. /** R3 */
  51847. R3 = 11,
  51848. /** DPadUp */
  51849. DPadUp = 12,
  51850. /** DPadDown */
  51851. DPadDown = 13,
  51852. /** DPadLeft */
  51853. DPadLeft = 14,
  51854. /** DRight */
  51855. DPadRight = 15,
  51856. /** Home */
  51857. Home = 16,
  51858. /** TouchPad */
  51859. TouchPad = 17,
  51860. /** LStickXAxis */
  51861. LStickXAxis = 18,
  51862. /** LStickYAxis */
  51863. LStickYAxis = 19,
  51864. /** RStickXAxis */
  51865. RStickXAxis = 20,
  51866. /** RStickYAxis */
  51867. RStickYAxis = 21
  51868. }
  51869. /**
  51870. * Enum for Xbox Gamepad
  51871. */
  51872. export enum XboxInput {
  51873. /** A */
  51874. A = 0,
  51875. /** B */
  51876. B = 1,
  51877. /** X */
  51878. X = 2,
  51879. /** Y */
  51880. Y = 3,
  51881. /** LB */
  51882. LB = 4,
  51883. /** RB */
  51884. RB = 5,
  51885. /** LT */
  51886. LT = 6,
  51887. /** RT */
  51888. RT = 7,
  51889. /** Back */
  51890. Back = 8,
  51891. /** Start */
  51892. Start = 9,
  51893. /** LS */
  51894. LS = 10,
  51895. /** RS */
  51896. RS = 11,
  51897. /** DPadUp */
  51898. DPadUp = 12,
  51899. /** DPadDown */
  51900. DPadDown = 13,
  51901. /** DPadLeft */
  51902. DPadLeft = 14,
  51903. /** DRight */
  51904. DPadRight = 15,
  51905. /** Home */
  51906. Home = 16,
  51907. /** LStickXAxis */
  51908. LStickXAxis = 17,
  51909. /** LStickYAxis */
  51910. LStickYAxis = 18,
  51911. /** RStickXAxis */
  51912. RStickXAxis = 19,
  51913. /** RStickYAxis */
  51914. RStickYAxis = 20
  51915. }
  51916. /**
  51917. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51918. */
  51919. export enum SwitchInput {
  51920. /** B */
  51921. B = 0,
  51922. /** A */
  51923. A = 1,
  51924. /** Y */
  51925. Y = 2,
  51926. /** X */
  51927. X = 3,
  51928. /** L */
  51929. L = 4,
  51930. /** R */
  51931. R = 5,
  51932. /** ZL */
  51933. ZL = 6,
  51934. /** ZR */
  51935. ZR = 7,
  51936. /** Minus */
  51937. Minus = 8,
  51938. /** Plus */
  51939. Plus = 9,
  51940. /** LS */
  51941. LS = 10,
  51942. /** RS */
  51943. RS = 11,
  51944. /** DPadUp */
  51945. DPadUp = 12,
  51946. /** DPadDown */
  51947. DPadDown = 13,
  51948. /** DPadLeft */
  51949. DPadLeft = 14,
  51950. /** DRight */
  51951. DPadRight = 15,
  51952. /** Home */
  51953. Home = 16,
  51954. /** Capture */
  51955. Capture = 17,
  51956. /** LStickXAxis */
  51957. LStickXAxis = 18,
  51958. /** LStickYAxis */
  51959. LStickYAxis = 19,
  51960. /** RStickXAxis */
  51961. RStickXAxis = 20,
  51962. /** RStickYAxis */
  51963. RStickYAxis = 21
  51964. }
  51965. }
  51966. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  51967. import { Engine } from "babylonjs/Engines/engine";
  51968. import { IDisposable } from "babylonjs/scene";
  51969. import { Nullable } from "babylonjs/types";
  51970. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  51971. /**
  51972. * This class will take all inputs from Keyboard, Pointer, and
  51973. * any Gamepads and provide a polling system that all devices
  51974. * will use. This class assumes that there will only be one
  51975. * pointer device and one keyboard.
  51976. */
  51977. export class DeviceInputSystem implements IDisposable {
  51978. /**
  51979. * Callback to be triggered when a device is connected
  51980. */
  51981. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51982. /**
  51983. * Callback to be triggered when a device is disconnected
  51984. */
  51985. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51986. /**
  51987. * Callback to be triggered when event driven input is updated
  51988. */
  51989. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51990. private _inputs;
  51991. private _gamepads;
  51992. private _keyboardActive;
  51993. private _pointerActive;
  51994. private _elementToAttachTo;
  51995. private _keyboardDownEvent;
  51996. private _keyboardUpEvent;
  51997. private _pointerMoveEvent;
  51998. private _pointerDownEvent;
  51999. private _pointerUpEvent;
  52000. private _gamepadConnectedEvent;
  52001. private _gamepadDisconnectedEvent;
  52002. private static _MAX_KEYCODES;
  52003. private static _MAX_POINTER_INPUTS;
  52004. private constructor();
  52005. /**
  52006. * Creates a new DeviceInputSystem instance
  52007. * @param engine Engine to pull input element from
  52008. * @returns The new instance
  52009. */
  52010. static Create(engine: Engine): DeviceInputSystem;
  52011. /**
  52012. * Checks for current device input value, given an id and input index
  52013. * @param deviceName Id of connected device
  52014. * @param inputIndex Index of device input
  52015. * @returns Current value of input
  52016. */
  52017. /**
  52018. * Checks for current device input value, given an id and input index
  52019. * @param deviceType Enum specifiying device type
  52020. * @param deviceSlot "Slot" or index that device is referenced in
  52021. * @param inputIndex Id of input to be checked
  52022. * @returns Current value of input
  52023. */
  52024. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52025. /**
  52026. * Dispose of all the eventlisteners
  52027. */
  52028. dispose(): void;
  52029. /**
  52030. * Add device and inputs to device array
  52031. * @param deviceType Enum specifiying device type
  52032. * @param deviceSlot "Slot" or index that device is referenced in
  52033. * @param numberOfInputs Number of input entries to create for given device
  52034. */
  52035. private _registerDevice;
  52036. /**
  52037. * Given a specific device name, remove that device from the device map
  52038. * @param deviceType Enum specifiying device type
  52039. * @param deviceSlot "Slot" or index that device is referenced in
  52040. */
  52041. private _unregisterDevice;
  52042. /**
  52043. * Handle all actions that come from keyboard interaction
  52044. */
  52045. private _handleKeyActions;
  52046. /**
  52047. * Handle all actions that come from pointer interaction
  52048. */
  52049. private _handlePointerActions;
  52050. /**
  52051. * Handle all actions that come from gamepad interaction
  52052. */
  52053. private _handleGamepadActions;
  52054. /**
  52055. * Update all non-event based devices with each frame
  52056. * @param deviceType Enum specifiying device type
  52057. * @param deviceSlot "Slot" or index that device is referenced in
  52058. * @param inputIndex Id of input to be checked
  52059. */
  52060. private _updateDevice;
  52061. /**
  52062. * Gets DeviceType from the device name
  52063. * @param deviceName Name of Device from DeviceInputSystem
  52064. * @returns DeviceType enum value
  52065. */
  52066. private _getGamepadDeviceType;
  52067. }
  52068. }
  52069. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52070. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52071. /**
  52072. * Type to handle enforcement of inputs
  52073. */
  52074. 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;
  52075. }
  52076. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52077. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52078. import { Engine } from "babylonjs/Engines/engine";
  52079. import { IDisposable } from "babylonjs/scene";
  52080. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52081. import { Nullable } from "babylonjs/types";
  52082. import { Observable } from "babylonjs/Misc/observable";
  52083. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52084. /**
  52085. * Class that handles all input for a specific device
  52086. */
  52087. export class DeviceSource<T extends DeviceType> {
  52088. /** Type of device */
  52089. readonly deviceType: DeviceType;
  52090. /** "Slot" or index that device is referenced in */
  52091. readonly deviceSlot: number;
  52092. /**
  52093. * Observable to handle device input changes per device
  52094. */
  52095. readonly onInputChangedObservable: Observable<{
  52096. inputIndex: DeviceInput<T>;
  52097. previousState: Nullable<number>;
  52098. currentState: Nullable<number>;
  52099. }>;
  52100. private readonly _deviceInputSystem;
  52101. /**
  52102. * Default Constructor
  52103. * @param deviceInputSystem Reference to DeviceInputSystem
  52104. * @param deviceType Type of device
  52105. * @param deviceSlot "Slot" or index that device is referenced in
  52106. */
  52107. constructor(deviceInputSystem: DeviceInputSystem,
  52108. /** Type of device */
  52109. deviceType: DeviceType,
  52110. /** "Slot" or index that device is referenced in */
  52111. deviceSlot?: number);
  52112. /**
  52113. * Get input for specific input
  52114. * @param inputIndex index of specific input on device
  52115. * @returns Input value from DeviceInputSystem
  52116. */
  52117. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52118. }
  52119. /**
  52120. * Class to keep track of devices
  52121. */
  52122. export class DeviceSourceManager implements IDisposable {
  52123. /**
  52124. * Observable to be triggered when before a device is connected
  52125. */
  52126. readonly onBeforeDeviceConnectedObservable: Observable<{
  52127. deviceType: DeviceType;
  52128. deviceSlot: number;
  52129. }>;
  52130. /**
  52131. * Observable to be triggered when before a device is disconnected
  52132. */
  52133. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52134. deviceType: DeviceType;
  52135. deviceSlot: number;
  52136. }>;
  52137. /**
  52138. * Observable to be triggered when after a device is connected
  52139. */
  52140. readonly onAfterDeviceConnectedObservable: Observable<{
  52141. deviceType: DeviceType;
  52142. deviceSlot: number;
  52143. }>;
  52144. /**
  52145. * Observable to be triggered when after a device is disconnected
  52146. */
  52147. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52148. deviceType: DeviceType;
  52149. deviceSlot: number;
  52150. }>;
  52151. private readonly _devices;
  52152. private readonly _firstDevice;
  52153. private readonly _deviceInputSystem;
  52154. /**
  52155. * Default Constructor
  52156. * @param engine engine to pull input element from
  52157. */
  52158. constructor(engine: Engine);
  52159. /**
  52160. * Gets a DeviceSource, given a type and slot
  52161. * @param deviceType Enum specifying device type
  52162. * @param deviceSlot "Slot" or index that device is referenced in
  52163. * @returns DeviceSource object
  52164. */
  52165. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52166. /**
  52167. * Gets an array of DeviceSource objects for a given device type
  52168. * @param deviceType Enum specifying device type
  52169. * @returns Array of DeviceSource objects
  52170. */
  52171. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52172. /**
  52173. * Dispose of DeviceInputSystem and other parts
  52174. */
  52175. dispose(): void;
  52176. /**
  52177. * Function to add device name to device list
  52178. * @param deviceType Enum specifying device type
  52179. * @param deviceSlot "Slot" or index that device is referenced in
  52180. */
  52181. private _addDevice;
  52182. /**
  52183. * Function to remove device name to device list
  52184. * @param deviceType Enum specifying device type
  52185. * @param deviceSlot "Slot" or index that device is referenced in
  52186. */
  52187. private _removeDevice;
  52188. /**
  52189. * Updates array storing first connected device of each type
  52190. * @param type Type of Device
  52191. */
  52192. private _updateFirstDevices;
  52193. }
  52194. }
  52195. declare module "babylonjs/DeviceInput/index" {
  52196. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52197. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52198. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52199. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52200. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52201. }
  52202. declare module "babylonjs/Engines/nullEngine" {
  52203. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52204. import { Engine } from "babylonjs/Engines/engine";
  52205. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52206. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52208. import { Effect } from "babylonjs/Materials/effect";
  52209. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52210. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52211. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52212. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52213. /**
  52214. * Options to create the null engine
  52215. */
  52216. export class NullEngineOptions {
  52217. /**
  52218. * Render width (Default: 512)
  52219. */
  52220. renderWidth: number;
  52221. /**
  52222. * Render height (Default: 256)
  52223. */
  52224. renderHeight: number;
  52225. /**
  52226. * Texture size (Default: 512)
  52227. */
  52228. textureSize: number;
  52229. /**
  52230. * If delta time between frames should be constant
  52231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52232. */
  52233. deterministicLockstep: boolean;
  52234. /**
  52235. * Maximum about of steps between frames (Default: 4)
  52236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52237. */
  52238. lockstepMaxSteps: number;
  52239. }
  52240. /**
  52241. * The null engine class provides support for headless version of babylon.js.
  52242. * This can be used in server side scenario or for testing purposes
  52243. */
  52244. export class NullEngine extends Engine {
  52245. private _options;
  52246. /**
  52247. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52249. * @returns true if engine is in deterministic lock step mode
  52250. */
  52251. isDeterministicLockStep(): boolean;
  52252. /**
  52253. * Gets the max steps when engine is running in deterministic lock step
  52254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52255. * @returns the max steps
  52256. */
  52257. getLockstepMaxSteps(): number;
  52258. /**
  52259. * Gets the current hardware scaling level.
  52260. * By default the hardware scaling level is computed from the window device ratio.
  52261. * 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.
  52262. * @returns a number indicating the current hardware scaling level
  52263. */
  52264. getHardwareScalingLevel(): number;
  52265. constructor(options?: NullEngineOptions);
  52266. /**
  52267. * Creates a vertex buffer
  52268. * @param vertices the data for the vertex buffer
  52269. * @returns the new WebGL static buffer
  52270. */
  52271. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52272. /**
  52273. * Creates a new index buffer
  52274. * @param indices defines the content of the index buffer
  52275. * @param updatable defines if the index buffer must be updatable
  52276. * @returns a new webGL buffer
  52277. */
  52278. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52279. /**
  52280. * Clear the current render buffer or the current render target (if any is set up)
  52281. * @param color defines the color to use
  52282. * @param backBuffer defines if the back buffer must be cleared
  52283. * @param depth defines if the depth buffer must be cleared
  52284. * @param stencil defines if the stencil buffer must be cleared
  52285. */
  52286. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52287. /**
  52288. * Gets the current render width
  52289. * @param useScreen defines if screen size must be used (or the current render target if any)
  52290. * @returns a number defining the current render width
  52291. */
  52292. getRenderWidth(useScreen?: boolean): number;
  52293. /**
  52294. * Gets the current render height
  52295. * @param useScreen defines if screen size must be used (or the current render target if any)
  52296. * @returns a number defining the current render height
  52297. */
  52298. getRenderHeight(useScreen?: boolean): number;
  52299. /**
  52300. * Set the WebGL's viewport
  52301. * @param viewport defines the viewport element to be used
  52302. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52303. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52304. */
  52305. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52306. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52307. /**
  52308. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52309. * @param pipelineContext defines the pipeline context to use
  52310. * @param uniformsNames defines the list of uniform names
  52311. * @returns an array of webGL uniform locations
  52312. */
  52313. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52314. /**
  52315. * Gets the lsit of active attributes for a given webGL program
  52316. * @param pipelineContext defines the pipeline context to use
  52317. * @param attributesNames defines the list of attribute names to get
  52318. * @returns an array of indices indicating the offset of each attribute
  52319. */
  52320. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52321. /**
  52322. * Binds an effect to the webGL context
  52323. * @param effect defines the effect to bind
  52324. */
  52325. bindSamplers(effect: Effect): void;
  52326. /**
  52327. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52328. * @param effect defines the effect to activate
  52329. */
  52330. enableEffect(effect: Effect): void;
  52331. /**
  52332. * Set various states to the webGL context
  52333. * @param culling defines backface culling state
  52334. * @param zOffset defines the value to apply to zOffset (0 by default)
  52335. * @param force defines if states must be applied even if cache is up to date
  52336. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52337. */
  52338. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52339. /**
  52340. * Set the value of an uniform to an array of int32
  52341. * @param uniform defines the webGL uniform location where to store the value
  52342. * @param array defines the array of int32 to store
  52343. */
  52344. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52345. /**
  52346. * Set the value of an uniform to an array of int32 (stored as vec2)
  52347. * @param uniform defines the webGL uniform location where to store the value
  52348. * @param array defines the array of int32 to store
  52349. */
  52350. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52351. /**
  52352. * Set the value of an uniform to an array of int32 (stored as vec3)
  52353. * @param uniform defines the webGL uniform location where to store the value
  52354. * @param array defines the array of int32 to store
  52355. */
  52356. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52357. /**
  52358. * Set the value of an uniform to an array of int32 (stored as vec4)
  52359. * @param uniform defines the webGL uniform location where to store the value
  52360. * @param array defines the array of int32 to store
  52361. */
  52362. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52363. /**
  52364. * Set the value of an uniform to an array of float32
  52365. * @param uniform defines the webGL uniform location where to store the value
  52366. * @param array defines the array of float32 to store
  52367. */
  52368. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52369. /**
  52370. * Set the value of an uniform to an array of float32 (stored as vec2)
  52371. * @param uniform defines the webGL uniform location where to store the value
  52372. * @param array defines the array of float32 to store
  52373. */
  52374. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52375. /**
  52376. * Set the value of an uniform to an array of float32 (stored as vec3)
  52377. * @param uniform defines the webGL uniform location where to store the value
  52378. * @param array defines the array of float32 to store
  52379. */
  52380. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52381. /**
  52382. * Set the value of an uniform to an array of float32 (stored as vec4)
  52383. * @param uniform defines the webGL uniform location where to store the value
  52384. * @param array defines the array of float32 to store
  52385. */
  52386. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52387. /**
  52388. * Set the value of an uniform to an array of number
  52389. * @param uniform defines the webGL uniform location where to store the value
  52390. * @param array defines the array of number to store
  52391. */
  52392. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52393. /**
  52394. * Set the value of an uniform to an array of number (stored as vec2)
  52395. * @param uniform defines the webGL uniform location where to store the value
  52396. * @param array defines the array of number to store
  52397. */
  52398. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52399. /**
  52400. * Set the value of an uniform to an array of number (stored as vec3)
  52401. * @param uniform defines the webGL uniform location where to store the value
  52402. * @param array defines the array of number to store
  52403. */
  52404. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52405. /**
  52406. * Set the value of an uniform to an array of number (stored as vec4)
  52407. * @param uniform defines the webGL uniform location where to store the value
  52408. * @param array defines the array of number to store
  52409. */
  52410. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52411. /**
  52412. * Set the value of an uniform to an array of float32 (stored as matrices)
  52413. * @param uniform defines the webGL uniform location where to store the value
  52414. * @param matrices defines the array of float32 to store
  52415. */
  52416. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52417. /**
  52418. * Set the value of an uniform to a matrix (3x3)
  52419. * @param uniform defines the webGL uniform location where to store the value
  52420. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52421. */
  52422. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52423. /**
  52424. * Set the value of an uniform to a matrix (2x2)
  52425. * @param uniform defines the webGL uniform location where to store the value
  52426. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52427. */
  52428. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52429. /**
  52430. * Set the value of an uniform to a number (float)
  52431. * @param uniform defines the webGL uniform location where to store the value
  52432. * @param value defines the float number to store
  52433. */
  52434. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52435. /**
  52436. * Set the value of an uniform to a vec2
  52437. * @param uniform defines the webGL uniform location where to store the value
  52438. * @param x defines the 1st component of the value
  52439. * @param y defines the 2nd component of the value
  52440. */
  52441. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52442. /**
  52443. * Set the value of an uniform to a vec3
  52444. * @param uniform defines the webGL uniform location where to store the value
  52445. * @param x defines the 1st component of the value
  52446. * @param y defines the 2nd component of the value
  52447. * @param z defines the 3rd component of the value
  52448. */
  52449. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52450. /**
  52451. * Set the value of an uniform to a boolean
  52452. * @param uniform defines the webGL uniform location where to store the value
  52453. * @param bool defines the boolean to store
  52454. */
  52455. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52456. /**
  52457. * Set the value of an uniform to a vec4
  52458. * @param uniform defines the webGL uniform location where to store the value
  52459. * @param x defines the 1st component of the value
  52460. * @param y defines the 2nd component of the value
  52461. * @param z defines the 3rd component of the value
  52462. * @param w defines the 4th component of the value
  52463. */
  52464. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52465. /**
  52466. * Sets the current alpha mode
  52467. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52468. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52469. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52470. */
  52471. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52472. /**
  52473. * Bind webGl buffers directly to the webGL context
  52474. * @param vertexBuffers defines the vertex buffer to bind
  52475. * @param indexBuffer defines the index buffer to bind
  52476. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52477. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52478. * @param effect defines the effect associated with the vertex buffer
  52479. */
  52480. bindBuffers(vertexBuffers: {
  52481. [key: string]: VertexBuffer;
  52482. }, indexBuffer: DataBuffer, effect: Effect): void;
  52483. /**
  52484. * Force the entire cache to be cleared
  52485. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52486. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52487. */
  52488. wipeCaches(bruteForce?: boolean): void;
  52489. /**
  52490. * Send a draw order
  52491. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52492. * @param indexStart defines the starting index
  52493. * @param indexCount defines the number of index to draw
  52494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52495. */
  52496. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52497. /**
  52498. * Draw a list of indexed primitives
  52499. * @param fillMode defines the primitive to use
  52500. * @param indexStart defines the starting index
  52501. * @param indexCount defines the number of index to draw
  52502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52503. */
  52504. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52505. /**
  52506. * Draw a list of unindexed primitives
  52507. * @param fillMode defines the primitive to use
  52508. * @param verticesStart defines the index of first vertex to draw
  52509. * @param verticesCount defines the count of vertices to draw
  52510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52511. */
  52512. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52513. /** @hidden */
  52514. _createTexture(): WebGLTexture;
  52515. /** @hidden */
  52516. _releaseTexture(texture: InternalTexture): void;
  52517. /**
  52518. * Usually called from Texture.ts.
  52519. * Passed information to create a WebGLTexture
  52520. * @param urlArg defines a value which contains one of the following:
  52521. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52522. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52523. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52524. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52525. * @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)
  52526. * @param scene needed for loading to the correct scene
  52527. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52528. * @param onLoad optional callback to be called upon successful completion
  52529. * @param onError optional callback to be called upon failure
  52530. * @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
  52531. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52532. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52533. * @param forcedExtension defines the extension to use to pick the right loader
  52534. * @param mimeType defines an optional mime type
  52535. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52536. */
  52537. 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;
  52538. /**
  52539. * Creates a new render target texture
  52540. * @param size defines the size of the texture
  52541. * @param options defines the options used to create the texture
  52542. * @returns a new render target texture stored in an InternalTexture
  52543. */
  52544. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52545. /**
  52546. * Update the sampling mode of a given texture
  52547. * @param samplingMode defines the required sampling mode
  52548. * @param texture defines the texture to update
  52549. */
  52550. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52551. /**
  52552. * Binds the frame buffer to the specified texture.
  52553. * @param texture The texture to render to or null for the default canvas
  52554. * @param faceIndex The face of the texture to render to in case of cube texture
  52555. * @param requiredWidth The width of the target to render to
  52556. * @param requiredHeight The height of the target to render to
  52557. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52558. * @param lodLevel defines le lod level to bind to the frame buffer
  52559. */
  52560. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52561. /**
  52562. * Unbind the current render target texture from the webGL context
  52563. * @param texture defines the render target texture to unbind
  52564. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52565. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52566. */
  52567. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52568. /**
  52569. * Creates a dynamic vertex buffer
  52570. * @param vertices the data for the dynamic vertex buffer
  52571. * @returns the new WebGL dynamic buffer
  52572. */
  52573. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52574. /**
  52575. * Update the content of a dynamic texture
  52576. * @param texture defines the texture to update
  52577. * @param canvas defines the canvas containing the source
  52578. * @param invertY defines if data must be stored with Y axis inverted
  52579. * @param premulAlpha defines if alpha is stored as premultiplied
  52580. * @param format defines the format of the data
  52581. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52582. */
  52583. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52584. /**
  52585. * Gets a boolean indicating if all created effects are ready
  52586. * @returns true if all effects are ready
  52587. */
  52588. areAllEffectsReady(): boolean;
  52589. /**
  52590. * @hidden
  52591. * Get the current error code of the webGL context
  52592. * @returns the error code
  52593. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52594. */
  52595. getError(): number;
  52596. /** @hidden */
  52597. _getUnpackAlignement(): number;
  52598. /** @hidden */
  52599. _unpackFlipY(value: boolean): void;
  52600. /**
  52601. * Update a dynamic index buffer
  52602. * @param indexBuffer defines the target index buffer
  52603. * @param indices defines the data to update
  52604. * @param offset defines the offset in the target index buffer where update should start
  52605. */
  52606. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52607. /**
  52608. * Updates a dynamic vertex buffer.
  52609. * @param vertexBuffer the vertex buffer to update
  52610. * @param vertices the data used to update the vertex buffer
  52611. * @param byteOffset the byte offset of the data (optional)
  52612. * @param byteLength the byte length of the data (optional)
  52613. */
  52614. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52615. /** @hidden */
  52616. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52617. /** @hidden */
  52618. _bindTexture(channel: number, texture: InternalTexture): void;
  52619. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52620. /**
  52621. * 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
  52622. */
  52623. releaseEffects(): void;
  52624. displayLoadingUI(): void;
  52625. hideLoadingUI(): void;
  52626. /** @hidden */
  52627. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52628. /** @hidden */
  52629. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52630. /** @hidden */
  52631. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52632. /** @hidden */
  52633. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52634. }
  52635. }
  52636. declare module "babylonjs/Instrumentation/timeToken" {
  52637. import { Nullable } from "babylonjs/types";
  52638. /**
  52639. * @hidden
  52640. **/
  52641. export class _TimeToken {
  52642. _startTimeQuery: Nullable<WebGLQuery>;
  52643. _endTimeQuery: Nullable<WebGLQuery>;
  52644. _timeElapsedQuery: Nullable<WebGLQuery>;
  52645. _timeElapsedQueryEnded: boolean;
  52646. }
  52647. }
  52648. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52649. import { Nullable, int } from "babylonjs/types";
  52650. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52651. /** @hidden */
  52652. export class _OcclusionDataStorage {
  52653. /** @hidden */
  52654. occlusionInternalRetryCounter: number;
  52655. /** @hidden */
  52656. isOcclusionQueryInProgress: boolean;
  52657. /** @hidden */
  52658. isOccluded: boolean;
  52659. /** @hidden */
  52660. occlusionRetryCount: number;
  52661. /** @hidden */
  52662. occlusionType: number;
  52663. /** @hidden */
  52664. occlusionQueryAlgorithmType: number;
  52665. }
  52666. module "babylonjs/Engines/engine" {
  52667. interface Engine {
  52668. /**
  52669. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52670. * @return the new query
  52671. */
  52672. createQuery(): WebGLQuery;
  52673. /**
  52674. * Delete and release a webGL query
  52675. * @param query defines the query to delete
  52676. * @return the current engine
  52677. */
  52678. deleteQuery(query: WebGLQuery): Engine;
  52679. /**
  52680. * Check if a given query has resolved and got its value
  52681. * @param query defines the query to check
  52682. * @returns true if the query got its value
  52683. */
  52684. isQueryResultAvailable(query: WebGLQuery): boolean;
  52685. /**
  52686. * Gets the value of a given query
  52687. * @param query defines the query to check
  52688. * @returns the value of the query
  52689. */
  52690. getQueryResult(query: WebGLQuery): number;
  52691. /**
  52692. * Initiates an occlusion query
  52693. * @param algorithmType defines the algorithm to use
  52694. * @param query defines the query to use
  52695. * @returns the current engine
  52696. * @see http://doc.babylonjs.com/features/occlusionquery
  52697. */
  52698. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52699. /**
  52700. * Ends an occlusion query
  52701. * @see http://doc.babylonjs.com/features/occlusionquery
  52702. * @param algorithmType defines the algorithm to use
  52703. * @returns the current engine
  52704. */
  52705. endOcclusionQuery(algorithmType: number): Engine;
  52706. /**
  52707. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52708. * Please note that only one query can be issued at a time
  52709. * @returns a time token used to track the time span
  52710. */
  52711. startTimeQuery(): Nullable<_TimeToken>;
  52712. /**
  52713. * Ends a time query
  52714. * @param token defines the token used to measure the time span
  52715. * @returns the time spent (in ns)
  52716. */
  52717. endTimeQuery(token: _TimeToken): int;
  52718. /** @hidden */
  52719. _currentNonTimestampToken: Nullable<_TimeToken>;
  52720. /** @hidden */
  52721. _createTimeQuery(): WebGLQuery;
  52722. /** @hidden */
  52723. _deleteTimeQuery(query: WebGLQuery): void;
  52724. /** @hidden */
  52725. _getGlAlgorithmType(algorithmType: number): number;
  52726. /** @hidden */
  52727. _getTimeQueryResult(query: WebGLQuery): any;
  52728. /** @hidden */
  52729. _getTimeQueryAvailability(query: WebGLQuery): any;
  52730. }
  52731. }
  52732. module "babylonjs/Meshes/abstractMesh" {
  52733. interface AbstractMesh {
  52734. /**
  52735. * Backing filed
  52736. * @hidden
  52737. */
  52738. __occlusionDataStorage: _OcclusionDataStorage;
  52739. /**
  52740. * Access property
  52741. * @hidden
  52742. */
  52743. _occlusionDataStorage: _OcclusionDataStorage;
  52744. /**
  52745. * 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.
  52746. * The default value is -1 which means don't break the query and wait till the result
  52747. * @see http://doc.babylonjs.com/features/occlusionquery
  52748. */
  52749. occlusionRetryCount: number;
  52750. /**
  52751. * 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:
  52752. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52753. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52754. * * 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.
  52755. * @see http://doc.babylonjs.com/features/occlusionquery
  52756. */
  52757. occlusionType: number;
  52758. /**
  52759. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52760. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52761. * * 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.
  52762. * @see http://doc.babylonjs.com/features/occlusionquery
  52763. */
  52764. occlusionQueryAlgorithmType: number;
  52765. /**
  52766. * 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
  52767. * @see http://doc.babylonjs.com/features/occlusionquery
  52768. */
  52769. isOccluded: boolean;
  52770. /**
  52771. * Flag to check the progress status of the query
  52772. * @see http://doc.babylonjs.com/features/occlusionquery
  52773. */
  52774. isOcclusionQueryInProgress: boolean;
  52775. }
  52776. }
  52777. }
  52778. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52779. import { Nullable } from "babylonjs/types";
  52780. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52781. /** @hidden */
  52782. export var _forceTransformFeedbackToBundle: boolean;
  52783. module "babylonjs/Engines/engine" {
  52784. interface Engine {
  52785. /**
  52786. * Creates a webGL transform feedback object
  52787. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52788. * @returns the webGL transform feedback object
  52789. */
  52790. createTransformFeedback(): WebGLTransformFeedback;
  52791. /**
  52792. * Delete a webGL transform feedback object
  52793. * @param value defines the webGL transform feedback object to delete
  52794. */
  52795. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52796. /**
  52797. * Bind a webGL transform feedback object to the webgl context
  52798. * @param value defines the webGL transform feedback object to bind
  52799. */
  52800. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52801. /**
  52802. * Begins a transform feedback operation
  52803. * @param usePoints defines if points or triangles must be used
  52804. */
  52805. beginTransformFeedback(usePoints: boolean): void;
  52806. /**
  52807. * Ends a transform feedback operation
  52808. */
  52809. endTransformFeedback(): void;
  52810. /**
  52811. * Specify the varyings to use with transform feedback
  52812. * @param program defines the associated webGL program
  52813. * @param value defines the list of strings representing the varying names
  52814. */
  52815. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52816. /**
  52817. * Bind a webGL buffer for a transform feedback operation
  52818. * @param value defines the webGL buffer to bind
  52819. */
  52820. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52821. }
  52822. }
  52823. }
  52824. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52825. import { Scene } from "babylonjs/scene";
  52826. import { Engine } from "babylonjs/Engines/engine";
  52827. import { Texture } from "babylonjs/Materials/Textures/texture";
  52828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52829. import "babylonjs/Engines/Extensions/engine.multiRender";
  52830. /**
  52831. * Creation options of the multi render target texture.
  52832. */
  52833. export interface IMultiRenderTargetOptions {
  52834. /**
  52835. * Define if the texture needs to create mip maps after render.
  52836. */
  52837. generateMipMaps?: boolean;
  52838. /**
  52839. * Define the types of all the draw buffers we want to create
  52840. */
  52841. types?: number[];
  52842. /**
  52843. * Define the sampling modes of all the draw buffers we want to create
  52844. */
  52845. samplingModes?: number[];
  52846. /**
  52847. * Define if a depth buffer is required
  52848. */
  52849. generateDepthBuffer?: boolean;
  52850. /**
  52851. * Define if a stencil buffer is required
  52852. */
  52853. generateStencilBuffer?: boolean;
  52854. /**
  52855. * Define if a depth texture is required instead of a depth buffer
  52856. */
  52857. generateDepthTexture?: boolean;
  52858. /**
  52859. * Define the number of desired draw buffers
  52860. */
  52861. textureCount?: number;
  52862. /**
  52863. * Define if aspect ratio should be adapted to the texture or stay the scene one
  52864. */
  52865. doNotChangeAspectRatio?: boolean;
  52866. /**
  52867. * Define the default type of the buffers we are creating
  52868. */
  52869. defaultType?: number;
  52870. }
  52871. /**
  52872. * A multi render target, like a render target provides the ability to render to a texture.
  52873. * Unlike the render target, it can render to several draw buffers in one draw.
  52874. * This is specially interesting in deferred rendering or for any effects requiring more than
  52875. * just one color from a single pass.
  52876. */
  52877. export class MultiRenderTarget extends RenderTargetTexture {
  52878. private _internalTextures;
  52879. private _textures;
  52880. private _multiRenderTargetOptions;
  52881. /**
  52882. * Get if draw buffers are currently supported by the used hardware and browser.
  52883. */
  52884. get isSupported(): boolean;
  52885. /**
  52886. * Get the list of textures generated by the multi render target.
  52887. */
  52888. get textures(): Texture[];
  52889. /**
  52890. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  52891. */
  52892. get depthTexture(): Texture;
  52893. /**
  52894. * Set the wrapping mode on U of all the textures we are rendering to.
  52895. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52896. */
  52897. set wrapU(wrap: number);
  52898. /**
  52899. * Set the wrapping mode on V of all the textures we are rendering to.
  52900. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  52901. */
  52902. set wrapV(wrap: number);
  52903. /**
  52904. * Instantiate a new multi render target texture.
  52905. * A multi render target, like a render target provides the ability to render to a texture.
  52906. * Unlike the render target, it can render to several draw buffers in one draw.
  52907. * This is specially interesting in deferred rendering or for any effects requiring more than
  52908. * just one color from a single pass.
  52909. * @param name Define the name of the texture
  52910. * @param size Define the size of the buffers to render to
  52911. * @param count Define the number of target we are rendering into
  52912. * @param scene Define the scene the texture belongs to
  52913. * @param options Define the options used to create the multi render target
  52914. */
  52915. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  52916. /** @hidden */
  52917. _rebuild(): void;
  52918. private _createInternalTextures;
  52919. private _createTextures;
  52920. /**
  52921. * Define the number of samples used if MSAA is enabled.
  52922. */
  52923. get samples(): number;
  52924. set samples(value: number);
  52925. /**
  52926. * Resize all the textures in the multi render target.
  52927. * Be carrefull as it will recreate all the data in the new texture.
  52928. * @param size Define the new size
  52929. */
  52930. resize(size: any): void;
  52931. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  52932. /**
  52933. * Dispose the render targets and their associated resources
  52934. */
  52935. dispose(): void;
  52936. /**
  52937. * Release all the underlying texture used as draw buffers.
  52938. */
  52939. releaseInternalTextures(): void;
  52940. }
  52941. }
  52942. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  52943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52944. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  52945. import { Nullable } from "babylonjs/types";
  52946. module "babylonjs/Engines/thinEngine" {
  52947. interface ThinEngine {
  52948. /**
  52949. * Unbind a list of render target textures from the webGL context
  52950. * This is used only when drawBuffer extension or webGL2 are active
  52951. * @param textures defines the render target textures to unbind
  52952. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52953. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52954. */
  52955. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  52956. /**
  52957. * Create a multi render target texture
  52958. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  52959. * @param size defines the size of the texture
  52960. * @param options defines the creation options
  52961. * @returns the cube texture as an InternalTexture
  52962. */
  52963. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  52964. /**
  52965. * Update the sample count for a given multiple render target texture
  52966. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  52967. * @param textures defines the textures to update
  52968. * @param samples defines the sample count to set
  52969. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  52970. */
  52971. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  52972. }
  52973. }
  52974. }
  52975. declare module "babylonjs/Engines/Extensions/engine.views" {
  52976. import { Camera } from "babylonjs/Cameras/camera";
  52977. import { Nullable } from "babylonjs/types";
  52978. /**
  52979. * Class used to define an additional view for the engine
  52980. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52981. */
  52982. export class EngineView {
  52983. /** Defines the canvas where to render the view */
  52984. target: HTMLCanvasElement;
  52985. /** Defines an optional camera used to render the view (will use active camera else) */
  52986. camera?: Camera;
  52987. }
  52988. module "babylonjs/Engines/engine" {
  52989. interface Engine {
  52990. /**
  52991. * Gets or sets the HTML element to use for attaching events
  52992. */
  52993. inputElement: Nullable<HTMLElement>;
  52994. /**
  52995. * Gets the current engine view
  52996. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52997. */
  52998. activeView: Nullable<EngineView>;
  52999. /** Gets or sets the list of views */
  53000. views: EngineView[];
  53001. /**
  53002. * Register a new child canvas
  53003. * @param canvas defines the canvas to register
  53004. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53005. * @returns the associated view
  53006. */
  53007. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53008. /**
  53009. * Remove a registered child canvas
  53010. * @param canvas defines the canvas to remove
  53011. * @returns the current engine
  53012. */
  53013. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53014. }
  53015. }
  53016. }
  53017. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53018. import { Nullable } from "babylonjs/types";
  53019. module "babylonjs/Engines/engine" {
  53020. interface Engine {
  53021. /** @hidden */
  53022. _excludedCompressedTextures: string[];
  53023. /** @hidden */
  53024. _textureFormatInUse: string;
  53025. /**
  53026. * Gets the list of texture formats supported
  53027. */
  53028. readonly texturesSupported: Array<string>;
  53029. /**
  53030. * Gets the texture format in use
  53031. */
  53032. readonly textureFormatInUse: Nullable<string>;
  53033. /**
  53034. * Set the compressed texture extensions or file names to skip.
  53035. *
  53036. * @param skippedFiles defines the list of those texture files you want to skip
  53037. * Example: [".dds", ".env", "myfile.png"]
  53038. */
  53039. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53040. /**
  53041. * Set the compressed texture format to use, based on the formats you have, and the formats
  53042. * supported by the hardware / browser.
  53043. *
  53044. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53045. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53046. * to API arguments needed to compressed textures. This puts the burden on the container
  53047. * generator to house the arcane code for determining these for current & future formats.
  53048. *
  53049. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53050. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53051. *
  53052. * Note: The result of this call is not taken into account when a texture is base64.
  53053. *
  53054. * @param formatsAvailable defines the list of those format families you have created
  53055. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53056. *
  53057. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53058. * @returns The extension selected.
  53059. */
  53060. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53061. }
  53062. }
  53063. }
  53064. declare module "babylonjs/Engines/Extensions/index" {
  53065. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53066. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53067. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53068. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53069. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53070. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53071. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53072. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53073. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53074. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53075. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53076. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53077. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53078. export * from "babylonjs/Engines/Extensions/engine.views";
  53079. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53080. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53081. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53082. }
  53083. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53084. import { Nullable } from "babylonjs/types";
  53085. /**
  53086. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53087. */
  53088. export interface CubeMapInfo {
  53089. /**
  53090. * The pixel array for the front face.
  53091. * This is stored in format, left to right, up to down format.
  53092. */
  53093. front: Nullable<ArrayBufferView>;
  53094. /**
  53095. * The pixel array for the back face.
  53096. * This is stored in format, left to right, up to down format.
  53097. */
  53098. back: Nullable<ArrayBufferView>;
  53099. /**
  53100. * The pixel array for the left face.
  53101. * This is stored in format, left to right, up to down format.
  53102. */
  53103. left: Nullable<ArrayBufferView>;
  53104. /**
  53105. * The pixel array for the right face.
  53106. * This is stored in format, left to right, up to down format.
  53107. */
  53108. right: Nullable<ArrayBufferView>;
  53109. /**
  53110. * The pixel array for the up face.
  53111. * This is stored in format, left to right, up to down format.
  53112. */
  53113. up: Nullable<ArrayBufferView>;
  53114. /**
  53115. * The pixel array for the down face.
  53116. * This is stored in format, left to right, up to down format.
  53117. */
  53118. down: Nullable<ArrayBufferView>;
  53119. /**
  53120. * The size of the cubemap stored.
  53121. *
  53122. * Each faces will be size * size pixels.
  53123. */
  53124. size: number;
  53125. /**
  53126. * The format of the texture.
  53127. *
  53128. * RGBA, RGB.
  53129. */
  53130. format: number;
  53131. /**
  53132. * The type of the texture data.
  53133. *
  53134. * UNSIGNED_INT, FLOAT.
  53135. */
  53136. type: number;
  53137. /**
  53138. * Specifies whether the texture is in gamma space.
  53139. */
  53140. gammaSpace: boolean;
  53141. }
  53142. /**
  53143. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53144. */
  53145. export class PanoramaToCubeMapTools {
  53146. private static FACE_LEFT;
  53147. private static FACE_RIGHT;
  53148. private static FACE_FRONT;
  53149. private static FACE_BACK;
  53150. private static FACE_DOWN;
  53151. private static FACE_UP;
  53152. /**
  53153. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53154. *
  53155. * @param float32Array The source data.
  53156. * @param inputWidth The width of the input panorama.
  53157. * @param inputHeight The height of the input panorama.
  53158. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53159. * @return The cubemap data
  53160. */
  53161. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53162. private static CreateCubemapTexture;
  53163. private static CalcProjectionSpherical;
  53164. }
  53165. }
  53166. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53167. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53169. import { Nullable } from "babylonjs/types";
  53170. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53171. /**
  53172. * Helper class dealing with the extraction of spherical polynomial dataArray
  53173. * from a cube map.
  53174. */
  53175. export class CubeMapToSphericalPolynomialTools {
  53176. private static FileFaces;
  53177. /**
  53178. * Converts a texture to the according Spherical Polynomial data.
  53179. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53180. *
  53181. * @param texture The texture to extract the information from.
  53182. * @return The Spherical Polynomial data.
  53183. */
  53184. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53185. /**
  53186. * Converts a cubemap to the according Spherical Polynomial data.
  53187. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53188. *
  53189. * @param cubeInfo The Cube map to extract the information from.
  53190. * @return The Spherical Polynomial data.
  53191. */
  53192. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53193. }
  53194. }
  53195. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53196. import { Nullable } from "babylonjs/types";
  53197. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53198. module "babylonjs/Materials/Textures/baseTexture" {
  53199. interface BaseTexture {
  53200. /**
  53201. * Get the polynomial representation of the texture data.
  53202. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53203. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53204. */
  53205. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53206. }
  53207. }
  53208. }
  53209. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53210. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53211. /** @hidden */
  53212. export var rgbdEncodePixelShader: {
  53213. name: string;
  53214. shader: string;
  53215. };
  53216. }
  53217. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53218. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53219. /** @hidden */
  53220. export var rgbdDecodePixelShader: {
  53221. name: string;
  53222. shader: string;
  53223. };
  53224. }
  53225. declare module "babylonjs/Misc/environmentTextureTools" {
  53226. import { Nullable } from "babylonjs/types";
  53227. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53230. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53231. import "babylonjs/Engines/Extensions/engine.readTexture";
  53232. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53233. import "babylonjs/Shaders/rgbdEncode.fragment";
  53234. import "babylonjs/Shaders/rgbdDecode.fragment";
  53235. /**
  53236. * Raw texture data and descriptor sufficient for WebGL texture upload
  53237. */
  53238. export interface EnvironmentTextureInfo {
  53239. /**
  53240. * Version of the environment map
  53241. */
  53242. version: number;
  53243. /**
  53244. * Width of image
  53245. */
  53246. width: number;
  53247. /**
  53248. * Irradiance information stored in the file.
  53249. */
  53250. irradiance: any;
  53251. /**
  53252. * Specular information stored in the file.
  53253. */
  53254. specular: any;
  53255. }
  53256. /**
  53257. * Defines One Image in the file. It requires only the position in the file
  53258. * as well as the length.
  53259. */
  53260. interface BufferImageData {
  53261. /**
  53262. * Length of the image data.
  53263. */
  53264. length: number;
  53265. /**
  53266. * Position of the data from the null terminator delimiting the end of the JSON.
  53267. */
  53268. position: number;
  53269. }
  53270. /**
  53271. * Defines the specular data enclosed in the file.
  53272. * This corresponds to the version 1 of the data.
  53273. */
  53274. export interface EnvironmentTextureSpecularInfoV1 {
  53275. /**
  53276. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53277. */
  53278. specularDataPosition?: number;
  53279. /**
  53280. * This contains all the images data needed to reconstruct the cubemap.
  53281. */
  53282. mipmaps: Array<BufferImageData>;
  53283. /**
  53284. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53285. */
  53286. lodGenerationScale: number;
  53287. }
  53288. /**
  53289. * Sets of helpers addressing the serialization and deserialization of environment texture
  53290. * stored in a BabylonJS env file.
  53291. * Those files are usually stored as .env files.
  53292. */
  53293. export class EnvironmentTextureTools {
  53294. /**
  53295. * Magic number identifying the env file.
  53296. */
  53297. private static _MagicBytes;
  53298. /**
  53299. * Gets the environment info from an env file.
  53300. * @param data The array buffer containing the .env bytes.
  53301. * @returns the environment file info (the json header) if successfully parsed.
  53302. */
  53303. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53304. /**
  53305. * Creates an environment texture from a loaded cube texture.
  53306. * @param texture defines the cube texture to convert in env file
  53307. * @return a promise containing the environment data if succesfull.
  53308. */
  53309. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53310. /**
  53311. * Creates a JSON representation of the spherical data.
  53312. * @param texture defines the texture containing the polynomials
  53313. * @return the JSON representation of the spherical info
  53314. */
  53315. private static _CreateEnvTextureIrradiance;
  53316. /**
  53317. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53318. * @param data the image data
  53319. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53320. * @return the views described by info providing access to the underlying buffer
  53321. */
  53322. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53323. /**
  53324. * Uploads the texture info contained in the env file to the GPU.
  53325. * @param texture defines the internal texture to upload to
  53326. * @param data defines the data to load
  53327. * @param info defines the texture info retrieved through the GetEnvInfo method
  53328. * @returns a promise
  53329. */
  53330. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53331. private static _OnImageReadyAsync;
  53332. /**
  53333. * Uploads the levels of image data to the GPU.
  53334. * @param texture defines the internal texture to upload to
  53335. * @param imageData defines the array buffer views of image data [mipmap][face]
  53336. * @returns a promise
  53337. */
  53338. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53339. /**
  53340. * Uploads spherical polynomials information to the texture.
  53341. * @param texture defines the texture we are trying to upload the information to
  53342. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53343. */
  53344. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53345. /** @hidden */
  53346. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53347. }
  53348. }
  53349. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53350. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53351. /** @hidden */
  53352. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53353. private _genericAttributeLocation;
  53354. private _varyingLocationCount;
  53355. private _varyingLocationMap;
  53356. private _replacements;
  53357. private _textureCount;
  53358. private _uniforms;
  53359. lineProcessor(line: string): string;
  53360. attributeProcessor(attribute: string): string;
  53361. varyingProcessor(varying: string, isFragment: boolean): string;
  53362. uniformProcessor(uniform: string): string;
  53363. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53364. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53365. }
  53366. }
  53367. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53368. /**
  53369. * Class used to inline functions in shader code
  53370. */
  53371. export class ShaderCodeInliner {
  53372. private static readonly _RegexpFindFunctionNameAndType;
  53373. private _sourceCode;
  53374. private _functionDescr;
  53375. private _numMaxIterations;
  53376. /** Gets or sets the token used to mark the functions to inline */
  53377. inlineToken: string;
  53378. /** Gets or sets the debug mode */
  53379. debug: boolean;
  53380. /** Gets the code after the inlining process */
  53381. get code(): string;
  53382. /**
  53383. * Initializes the inliner
  53384. * @param sourceCode shader code source to inline
  53385. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53386. */
  53387. constructor(sourceCode: string, numMaxIterations?: number);
  53388. /**
  53389. * Start the processing of the shader code
  53390. */
  53391. processCode(): void;
  53392. private _collectFunctions;
  53393. private _processInlining;
  53394. private _extractBetweenMarkers;
  53395. private _skipWhitespaces;
  53396. private _removeComments;
  53397. private _replaceFunctionCallsByCode;
  53398. private _findBackward;
  53399. private _escapeRegExp;
  53400. private _replaceNames;
  53401. }
  53402. }
  53403. declare module "babylonjs/Engines/nativeEngine" {
  53404. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53405. import { Engine } from "babylonjs/Engines/engine";
  53406. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53409. import { Effect } from "babylonjs/Materials/effect";
  53410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53411. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53412. import { IColor4Like } from "babylonjs/Maths/math.like";
  53413. import { Scene } from "babylonjs/scene";
  53414. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53415. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53416. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53417. /**
  53418. * Container for accessors for natively-stored mesh data buffers.
  53419. */
  53420. class NativeDataBuffer extends DataBuffer {
  53421. /**
  53422. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53423. */
  53424. nativeIndexBuffer?: any;
  53425. /**
  53426. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53427. */
  53428. nativeVertexBuffer?: any;
  53429. }
  53430. /** @hidden */
  53431. class NativeTexture extends InternalTexture {
  53432. getInternalTexture(): InternalTexture;
  53433. getViewCount(): number;
  53434. }
  53435. /** @hidden */
  53436. export class NativeEngine extends Engine {
  53437. private readonly _native;
  53438. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53439. private readonly INVALID_HANDLE;
  53440. getHardwareScalingLevel(): number;
  53441. constructor();
  53442. dispose(): void;
  53443. /**
  53444. * Can be used to override the current requestAnimationFrame requester.
  53445. * @hidden
  53446. */
  53447. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53448. /**
  53449. * Override default engine behavior.
  53450. * @param color
  53451. * @param backBuffer
  53452. * @param depth
  53453. * @param stencil
  53454. */
  53455. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53456. /**
  53457. * Gets host document
  53458. * @returns the host document object
  53459. */
  53460. getHostDocument(): Nullable<Document>;
  53461. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53462. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53463. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53464. recordVertexArrayObject(vertexBuffers: {
  53465. [key: string]: VertexBuffer;
  53466. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53467. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53468. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53469. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53470. /**
  53471. * Draw a list of indexed primitives
  53472. * @param fillMode defines the primitive to use
  53473. * @param indexStart defines the starting index
  53474. * @param indexCount defines the number of index to draw
  53475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53476. */
  53477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53478. /**
  53479. * Draw a list of unindexed primitives
  53480. * @param fillMode defines the primitive to use
  53481. * @param verticesStart defines the index of first vertex to draw
  53482. * @param verticesCount defines the count of vertices to draw
  53483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53484. */
  53485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53486. createPipelineContext(): IPipelineContext;
  53487. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53488. /** @hidden */
  53489. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53490. /** @hidden */
  53491. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53492. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53493. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53494. protected _setProgram(program: WebGLProgram): void;
  53495. _releaseEffect(effect: Effect): void;
  53496. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53497. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53498. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53499. bindSamplers(effect: Effect): void;
  53500. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53501. getRenderWidth(useScreen?: boolean): number;
  53502. getRenderHeight(useScreen?: boolean): number;
  53503. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53504. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53505. /**
  53506. * Set the z offset to apply to current rendering
  53507. * @param value defines the offset to apply
  53508. */
  53509. setZOffset(value: number): void;
  53510. /**
  53511. * Gets the current value of the zOffset
  53512. * @returns the current zOffset state
  53513. */
  53514. getZOffset(): number;
  53515. /**
  53516. * Enable or disable depth buffering
  53517. * @param enable defines the state to set
  53518. */
  53519. setDepthBuffer(enable: boolean): void;
  53520. /**
  53521. * Gets a boolean indicating if depth writing is enabled
  53522. * @returns the current depth writing state
  53523. */
  53524. getDepthWrite(): boolean;
  53525. /**
  53526. * Enable or disable depth writing
  53527. * @param enable defines the state to set
  53528. */
  53529. setDepthWrite(enable: boolean): void;
  53530. /**
  53531. * Enable or disable color writing
  53532. * @param enable defines the state to set
  53533. */
  53534. setColorWrite(enable: boolean): void;
  53535. /**
  53536. * Gets a boolean indicating if color writing is enabled
  53537. * @returns the current color writing state
  53538. */
  53539. getColorWrite(): boolean;
  53540. /**
  53541. * Sets alpha constants used by some alpha blending modes
  53542. * @param r defines the red component
  53543. * @param g defines the green component
  53544. * @param b defines the blue component
  53545. * @param a defines the alpha component
  53546. */
  53547. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53548. /**
  53549. * Sets the current alpha mode
  53550. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53551. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53552. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53553. */
  53554. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53555. /**
  53556. * Gets the current alpha mode
  53557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53558. * @returns the current alpha mode
  53559. */
  53560. getAlphaMode(): number;
  53561. setInt(uniform: WebGLUniformLocation, int: number): void;
  53562. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53563. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53564. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53565. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53566. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53567. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53568. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53569. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53570. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53571. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53572. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53573. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53574. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53575. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53576. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53577. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53578. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53579. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53580. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53581. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53582. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53583. wipeCaches(bruteForce?: boolean): void;
  53584. _createTexture(): WebGLTexture;
  53585. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53586. /**
  53587. * Usually called from Texture.ts.
  53588. * Passed information to create a WebGLTexture
  53589. * @param url defines a value which contains one of the following:
  53590. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53591. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53592. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53593. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53594. * @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)
  53595. * @param scene needed for loading to the correct scene
  53596. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53597. * @param onLoad optional callback to be called upon successful completion
  53598. * @param onError optional callback to be called upon failure
  53599. * @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
  53600. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53601. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53602. * @param forcedExtension defines the extension to use to pick the right loader
  53603. * @param mimeType defines an optional mime type
  53604. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53605. */
  53606. 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;
  53607. /**
  53608. * Creates a cube texture
  53609. * @param rootUrl defines the url where the files to load is located
  53610. * @param scene defines the current scene
  53611. * @param files defines the list of files to load (1 per face)
  53612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53613. * @param onLoad defines an optional callback raised when the texture is loaded
  53614. * @param onError defines an optional callback raised if there is an issue to load the texture
  53615. * @param format defines the format of the data
  53616. * @param forcedExtension defines the extension to use to pick the right loader
  53617. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53620. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53621. * @returns the cube texture as an InternalTexture
  53622. */
  53623. 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;
  53624. private _getSamplingFilter;
  53625. private static _GetNativeTextureFormat;
  53626. createRenderTargetTexture(size: number | {
  53627. width: number;
  53628. height: number;
  53629. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53630. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53631. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53632. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53633. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53634. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53635. /**
  53636. * Updates a dynamic vertex buffer.
  53637. * @param vertexBuffer the vertex buffer to update
  53638. * @param data the data used to update the vertex buffer
  53639. * @param byteOffset the byte offset of the data (optional)
  53640. * @param byteLength the byte length of the data (optional)
  53641. */
  53642. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53643. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53644. private _updateAnisotropicLevel;
  53645. private _getAddressMode;
  53646. /** @hidden */
  53647. _bindTexture(channel: number, texture: InternalTexture): void;
  53648. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53649. releaseEffects(): void;
  53650. /** @hidden */
  53651. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53652. /** @hidden */
  53653. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53654. /** @hidden */
  53655. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53656. /** @hidden */
  53657. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53658. }
  53659. }
  53660. declare module "babylonjs/Engines/index" {
  53661. export * from "babylonjs/Engines/constants";
  53662. export * from "babylonjs/Engines/engineCapabilities";
  53663. export * from "babylonjs/Engines/instancingAttributeInfo";
  53664. export * from "babylonjs/Engines/thinEngine";
  53665. export * from "babylonjs/Engines/engine";
  53666. export * from "babylonjs/Engines/engineStore";
  53667. export * from "babylonjs/Engines/nullEngine";
  53668. export * from "babylonjs/Engines/Extensions/index";
  53669. export * from "babylonjs/Engines/IPipelineContext";
  53670. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53671. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53672. export * from "babylonjs/Engines/nativeEngine";
  53673. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53674. }
  53675. declare module "babylonjs/Events/clipboardEvents" {
  53676. /**
  53677. * Gather the list of clipboard event types as constants.
  53678. */
  53679. export class ClipboardEventTypes {
  53680. /**
  53681. * The clipboard event is fired when a copy command is active (pressed).
  53682. */
  53683. static readonly COPY: number;
  53684. /**
  53685. * The clipboard event is fired when a cut command is active (pressed).
  53686. */
  53687. static readonly CUT: number;
  53688. /**
  53689. * The clipboard event is fired when a paste command is active (pressed).
  53690. */
  53691. static readonly PASTE: number;
  53692. }
  53693. /**
  53694. * This class is used to store clipboard related info for the onClipboardObservable event.
  53695. */
  53696. export class ClipboardInfo {
  53697. /**
  53698. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53699. */
  53700. type: number;
  53701. /**
  53702. * Defines the related dom event
  53703. */
  53704. event: ClipboardEvent;
  53705. /**
  53706. *Creates an instance of ClipboardInfo.
  53707. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53708. * @param event Defines the related dom event
  53709. */
  53710. constructor(
  53711. /**
  53712. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53713. */
  53714. type: number,
  53715. /**
  53716. * Defines the related dom event
  53717. */
  53718. event: ClipboardEvent);
  53719. /**
  53720. * Get the clipboard event's type from the keycode.
  53721. * @param keyCode Defines the keyCode for the current keyboard event.
  53722. * @return {number}
  53723. */
  53724. static GetTypeFromCharacter(keyCode: number): number;
  53725. }
  53726. }
  53727. declare module "babylonjs/Events/index" {
  53728. export * from "babylonjs/Events/keyboardEvents";
  53729. export * from "babylonjs/Events/pointerEvents";
  53730. export * from "babylonjs/Events/clipboardEvents";
  53731. }
  53732. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53733. import { Scene } from "babylonjs/scene";
  53734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53735. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53736. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53737. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53738. /**
  53739. * Google Daydream controller
  53740. */
  53741. export class DaydreamController extends WebVRController {
  53742. /**
  53743. * Base Url for the controller model.
  53744. */
  53745. static MODEL_BASE_URL: string;
  53746. /**
  53747. * File name for the controller model.
  53748. */
  53749. static MODEL_FILENAME: string;
  53750. /**
  53751. * Gamepad Id prefix used to identify Daydream Controller.
  53752. */
  53753. static readonly GAMEPAD_ID_PREFIX: string;
  53754. /**
  53755. * Creates a new DaydreamController from a gamepad
  53756. * @param vrGamepad the gamepad that the controller should be created from
  53757. */
  53758. constructor(vrGamepad: any);
  53759. /**
  53760. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53761. * @param scene scene in which to add meshes
  53762. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53763. */
  53764. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53765. /**
  53766. * Called once for each button that changed state since the last frame
  53767. * @param buttonIdx Which button index changed
  53768. * @param state New state of the button
  53769. * @param changes Which properties on the state changed since last frame
  53770. */
  53771. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53772. }
  53773. }
  53774. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53775. import { Scene } from "babylonjs/scene";
  53776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53777. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53778. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53779. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53780. /**
  53781. * Gear VR Controller
  53782. */
  53783. export class GearVRController extends WebVRController {
  53784. /**
  53785. * Base Url for the controller model.
  53786. */
  53787. static MODEL_BASE_URL: string;
  53788. /**
  53789. * File name for the controller model.
  53790. */
  53791. static MODEL_FILENAME: string;
  53792. /**
  53793. * Gamepad Id prefix used to identify this controller.
  53794. */
  53795. static readonly GAMEPAD_ID_PREFIX: string;
  53796. private readonly _buttonIndexToObservableNameMap;
  53797. /**
  53798. * Creates a new GearVRController from a gamepad
  53799. * @param vrGamepad the gamepad that the controller should be created from
  53800. */
  53801. constructor(vrGamepad: any);
  53802. /**
  53803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53804. * @param scene scene in which to add meshes
  53805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53806. */
  53807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53808. /**
  53809. * Called once for each button that changed state since the last frame
  53810. * @param buttonIdx Which button index changed
  53811. * @param state New state of the button
  53812. * @param changes Which properties on the state changed since last frame
  53813. */
  53814. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53815. }
  53816. }
  53817. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53818. import { Scene } from "babylonjs/scene";
  53819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53820. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53821. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53822. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53823. /**
  53824. * Generic Controller
  53825. */
  53826. export class GenericController extends WebVRController {
  53827. /**
  53828. * Base Url for the controller model.
  53829. */
  53830. static readonly MODEL_BASE_URL: string;
  53831. /**
  53832. * File name for the controller model.
  53833. */
  53834. static readonly MODEL_FILENAME: string;
  53835. /**
  53836. * Creates a new GenericController from a gamepad
  53837. * @param vrGamepad the gamepad that the controller should be created from
  53838. */
  53839. constructor(vrGamepad: any);
  53840. /**
  53841. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53842. * @param scene scene in which to add meshes
  53843. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53844. */
  53845. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53846. /**
  53847. * Called once for each button that changed state since the last frame
  53848. * @param buttonIdx Which button index changed
  53849. * @param state New state of the button
  53850. * @param changes Which properties on the state changed since last frame
  53851. */
  53852. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53853. }
  53854. }
  53855. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  53856. import { Observable } from "babylonjs/Misc/observable";
  53857. import { Scene } from "babylonjs/scene";
  53858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53859. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53860. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53861. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53862. /**
  53863. * Oculus Touch Controller
  53864. */
  53865. export class OculusTouchController extends WebVRController {
  53866. /**
  53867. * Base Url for the controller model.
  53868. */
  53869. static MODEL_BASE_URL: string;
  53870. /**
  53871. * File name for the left controller model.
  53872. */
  53873. static MODEL_LEFT_FILENAME: string;
  53874. /**
  53875. * File name for the right controller model.
  53876. */
  53877. static MODEL_RIGHT_FILENAME: string;
  53878. /**
  53879. * Base Url for the Quest controller model.
  53880. */
  53881. static QUEST_MODEL_BASE_URL: string;
  53882. /**
  53883. * @hidden
  53884. * If the controllers are running on a device that needs the updated Quest controller models
  53885. */
  53886. static _IsQuest: boolean;
  53887. /**
  53888. * Fired when the secondary trigger on this controller is modified
  53889. */
  53890. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53891. /**
  53892. * Fired when the thumb rest on this controller is modified
  53893. */
  53894. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53895. /**
  53896. * Creates a new OculusTouchController from a gamepad
  53897. * @param vrGamepad the gamepad that the controller should be created from
  53898. */
  53899. constructor(vrGamepad: any);
  53900. /**
  53901. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53902. * @param scene scene in which to add meshes
  53903. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53904. */
  53905. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53906. /**
  53907. * Fired when the A button on this controller is modified
  53908. */
  53909. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53910. /**
  53911. * Fired when the B button on this controller is modified
  53912. */
  53913. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53914. /**
  53915. * Fired when the X button on this controller is modified
  53916. */
  53917. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53918. /**
  53919. * Fired when the Y button on this controller is modified
  53920. */
  53921. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53922. /**
  53923. * Called once for each button that changed state since the last frame
  53924. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53925. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53926. * 2) secondary trigger (same)
  53927. * 3) A (right) X (left), touch, pressed = value
  53928. * 4) B / Y
  53929. * 5) thumb rest
  53930. * @param buttonIdx Which button index changed
  53931. * @param state New state of the button
  53932. * @param changes Which properties on the state changed since last frame
  53933. */
  53934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53935. }
  53936. }
  53937. declare module "babylonjs/Gamepads/Controllers/viveController" {
  53938. import { Scene } from "babylonjs/scene";
  53939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53940. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53941. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53942. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53943. import { Observable } from "babylonjs/Misc/observable";
  53944. /**
  53945. * Vive Controller
  53946. */
  53947. export class ViveController extends WebVRController {
  53948. /**
  53949. * Base Url for the controller model.
  53950. */
  53951. static MODEL_BASE_URL: string;
  53952. /**
  53953. * File name for the controller model.
  53954. */
  53955. static MODEL_FILENAME: string;
  53956. /**
  53957. * Creates a new ViveController from a gamepad
  53958. * @param vrGamepad the gamepad that the controller should be created from
  53959. */
  53960. constructor(vrGamepad: any);
  53961. /**
  53962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53963. * @param scene scene in which to add meshes
  53964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53965. */
  53966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53967. /**
  53968. * Fired when the left button on this controller is modified
  53969. */
  53970. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53971. /**
  53972. * Fired when the right button on this controller is modified
  53973. */
  53974. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53975. /**
  53976. * Fired when the menu button on this controller is modified
  53977. */
  53978. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53979. /**
  53980. * Called once for each button that changed state since the last frame
  53981. * Vive mapping:
  53982. * 0: touchpad
  53983. * 1: trigger
  53984. * 2: left AND right buttons
  53985. * 3: menu button
  53986. * @param buttonIdx Which button index changed
  53987. * @param state New state of the button
  53988. * @param changes Which properties on the state changed since last frame
  53989. */
  53990. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53991. }
  53992. }
  53993. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  53994. import { Observable } from "babylonjs/Misc/observable";
  53995. import { Scene } from "babylonjs/scene";
  53996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53997. import { Ray } from "babylonjs/Culling/ray";
  53998. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53999. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54000. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54001. /**
  54002. * Defines the WindowsMotionController object that the state of the windows motion controller
  54003. */
  54004. export class WindowsMotionController extends WebVRController {
  54005. /**
  54006. * The base url used to load the left and right controller models
  54007. */
  54008. static MODEL_BASE_URL: string;
  54009. /**
  54010. * The name of the left controller model file
  54011. */
  54012. static MODEL_LEFT_FILENAME: string;
  54013. /**
  54014. * The name of the right controller model file
  54015. */
  54016. static MODEL_RIGHT_FILENAME: string;
  54017. /**
  54018. * The controller name prefix for this controller type
  54019. */
  54020. static readonly GAMEPAD_ID_PREFIX: string;
  54021. /**
  54022. * The controller id pattern for this controller type
  54023. */
  54024. private static readonly GAMEPAD_ID_PATTERN;
  54025. private _loadedMeshInfo;
  54026. protected readonly _mapping: {
  54027. buttons: string[];
  54028. buttonMeshNames: {
  54029. trigger: string;
  54030. menu: string;
  54031. grip: string;
  54032. thumbstick: string;
  54033. trackpad: string;
  54034. };
  54035. buttonObservableNames: {
  54036. trigger: string;
  54037. menu: string;
  54038. grip: string;
  54039. thumbstick: string;
  54040. trackpad: string;
  54041. };
  54042. axisMeshNames: string[];
  54043. pointingPoseMeshName: string;
  54044. };
  54045. /**
  54046. * Fired when the trackpad on this controller is clicked
  54047. */
  54048. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54049. /**
  54050. * Fired when the trackpad on this controller is modified
  54051. */
  54052. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54053. /**
  54054. * The current x and y values of this controller's trackpad
  54055. */
  54056. trackpad: StickValues;
  54057. /**
  54058. * Creates a new WindowsMotionController from a gamepad
  54059. * @param vrGamepad the gamepad that the controller should be created from
  54060. */
  54061. constructor(vrGamepad: any);
  54062. /**
  54063. * Fired when the trigger on this controller is modified
  54064. */
  54065. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54066. /**
  54067. * Fired when the menu button on this controller is modified
  54068. */
  54069. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54070. /**
  54071. * Fired when the grip button on this controller is modified
  54072. */
  54073. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54074. /**
  54075. * Fired when the thumbstick button on this controller is modified
  54076. */
  54077. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54078. /**
  54079. * Fired when the touchpad button on this controller is modified
  54080. */
  54081. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54082. /**
  54083. * Fired when the touchpad values on this controller are modified
  54084. */
  54085. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54086. protected _updateTrackpad(): void;
  54087. /**
  54088. * Called once per frame by the engine.
  54089. */
  54090. update(): void;
  54091. /**
  54092. * Called once for each button that changed state since the last frame
  54093. * @param buttonIdx Which button index changed
  54094. * @param state New state of the button
  54095. * @param changes Which properties on the state changed since last frame
  54096. */
  54097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54098. /**
  54099. * Moves the buttons on the controller mesh based on their current state
  54100. * @param buttonName the name of the button to move
  54101. * @param buttonValue the value of the button which determines the buttons new position
  54102. */
  54103. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54104. /**
  54105. * Moves the axis on the controller mesh based on its current state
  54106. * @param axis the index of the axis
  54107. * @param axisValue the value of the axis which determines the meshes new position
  54108. * @hidden
  54109. */
  54110. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54111. /**
  54112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54113. * @param scene scene in which to add meshes
  54114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54115. */
  54116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54117. /**
  54118. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54119. * can be transformed by button presses and axes values, based on this._mapping.
  54120. *
  54121. * @param scene scene in which the meshes exist
  54122. * @param meshes list of meshes that make up the controller model to process
  54123. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54124. */
  54125. private processModel;
  54126. private createMeshInfo;
  54127. /**
  54128. * Gets the ray of the controller in the direction the controller is pointing
  54129. * @param length the length the resulting ray should be
  54130. * @returns a ray in the direction the controller is pointing
  54131. */
  54132. getForwardRay(length?: number): Ray;
  54133. /**
  54134. * Disposes of the controller
  54135. */
  54136. dispose(): void;
  54137. }
  54138. /**
  54139. * This class represents a new windows motion controller in XR.
  54140. */
  54141. export class XRWindowsMotionController extends WindowsMotionController {
  54142. /**
  54143. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54144. */
  54145. protected readonly _mapping: {
  54146. buttons: string[];
  54147. buttonMeshNames: {
  54148. trigger: string;
  54149. menu: string;
  54150. grip: string;
  54151. thumbstick: string;
  54152. trackpad: string;
  54153. };
  54154. buttonObservableNames: {
  54155. trigger: string;
  54156. menu: string;
  54157. grip: string;
  54158. thumbstick: string;
  54159. trackpad: string;
  54160. };
  54161. axisMeshNames: string[];
  54162. pointingPoseMeshName: string;
  54163. };
  54164. /**
  54165. * Construct a new XR-Based windows motion controller
  54166. *
  54167. * @param gamepadInfo the gamepad object from the browser
  54168. */
  54169. constructor(gamepadInfo: any);
  54170. /**
  54171. * holds the thumbstick values (X,Y)
  54172. */
  54173. thumbstickValues: StickValues;
  54174. /**
  54175. * Fired when the thumbstick on this controller is clicked
  54176. */
  54177. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54178. /**
  54179. * Fired when the thumbstick on this controller is modified
  54180. */
  54181. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54182. /**
  54183. * Fired when the touchpad button on this controller is modified
  54184. */
  54185. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54186. /**
  54187. * Fired when the touchpad values on this controller are modified
  54188. */
  54189. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54190. /**
  54191. * Fired when the thumbstick button on this controller is modified
  54192. * here to prevent breaking changes
  54193. */
  54194. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54195. /**
  54196. * updating the thumbstick(!) and not the trackpad.
  54197. * This is named this way due to the difference between WebVR and XR and to avoid
  54198. * changing the parent class.
  54199. */
  54200. protected _updateTrackpad(): void;
  54201. /**
  54202. * Disposes the class with joy
  54203. */
  54204. dispose(): void;
  54205. }
  54206. }
  54207. declare module "babylonjs/Gamepads/Controllers/index" {
  54208. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54209. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54210. export * from "babylonjs/Gamepads/Controllers/genericController";
  54211. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54212. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54213. export * from "babylonjs/Gamepads/Controllers/viveController";
  54214. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54215. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54216. }
  54217. declare module "babylonjs/Gamepads/index" {
  54218. export * from "babylonjs/Gamepads/Controllers/index";
  54219. export * from "babylonjs/Gamepads/gamepad";
  54220. export * from "babylonjs/Gamepads/gamepadManager";
  54221. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54222. export * from "babylonjs/Gamepads/xboxGamepad";
  54223. export * from "babylonjs/Gamepads/dualShockGamepad";
  54224. }
  54225. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54226. import { Scene } from "babylonjs/scene";
  54227. import { Vector4 } from "babylonjs/Maths/math.vector";
  54228. import { Color4 } from "babylonjs/Maths/math.color";
  54229. import { Mesh } from "babylonjs/Meshes/mesh";
  54230. import { Nullable } from "babylonjs/types";
  54231. /**
  54232. * Class containing static functions to help procedurally build meshes
  54233. */
  54234. export class PolyhedronBuilder {
  54235. /**
  54236. * Creates a polyhedron mesh
  54237. * * 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
  54238. * * The parameter `size` (positive float, default 1) sets the polygon size
  54239. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54240. * * 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`
  54241. * * 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
  54242. * * 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)`)
  54243. * * 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
  54244. * * 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
  54245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54248. * @param name defines the name of the mesh
  54249. * @param options defines the options used to create the mesh
  54250. * @param scene defines the hosting scene
  54251. * @returns the polyhedron mesh
  54252. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54253. */
  54254. static CreatePolyhedron(name: string, options: {
  54255. type?: number;
  54256. size?: number;
  54257. sizeX?: number;
  54258. sizeY?: number;
  54259. sizeZ?: number;
  54260. custom?: any;
  54261. faceUV?: Vector4[];
  54262. faceColors?: Color4[];
  54263. flat?: boolean;
  54264. updatable?: boolean;
  54265. sideOrientation?: number;
  54266. frontUVs?: Vector4;
  54267. backUVs?: Vector4;
  54268. }, scene?: Nullable<Scene>): Mesh;
  54269. }
  54270. }
  54271. declare module "babylonjs/Gizmos/scaleGizmo" {
  54272. import { Observable } from "babylonjs/Misc/observable";
  54273. import { Nullable } from "babylonjs/types";
  54274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54275. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54276. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54277. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54278. /**
  54279. * Gizmo that enables scaling a mesh along 3 axis
  54280. */
  54281. export class ScaleGizmo extends Gizmo {
  54282. /**
  54283. * Internal gizmo used for interactions on the x axis
  54284. */
  54285. xGizmo: AxisScaleGizmo;
  54286. /**
  54287. * Internal gizmo used for interactions on the y axis
  54288. */
  54289. yGizmo: AxisScaleGizmo;
  54290. /**
  54291. * Internal gizmo used for interactions on the z axis
  54292. */
  54293. zGizmo: AxisScaleGizmo;
  54294. /**
  54295. * Internal gizmo used to scale all axis equally
  54296. */
  54297. uniformScaleGizmo: AxisScaleGizmo;
  54298. private _meshAttached;
  54299. private _updateGizmoRotationToMatchAttachedMesh;
  54300. private _snapDistance;
  54301. private _scaleRatio;
  54302. private _uniformScalingMesh;
  54303. private _octahedron;
  54304. private _sensitivity;
  54305. /** Fires an event when any of it's sub gizmos are dragged */
  54306. onDragStartObservable: Observable<unknown>;
  54307. /** Fires an event when any of it's sub gizmos are released from dragging */
  54308. onDragEndObservable: Observable<unknown>;
  54309. get attachedMesh(): Nullable<AbstractMesh>;
  54310. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54311. /**
  54312. * Creates a ScaleGizmo
  54313. * @param gizmoLayer The utility layer the gizmo will be added to
  54314. */
  54315. constructor(gizmoLayer?: UtilityLayerRenderer);
  54316. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54317. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54318. /**
  54319. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54320. */
  54321. set snapDistance(value: number);
  54322. get snapDistance(): number;
  54323. /**
  54324. * Ratio for the scale of the gizmo (Default: 1)
  54325. */
  54326. set scaleRatio(value: number);
  54327. get scaleRatio(): number;
  54328. /**
  54329. * Sensitivity factor for dragging (Default: 1)
  54330. */
  54331. set sensitivity(value: number);
  54332. get sensitivity(): number;
  54333. /**
  54334. * Disposes of the gizmo
  54335. */
  54336. dispose(): void;
  54337. }
  54338. }
  54339. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54340. import { Observable } from "babylonjs/Misc/observable";
  54341. import { Nullable } from "babylonjs/types";
  54342. import { Vector3 } from "babylonjs/Maths/math.vector";
  54343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54344. import { Mesh } from "babylonjs/Meshes/mesh";
  54345. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54346. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54347. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54348. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54349. import { Color3 } from "babylonjs/Maths/math.color";
  54350. /**
  54351. * Single axis scale gizmo
  54352. */
  54353. export class AxisScaleGizmo extends Gizmo {
  54354. /**
  54355. * Drag behavior responsible for the gizmos dragging interactions
  54356. */
  54357. dragBehavior: PointerDragBehavior;
  54358. private _pointerObserver;
  54359. /**
  54360. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54361. */
  54362. snapDistance: number;
  54363. /**
  54364. * Event that fires each time the gizmo snaps to a new location.
  54365. * * snapDistance is the the change in distance
  54366. */
  54367. onSnapObservable: Observable<{
  54368. snapDistance: number;
  54369. }>;
  54370. /**
  54371. * If the scaling operation should be done on all axis (default: false)
  54372. */
  54373. uniformScaling: boolean;
  54374. /**
  54375. * Custom sensitivity value for the drag strength
  54376. */
  54377. sensitivity: number;
  54378. private _isEnabled;
  54379. private _parent;
  54380. private _arrow;
  54381. private _coloredMaterial;
  54382. private _hoverMaterial;
  54383. /**
  54384. * Creates an AxisScaleGizmo
  54385. * @param gizmoLayer The utility layer the gizmo will be added to
  54386. * @param dragAxis The axis which the gizmo will be able to scale on
  54387. * @param color The color of the gizmo
  54388. */
  54389. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54390. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54391. /**
  54392. * If the gizmo is enabled
  54393. */
  54394. set isEnabled(value: boolean);
  54395. get isEnabled(): boolean;
  54396. /**
  54397. * Disposes of the gizmo
  54398. */
  54399. dispose(): void;
  54400. /**
  54401. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54402. * @param mesh The mesh to replace the default mesh of the gizmo
  54403. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54404. */
  54405. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54406. }
  54407. }
  54408. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54409. import { Observable } from "babylonjs/Misc/observable";
  54410. import { Nullable } from "babylonjs/types";
  54411. import { Vector3 } from "babylonjs/Maths/math.vector";
  54412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54413. import { Mesh } from "babylonjs/Meshes/mesh";
  54414. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54415. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54416. import { Color3 } from "babylonjs/Maths/math.color";
  54417. import "babylonjs/Meshes/Builders/boxBuilder";
  54418. /**
  54419. * Bounding box gizmo
  54420. */
  54421. export class BoundingBoxGizmo extends Gizmo {
  54422. private _lineBoundingBox;
  54423. private _rotateSpheresParent;
  54424. private _scaleBoxesParent;
  54425. private _boundingDimensions;
  54426. private _renderObserver;
  54427. private _pointerObserver;
  54428. private _scaleDragSpeed;
  54429. private _tmpQuaternion;
  54430. private _tmpVector;
  54431. private _tmpRotationMatrix;
  54432. /**
  54433. * 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)
  54434. */
  54435. ignoreChildren: boolean;
  54436. /**
  54437. * 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)
  54438. */
  54439. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54440. /**
  54441. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54442. */
  54443. rotationSphereSize: number;
  54444. /**
  54445. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54446. */
  54447. scaleBoxSize: number;
  54448. /**
  54449. * 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)
  54450. */
  54451. fixedDragMeshScreenSize: boolean;
  54452. /**
  54453. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54454. */
  54455. fixedDragMeshScreenSizeDistanceFactor: number;
  54456. /**
  54457. * Fired when a rotation sphere or scale box is dragged
  54458. */
  54459. onDragStartObservable: Observable<{}>;
  54460. /**
  54461. * Fired when a scale box is dragged
  54462. */
  54463. onScaleBoxDragObservable: Observable<{}>;
  54464. /**
  54465. * Fired when a scale box drag is ended
  54466. */
  54467. onScaleBoxDragEndObservable: Observable<{}>;
  54468. /**
  54469. * Fired when a rotation sphere is dragged
  54470. */
  54471. onRotationSphereDragObservable: Observable<{}>;
  54472. /**
  54473. * Fired when a rotation sphere drag is ended
  54474. */
  54475. onRotationSphereDragEndObservable: Observable<{}>;
  54476. /**
  54477. * 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)
  54478. */
  54479. scalePivot: Nullable<Vector3>;
  54480. /**
  54481. * Mesh used as a pivot to rotate the attached mesh
  54482. */
  54483. private _anchorMesh;
  54484. private _existingMeshScale;
  54485. private _dragMesh;
  54486. private pointerDragBehavior;
  54487. private coloredMaterial;
  54488. private hoverColoredMaterial;
  54489. /**
  54490. * Sets the color of the bounding box gizmo
  54491. * @param color the color to set
  54492. */
  54493. setColor(color: Color3): void;
  54494. /**
  54495. * Creates an BoundingBoxGizmo
  54496. * @param gizmoLayer The utility layer the gizmo will be added to
  54497. * @param color The color of the gizmo
  54498. */
  54499. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54500. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54501. private _selectNode;
  54502. /**
  54503. * Updates the bounding box information for the Gizmo
  54504. */
  54505. updateBoundingBox(): void;
  54506. private _updateRotationSpheres;
  54507. private _updateScaleBoxes;
  54508. /**
  54509. * Enables rotation on the specified axis and disables rotation on the others
  54510. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54511. */
  54512. setEnabledRotationAxis(axis: string): void;
  54513. /**
  54514. * Enables/disables scaling
  54515. * @param enable if scaling should be enabled
  54516. * @param homogeneousScaling defines if scaling should only be homogeneous
  54517. */
  54518. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54519. private _updateDummy;
  54520. /**
  54521. * Enables a pointer drag behavior on the bounding box of the gizmo
  54522. */
  54523. enableDragBehavior(): void;
  54524. /**
  54525. * Disposes of the gizmo
  54526. */
  54527. dispose(): void;
  54528. /**
  54529. * 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)
  54530. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54531. * @returns the bounding box mesh with the passed in mesh as a child
  54532. */
  54533. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54534. /**
  54535. * CustomMeshes are not supported by this gizmo
  54536. * @param mesh The mesh to replace the default mesh of the gizmo
  54537. */
  54538. setCustomMesh(mesh: Mesh): void;
  54539. }
  54540. }
  54541. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54542. import { Observable } from "babylonjs/Misc/observable";
  54543. import { Nullable } from "babylonjs/types";
  54544. import { Vector3 } from "babylonjs/Maths/math.vector";
  54545. import { Color3 } from "babylonjs/Maths/math.color";
  54546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54547. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54549. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54550. import "babylonjs/Meshes/Builders/linesBuilder";
  54551. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54552. /**
  54553. * Single plane rotation gizmo
  54554. */
  54555. export class PlaneRotationGizmo extends Gizmo {
  54556. /**
  54557. * Drag behavior responsible for the gizmos dragging interactions
  54558. */
  54559. dragBehavior: PointerDragBehavior;
  54560. private _pointerObserver;
  54561. /**
  54562. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54563. */
  54564. snapDistance: number;
  54565. /**
  54566. * Event that fires each time the gizmo snaps to a new location.
  54567. * * snapDistance is the the change in distance
  54568. */
  54569. onSnapObservable: Observable<{
  54570. snapDistance: number;
  54571. }>;
  54572. private _isEnabled;
  54573. private _parent;
  54574. /**
  54575. * Creates a PlaneRotationGizmo
  54576. * @param gizmoLayer The utility layer the gizmo will be added to
  54577. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54578. * @param color The color of the gizmo
  54579. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54580. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54581. */
  54582. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54583. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54584. /**
  54585. * If the gizmo is enabled
  54586. */
  54587. set isEnabled(value: boolean);
  54588. get isEnabled(): boolean;
  54589. /**
  54590. * Disposes of the gizmo
  54591. */
  54592. dispose(): void;
  54593. }
  54594. }
  54595. declare module "babylonjs/Gizmos/rotationGizmo" {
  54596. import { Observable } from "babylonjs/Misc/observable";
  54597. import { Nullable } from "babylonjs/types";
  54598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54599. import { Mesh } from "babylonjs/Meshes/mesh";
  54600. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54601. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54602. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54603. /**
  54604. * Gizmo that enables rotating a mesh along 3 axis
  54605. */
  54606. export class RotationGizmo extends Gizmo {
  54607. /**
  54608. * Internal gizmo used for interactions on the x axis
  54609. */
  54610. xGizmo: PlaneRotationGizmo;
  54611. /**
  54612. * Internal gizmo used for interactions on the y axis
  54613. */
  54614. yGizmo: PlaneRotationGizmo;
  54615. /**
  54616. * Internal gizmo used for interactions on the z axis
  54617. */
  54618. zGizmo: PlaneRotationGizmo;
  54619. /** Fires an event when any of it's sub gizmos are dragged */
  54620. onDragStartObservable: Observable<unknown>;
  54621. /** Fires an event when any of it's sub gizmos are released from dragging */
  54622. onDragEndObservable: Observable<unknown>;
  54623. private _meshAttached;
  54624. get attachedMesh(): Nullable<AbstractMesh>;
  54625. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54626. /**
  54627. * Creates a RotationGizmo
  54628. * @param gizmoLayer The utility layer the gizmo will be added to
  54629. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54630. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54631. */
  54632. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54633. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54634. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54635. /**
  54636. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54637. */
  54638. set snapDistance(value: number);
  54639. get snapDistance(): number;
  54640. /**
  54641. * Ratio for the scale of the gizmo (Default: 1)
  54642. */
  54643. set scaleRatio(value: number);
  54644. get scaleRatio(): number;
  54645. /**
  54646. * Disposes of the gizmo
  54647. */
  54648. dispose(): void;
  54649. /**
  54650. * CustomMeshes are not supported by this gizmo
  54651. * @param mesh The mesh to replace the default mesh of the gizmo
  54652. */
  54653. setCustomMesh(mesh: Mesh): void;
  54654. }
  54655. }
  54656. declare module "babylonjs/Gizmos/gizmoManager" {
  54657. import { Observable } from "babylonjs/Misc/observable";
  54658. import { Nullable } from "babylonjs/types";
  54659. import { Scene, IDisposable } from "babylonjs/scene";
  54660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54661. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54662. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54663. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54664. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54665. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54666. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54667. /**
  54668. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54669. */
  54670. export class GizmoManager implements IDisposable {
  54671. private scene;
  54672. /**
  54673. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54674. */
  54675. gizmos: {
  54676. positionGizmo: Nullable<PositionGizmo>;
  54677. rotationGizmo: Nullable<RotationGizmo>;
  54678. scaleGizmo: Nullable<ScaleGizmo>;
  54679. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54680. };
  54681. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54682. clearGizmoOnEmptyPointerEvent: boolean;
  54683. /** Fires an event when the manager is attached to a mesh */
  54684. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54685. private _gizmosEnabled;
  54686. private _pointerObserver;
  54687. private _attachedMesh;
  54688. private _boundingBoxColor;
  54689. private _defaultUtilityLayer;
  54690. private _defaultKeepDepthUtilityLayer;
  54691. /**
  54692. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54693. */
  54694. boundingBoxDragBehavior: SixDofDragBehavior;
  54695. /**
  54696. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54697. */
  54698. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54699. /**
  54700. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54701. */
  54702. usePointerToAttachGizmos: boolean;
  54703. /**
  54704. * Utility layer that the bounding box gizmo belongs to
  54705. */
  54706. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54707. /**
  54708. * Utility layer that all gizmos besides bounding box belong to
  54709. */
  54710. get utilityLayer(): UtilityLayerRenderer;
  54711. /**
  54712. * Instatiates a gizmo manager
  54713. * @param scene the scene to overlay the gizmos on top of
  54714. */
  54715. constructor(scene: Scene);
  54716. /**
  54717. * Attaches a set of gizmos to the specified mesh
  54718. * @param mesh The mesh the gizmo's should be attached to
  54719. */
  54720. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54721. /**
  54722. * If the position gizmo is enabled
  54723. */
  54724. set positionGizmoEnabled(value: boolean);
  54725. get positionGizmoEnabled(): boolean;
  54726. /**
  54727. * If the rotation gizmo is enabled
  54728. */
  54729. set rotationGizmoEnabled(value: boolean);
  54730. get rotationGizmoEnabled(): boolean;
  54731. /**
  54732. * If the scale gizmo is enabled
  54733. */
  54734. set scaleGizmoEnabled(value: boolean);
  54735. get scaleGizmoEnabled(): boolean;
  54736. /**
  54737. * If the boundingBox gizmo is enabled
  54738. */
  54739. set boundingBoxGizmoEnabled(value: boolean);
  54740. get boundingBoxGizmoEnabled(): boolean;
  54741. /**
  54742. * Disposes of the gizmo manager
  54743. */
  54744. dispose(): void;
  54745. }
  54746. }
  54747. declare module "babylonjs/Lights/directionalLight" {
  54748. import { Camera } from "babylonjs/Cameras/camera";
  54749. import { Scene } from "babylonjs/scene";
  54750. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54752. import { Light } from "babylonjs/Lights/light";
  54753. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54754. import { Effect } from "babylonjs/Materials/effect";
  54755. /**
  54756. * A directional light is defined by a direction (what a surprise!).
  54757. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54758. * 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.
  54759. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54760. */
  54761. export class DirectionalLight extends ShadowLight {
  54762. private _shadowFrustumSize;
  54763. /**
  54764. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54765. */
  54766. get shadowFrustumSize(): number;
  54767. /**
  54768. * Specifies a fix frustum size for the shadow generation.
  54769. */
  54770. set shadowFrustumSize(value: number);
  54771. private _shadowOrthoScale;
  54772. /**
  54773. * Gets the shadow projection scale against the optimal computed one.
  54774. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54775. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54776. */
  54777. get shadowOrthoScale(): number;
  54778. /**
  54779. * Sets the shadow projection scale against the optimal computed one.
  54780. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54781. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54782. */
  54783. set shadowOrthoScale(value: number);
  54784. /**
  54785. * Automatically compute the projection matrix to best fit (including all the casters)
  54786. * on each frame.
  54787. */
  54788. autoUpdateExtends: boolean;
  54789. /**
  54790. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54791. * on each frame. autoUpdateExtends must be set to true for this to work
  54792. */
  54793. autoCalcShadowZBounds: boolean;
  54794. private _orthoLeft;
  54795. private _orthoRight;
  54796. private _orthoTop;
  54797. private _orthoBottom;
  54798. /**
  54799. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54800. * The directional light is emitted from everywhere in the given direction.
  54801. * It can cast shadows.
  54802. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54803. * @param name The friendly name of the light
  54804. * @param direction The direction of the light
  54805. * @param scene The scene the light belongs to
  54806. */
  54807. constructor(name: string, direction: Vector3, scene: Scene);
  54808. /**
  54809. * Returns the string "DirectionalLight".
  54810. * @return The class name
  54811. */
  54812. getClassName(): string;
  54813. /**
  54814. * Returns the integer 1.
  54815. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54816. */
  54817. getTypeID(): number;
  54818. /**
  54819. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54820. * Returns the DirectionalLight Shadow projection matrix.
  54821. */
  54822. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54823. /**
  54824. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54825. * Returns the DirectionalLight Shadow projection matrix.
  54826. */
  54827. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54828. /**
  54829. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54830. * Returns the DirectionalLight Shadow projection matrix.
  54831. */
  54832. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54833. protected _buildUniformLayout(): void;
  54834. /**
  54835. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54836. * @param effect The effect to update
  54837. * @param lightIndex The index of the light in the effect to update
  54838. * @returns The directional light
  54839. */
  54840. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54841. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54842. /**
  54843. * Gets the minZ used for shadow according to both the scene and the light.
  54844. *
  54845. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54846. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54847. * @param activeCamera The camera we are returning the min for
  54848. * @returns the depth min z
  54849. */
  54850. getDepthMinZ(activeCamera: Camera): number;
  54851. /**
  54852. * Gets the maxZ used for shadow according to both the scene and the light.
  54853. *
  54854. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54855. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54856. * @param activeCamera The camera we are returning the max for
  54857. * @returns the depth max z
  54858. */
  54859. getDepthMaxZ(activeCamera: Camera): number;
  54860. /**
  54861. * Prepares the list of defines specific to the light type.
  54862. * @param defines the list of defines
  54863. * @param lightIndex defines the index of the light for the effect
  54864. */
  54865. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54866. }
  54867. }
  54868. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  54869. import { Mesh } from "babylonjs/Meshes/mesh";
  54870. /**
  54871. * Class containing static functions to help procedurally build meshes
  54872. */
  54873. export class HemisphereBuilder {
  54874. /**
  54875. * Creates a hemisphere mesh
  54876. * @param name defines the name of the mesh
  54877. * @param options defines the options used to create the mesh
  54878. * @param scene defines the hosting scene
  54879. * @returns the hemisphere mesh
  54880. */
  54881. static CreateHemisphere(name: string, options: {
  54882. segments?: number;
  54883. diameter?: number;
  54884. sideOrientation?: number;
  54885. }, scene: any): Mesh;
  54886. }
  54887. }
  54888. declare module "babylonjs/Lights/spotLight" {
  54889. import { Nullable } from "babylonjs/types";
  54890. import { Scene } from "babylonjs/scene";
  54891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54893. import { Effect } from "babylonjs/Materials/effect";
  54894. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54895. import { Light } from "babylonjs/Lights/light";
  54896. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54897. /**
  54898. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54899. * These values define a cone of light starting from the position, emitting toward the direction.
  54900. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54901. * and the exponent defines the speed of the decay of the light with distance (reach).
  54902. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54903. */
  54904. export class SpotLight extends ShadowLight {
  54905. private _angle;
  54906. private _innerAngle;
  54907. private _cosHalfAngle;
  54908. private _lightAngleScale;
  54909. private _lightAngleOffset;
  54910. /**
  54911. * Gets the cone angle of the spot light in Radians.
  54912. */
  54913. get angle(): number;
  54914. /**
  54915. * Sets the cone angle of the spot light in Radians.
  54916. */
  54917. set angle(value: number);
  54918. /**
  54919. * Only used in gltf falloff mode, this defines the angle where
  54920. * the directional falloff will start before cutting at angle which could be seen
  54921. * as outer angle.
  54922. */
  54923. get innerAngle(): number;
  54924. /**
  54925. * Only used in gltf falloff mode, this defines the angle where
  54926. * the directional falloff will start before cutting at angle which could be seen
  54927. * as outer angle.
  54928. */
  54929. set innerAngle(value: number);
  54930. private _shadowAngleScale;
  54931. /**
  54932. * Allows scaling the angle of the light for shadow generation only.
  54933. */
  54934. get shadowAngleScale(): number;
  54935. /**
  54936. * Allows scaling the angle of the light for shadow generation only.
  54937. */
  54938. set shadowAngleScale(value: number);
  54939. /**
  54940. * The light decay speed with the distance from the emission spot.
  54941. */
  54942. exponent: number;
  54943. private _projectionTextureMatrix;
  54944. /**
  54945. * Allows reading the projecton texture
  54946. */
  54947. get projectionTextureMatrix(): Matrix;
  54948. protected _projectionTextureLightNear: number;
  54949. /**
  54950. * Gets the near clip of the Spotlight for texture projection.
  54951. */
  54952. get projectionTextureLightNear(): number;
  54953. /**
  54954. * Sets the near clip of the Spotlight for texture projection.
  54955. */
  54956. set projectionTextureLightNear(value: number);
  54957. protected _projectionTextureLightFar: number;
  54958. /**
  54959. * Gets the far clip of the Spotlight for texture projection.
  54960. */
  54961. get projectionTextureLightFar(): number;
  54962. /**
  54963. * Sets the far clip of the Spotlight for texture projection.
  54964. */
  54965. set projectionTextureLightFar(value: number);
  54966. protected _projectionTextureUpDirection: Vector3;
  54967. /**
  54968. * Gets the Up vector of the Spotlight for texture projection.
  54969. */
  54970. get projectionTextureUpDirection(): Vector3;
  54971. /**
  54972. * Sets the Up vector of the Spotlight for texture projection.
  54973. */
  54974. set projectionTextureUpDirection(value: Vector3);
  54975. private _projectionTexture;
  54976. /**
  54977. * Gets the projection texture of the light.
  54978. */
  54979. get projectionTexture(): Nullable<BaseTexture>;
  54980. /**
  54981. * Sets the projection texture of the light.
  54982. */
  54983. set projectionTexture(value: Nullable<BaseTexture>);
  54984. private _projectionTextureViewLightDirty;
  54985. private _projectionTextureProjectionLightDirty;
  54986. private _projectionTextureDirty;
  54987. private _projectionTextureViewTargetVector;
  54988. private _projectionTextureViewLightMatrix;
  54989. private _projectionTextureProjectionLightMatrix;
  54990. private _projectionTextureScalingMatrix;
  54991. /**
  54992. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54993. * It can cast shadows.
  54994. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54995. * @param name The light friendly name
  54996. * @param position The position of the spot light in the scene
  54997. * @param direction The direction of the light in the scene
  54998. * @param angle The cone angle of the light in Radians
  54999. * @param exponent The light decay speed with the distance from the emission spot
  55000. * @param scene The scene the lights belongs to
  55001. */
  55002. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55003. /**
  55004. * Returns the string "SpotLight".
  55005. * @returns the class name
  55006. */
  55007. getClassName(): string;
  55008. /**
  55009. * Returns the integer 2.
  55010. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55011. */
  55012. getTypeID(): number;
  55013. /**
  55014. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55015. */
  55016. protected _setDirection(value: Vector3): void;
  55017. /**
  55018. * Overrides the position setter to recompute the projection texture view light Matrix.
  55019. */
  55020. protected _setPosition(value: Vector3): void;
  55021. /**
  55022. * 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.
  55023. * Returns the SpotLight.
  55024. */
  55025. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55026. protected _computeProjectionTextureViewLightMatrix(): void;
  55027. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55028. /**
  55029. * Main function for light texture projection matrix computing.
  55030. */
  55031. protected _computeProjectionTextureMatrix(): void;
  55032. protected _buildUniformLayout(): void;
  55033. private _computeAngleValues;
  55034. /**
  55035. * Sets the passed Effect "effect" with the Light textures.
  55036. * @param effect The effect to update
  55037. * @param lightIndex The index of the light in the effect to update
  55038. * @returns The light
  55039. */
  55040. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55041. /**
  55042. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55043. * @param effect The effect to update
  55044. * @param lightIndex The index of the light in the effect to update
  55045. * @returns The spot light
  55046. */
  55047. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55048. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55049. /**
  55050. * Disposes the light and the associated resources.
  55051. */
  55052. dispose(): void;
  55053. /**
  55054. * Prepares the list of defines specific to the light type.
  55055. * @param defines the list of defines
  55056. * @param lightIndex defines the index of the light for the effect
  55057. */
  55058. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55059. }
  55060. }
  55061. declare module "babylonjs/Gizmos/lightGizmo" {
  55062. import { Nullable } from "babylonjs/types";
  55063. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55064. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55065. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55066. import { Light } from "babylonjs/Lights/light";
  55067. /**
  55068. * Gizmo that enables viewing a light
  55069. */
  55070. export class LightGizmo extends Gizmo {
  55071. private _lightMesh;
  55072. private _material;
  55073. private _cachedPosition;
  55074. private _cachedForward;
  55075. private _attachedMeshParent;
  55076. /**
  55077. * Creates a LightGizmo
  55078. * @param gizmoLayer The utility layer the gizmo will be added to
  55079. */
  55080. constructor(gizmoLayer?: UtilityLayerRenderer);
  55081. private _light;
  55082. /**
  55083. * The light that the gizmo is attached to
  55084. */
  55085. set light(light: Nullable<Light>);
  55086. get light(): Nullable<Light>;
  55087. /**
  55088. * Gets the material used to render the light gizmo
  55089. */
  55090. get material(): StandardMaterial;
  55091. /**
  55092. * @hidden
  55093. * Updates the gizmo to match the attached mesh's position/rotation
  55094. */
  55095. protected _update(): void;
  55096. private static _Scale;
  55097. /**
  55098. * Creates the lines for a light mesh
  55099. */
  55100. private static _CreateLightLines;
  55101. /**
  55102. * Disposes of the light gizmo
  55103. */
  55104. dispose(): void;
  55105. private static _CreateHemisphericLightMesh;
  55106. private static _CreatePointLightMesh;
  55107. private static _CreateSpotLightMesh;
  55108. private static _CreateDirectionalLightMesh;
  55109. }
  55110. }
  55111. declare module "babylonjs/Gizmos/index" {
  55112. export * from "babylonjs/Gizmos/axisDragGizmo";
  55113. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55114. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55115. export * from "babylonjs/Gizmos/gizmo";
  55116. export * from "babylonjs/Gizmos/gizmoManager";
  55117. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55118. export * from "babylonjs/Gizmos/positionGizmo";
  55119. export * from "babylonjs/Gizmos/rotationGizmo";
  55120. export * from "babylonjs/Gizmos/scaleGizmo";
  55121. export * from "babylonjs/Gizmos/lightGizmo";
  55122. export * from "babylonjs/Gizmos/planeDragGizmo";
  55123. }
  55124. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55125. /** @hidden */
  55126. export var backgroundFragmentDeclaration: {
  55127. name: string;
  55128. shader: string;
  55129. };
  55130. }
  55131. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55132. /** @hidden */
  55133. export var backgroundUboDeclaration: {
  55134. name: string;
  55135. shader: string;
  55136. };
  55137. }
  55138. declare module "babylonjs/Shaders/background.fragment" {
  55139. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55140. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55141. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55142. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55143. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55144. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55145. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55146. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55147. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55148. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55150. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55151. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55152. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55153. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55154. /** @hidden */
  55155. export var backgroundPixelShader: {
  55156. name: string;
  55157. shader: string;
  55158. };
  55159. }
  55160. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55161. /** @hidden */
  55162. export var backgroundVertexDeclaration: {
  55163. name: string;
  55164. shader: string;
  55165. };
  55166. }
  55167. declare module "babylonjs/Shaders/background.vertex" {
  55168. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55169. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55170. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55171. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55172. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55173. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55174. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55175. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55176. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55177. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55178. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55179. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55180. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55181. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55182. /** @hidden */
  55183. export var backgroundVertexShader: {
  55184. name: string;
  55185. shader: string;
  55186. };
  55187. }
  55188. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55189. import { Nullable, int, float } from "babylonjs/types";
  55190. import { Scene } from "babylonjs/scene";
  55191. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55192. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55194. import { Mesh } from "babylonjs/Meshes/mesh";
  55195. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55196. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55197. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55199. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55200. import { Color3 } from "babylonjs/Maths/math.color";
  55201. import "babylonjs/Shaders/background.fragment";
  55202. import "babylonjs/Shaders/background.vertex";
  55203. /**
  55204. * Background material used to create an efficient environement around your scene.
  55205. */
  55206. export class BackgroundMaterial extends PushMaterial {
  55207. /**
  55208. * Standard reflectance value at parallel view angle.
  55209. */
  55210. static StandardReflectance0: number;
  55211. /**
  55212. * Standard reflectance value at grazing angle.
  55213. */
  55214. static StandardReflectance90: number;
  55215. protected _primaryColor: Color3;
  55216. /**
  55217. * Key light Color (multiply against the environement texture)
  55218. */
  55219. primaryColor: Color3;
  55220. protected __perceptualColor: Nullable<Color3>;
  55221. /**
  55222. * Experimental Internal Use Only.
  55223. *
  55224. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55225. * This acts as a helper to set the primary color to a more "human friendly" value.
  55226. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55227. * output color as close as possible from the chosen value.
  55228. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55229. * part of lighting setup.)
  55230. */
  55231. get _perceptualColor(): Nullable<Color3>;
  55232. set _perceptualColor(value: Nullable<Color3>);
  55233. protected _primaryColorShadowLevel: float;
  55234. /**
  55235. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55236. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55237. */
  55238. get primaryColorShadowLevel(): float;
  55239. set primaryColorShadowLevel(value: float);
  55240. protected _primaryColorHighlightLevel: float;
  55241. /**
  55242. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55243. * The primary color is used at the level chosen to define what the white area would look.
  55244. */
  55245. get primaryColorHighlightLevel(): float;
  55246. set primaryColorHighlightLevel(value: float);
  55247. protected _reflectionTexture: Nullable<BaseTexture>;
  55248. /**
  55249. * Reflection Texture used in the material.
  55250. * Should be author in a specific way for the best result (refer to the documentation).
  55251. */
  55252. reflectionTexture: Nullable<BaseTexture>;
  55253. protected _reflectionBlur: float;
  55254. /**
  55255. * Reflection Texture level of blur.
  55256. *
  55257. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55258. * texture twice.
  55259. */
  55260. reflectionBlur: float;
  55261. protected _diffuseTexture: Nullable<BaseTexture>;
  55262. /**
  55263. * Diffuse Texture used in the material.
  55264. * Should be author in a specific way for the best result (refer to the documentation).
  55265. */
  55266. diffuseTexture: Nullable<BaseTexture>;
  55267. protected _shadowLights: Nullable<IShadowLight[]>;
  55268. /**
  55269. * Specify the list of lights casting shadow on the material.
  55270. * All scene shadow lights will be included if null.
  55271. */
  55272. shadowLights: Nullable<IShadowLight[]>;
  55273. protected _shadowLevel: float;
  55274. /**
  55275. * Helps adjusting the shadow to a softer level if required.
  55276. * 0 means black shadows and 1 means no shadows.
  55277. */
  55278. shadowLevel: float;
  55279. protected _sceneCenter: Vector3;
  55280. /**
  55281. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55282. * It is usually zero but might be interesting to modify according to your setup.
  55283. */
  55284. sceneCenter: Vector3;
  55285. protected _opacityFresnel: boolean;
  55286. /**
  55287. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55288. * This helps ensuring a nice transition when the camera goes under the ground.
  55289. */
  55290. opacityFresnel: boolean;
  55291. protected _reflectionFresnel: boolean;
  55292. /**
  55293. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55294. * This helps adding a mirror texture on the ground.
  55295. */
  55296. reflectionFresnel: boolean;
  55297. protected _reflectionFalloffDistance: number;
  55298. /**
  55299. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55300. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55301. */
  55302. reflectionFalloffDistance: number;
  55303. protected _reflectionAmount: number;
  55304. /**
  55305. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55306. */
  55307. reflectionAmount: number;
  55308. protected _reflectionReflectance0: number;
  55309. /**
  55310. * This specifies the weight of the reflection at grazing angle.
  55311. */
  55312. reflectionReflectance0: number;
  55313. protected _reflectionReflectance90: number;
  55314. /**
  55315. * This specifies the weight of the reflection at a perpendicular point of view.
  55316. */
  55317. reflectionReflectance90: number;
  55318. /**
  55319. * Sets the reflection reflectance fresnel values according to the default standard
  55320. * empirically know to work well :-)
  55321. */
  55322. set reflectionStandardFresnelWeight(value: number);
  55323. protected _useRGBColor: boolean;
  55324. /**
  55325. * Helps to directly use the maps channels instead of their level.
  55326. */
  55327. useRGBColor: boolean;
  55328. protected _enableNoise: boolean;
  55329. /**
  55330. * This helps reducing the banding effect that could occur on the background.
  55331. */
  55332. enableNoise: boolean;
  55333. /**
  55334. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55335. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55336. * Recommended to be keep at 1.0 except for special cases.
  55337. */
  55338. get fovMultiplier(): number;
  55339. set fovMultiplier(value: number);
  55340. private _fovMultiplier;
  55341. /**
  55342. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55343. */
  55344. useEquirectangularFOV: boolean;
  55345. private _maxSimultaneousLights;
  55346. /**
  55347. * Number of Simultaneous lights allowed on the material.
  55348. */
  55349. maxSimultaneousLights: int;
  55350. /**
  55351. * Default configuration related to image processing available in the Background Material.
  55352. */
  55353. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55354. /**
  55355. * Keep track of the image processing observer to allow dispose and replace.
  55356. */
  55357. private _imageProcessingObserver;
  55358. /**
  55359. * Attaches a new image processing configuration to the PBR Material.
  55360. * @param configuration (if null the scene configuration will be use)
  55361. */
  55362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55363. /**
  55364. * Gets the image processing configuration used either in this material.
  55365. */
  55366. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55367. /**
  55368. * Sets the Default image processing configuration used either in the this material.
  55369. *
  55370. * If sets to null, the scene one is in use.
  55371. */
  55372. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55373. /**
  55374. * Gets wether the color curves effect is enabled.
  55375. */
  55376. get cameraColorCurvesEnabled(): boolean;
  55377. /**
  55378. * Sets wether the color curves effect is enabled.
  55379. */
  55380. set cameraColorCurvesEnabled(value: boolean);
  55381. /**
  55382. * Gets wether the color grading effect is enabled.
  55383. */
  55384. get cameraColorGradingEnabled(): boolean;
  55385. /**
  55386. * Gets wether the color grading effect is enabled.
  55387. */
  55388. set cameraColorGradingEnabled(value: boolean);
  55389. /**
  55390. * Gets wether tonemapping is enabled or not.
  55391. */
  55392. get cameraToneMappingEnabled(): boolean;
  55393. /**
  55394. * Sets wether tonemapping is enabled or not
  55395. */
  55396. set cameraToneMappingEnabled(value: boolean);
  55397. /**
  55398. * The camera exposure used on this material.
  55399. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55400. * This corresponds to a photographic exposure.
  55401. */
  55402. get cameraExposure(): float;
  55403. /**
  55404. * The camera exposure used on this material.
  55405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55406. * This corresponds to a photographic exposure.
  55407. */
  55408. set cameraExposure(value: float);
  55409. /**
  55410. * Gets The camera contrast used on this material.
  55411. */
  55412. get cameraContrast(): float;
  55413. /**
  55414. * Sets The camera contrast used on this material.
  55415. */
  55416. set cameraContrast(value: float);
  55417. /**
  55418. * Gets the Color Grading 2D Lookup Texture.
  55419. */
  55420. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55421. /**
  55422. * Sets the Color Grading 2D Lookup Texture.
  55423. */
  55424. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55425. /**
  55426. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55427. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55428. * 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;
  55429. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55430. */
  55431. get cameraColorCurves(): Nullable<ColorCurves>;
  55432. /**
  55433. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55434. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55435. * 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;
  55436. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55437. */
  55438. set cameraColorCurves(value: Nullable<ColorCurves>);
  55439. /**
  55440. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55441. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55442. */
  55443. switchToBGR: boolean;
  55444. private _renderTargets;
  55445. private _reflectionControls;
  55446. private _white;
  55447. private _primaryShadowColor;
  55448. private _primaryHighlightColor;
  55449. /**
  55450. * Instantiates a Background Material in the given scene
  55451. * @param name The friendly name of the material
  55452. * @param scene The scene to add the material to
  55453. */
  55454. constructor(name: string, scene: Scene);
  55455. /**
  55456. * Gets a boolean indicating that current material needs to register RTT
  55457. */
  55458. get hasRenderTargetTextures(): boolean;
  55459. /**
  55460. * The entire material has been created in order to prevent overdraw.
  55461. * @returns false
  55462. */
  55463. needAlphaTesting(): boolean;
  55464. /**
  55465. * The entire material has been created in order to prevent overdraw.
  55466. * @returns true if blending is enable
  55467. */
  55468. needAlphaBlending(): boolean;
  55469. /**
  55470. * Checks wether the material is ready to be rendered for a given mesh.
  55471. * @param mesh The mesh to render
  55472. * @param subMesh The submesh to check against
  55473. * @param useInstances Specify wether or not the material is used with instances
  55474. * @returns true if all the dependencies are ready (Textures, Effects...)
  55475. */
  55476. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55477. /**
  55478. * Compute the primary color according to the chosen perceptual color.
  55479. */
  55480. private _computePrimaryColorFromPerceptualColor;
  55481. /**
  55482. * Compute the highlights and shadow colors according to their chosen levels.
  55483. */
  55484. private _computePrimaryColors;
  55485. /**
  55486. * Build the uniform buffer used in the material.
  55487. */
  55488. buildUniformLayout(): void;
  55489. /**
  55490. * Unbind the material.
  55491. */
  55492. unbind(): void;
  55493. /**
  55494. * Bind only the world matrix to the material.
  55495. * @param world The world matrix to bind.
  55496. */
  55497. bindOnlyWorldMatrix(world: Matrix): void;
  55498. /**
  55499. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55500. * @param world The world matrix to bind.
  55501. * @param subMesh The submesh to bind for.
  55502. */
  55503. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55504. /**
  55505. * Checks to see if a texture is used in the material.
  55506. * @param texture - Base texture to use.
  55507. * @returns - Boolean specifying if a texture is used in the material.
  55508. */
  55509. hasTexture(texture: BaseTexture): boolean;
  55510. /**
  55511. * Dispose the material.
  55512. * @param forceDisposeEffect Force disposal of the associated effect.
  55513. * @param forceDisposeTextures Force disposal of the associated textures.
  55514. */
  55515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55516. /**
  55517. * Clones the material.
  55518. * @param name The cloned name.
  55519. * @returns The cloned material.
  55520. */
  55521. clone(name: string): BackgroundMaterial;
  55522. /**
  55523. * Serializes the current material to its JSON representation.
  55524. * @returns The JSON representation.
  55525. */
  55526. serialize(): any;
  55527. /**
  55528. * Gets the class name of the material
  55529. * @returns "BackgroundMaterial"
  55530. */
  55531. getClassName(): string;
  55532. /**
  55533. * Parse a JSON input to create back a background material.
  55534. * @param source The JSON data to parse
  55535. * @param scene The scene to create the parsed material in
  55536. * @param rootUrl The root url of the assets the material depends upon
  55537. * @returns the instantiated BackgroundMaterial.
  55538. */
  55539. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55540. }
  55541. }
  55542. declare module "babylonjs/Helpers/environmentHelper" {
  55543. import { Observable } from "babylonjs/Misc/observable";
  55544. import { Nullable } from "babylonjs/types";
  55545. import { Scene } from "babylonjs/scene";
  55546. import { Vector3 } from "babylonjs/Maths/math.vector";
  55547. import { Color3 } from "babylonjs/Maths/math.color";
  55548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55549. import { Mesh } from "babylonjs/Meshes/mesh";
  55550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55551. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55552. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55553. import "babylonjs/Meshes/Builders/planeBuilder";
  55554. import "babylonjs/Meshes/Builders/boxBuilder";
  55555. /**
  55556. * Represents the different options available during the creation of
  55557. * a Environment helper.
  55558. *
  55559. * This can control the default ground, skybox and image processing setup of your scene.
  55560. */
  55561. export interface IEnvironmentHelperOptions {
  55562. /**
  55563. * Specifies whether or not to create a ground.
  55564. * True by default.
  55565. */
  55566. createGround: boolean;
  55567. /**
  55568. * Specifies the ground size.
  55569. * 15 by default.
  55570. */
  55571. groundSize: number;
  55572. /**
  55573. * The texture used on the ground for the main color.
  55574. * Comes from the BabylonJS CDN by default.
  55575. *
  55576. * Remarks: Can be either a texture or a url.
  55577. */
  55578. groundTexture: string | BaseTexture;
  55579. /**
  55580. * The color mixed in the ground texture by default.
  55581. * BabylonJS clearColor by default.
  55582. */
  55583. groundColor: Color3;
  55584. /**
  55585. * Specifies the ground opacity.
  55586. * 1 by default.
  55587. */
  55588. groundOpacity: number;
  55589. /**
  55590. * Enables the ground to receive shadows.
  55591. * True by default.
  55592. */
  55593. enableGroundShadow: boolean;
  55594. /**
  55595. * Helps preventing the shadow to be fully black on the ground.
  55596. * 0.5 by default.
  55597. */
  55598. groundShadowLevel: number;
  55599. /**
  55600. * Creates a mirror texture attach to the ground.
  55601. * false by default.
  55602. */
  55603. enableGroundMirror: boolean;
  55604. /**
  55605. * Specifies the ground mirror size ratio.
  55606. * 0.3 by default as the default kernel is 64.
  55607. */
  55608. groundMirrorSizeRatio: number;
  55609. /**
  55610. * Specifies the ground mirror blur kernel size.
  55611. * 64 by default.
  55612. */
  55613. groundMirrorBlurKernel: number;
  55614. /**
  55615. * Specifies the ground mirror visibility amount.
  55616. * 1 by default
  55617. */
  55618. groundMirrorAmount: number;
  55619. /**
  55620. * Specifies the ground mirror reflectance weight.
  55621. * This uses the standard weight of the background material to setup the fresnel effect
  55622. * of the mirror.
  55623. * 1 by default.
  55624. */
  55625. groundMirrorFresnelWeight: number;
  55626. /**
  55627. * Specifies the ground mirror Falloff distance.
  55628. * This can helps reducing the size of the reflection.
  55629. * 0 by Default.
  55630. */
  55631. groundMirrorFallOffDistance: number;
  55632. /**
  55633. * Specifies the ground mirror texture type.
  55634. * Unsigned Int by Default.
  55635. */
  55636. groundMirrorTextureType: number;
  55637. /**
  55638. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55639. * the shown objects.
  55640. */
  55641. groundYBias: number;
  55642. /**
  55643. * Specifies whether or not to create a skybox.
  55644. * True by default.
  55645. */
  55646. createSkybox: boolean;
  55647. /**
  55648. * Specifies the skybox size.
  55649. * 20 by default.
  55650. */
  55651. skyboxSize: number;
  55652. /**
  55653. * The texture used on the skybox for the main color.
  55654. * Comes from the BabylonJS CDN by default.
  55655. *
  55656. * Remarks: Can be either a texture or a url.
  55657. */
  55658. skyboxTexture: string | BaseTexture;
  55659. /**
  55660. * The color mixed in the skybox texture by default.
  55661. * BabylonJS clearColor by default.
  55662. */
  55663. skyboxColor: Color3;
  55664. /**
  55665. * The background rotation around the Y axis of the scene.
  55666. * This helps aligning the key lights of your scene with the background.
  55667. * 0 by default.
  55668. */
  55669. backgroundYRotation: number;
  55670. /**
  55671. * Compute automatically the size of the elements to best fit with the scene.
  55672. */
  55673. sizeAuto: boolean;
  55674. /**
  55675. * Default position of the rootMesh if autoSize is not true.
  55676. */
  55677. rootPosition: Vector3;
  55678. /**
  55679. * Sets up the image processing in the scene.
  55680. * true by default.
  55681. */
  55682. setupImageProcessing: boolean;
  55683. /**
  55684. * The texture used as your environment texture in the scene.
  55685. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55686. *
  55687. * Remarks: Can be either a texture or a url.
  55688. */
  55689. environmentTexture: string | BaseTexture;
  55690. /**
  55691. * The value of the exposure to apply to the scene.
  55692. * 0.6 by default if setupImageProcessing is true.
  55693. */
  55694. cameraExposure: number;
  55695. /**
  55696. * The value of the contrast to apply to the scene.
  55697. * 1.6 by default if setupImageProcessing is true.
  55698. */
  55699. cameraContrast: number;
  55700. /**
  55701. * Specifies whether or not tonemapping should be enabled in the scene.
  55702. * true by default if setupImageProcessing is true.
  55703. */
  55704. toneMappingEnabled: boolean;
  55705. }
  55706. /**
  55707. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55708. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55709. * It also helps with the default setup of your imageProcessing configuration.
  55710. */
  55711. export class EnvironmentHelper {
  55712. /**
  55713. * Default ground texture URL.
  55714. */
  55715. private static _groundTextureCDNUrl;
  55716. /**
  55717. * Default skybox texture URL.
  55718. */
  55719. private static _skyboxTextureCDNUrl;
  55720. /**
  55721. * Default environment texture URL.
  55722. */
  55723. private static _environmentTextureCDNUrl;
  55724. /**
  55725. * Creates the default options for the helper.
  55726. */
  55727. private static _getDefaultOptions;
  55728. private _rootMesh;
  55729. /**
  55730. * Gets the root mesh created by the helper.
  55731. */
  55732. get rootMesh(): Mesh;
  55733. private _skybox;
  55734. /**
  55735. * Gets the skybox created by the helper.
  55736. */
  55737. get skybox(): Nullable<Mesh>;
  55738. private _skyboxTexture;
  55739. /**
  55740. * Gets the skybox texture created by the helper.
  55741. */
  55742. get skyboxTexture(): Nullable<BaseTexture>;
  55743. private _skyboxMaterial;
  55744. /**
  55745. * Gets the skybox material created by the helper.
  55746. */
  55747. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55748. private _ground;
  55749. /**
  55750. * Gets the ground mesh created by the helper.
  55751. */
  55752. get ground(): Nullable<Mesh>;
  55753. private _groundTexture;
  55754. /**
  55755. * Gets the ground texture created by the helper.
  55756. */
  55757. get groundTexture(): Nullable<BaseTexture>;
  55758. private _groundMirror;
  55759. /**
  55760. * Gets the ground mirror created by the helper.
  55761. */
  55762. get groundMirror(): Nullable<MirrorTexture>;
  55763. /**
  55764. * Gets the ground mirror render list to helps pushing the meshes
  55765. * you wish in the ground reflection.
  55766. */
  55767. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55768. private _groundMaterial;
  55769. /**
  55770. * Gets the ground material created by the helper.
  55771. */
  55772. get groundMaterial(): Nullable<BackgroundMaterial>;
  55773. /**
  55774. * Stores the creation options.
  55775. */
  55776. private readonly _scene;
  55777. private _options;
  55778. /**
  55779. * This observable will be notified with any error during the creation of the environment,
  55780. * mainly texture creation errors.
  55781. */
  55782. onErrorObservable: Observable<{
  55783. message?: string;
  55784. exception?: any;
  55785. }>;
  55786. /**
  55787. * constructor
  55788. * @param options Defines the options we want to customize the helper
  55789. * @param scene The scene to add the material to
  55790. */
  55791. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55792. /**
  55793. * Updates the background according to the new options
  55794. * @param options
  55795. */
  55796. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55797. /**
  55798. * Sets the primary color of all the available elements.
  55799. * @param color the main color to affect to the ground and the background
  55800. */
  55801. setMainColor(color: Color3): void;
  55802. /**
  55803. * Setup the image processing according to the specified options.
  55804. */
  55805. private _setupImageProcessing;
  55806. /**
  55807. * Setup the environment texture according to the specified options.
  55808. */
  55809. private _setupEnvironmentTexture;
  55810. /**
  55811. * Setup the background according to the specified options.
  55812. */
  55813. private _setupBackground;
  55814. /**
  55815. * Get the scene sizes according to the setup.
  55816. */
  55817. private _getSceneSize;
  55818. /**
  55819. * Setup the ground according to the specified options.
  55820. */
  55821. private _setupGround;
  55822. /**
  55823. * Setup the ground material according to the specified options.
  55824. */
  55825. private _setupGroundMaterial;
  55826. /**
  55827. * Setup the ground diffuse texture according to the specified options.
  55828. */
  55829. private _setupGroundDiffuseTexture;
  55830. /**
  55831. * Setup the ground mirror texture according to the specified options.
  55832. */
  55833. private _setupGroundMirrorTexture;
  55834. /**
  55835. * Setup the ground to receive the mirror texture.
  55836. */
  55837. private _setupMirrorInGroundMaterial;
  55838. /**
  55839. * Setup the skybox according to the specified options.
  55840. */
  55841. private _setupSkybox;
  55842. /**
  55843. * Setup the skybox material according to the specified options.
  55844. */
  55845. private _setupSkyboxMaterial;
  55846. /**
  55847. * Setup the skybox reflection texture according to the specified options.
  55848. */
  55849. private _setupSkyboxReflectionTexture;
  55850. private _errorHandler;
  55851. /**
  55852. * Dispose all the elements created by the Helper.
  55853. */
  55854. dispose(): void;
  55855. }
  55856. }
  55857. declare module "babylonjs/Helpers/photoDome" {
  55858. import { Observable } from "babylonjs/Misc/observable";
  55859. import { Nullable } from "babylonjs/types";
  55860. import { Scene } from "babylonjs/scene";
  55861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55862. import { Mesh } from "babylonjs/Meshes/mesh";
  55863. import { Texture } from "babylonjs/Materials/Textures/texture";
  55864. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55865. import "babylonjs/Meshes/Builders/sphereBuilder";
  55866. /**
  55867. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55868. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55869. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55870. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55871. */
  55872. export class PhotoDome extends TransformNode {
  55873. /**
  55874. * Define the image as a Monoscopic panoramic 360 image.
  55875. */
  55876. static readonly MODE_MONOSCOPIC: number;
  55877. /**
  55878. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55879. */
  55880. static readonly MODE_TOPBOTTOM: number;
  55881. /**
  55882. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55883. */
  55884. static readonly MODE_SIDEBYSIDE: number;
  55885. private _useDirectMapping;
  55886. /**
  55887. * The texture being displayed on the sphere
  55888. */
  55889. protected _photoTexture: Texture;
  55890. /**
  55891. * Gets or sets the texture being displayed on the sphere
  55892. */
  55893. get photoTexture(): Texture;
  55894. set photoTexture(value: Texture);
  55895. /**
  55896. * Observable raised when an error occured while loading the 360 image
  55897. */
  55898. onLoadErrorObservable: Observable<string>;
  55899. /**
  55900. * The skybox material
  55901. */
  55902. protected _material: BackgroundMaterial;
  55903. /**
  55904. * The surface used for the skybox
  55905. */
  55906. protected _mesh: Mesh;
  55907. /**
  55908. * Gets the mesh used for the skybox.
  55909. */
  55910. get mesh(): Mesh;
  55911. /**
  55912. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55913. * Also see the options.resolution property.
  55914. */
  55915. get fovMultiplier(): number;
  55916. set fovMultiplier(value: number);
  55917. private _imageMode;
  55918. /**
  55919. * Gets or set the current video mode for the video. It can be:
  55920. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  55921. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55922. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55923. */
  55924. get imageMode(): number;
  55925. set imageMode(value: number);
  55926. /**
  55927. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  55928. * @param name Element's name, child elements will append suffixes for their own names.
  55929. * @param urlsOfPhoto defines the url of the photo to display
  55930. * @param options defines an object containing optional or exposed sub element properties
  55931. * @param onError defines a callback called when an error occured while loading the texture
  55932. */
  55933. constructor(name: string, urlOfPhoto: string, options: {
  55934. resolution?: number;
  55935. size?: number;
  55936. useDirectMapping?: boolean;
  55937. faceForward?: boolean;
  55938. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55939. private _onBeforeCameraRenderObserver;
  55940. private _changeImageMode;
  55941. /**
  55942. * Releases resources associated with this node.
  55943. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55944. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55945. */
  55946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55947. }
  55948. }
  55949. declare module "babylonjs/Misc/rgbdTextureTools" {
  55950. import "babylonjs/Shaders/rgbdDecode.fragment";
  55951. import "babylonjs/Engines/Extensions/engine.renderTarget";
  55952. import { Texture } from "babylonjs/Materials/Textures/texture";
  55953. /**
  55954. * Class used to host RGBD texture specific utilities
  55955. */
  55956. export class RGBDTextureTools {
  55957. /**
  55958. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55959. * @param texture the texture to expand.
  55960. */
  55961. static ExpandRGBDTexture(texture: Texture): void;
  55962. }
  55963. }
  55964. declare module "babylonjs/Misc/brdfTextureTools" {
  55965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55966. import { Scene } from "babylonjs/scene";
  55967. /**
  55968. * Class used to host texture specific utilities
  55969. */
  55970. export class BRDFTextureTools {
  55971. /**
  55972. * Prevents texture cache collision
  55973. */
  55974. private static _instanceNumber;
  55975. /**
  55976. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55977. * @param scene defines the hosting scene
  55978. * @returns the environment BRDF texture
  55979. */
  55980. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55981. private static _environmentBRDFBase64Texture;
  55982. }
  55983. }
  55984. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  55985. import { Nullable } from "babylonjs/types";
  55986. import { Color3 } from "babylonjs/Maths/math.color";
  55987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  55989. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  55990. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55991. import { Engine } from "babylonjs/Engines/engine";
  55992. import { Scene } from "babylonjs/scene";
  55993. /**
  55994. * @hidden
  55995. */
  55996. export interface IMaterialClearCoatDefines {
  55997. CLEARCOAT: boolean;
  55998. CLEARCOAT_DEFAULTIOR: boolean;
  55999. CLEARCOAT_TEXTURE: boolean;
  56000. CLEARCOAT_TEXTUREDIRECTUV: number;
  56001. CLEARCOAT_BUMP: boolean;
  56002. CLEARCOAT_BUMPDIRECTUV: number;
  56003. CLEARCOAT_TINT: boolean;
  56004. CLEARCOAT_TINT_TEXTURE: boolean;
  56005. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56006. /** @hidden */
  56007. _areTexturesDirty: boolean;
  56008. }
  56009. /**
  56010. * Define the code related to the clear coat parameters of the pbr material.
  56011. */
  56012. export class PBRClearCoatConfiguration {
  56013. /**
  56014. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56015. * The default fits with a polyurethane material.
  56016. */
  56017. private static readonly _DefaultIndexOfRefraction;
  56018. private _isEnabled;
  56019. /**
  56020. * Defines if the clear coat is enabled in the material.
  56021. */
  56022. isEnabled: boolean;
  56023. /**
  56024. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56025. */
  56026. intensity: number;
  56027. /**
  56028. * Defines the clear coat layer roughness.
  56029. */
  56030. roughness: number;
  56031. private _indexOfRefraction;
  56032. /**
  56033. * Defines the index of refraction of the clear coat.
  56034. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56035. * The default fits with a polyurethane material.
  56036. * Changing the default value is more performance intensive.
  56037. */
  56038. indexOfRefraction: number;
  56039. private _texture;
  56040. /**
  56041. * Stores the clear coat values in a texture.
  56042. */
  56043. texture: Nullable<BaseTexture>;
  56044. private _bumpTexture;
  56045. /**
  56046. * Define the clear coat specific bump texture.
  56047. */
  56048. bumpTexture: Nullable<BaseTexture>;
  56049. private _isTintEnabled;
  56050. /**
  56051. * Defines if the clear coat tint is enabled in the material.
  56052. */
  56053. isTintEnabled: boolean;
  56054. /**
  56055. * Defines the clear coat tint of the material.
  56056. * This is only use if tint is enabled
  56057. */
  56058. tintColor: Color3;
  56059. /**
  56060. * Defines the distance at which the tint color should be found in the
  56061. * clear coat media.
  56062. * This is only use if tint is enabled
  56063. */
  56064. tintColorAtDistance: number;
  56065. /**
  56066. * Defines the clear coat layer thickness.
  56067. * This is only use if tint is enabled
  56068. */
  56069. tintThickness: number;
  56070. private _tintTexture;
  56071. /**
  56072. * Stores the clear tint values in a texture.
  56073. * rgb is tint
  56074. * a is a thickness factor
  56075. */
  56076. tintTexture: Nullable<BaseTexture>;
  56077. /** @hidden */
  56078. private _internalMarkAllSubMeshesAsTexturesDirty;
  56079. /** @hidden */
  56080. _markAllSubMeshesAsTexturesDirty(): void;
  56081. /**
  56082. * Instantiate a new istance of clear coat configuration.
  56083. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56084. */
  56085. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56086. /**
  56087. * Gets wehter the submesh is ready to be used or not.
  56088. * @param defines the list of "defines" to update.
  56089. * @param scene defines the scene the material belongs to.
  56090. * @param engine defines the engine the material belongs to.
  56091. * @param disableBumpMap defines wether the material disables bump or not.
  56092. * @returns - boolean indicating that the submesh is ready or not.
  56093. */
  56094. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56095. /**
  56096. * Checks to see if a texture is used in the material.
  56097. * @param defines the list of "defines" to update.
  56098. * @param scene defines the scene to the material belongs to.
  56099. */
  56100. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56101. /**
  56102. * Binds the material data.
  56103. * @param uniformBuffer defines the Uniform buffer to fill in.
  56104. * @param scene defines the scene the material belongs to.
  56105. * @param engine defines the engine the material belongs to.
  56106. * @param disableBumpMap defines wether the material disables bump or not.
  56107. * @param isFrozen defines wether the material is frozen or not.
  56108. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56109. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56110. */
  56111. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56112. /**
  56113. * Checks to see if a texture is used in the material.
  56114. * @param texture - Base texture to use.
  56115. * @returns - Boolean specifying if a texture is used in the material.
  56116. */
  56117. hasTexture(texture: BaseTexture): boolean;
  56118. /**
  56119. * Returns an array of the actively used textures.
  56120. * @param activeTextures Array of BaseTextures
  56121. */
  56122. getActiveTextures(activeTextures: BaseTexture[]): void;
  56123. /**
  56124. * Returns the animatable textures.
  56125. * @param animatables Array of animatable textures.
  56126. */
  56127. getAnimatables(animatables: IAnimatable[]): void;
  56128. /**
  56129. * Disposes the resources of the material.
  56130. * @param forceDisposeTextures - Forces the disposal of all textures.
  56131. */
  56132. dispose(forceDisposeTextures?: boolean): void;
  56133. /**
  56134. * Get the current class name of the texture useful for serialization or dynamic coding.
  56135. * @returns "PBRClearCoatConfiguration"
  56136. */
  56137. getClassName(): string;
  56138. /**
  56139. * Add fallbacks to the effect fallbacks list.
  56140. * @param defines defines the Base texture to use.
  56141. * @param fallbacks defines the current fallback list.
  56142. * @param currentRank defines the current fallback rank.
  56143. * @returns the new fallback rank.
  56144. */
  56145. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56146. /**
  56147. * Add the required uniforms to the current list.
  56148. * @param uniforms defines the current uniform list.
  56149. */
  56150. static AddUniforms(uniforms: string[]): void;
  56151. /**
  56152. * Add the required samplers to the current list.
  56153. * @param samplers defines the current sampler list.
  56154. */
  56155. static AddSamplers(samplers: string[]): void;
  56156. /**
  56157. * Add the required uniforms to the current buffer.
  56158. * @param uniformBuffer defines the current uniform buffer.
  56159. */
  56160. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56161. /**
  56162. * Makes a duplicate of the current configuration into another one.
  56163. * @param clearCoatConfiguration define the config where to copy the info
  56164. */
  56165. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56166. /**
  56167. * Serializes this clear coat configuration.
  56168. * @returns - An object with the serialized config.
  56169. */
  56170. serialize(): any;
  56171. /**
  56172. * Parses a anisotropy Configuration from a serialized object.
  56173. * @param source - Serialized object.
  56174. * @param scene Defines the scene we are parsing for
  56175. * @param rootUrl Defines the rootUrl to load from
  56176. */
  56177. parse(source: any, scene: Scene, rootUrl: string): void;
  56178. }
  56179. }
  56180. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56183. import { Vector2 } from "babylonjs/Maths/math.vector";
  56184. import { Scene } from "babylonjs/scene";
  56185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56186. import { Nullable } from "babylonjs/types";
  56187. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56188. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56189. /**
  56190. * @hidden
  56191. */
  56192. export interface IMaterialAnisotropicDefines {
  56193. ANISOTROPIC: boolean;
  56194. ANISOTROPIC_TEXTURE: boolean;
  56195. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56196. MAINUV1: boolean;
  56197. _areTexturesDirty: boolean;
  56198. _needUVs: boolean;
  56199. }
  56200. /**
  56201. * Define the code related to the anisotropic parameters of the pbr material.
  56202. */
  56203. export class PBRAnisotropicConfiguration {
  56204. private _isEnabled;
  56205. /**
  56206. * Defines if the anisotropy is enabled in the material.
  56207. */
  56208. isEnabled: boolean;
  56209. /**
  56210. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56211. */
  56212. intensity: number;
  56213. /**
  56214. * Defines if the effect is along the tangents, bitangents or in between.
  56215. * By default, the effect is "strectching" the highlights along the tangents.
  56216. */
  56217. direction: Vector2;
  56218. private _texture;
  56219. /**
  56220. * Stores the anisotropy values in a texture.
  56221. * rg is direction (like normal from -1 to 1)
  56222. * b is a intensity
  56223. */
  56224. texture: Nullable<BaseTexture>;
  56225. /** @hidden */
  56226. private _internalMarkAllSubMeshesAsTexturesDirty;
  56227. /** @hidden */
  56228. _markAllSubMeshesAsTexturesDirty(): void;
  56229. /**
  56230. * Instantiate a new istance of anisotropy configuration.
  56231. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56232. */
  56233. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56234. /**
  56235. * Specifies that the submesh is ready to be used.
  56236. * @param defines the list of "defines" to update.
  56237. * @param scene defines the scene the material belongs to.
  56238. * @returns - boolean indicating that the submesh is ready or not.
  56239. */
  56240. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56241. /**
  56242. * Checks to see if a texture is used in the material.
  56243. * @param defines the list of "defines" to update.
  56244. * @param mesh the mesh we are preparing the defines for.
  56245. * @param scene defines the scene the material belongs to.
  56246. */
  56247. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56248. /**
  56249. * Binds the material data.
  56250. * @param uniformBuffer defines the Uniform buffer to fill in.
  56251. * @param scene defines the scene the material belongs to.
  56252. * @param isFrozen defines wether the material is frozen or not.
  56253. */
  56254. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56255. /**
  56256. * Checks to see if a texture is used in the material.
  56257. * @param texture - Base texture to use.
  56258. * @returns - Boolean specifying if a texture is used in the material.
  56259. */
  56260. hasTexture(texture: BaseTexture): boolean;
  56261. /**
  56262. * Returns an array of the actively used textures.
  56263. * @param activeTextures Array of BaseTextures
  56264. */
  56265. getActiveTextures(activeTextures: BaseTexture[]): void;
  56266. /**
  56267. * Returns the animatable textures.
  56268. * @param animatables Array of animatable textures.
  56269. */
  56270. getAnimatables(animatables: IAnimatable[]): void;
  56271. /**
  56272. * Disposes the resources of the material.
  56273. * @param forceDisposeTextures - Forces the disposal of all textures.
  56274. */
  56275. dispose(forceDisposeTextures?: boolean): void;
  56276. /**
  56277. * Get the current class name of the texture useful for serialization or dynamic coding.
  56278. * @returns "PBRAnisotropicConfiguration"
  56279. */
  56280. getClassName(): string;
  56281. /**
  56282. * Add fallbacks to the effect fallbacks list.
  56283. * @param defines defines the Base texture to use.
  56284. * @param fallbacks defines the current fallback list.
  56285. * @param currentRank defines the current fallback rank.
  56286. * @returns the new fallback rank.
  56287. */
  56288. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56289. /**
  56290. * Add the required uniforms to the current list.
  56291. * @param uniforms defines the current uniform list.
  56292. */
  56293. static AddUniforms(uniforms: string[]): void;
  56294. /**
  56295. * Add the required uniforms to the current buffer.
  56296. * @param uniformBuffer defines the current uniform buffer.
  56297. */
  56298. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56299. /**
  56300. * Add the required samplers to the current list.
  56301. * @param samplers defines the current sampler list.
  56302. */
  56303. static AddSamplers(samplers: string[]): void;
  56304. /**
  56305. * Makes a duplicate of the current configuration into another one.
  56306. * @param anisotropicConfiguration define the config where to copy the info
  56307. */
  56308. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56309. /**
  56310. * Serializes this anisotropy configuration.
  56311. * @returns - An object with the serialized config.
  56312. */
  56313. serialize(): any;
  56314. /**
  56315. * Parses a anisotropy Configuration from a serialized object.
  56316. * @param source - Serialized object.
  56317. * @param scene Defines the scene we are parsing for
  56318. * @param rootUrl Defines the rootUrl to load from
  56319. */
  56320. parse(source: any, scene: Scene, rootUrl: string): void;
  56321. }
  56322. }
  56323. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56324. import { Scene } from "babylonjs/scene";
  56325. /**
  56326. * @hidden
  56327. */
  56328. export interface IMaterialBRDFDefines {
  56329. BRDF_V_HEIGHT_CORRELATED: boolean;
  56330. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56331. SPHERICAL_HARMONICS: boolean;
  56332. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56333. /** @hidden */
  56334. _areMiscDirty: boolean;
  56335. }
  56336. /**
  56337. * Define the code related to the BRDF parameters of the pbr material.
  56338. */
  56339. export class PBRBRDFConfiguration {
  56340. /**
  56341. * Default value used for the energy conservation.
  56342. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56343. */
  56344. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56345. /**
  56346. * Default value used for the Smith Visibility Height Correlated mode.
  56347. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56348. */
  56349. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56350. /**
  56351. * Default value used for the IBL diffuse part.
  56352. * This can help switching back to the polynomials mode globally which is a tiny bit
  56353. * less GPU intensive at the drawback of a lower quality.
  56354. */
  56355. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56356. /**
  56357. * Default value used for activating energy conservation for the specular workflow.
  56358. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56359. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56360. */
  56361. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56362. private _useEnergyConservation;
  56363. /**
  56364. * Defines if the material uses energy conservation.
  56365. */
  56366. useEnergyConservation: boolean;
  56367. private _useSmithVisibilityHeightCorrelated;
  56368. /**
  56369. * LEGACY Mode set to false
  56370. * Defines if the material uses height smith correlated visibility term.
  56371. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56372. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56373. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56374. * Not relying on height correlated will also disable energy conservation.
  56375. */
  56376. useSmithVisibilityHeightCorrelated: boolean;
  56377. private _useSphericalHarmonics;
  56378. /**
  56379. * LEGACY Mode set to false
  56380. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56381. * diffuse part of the IBL.
  56382. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56383. * to the ground truth.
  56384. */
  56385. useSphericalHarmonics: boolean;
  56386. private _useSpecularGlossinessInputEnergyConservation;
  56387. /**
  56388. * Defines if the material uses energy conservation, when the specular workflow is active.
  56389. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56390. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56391. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56392. */
  56393. useSpecularGlossinessInputEnergyConservation: boolean;
  56394. /** @hidden */
  56395. private _internalMarkAllSubMeshesAsMiscDirty;
  56396. /** @hidden */
  56397. _markAllSubMeshesAsMiscDirty(): void;
  56398. /**
  56399. * Instantiate a new istance of clear coat configuration.
  56400. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56401. */
  56402. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56403. /**
  56404. * Checks to see if a texture is used in the material.
  56405. * @param defines the list of "defines" to update.
  56406. */
  56407. prepareDefines(defines: IMaterialBRDFDefines): void;
  56408. /**
  56409. * Get the current class name of the texture useful for serialization or dynamic coding.
  56410. * @returns "PBRClearCoatConfiguration"
  56411. */
  56412. getClassName(): string;
  56413. /**
  56414. * Makes a duplicate of the current configuration into another one.
  56415. * @param brdfConfiguration define the config where to copy the info
  56416. */
  56417. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56418. /**
  56419. * Serializes this BRDF configuration.
  56420. * @returns - An object with the serialized config.
  56421. */
  56422. serialize(): any;
  56423. /**
  56424. * Parses a anisotropy Configuration from a serialized object.
  56425. * @param source - Serialized object.
  56426. * @param scene Defines the scene we are parsing for
  56427. * @param rootUrl Defines the rootUrl to load from
  56428. */
  56429. parse(source: any, scene: Scene, rootUrl: string): void;
  56430. }
  56431. }
  56432. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56433. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56434. import { Color3 } from "babylonjs/Maths/math.color";
  56435. import { Scene } from "babylonjs/scene";
  56436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56437. import { Nullable } from "babylonjs/types";
  56438. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56439. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56440. /**
  56441. * @hidden
  56442. */
  56443. export interface IMaterialSheenDefines {
  56444. SHEEN: boolean;
  56445. SHEEN_TEXTURE: boolean;
  56446. SHEEN_TEXTUREDIRECTUV: number;
  56447. SHEEN_LINKWITHALBEDO: boolean;
  56448. SHEEN_ROUGHNESS: boolean;
  56449. SHEEN_ALBEDOSCALING: boolean;
  56450. /** @hidden */
  56451. _areTexturesDirty: boolean;
  56452. }
  56453. /**
  56454. * Define the code related to the Sheen parameters of the pbr material.
  56455. */
  56456. export class PBRSheenConfiguration {
  56457. private _isEnabled;
  56458. /**
  56459. * Defines if the material uses sheen.
  56460. */
  56461. isEnabled: boolean;
  56462. private _linkSheenWithAlbedo;
  56463. /**
  56464. * Defines if the sheen is linked to the sheen color.
  56465. */
  56466. linkSheenWithAlbedo: boolean;
  56467. /**
  56468. * Defines the sheen intensity.
  56469. */
  56470. intensity: number;
  56471. /**
  56472. * Defines the sheen color.
  56473. */
  56474. color: Color3;
  56475. private _texture;
  56476. /**
  56477. * Stores the sheen tint values in a texture.
  56478. * rgb is tint
  56479. * a is a intensity
  56480. */
  56481. texture: Nullable<BaseTexture>;
  56482. private _roughness;
  56483. /**
  56484. * Defines the sheen roughness.
  56485. * It is not taken into account if linkSheenWithAlbedo is true.
  56486. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56487. */
  56488. roughness: Nullable<number>;
  56489. private _albedoScaling;
  56490. /**
  56491. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56492. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56493. * making it easier to setup and tweak the effect
  56494. */
  56495. albedoScaling: boolean;
  56496. /** @hidden */
  56497. private _internalMarkAllSubMeshesAsTexturesDirty;
  56498. /** @hidden */
  56499. _markAllSubMeshesAsTexturesDirty(): void;
  56500. /**
  56501. * Instantiate a new istance of clear coat configuration.
  56502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56503. */
  56504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56505. /**
  56506. * Specifies that the submesh is ready to be used.
  56507. * @param defines the list of "defines" to update.
  56508. * @param scene defines the scene the material belongs to.
  56509. * @returns - boolean indicating that the submesh is ready or not.
  56510. */
  56511. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56512. /**
  56513. * Checks to see if a texture is used in the material.
  56514. * @param defines the list of "defines" to update.
  56515. * @param scene defines the scene the material belongs to.
  56516. */
  56517. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56518. /**
  56519. * Binds the material data.
  56520. * @param uniformBuffer defines the Uniform buffer to fill in.
  56521. * @param scene defines the scene the material belongs to.
  56522. * @param isFrozen defines wether the material is frozen or not.
  56523. */
  56524. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56525. /**
  56526. * Checks to see if a texture is used in the material.
  56527. * @param texture - Base texture to use.
  56528. * @returns - Boolean specifying if a texture is used in the material.
  56529. */
  56530. hasTexture(texture: BaseTexture): boolean;
  56531. /**
  56532. * Returns an array of the actively used textures.
  56533. * @param activeTextures Array of BaseTextures
  56534. */
  56535. getActiveTextures(activeTextures: BaseTexture[]): void;
  56536. /**
  56537. * Returns the animatable textures.
  56538. * @param animatables Array of animatable textures.
  56539. */
  56540. getAnimatables(animatables: IAnimatable[]): void;
  56541. /**
  56542. * Disposes the resources of the material.
  56543. * @param forceDisposeTextures - Forces the disposal of all textures.
  56544. */
  56545. dispose(forceDisposeTextures?: boolean): void;
  56546. /**
  56547. * Get the current class name of the texture useful for serialization or dynamic coding.
  56548. * @returns "PBRSheenConfiguration"
  56549. */
  56550. getClassName(): string;
  56551. /**
  56552. * Add fallbacks to the effect fallbacks list.
  56553. * @param defines defines the Base texture to use.
  56554. * @param fallbacks defines the current fallback list.
  56555. * @param currentRank defines the current fallback rank.
  56556. * @returns the new fallback rank.
  56557. */
  56558. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56559. /**
  56560. * Add the required uniforms to the current list.
  56561. * @param uniforms defines the current uniform list.
  56562. */
  56563. static AddUniforms(uniforms: string[]): void;
  56564. /**
  56565. * Add the required uniforms to the current buffer.
  56566. * @param uniformBuffer defines the current uniform buffer.
  56567. */
  56568. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56569. /**
  56570. * Add the required samplers to the current list.
  56571. * @param samplers defines the current sampler list.
  56572. */
  56573. static AddSamplers(samplers: string[]): void;
  56574. /**
  56575. * Makes a duplicate of the current configuration into another one.
  56576. * @param sheenConfiguration define the config where to copy the info
  56577. */
  56578. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56579. /**
  56580. * Serializes this BRDF configuration.
  56581. * @returns - An object with the serialized config.
  56582. */
  56583. serialize(): any;
  56584. /**
  56585. * Parses a anisotropy Configuration from a serialized object.
  56586. * @param source - Serialized object.
  56587. * @param scene Defines the scene we are parsing for
  56588. * @param rootUrl Defines the rootUrl to load from
  56589. */
  56590. parse(source: any, scene: Scene, rootUrl: string): void;
  56591. }
  56592. }
  56593. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56594. import { Nullable } from "babylonjs/types";
  56595. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56596. import { Color3 } from "babylonjs/Maths/math.color";
  56597. import { SmartArray } from "babylonjs/Misc/smartArray";
  56598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56599. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56600. import { Effect } from "babylonjs/Materials/effect";
  56601. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56602. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56603. import { Engine } from "babylonjs/Engines/engine";
  56604. import { Scene } from "babylonjs/scene";
  56605. /**
  56606. * @hidden
  56607. */
  56608. export interface IMaterialSubSurfaceDefines {
  56609. SUBSURFACE: boolean;
  56610. SS_REFRACTION: boolean;
  56611. SS_TRANSLUCENCY: boolean;
  56612. SS_SCATTERING: boolean;
  56613. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56614. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56615. SS_REFRACTIONMAP_3D: boolean;
  56616. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56617. SS_LODINREFRACTIONALPHA: boolean;
  56618. SS_GAMMAREFRACTION: boolean;
  56619. SS_RGBDREFRACTION: boolean;
  56620. SS_LINEARSPECULARREFRACTION: boolean;
  56621. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56622. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56623. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56624. /** @hidden */
  56625. _areTexturesDirty: boolean;
  56626. }
  56627. /**
  56628. * Define the code related to the sub surface parameters of the pbr material.
  56629. */
  56630. export class PBRSubSurfaceConfiguration {
  56631. private _isRefractionEnabled;
  56632. /**
  56633. * Defines if the refraction is enabled in the material.
  56634. */
  56635. isRefractionEnabled: boolean;
  56636. private _isTranslucencyEnabled;
  56637. /**
  56638. * Defines if the translucency is enabled in the material.
  56639. */
  56640. isTranslucencyEnabled: boolean;
  56641. private _isScatteringEnabled;
  56642. /**
  56643. * Defines the refraction intensity of the material.
  56644. * The refraction when enabled replaces the Diffuse part of the material.
  56645. * The intensity helps transitionning between diffuse and refraction.
  56646. */
  56647. refractionIntensity: number;
  56648. /**
  56649. * Defines the translucency intensity of the material.
  56650. * When translucency has been enabled, this defines how much of the "translucency"
  56651. * is addded to the diffuse part of the material.
  56652. */
  56653. translucencyIntensity: number;
  56654. /**
  56655. * Defines the scattering intensity of the material.
  56656. * When scattering has been enabled, this defines how much of the "scattered light"
  56657. * is addded to the diffuse part of the material.
  56658. */
  56659. scatteringIntensity: number;
  56660. /**
  56661. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56662. */
  56663. useAlbedoToTintRefraction: boolean;
  56664. private _thicknessTexture;
  56665. /**
  56666. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56667. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56668. * 0 would mean minimumThickness
  56669. * 1 would mean maximumThickness
  56670. * The other channels might be use as a mask to vary the different effects intensity.
  56671. */
  56672. thicknessTexture: Nullable<BaseTexture>;
  56673. private _refractionTexture;
  56674. /**
  56675. * Defines the texture to use for refraction.
  56676. */
  56677. refractionTexture: Nullable<BaseTexture>;
  56678. private _indexOfRefraction;
  56679. /**
  56680. * Index of refraction of the material base layer.
  56681. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56682. *
  56683. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56684. *
  56685. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56686. */
  56687. indexOfRefraction: number;
  56688. private _volumeIndexOfRefraction;
  56689. /**
  56690. * Index of refraction of the material's volume.
  56691. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56692. *
  56693. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56694. * the volume will use the same IOR as the surface.
  56695. */
  56696. get volumeIndexOfRefraction(): number;
  56697. set volumeIndexOfRefraction(value: number);
  56698. private _invertRefractionY;
  56699. /**
  56700. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56701. */
  56702. invertRefractionY: boolean;
  56703. private _linkRefractionWithTransparency;
  56704. /**
  56705. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56706. * Materials half opaque for instance using refraction could benefit from this control.
  56707. */
  56708. linkRefractionWithTransparency: boolean;
  56709. /**
  56710. * Defines the minimum thickness stored in the thickness map.
  56711. * If no thickness map is defined, this value will be used to simulate thickness.
  56712. */
  56713. minimumThickness: number;
  56714. /**
  56715. * Defines the maximum thickness stored in the thickness map.
  56716. */
  56717. maximumThickness: number;
  56718. /**
  56719. * Defines the volume tint of the material.
  56720. * This is used for both translucency and scattering.
  56721. */
  56722. tintColor: Color3;
  56723. /**
  56724. * Defines the distance at which the tint color should be found in the media.
  56725. * This is used for refraction only.
  56726. */
  56727. tintColorAtDistance: number;
  56728. /**
  56729. * Defines how far each channel transmit through the media.
  56730. * It is defined as a color to simplify it selection.
  56731. */
  56732. diffusionDistance: Color3;
  56733. private _useMaskFromThicknessTexture;
  56734. /**
  56735. * Stores the intensity of the different subsurface effects in the thickness texture.
  56736. * * the green channel is the translucency intensity.
  56737. * * the blue channel is the scattering intensity.
  56738. * * the alpha channel is the refraction intensity.
  56739. */
  56740. useMaskFromThicknessTexture: boolean;
  56741. /** @hidden */
  56742. private _internalMarkAllSubMeshesAsTexturesDirty;
  56743. /** @hidden */
  56744. _markAllSubMeshesAsTexturesDirty(): void;
  56745. /**
  56746. * Instantiate a new istance of sub surface configuration.
  56747. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56748. */
  56749. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56750. /**
  56751. * Gets wehter the submesh is ready to be used or not.
  56752. * @param defines the list of "defines" to update.
  56753. * @param scene defines the scene the material belongs to.
  56754. * @returns - boolean indicating that the submesh is ready or not.
  56755. */
  56756. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56757. /**
  56758. * Checks to see if a texture is used in the material.
  56759. * @param defines the list of "defines" to update.
  56760. * @param scene defines the scene to the material belongs to.
  56761. */
  56762. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56763. /**
  56764. * Binds the material data.
  56765. * @param uniformBuffer defines the Uniform buffer to fill in.
  56766. * @param scene defines the scene the material belongs to.
  56767. * @param engine defines the engine the material belongs to.
  56768. * @param isFrozen defines whether the material is frozen or not.
  56769. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56770. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56771. */
  56772. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56773. /**
  56774. * Unbinds the material from the mesh.
  56775. * @param activeEffect defines the effect that should be unbound from.
  56776. * @returns true if unbound, otherwise false
  56777. */
  56778. unbind(activeEffect: Effect): boolean;
  56779. /**
  56780. * Returns the texture used for refraction or null if none is used.
  56781. * @param scene defines the scene the material belongs to.
  56782. * @returns - Refraction texture if present. If no refraction texture and refraction
  56783. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56784. */
  56785. private _getRefractionTexture;
  56786. /**
  56787. * Returns true if alpha blending should be disabled.
  56788. */
  56789. get disableAlphaBlending(): boolean;
  56790. /**
  56791. * Fills the list of render target textures.
  56792. * @param renderTargets the list of render targets to update
  56793. */
  56794. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56795. /**
  56796. * Checks to see if a texture is used in the material.
  56797. * @param texture - Base texture to use.
  56798. * @returns - Boolean specifying if a texture is used in the material.
  56799. */
  56800. hasTexture(texture: BaseTexture): boolean;
  56801. /**
  56802. * Gets a boolean indicating that current material needs to register RTT
  56803. * @returns true if this uses a render target otherwise false.
  56804. */
  56805. hasRenderTargetTextures(): boolean;
  56806. /**
  56807. * Returns an array of the actively used textures.
  56808. * @param activeTextures Array of BaseTextures
  56809. */
  56810. getActiveTextures(activeTextures: BaseTexture[]): void;
  56811. /**
  56812. * Returns the animatable textures.
  56813. * @param animatables Array of animatable textures.
  56814. */
  56815. getAnimatables(animatables: IAnimatable[]): void;
  56816. /**
  56817. * Disposes the resources of the material.
  56818. * @param forceDisposeTextures - Forces the disposal of all textures.
  56819. */
  56820. dispose(forceDisposeTextures?: boolean): void;
  56821. /**
  56822. * Get the current class name of the texture useful for serialization or dynamic coding.
  56823. * @returns "PBRSubSurfaceConfiguration"
  56824. */
  56825. getClassName(): string;
  56826. /**
  56827. * Add fallbacks to the effect fallbacks list.
  56828. * @param defines defines the Base texture to use.
  56829. * @param fallbacks defines the current fallback list.
  56830. * @param currentRank defines the current fallback rank.
  56831. * @returns the new fallback rank.
  56832. */
  56833. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56834. /**
  56835. * Add the required uniforms to the current list.
  56836. * @param uniforms defines the current uniform list.
  56837. */
  56838. static AddUniforms(uniforms: string[]): void;
  56839. /**
  56840. * Add the required samplers to the current list.
  56841. * @param samplers defines the current sampler list.
  56842. */
  56843. static AddSamplers(samplers: string[]): void;
  56844. /**
  56845. * Add the required uniforms to the current buffer.
  56846. * @param uniformBuffer defines the current uniform buffer.
  56847. */
  56848. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56849. /**
  56850. * Makes a duplicate of the current configuration into another one.
  56851. * @param configuration define the config where to copy the info
  56852. */
  56853. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56854. /**
  56855. * Serializes this Sub Surface configuration.
  56856. * @returns - An object with the serialized config.
  56857. */
  56858. serialize(): any;
  56859. /**
  56860. * Parses a anisotropy Configuration from a serialized object.
  56861. * @param source - Serialized object.
  56862. * @param scene Defines the scene we are parsing for
  56863. * @param rootUrl Defines the rootUrl to load from
  56864. */
  56865. parse(source: any, scene: Scene, rootUrl: string): void;
  56866. }
  56867. }
  56868. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  56869. /** @hidden */
  56870. export var pbrFragmentDeclaration: {
  56871. name: string;
  56872. shader: string;
  56873. };
  56874. }
  56875. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  56876. /** @hidden */
  56877. export var pbrUboDeclaration: {
  56878. name: string;
  56879. shader: string;
  56880. };
  56881. }
  56882. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  56883. /** @hidden */
  56884. export var pbrFragmentExtraDeclaration: {
  56885. name: string;
  56886. shader: string;
  56887. };
  56888. }
  56889. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  56890. /** @hidden */
  56891. export var pbrFragmentSamplersDeclaration: {
  56892. name: string;
  56893. shader: string;
  56894. };
  56895. }
  56896. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  56897. /** @hidden */
  56898. export var importanceSampling: {
  56899. name: string;
  56900. shader: string;
  56901. };
  56902. }
  56903. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  56904. /** @hidden */
  56905. export var pbrHelperFunctions: {
  56906. name: string;
  56907. shader: string;
  56908. };
  56909. }
  56910. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  56911. /** @hidden */
  56912. export var harmonicsFunctions: {
  56913. name: string;
  56914. shader: string;
  56915. };
  56916. }
  56917. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  56918. /** @hidden */
  56919. export var pbrDirectLightingSetupFunctions: {
  56920. name: string;
  56921. shader: string;
  56922. };
  56923. }
  56924. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  56925. /** @hidden */
  56926. export var pbrDirectLightingFalloffFunctions: {
  56927. name: string;
  56928. shader: string;
  56929. };
  56930. }
  56931. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  56932. /** @hidden */
  56933. export var pbrBRDFFunctions: {
  56934. name: string;
  56935. shader: string;
  56936. };
  56937. }
  56938. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  56939. /** @hidden */
  56940. export var hdrFilteringFunctions: {
  56941. name: string;
  56942. shader: string;
  56943. };
  56944. }
  56945. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  56946. /** @hidden */
  56947. export var pbrDirectLightingFunctions: {
  56948. name: string;
  56949. shader: string;
  56950. };
  56951. }
  56952. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  56953. /** @hidden */
  56954. export var pbrIBLFunctions: {
  56955. name: string;
  56956. shader: string;
  56957. };
  56958. }
  56959. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  56960. /** @hidden */
  56961. export var pbrBlockAlbedoOpacity: {
  56962. name: string;
  56963. shader: string;
  56964. };
  56965. }
  56966. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  56967. /** @hidden */
  56968. export var pbrBlockReflectivity: {
  56969. name: string;
  56970. shader: string;
  56971. };
  56972. }
  56973. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  56974. /** @hidden */
  56975. export var pbrBlockAmbientOcclusion: {
  56976. name: string;
  56977. shader: string;
  56978. };
  56979. }
  56980. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  56981. /** @hidden */
  56982. export var pbrBlockAlphaFresnel: {
  56983. name: string;
  56984. shader: string;
  56985. };
  56986. }
  56987. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  56988. /** @hidden */
  56989. export var pbrBlockAnisotropic: {
  56990. name: string;
  56991. shader: string;
  56992. };
  56993. }
  56994. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  56995. /** @hidden */
  56996. export var pbrBlockReflection: {
  56997. name: string;
  56998. shader: string;
  56999. };
  57000. }
  57001. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57002. /** @hidden */
  57003. export var pbrBlockSheen: {
  57004. name: string;
  57005. shader: string;
  57006. };
  57007. }
  57008. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57009. /** @hidden */
  57010. export var pbrBlockClearcoat: {
  57011. name: string;
  57012. shader: string;
  57013. };
  57014. }
  57015. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57016. /** @hidden */
  57017. export var pbrBlockSubSurface: {
  57018. name: string;
  57019. shader: string;
  57020. };
  57021. }
  57022. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57023. /** @hidden */
  57024. export var pbrBlockNormalGeometric: {
  57025. name: string;
  57026. shader: string;
  57027. };
  57028. }
  57029. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57030. /** @hidden */
  57031. export var pbrBlockNormalFinal: {
  57032. name: string;
  57033. shader: string;
  57034. };
  57035. }
  57036. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57037. /** @hidden */
  57038. export var pbrBlockGeometryInfo: {
  57039. name: string;
  57040. shader: string;
  57041. };
  57042. }
  57043. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57044. /** @hidden */
  57045. export var pbrBlockReflectance0: {
  57046. name: string;
  57047. shader: string;
  57048. };
  57049. }
  57050. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57051. /** @hidden */
  57052. export var pbrBlockReflectance: {
  57053. name: string;
  57054. shader: string;
  57055. };
  57056. }
  57057. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57058. /** @hidden */
  57059. export var pbrBlockDirectLighting: {
  57060. name: string;
  57061. shader: string;
  57062. };
  57063. }
  57064. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57065. /** @hidden */
  57066. export var pbrBlockFinalLitComponents: {
  57067. name: string;
  57068. shader: string;
  57069. };
  57070. }
  57071. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57072. /** @hidden */
  57073. export var pbrBlockFinalUnlitComponents: {
  57074. name: string;
  57075. shader: string;
  57076. };
  57077. }
  57078. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57079. /** @hidden */
  57080. export var pbrBlockFinalColorComposition: {
  57081. name: string;
  57082. shader: string;
  57083. };
  57084. }
  57085. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57086. /** @hidden */
  57087. export var pbrBlockImageProcessing: {
  57088. name: string;
  57089. shader: string;
  57090. };
  57091. }
  57092. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57093. /** @hidden */
  57094. export var pbrDebug: {
  57095. name: string;
  57096. shader: string;
  57097. };
  57098. }
  57099. declare module "babylonjs/Shaders/pbr.fragment" {
  57100. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57101. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57102. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57103. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57104. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57105. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57106. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57107. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57108. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57109. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57111. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57112. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57113. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57114. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57115. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57116. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57117. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57118. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57119. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57120. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57121. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57122. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57123. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57124. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57125. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57126. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57127. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57128. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57129. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57130. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57131. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57132. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57133. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57134. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57135. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57136. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57137. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57138. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57139. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57140. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57141. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57142. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57143. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57144. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57145. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57146. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57147. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57148. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57149. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57150. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57151. /** @hidden */
  57152. export var pbrPixelShader: {
  57153. name: string;
  57154. shader: string;
  57155. };
  57156. }
  57157. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57158. /** @hidden */
  57159. export var pbrVertexDeclaration: {
  57160. name: string;
  57161. shader: string;
  57162. };
  57163. }
  57164. declare module "babylonjs/Shaders/pbr.vertex" {
  57165. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57166. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57167. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57168. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57169. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57170. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57171. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57172. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57173. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57174. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57175. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57176. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57177. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57178. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57179. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57180. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57181. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57182. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57183. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57184. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57185. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57186. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57187. /** @hidden */
  57188. export var pbrVertexShader: {
  57189. name: string;
  57190. shader: string;
  57191. };
  57192. }
  57193. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57194. import { Nullable } from "babylonjs/types";
  57195. import { Scene } from "babylonjs/scene";
  57196. import { Matrix } from "babylonjs/Maths/math.vector";
  57197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57199. import { Mesh } from "babylonjs/Meshes/mesh";
  57200. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57201. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57202. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57203. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57204. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57205. import { Color3 } from "babylonjs/Maths/math.color";
  57206. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57207. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57208. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57209. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57211. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57212. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57213. import "babylonjs/Shaders/pbr.fragment";
  57214. import "babylonjs/Shaders/pbr.vertex";
  57215. /**
  57216. * Manages the defines for the PBR Material.
  57217. * @hidden
  57218. */
  57219. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  57220. PBR: boolean;
  57221. NUM_SAMPLES: string;
  57222. REALTIME_FILTERING: boolean;
  57223. MAINUV1: boolean;
  57224. MAINUV2: boolean;
  57225. UV1: boolean;
  57226. UV2: boolean;
  57227. ALBEDO: boolean;
  57228. GAMMAALBEDO: boolean;
  57229. ALBEDODIRECTUV: number;
  57230. VERTEXCOLOR: boolean;
  57231. AMBIENT: boolean;
  57232. AMBIENTDIRECTUV: number;
  57233. AMBIENTINGRAYSCALE: boolean;
  57234. OPACITY: boolean;
  57235. VERTEXALPHA: boolean;
  57236. OPACITYDIRECTUV: number;
  57237. OPACITYRGB: boolean;
  57238. ALPHATEST: boolean;
  57239. DEPTHPREPASS: boolean;
  57240. ALPHABLEND: boolean;
  57241. ALPHAFROMALBEDO: boolean;
  57242. ALPHATESTVALUE: string;
  57243. SPECULAROVERALPHA: boolean;
  57244. RADIANCEOVERALPHA: boolean;
  57245. ALPHAFRESNEL: boolean;
  57246. LINEARALPHAFRESNEL: boolean;
  57247. PREMULTIPLYALPHA: boolean;
  57248. EMISSIVE: boolean;
  57249. EMISSIVEDIRECTUV: number;
  57250. REFLECTIVITY: boolean;
  57251. REFLECTIVITYDIRECTUV: number;
  57252. SPECULARTERM: boolean;
  57253. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57254. MICROSURFACEAUTOMATIC: boolean;
  57255. LODBASEDMICROSFURACE: boolean;
  57256. MICROSURFACEMAP: boolean;
  57257. MICROSURFACEMAPDIRECTUV: number;
  57258. METALLICWORKFLOW: boolean;
  57259. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57260. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57261. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57262. AOSTOREINMETALMAPRED: boolean;
  57263. METALLIC_REFLECTANCE: boolean;
  57264. METALLIC_REFLECTANCEDIRECTUV: number;
  57265. ENVIRONMENTBRDF: boolean;
  57266. ENVIRONMENTBRDF_RGBD: boolean;
  57267. NORMAL: boolean;
  57268. TANGENT: boolean;
  57269. BUMP: boolean;
  57270. BUMPDIRECTUV: number;
  57271. OBJECTSPACE_NORMALMAP: boolean;
  57272. PARALLAX: boolean;
  57273. PARALLAXOCCLUSION: boolean;
  57274. NORMALXYSCALE: boolean;
  57275. LIGHTMAP: boolean;
  57276. LIGHTMAPDIRECTUV: number;
  57277. USELIGHTMAPASSHADOWMAP: boolean;
  57278. GAMMALIGHTMAP: boolean;
  57279. RGBDLIGHTMAP: boolean;
  57280. REFLECTION: boolean;
  57281. REFLECTIONMAP_3D: boolean;
  57282. REFLECTIONMAP_SPHERICAL: boolean;
  57283. REFLECTIONMAP_PLANAR: boolean;
  57284. REFLECTIONMAP_CUBIC: boolean;
  57285. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57286. REFLECTIONMAP_PROJECTION: boolean;
  57287. REFLECTIONMAP_SKYBOX: boolean;
  57288. REFLECTIONMAP_EXPLICIT: boolean;
  57289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57292. INVERTCUBICMAP: boolean;
  57293. USESPHERICALFROMREFLECTIONMAP: boolean;
  57294. USEIRRADIANCEMAP: boolean;
  57295. SPHERICAL_HARMONICS: boolean;
  57296. USESPHERICALINVERTEX: boolean;
  57297. REFLECTIONMAP_OPPOSITEZ: boolean;
  57298. LODINREFLECTIONALPHA: boolean;
  57299. GAMMAREFLECTION: boolean;
  57300. RGBDREFLECTION: boolean;
  57301. LINEARSPECULARREFLECTION: boolean;
  57302. RADIANCEOCCLUSION: boolean;
  57303. HORIZONOCCLUSION: boolean;
  57304. INSTANCES: boolean;
  57305. THIN_INSTANCES: boolean;
  57306. NUM_BONE_INFLUENCERS: number;
  57307. BonesPerMesh: number;
  57308. BONETEXTURE: boolean;
  57309. NONUNIFORMSCALING: boolean;
  57310. MORPHTARGETS: boolean;
  57311. MORPHTARGETS_NORMAL: boolean;
  57312. MORPHTARGETS_TANGENT: boolean;
  57313. MORPHTARGETS_UV: boolean;
  57314. NUM_MORPH_INFLUENCERS: number;
  57315. IMAGEPROCESSING: boolean;
  57316. VIGNETTE: boolean;
  57317. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57318. VIGNETTEBLENDMODEOPAQUE: boolean;
  57319. TONEMAPPING: boolean;
  57320. TONEMAPPING_ACES: boolean;
  57321. CONTRAST: boolean;
  57322. COLORCURVES: boolean;
  57323. COLORGRADING: boolean;
  57324. COLORGRADING3D: boolean;
  57325. SAMPLER3DGREENDEPTH: boolean;
  57326. SAMPLER3DBGRMAP: boolean;
  57327. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57328. EXPOSURE: boolean;
  57329. MULTIVIEW: boolean;
  57330. USEPHYSICALLIGHTFALLOFF: boolean;
  57331. USEGLTFLIGHTFALLOFF: boolean;
  57332. TWOSIDEDLIGHTING: boolean;
  57333. SHADOWFLOAT: boolean;
  57334. CLIPPLANE: boolean;
  57335. CLIPPLANE2: boolean;
  57336. CLIPPLANE3: boolean;
  57337. CLIPPLANE4: boolean;
  57338. CLIPPLANE5: boolean;
  57339. CLIPPLANE6: boolean;
  57340. POINTSIZE: boolean;
  57341. FOG: boolean;
  57342. LOGARITHMICDEPTH: boolean;
  57343. FORCENORMALFORWARD: boolean;
  57344. SPECULARAA: boolean;
  57345. CLEARCOAT: boolean;
  57346. CLEARCOAT_DEFAULTIOR: boolean;
  57347. CLEARCOAT_TEXTURE: boolean;
  57348. CLEARCOAT_TEXTUREDIRECTUV: number;
  57349. CLEARCOAT_BUMP: boolean;
  57350. CLEARCOAT_BUMPDIRECTUV: number;
  57351. CLEARCOAT_TINT: boolean;
  57352. CLEARCOAT_TINT_TEXTURE: boolean;
  57353. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57354. ANISOTROPIC: boolean;
  57355. ANISOTROPIC_TEXTURE: boolean;
  57356. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57357. BRDF_V_HEIGHT_CORRELATED: boolean;
  57358. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57359. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57360. SHEEN: boolean;
  57361. SHEEN_TEXTURE: boolean;
  57362. SHEEN_TEXTUREDIRECTUV: number;
  57363. SHEEN_LINKWITHALBEDO: boolean;
  57364. SHEEN_ROUGHNESS: boolean;
  57365. SHEEN_ALBEDOSCALING: boolean;
  57366. SUBSURFACE: boolean;
  57367. SS_REFRACTION: boolean;
  57368. SS_TRANSLUCENCY: boolean;
  57369. SS_SCATTERING: boolean;
  57370. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57371. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57372. SS_REFRACTIONMAP_3D: boolean;
  57373. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57374. SS_LODINREFRACTIONALPHA: boolean;
  57375. SS_GAMMAREFRACTION: boolean;
  57376. SS_RGBDREFRACTION: boolean;
  57377. SS_LINEARSPECULARREFRACTION: boolean;
  57378. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57379. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57380. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57381. UNLIT: boolean;
  57382. DEBUGMODE: number;
  57383. /**
  57384. * Initializes the PBR Material defines.
  57385. */
  57386. constructor();
  57387. /**
  57388. * Resets the PBR Material defines.
  57389. */
  57390. reset(): void;
  57391. }
  57392. /**
  57393. * The Physically based material base class of BJS.
  57394. *
  57395. * This offers the main features of a standard PBR material.
  57396. * For more information, please refer to the documentation :
  57397. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57398. */
  57399. export abstract class PBRBaseMaterial extends PushMaterial {
  57400. /**
  57401. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57402. */
  57403. static readonly PBRMATERIAL_OPAQUE: number;
  57404. /**
  57405. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57406. */
  57407. static readonly PBRMATERIAL_ALPHATEST: number;
  57408. /**
  57409. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57410. */
  57411. static readonly PBRMATERIAL_ALPHABLEND: number;
  57412. /**
  57413. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57414. * They are also discarded below the alpha cutoff threshold to improve performances.
  57415. */
  57416. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57417. /**
  57418. * Defines the default value of how much AO map is occluding the analytical lights
  57419. * (point spot...).
  57420. */
  57421. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57422. /**
  57423. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57424. */
  57425. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57426. /**
  57427. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57428. * to enhance interoperability with other engines.
  57429. */
  57430. static readonly LIGHTFALLOFF_GLTF: number;
  57431. /**
  57432. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57433. * to enhance interoperability with other materials.
  57434. */
  57435. static readonly LIGHTFALLOFF_STANDARD: number;
  57436. /**
  57437. * Intensity of the direct lights e.g. the four lights available in your scene.
  57438. * This impacts both the direct diffuse and specular highlights.
  57439. */
  57440. protected _directIntensity: number;
  57441. /**
  57442. * Intensity of the emissive part of the material.
  57443. * This helps controlling the emissive effect without modifying the emissive color.
  57444. */
  57445. protected _emissiveIntensity: number;
  57446. /**
  57447. * Intensity of the environment e.g. how much the environment will light the object
  57448. * either through harmonics for rough material or through the refelction for shiny ones.
  57449. */
  57450. protected _environmentIntensity: number;
  57451. /**
  57452. * This is a special control allowing the reduction of the specular highlights coming from the
  57453. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57454. */
  57455. protected _specularIntensity: number;
  57456. /**
  57457. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57458. */
  57459. private _lightingInfos;
  57460. /**
  57461. * Debug Control allowing disabling the bump map on this material.
  57462. */
  57463. protected _disableBumpMap: boolean;
  57464. /**
  57465. * AKA Diffuse Texture in standard nomenclature.
  57466. */
  57467. protected _albedoTexture: Nullable<BaseTexture>;
  57468. /**
  57469. * AKA Occlusion Texture in other nomenclature.
  57470. */
  57471. protected _ambientTexture: Nullable<BaseTexture>;
  57472. /**
  57473. * AKA Occlusion Texture Intensity in other nomenclature.
  57474. */
  57475. protected _ambientTextureStrength: number;
  57476. /**
  57477. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57478. * 1 means it completely occludes it
  57479. * 0 mean it has no impact
  57480. */
  57481. protected _ambientTextureImpactOnAnalyticalLights: number;
  57482. /**
  57483. * Stores the alpha values in a texture.
  57484. */
  57485. protected _opacityTexture: Nullable<BaseTexture>;
  57486. /**
  57487. * Stores the reflection values in a texture.
  57488. */
  57489. protected _reflectionTexture: Nullable<BaseTexture>;
  57490. /**
  57491. * Stores the emissive values in a texture.
  57492. */
  57493. protected _emissiveTexture: Nullable<BaseTexture>;
  57494. /**
  57495. * AKA Specular texture in other nomenclature.
  57496. */
  57497. protected _reflectivityTexture: Nullable<BaseTexture>;
  57498. /**
  57499. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57500. */
  57501. protected _metallicTexture: Nullable<BaseTexture>;
  57502. /**
  57503. * Specifies the metallic scalar of the metallic/roughness workflow.
  57504. * Can also be used to scale the metalness values of the metallic texture.
  57505. */
  57506. protected _metallic: Nullable<number>;
  57507. /**
  57508. * Specifies the roughness scalar of the metallic/roughness workflow.
  57509. * Can also be used to scale the roughness values of the metallic texture.
  57510. */
  57511. protected _roughness: Nullable<number>;
  57512. /**
  57513. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57514. * By default the indexOfrefraction is used to compute F0;
  57515. *
  57516. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57517. *
  57518. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57519. * F90 = metallicReflectanceColor;
  57520. */
  57521. protected _metallicF0Factor: number;
  57522. /**
  57523. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57524. * By default the F90 is always 1;
  57525. *
  57526. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57527. *
  57528. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57529. * F90 = metallicReflectanceColor;
  57530. */
  57531. protected _metallicReflectanceColor: Color3;
  57532. /**
  57533. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57534. * This is multiply against the scalar values defined in the material.
  57535. */
  57536. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57537. /**
  57538. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57539. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57540. */
  57541. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57542. /**
  57543. * Stores surface normal data used to displace a mesh in a texture.
  57544. */
  57545. protected _bumpTexture: Nullable<BaseTexture>;
  57546. /**
  57547. * Stores the pre-calculated light information of a mesh in a texture.
  57548. */
  57549. protected _lightmapTexture: Nullable<BaseTexture>;
  57550. /**
  57551. * The color of a material in ambient lighting.
  57552. */
  57553. protected _ambientColor: Color3;
  57554. /**
  57555. * AKA Diffuse Color in other nomenclature.
  57556. */
  57557. protected _albedoColor: Color3;
  57558. /**
  57559. * AKA Specular Color in other nomenclature.
  57560. */
  57561. protected _reflectivityColor: Color3;
  57562. /**
  57563. * The color applied when light is reflected from a material.
  57564. */
  57565. protected _reflectionColor: Color3;
  57566. /**
  57567. * The color applied when light is emitted from a material.
  57568. */
  57569. protected _emissiveColor: Color3;
  57570. /**
  57571. * AKA Glossiness in other nomenclature.
  57572. */
  57573. protected _microSurface: number;
  57574. /**
  57575. * Specifies that the material will use the light map as a show map.
  57576. */
  57577. protected _useLightmapAsShadowmap: boolean;
  57578. /**
  57579. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57580. * makes the reflect vector face the model (under horizon).
  57581. */
  57582. protected _useHorizonOcclusion: boolean;
  57583. /**
  57584. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57585. * too much the area relying on ambient texture to define their ambient occlusion.
  57586. */
  57587. protected _useRadianceOcclusion: boolean;
  57588. /**
  57589. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57590. */
  57591. protected _useAlphaFromAlbedoTexture: boolean;
  57592. /**
  57593. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57594. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57595. */
  57596. protected _useSpecularOverAlpha: boolean;
  57597. /**
  57598. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57599. */
  57600. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57601. /**
  57602. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57603. */
  57604. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57605. /**
  57606. * Specifies if the metallic texture contains the roughness information in its green channel.
  57607. */
  57608. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57609. /**
  57610. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57611. */
  57612. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57613. /**
  57614. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57615. */
  57616. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57617. /**
  57618. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57619. */
  57620. protected _useAmbientInGrayScale: boolean;
  57621. /**
  57622. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57623. * The material will try to infer what glossiness each pixel should be.
  57624. */
  57625. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57626. /**
  57627. * Defines the falloff type used in this material.
  57628. * It by default is Physical.
  57629. */
  57630. protected _lightFalloff: number;
  57631. /**
  57632. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57633. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57634. */
  57635. protected _useRadianceOverAlpha: boolean;
  57636. /**
  57637. * Allows using an object space normal map (instead of tangent space).
  57638. */
  57639. protected _useObjectSpaceNormalMap: boolean;
  57640. /**
  57641. * Allows using the bump map in parallax mode.
  57642. */
  57643. protected _useParallax: boolean;
  57644. /**
  57645. * Allows using the bump map in parallax occlusion mode.
  57646. */
  57647. protected _useParallaxOcclusion: boolean;
  57648. /**
  57649. * Controls the scale bias of the parallax mode.
  57650. */
  57651. protected _parallaxScaleBias: number;
  57652. /**
  57653. * If sets to true, disables all the lights affecting the material.
  57654. */
  57655. protected _disableLighting: boolean;
  57656. /**
  57657. * Number of Simultaneous lights allowed on the material.
  57658. */
  57659. protected _maxSimultaneousLights: number;
  57660. /**
  57661. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57662. */
  57663. protected _invertNormalMapX: boolean;
  57664. /**
  57665. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57666. */
  57667. protected _invertNormalMapY: boolean;
  57668. /**
  57669. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57670. */
  57671. protected _twoSidedLighting: boolean;
  57672. /**
  57673. * Defines the alpha limits in alpha test mode.
  57674. */
  57675. protected _alphaCutOff: number;
  57676. /**
  57677. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57678. */
  57679. protected _forceAlphaTest: boolean;
  57680. /**
  57681. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57682. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57683. */
  57684. protected _useAlphaFresnel: boolean;
  57685. /**
  57686. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57687. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57688. */
  57689. protected _useLinearAlphaFresnel: boolean;
  57690. /**
  57691. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57692. * from cos thetav and roughness:
  57693. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57694. */
  57695. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57696. /**
  57697. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57698. */
  57699. protected _forceIrradianceInFragment: boolean;
  57700. private _realTimeFiltering;
  57701. /**
  57702. * Enables realtime filtering on the texture.
  57703. */
  57704. get realTimeFiltering(): boolean;
  57705. set realTimeFiltering(b: boolean);
  57706. private _realTimeFilteringQuality;
  57707. /**
  57708. * Quality switch for realtime filtering
  57709. */
  57710. get realTimeFilteringQuality(): number;
  57711. set realTimeFilteringQuality(n: number);
  57712. /**
  57713. * Force normal to face away from face.
  57714. */
  57715. protected _forceNormalForward: boolean;
  57716. /**
  57717. * Enables specular anti aliasing in the PBR shader.
  57718. * It will both interacts on the Geometry for analytical and IBL lighting.
  57719. * It also prefilter the roughness map based on the bump values.
  57720. */
  57721. protected _enableSpecularAntiAliasing: boolean;
  57722. /**
  57723. * Default configuration related to image processing available in the PBR Material.
  57724. */
  57725. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57726. /**
  57727. * Keep track of the image processing observer to allow dispose and replace.
  57728. */
  57729. private _imageProcessingObserver;
  57730. /**
  57731. * Attaches a new image processing configuration to the PBR Material.
  57732. * @param configuration
  57733. */
  57734. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57735. /**
  57736. * Stores the available render targets.
  57737. */
  57738. private _renderTargets;
  57739. /**
  57740. * Sets the global ambient color for the material used in lighting calculations.
  57741. */
  57742. private _globalAmbientColor;
  57743. /**
  57744. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57745. */
  57746. private _useLogarithmicDepth;
  57747. /**
  57748. * If set to true, no lighting calculations will be applied.
  57749. */
  57750. private _unlit;
  57751. private _debugMode;
  57752. /**
  57753. * @hidden
  57754. * This is reserved for the inspector.
  57755. * Defines the material debug mode.
  57756. * It helps seeing only some components of the material while troubleshooting.
  57757. */
  57758. debugMode: number;
  57759. /**
  57760. * @hidden
  57761. * This is reserved for the inspector.
  57762. * Specify from where on screen the debug mode should start.
  57763. * The value goes from -1 (full screen) to 1 (not visible)
  57764. * It helps with side by side comparison against the final render
  57765. * This defaults to -1
  57766. */
  57767. private debugLimit;
  57768. /**
  57769. * @hidden
  57770. * This is reserved for the inspector.
  57771. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57772. * You can use the factor to better multiply the final value.
  57773. */
  57774. private debugFactor;
  57775. /**
  57776. * Defines the clear coat layer parameters for the material.
  57777. */
  57778. readonly clearCoat: PBRClearCoatConfiguration;
  57779. /**
  57780. * Defines the anisotropic parameters for the material.
  57781. */
  57782. readonly anisotropy: PBRAnisotropicConfiguration;
  57783. /**
  57784. * Defines the BRDF parameters for the material.
  57785. */
  57786. readonly brdf: PBRBRDFConfiguration;
  57787. /**
  57788. * Defines the Sheen parameters for the material.
  57789. */
  57790. readonly sheen: PBRSheenConfiguration;
  57791. /**
  57792. * Defines the SubSurface parameters for the material.
  57793. */
  57794. readonly subSurface: PBRSubSurfaceConfiguration;
  57795. protected _rebuildInParallel: boolean;
  57796. /**
  57797. * Instantiates a new PBRMaterial instance.
  57798. *
  57799. * @param name The material name
  57800. * @param scene The scene the material will be use in.
  57801. */
  57802. constructor(name: string, scene: Scene);
  57803. /**
  57804. * Gets a boolean indicating that current material needs to register RTT
  57805. */
  57806. get hasRenderTargetTextures(): boolean;
  57807. /**
  57808. * Gets the name of the material class.
  57809. */
  57810. getClassName(): string;
  57811. /**
  57812. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57813. */
  57814. get useLogarithmicDepth(): boolean;
  57815. /**
  57816. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57817. */
  57818. set useLogarithmicDepth(value: boolean);
  57819. /**
  57820. * Returns true if alpha blending should be disabled.
  57821. */
  57822. protected get _disableAlphaBlending(): boolean;
  57823. /**
  57824. * Specifies whether or not this material should be rendered in alpha blend mode.
  57825. */
  57826. needAlphaBlending(): boolean;
  57827. /**
  57828. * Specifies whether or not this material should be rendered in alpha test mode.
  57829. */
  57830. needAlphaTesting(): boolean;
  57831. /**
  57832. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57833. */
  57834. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57835. /**
  57836. * Gets the texture used for the alpha test.
  57837. */
  57838. getAlphaTestTexture(): Nullable<BaseTexture>;
  57839. /**
  57840. * Specifies that the submesh is ready to be used.
  57841. * @param mesh - BJS mesh.
  57842. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57843. * @param useInstances - Specifies that instances should be used.
  57844. * @returns - boolean indicating that the submesh is ready or not.
  57845. */
  57846. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57847. /**
  57848. * Specifies if the material uses metallic roughness workflow.
  57849. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57850. */
  57851. isMetallicWorkflow(): boolean;
  57852. private _prepareEffect;
  57853. private _prepareDefines;
  57854. /**
  57855. * Force shader compilation
  57856. */
  57857. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57858. /**
  57859. * Initializes the uniform buffer layout for the shader.
  57860. */
  57861. buildUniformLayout(): void;
  57862. /**
  57863. * Unbinds the material from the mesh
  57864. */
  57865. unbind(): void;
  57866. /**
  57867. * Binds the submesh data.
  57868. * @param world - The world matrix.
  57869. * @param mesh - The BJS mesh.
  57870. * @param subMesh - A submesh of the BJS mesh.
  57871. */
  57872. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57873. /**
  57874. * Returns the animatable textures.
  57875. * @returns - Array of animatable textures.
  57876. */
  57877. getAnimatables(): IAnimatable[];
  57878. /**
  57879. * Returns the texture used for reflections.
  57880. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57881. */
  57882. private _getReflectionTexture;
  57883. /**
  57884. * Returns an array of the actively used textures.
  57885. * @returns - Array of BaseTextures
  57886. */
  57887. getActiveTextures(): BaseTexture[];
  57888. /**
  57889. * Checks to see if a texture is used in the material.
  57890. * @param texture - Base texture to use.
  57891. * @returns - Boolean specifying if a texture is used in the material.
  57892. */
  57893. hasTexture(texture: BaseTexture): boolean;
  57894. /**
  57895. * Disposes the resources of the material.
  57896. * @param forceDisposeEffect - Forces the disposal of effects.
  57897. * @param forceDisposeTextures - Forces the disposal of all textures.
  57898. */
  57899. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57900. }
  57901. }
  57902. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  57903. import { Nullable } from "babylonjs/types";
  57904. import { Scene } from "babylonjs/scene";
  57905. import { Color3 } from "babylonjs/Maths/math.color";
  57906. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57907. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57908. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57909. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57910. /**
  57911. * The Physically based material of BJS.
  57912. *
  57913. * This offers the main features of a standard PBR material.
  57914. * For more information, please refer to the documentation :
  57915. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57916. */
  57917. export class PBRMaterial extends PBRBaseMaterial {
  57918. /**
  57919. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57920. */
  57921. static readonly PBRMATERIAL_OPAQUE: number;
  57922. /**
  57923. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57924. */
  57925. static readonly PBRMATERIAL_ALPHATEST: number;
  57926. /**
  57927. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57928. */
  57929. static readonly PBRMATERIAL_ALPHABLEND: number;
  57930. /**
  57931. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57932. * They are also discarded below the alpha cutoff threshold to improve performances.
  57933. */
  57934. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57935. /**
  57936. * Defines the default value of how much AO map is occluding the analytical lights
  57937. * (point spot...).
  57938. */
  57939. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57940. /**
  57941. * Intensity of the direct lights e.g. the four lights available in your scene.
  57942. * This impacts both the direct diffuse and specular highlights.
  57943. */
  57944. directIntensity: number;
  57945. /**
  57946. * Intensity of the emissive part of the material.
  57947. * This helps controlling the emissive effect without modifying the emissive color.
  57948. */
  57949. emissiveIntensity: number;
  57950. /**
  57951. * Intensity of the environment e.g. how much the environment will light the object
  57952. * either through harmonics for rough material or through the refelction for shiny ones.
  57953. */
  57954. environmentIntensity: number;
  57955. /**
  57956. * This is a special control allowing the reduction of the specular highlights coming from the
  57957. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57958. */
  57959. specularIntensity: number;
  57960. /**
  57961. * Debug Control allowing disabling the bump map on this material.
  57962. */
  57963. disableBumpMap: boolean;
  57964. /**
  57965. * AKA Diffuse Texture in standard nomenclature.
  57966. */
  57967. albedoTexture: BaseTexture;
  57968. /**
  57969. * AKA Occlusion Texture in other nomenclature.
  57970. */
  57971. ambientTexture: BaseTexture;
  57972. /**
  57973. * AKA Occlusion Texture Intensity in other nomenclature.
  57974. */
  57975. ambientTextureStrength: number;
  57976. /**
  57977. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57978. * 1 means it completely occludes it
  57979. * 0 mean it has no impact
  57980. */
  57981. ambientTextureImpactOnAnalyticalLights: number;
  57982. /**
  57983. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57984. */
  57985. opacityTexture: BaseTexture;
  57986. /**
  57987. * Stores the reflection values in a texture.
  57988. */
  57989. reflectionTexture: Nullable<BaseTexture>;
  57990. /**
  57991. * Stores the emissive values in a texture.
  57992. */
  57993. emissiveTexture: BaseTexture;
  57994. /**
  57995. * AKA Specular texture in other nomenclature.
  57996. */
  57997. reflectivityTexture: BaseTexture;
  57998. /**
  57999. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58000. */
  58001. metallicTexture: BaseTexture;
  58002. /**
  58003. * Specifies the metallic scalar of the metallic/roughness workflow.
  58004. * Can also be used to scale the metalness values of the metallic texture.
  58005. */
  58006. metallic: Nullable<number>;
  58007. /**
  58008. * Specifies the roughness scalar of the metallic/roughness workflow.
  58009. * Can also be used to scale the roughness values of the metallic texture.
  58010. */
  58011. roughness: Nullable<number>;
  58012. /**
  58013. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58014. * By default the indexOfrefraction is used to compute F0;
  58015. *
  58016. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58017. *
  58018. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58019. * F90 = metallicReflectanceColor;
  58020. */
  58021. metallicF0Factor: number;
  58022. /**
  58023. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58024. * By default the F90 is always 1;
  58025. *
  58026. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58027. *
  58028. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58029. * F90 = metallicReflectanceColor;
  58030. */
  58031. metallicReflectanceColor: Color3;
  58032. /**
  58033. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58034. * This is multiply against the scalar values defined in the material.
  58035. */
  58036. metallicReflectanceTexture: Nullable<BaseTexture>;
  58037. /**
  58038. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58039. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58040. */
  58041. microSurfaceTexture: BaseTexture;
  58042. /**
  58043. * Stores surface normal data used to displace a mesh in a texture.
  58044. */
  58045. bumpTexture: BaseTexture;
  58046. /**
  58047. * Stores the pre-calculated light information of a mesh in a texture.
  58048. */
  58049. lightmapTexture: BaseTexture;
  58050. /**
  58051. * Stores the refracted light information in a texture.
  58052. */
  58053. get refractionTexture(): Nullable<BaseTexture>;
  58054. set refractionTexture(value: Nullable<BaseTexture>);
  58055. /**
  58056. * The color of a material in ambient lighting.
  58057. */
  58058. ambientColor: Color3;
  58059. /**
  58060. * AKA Diffuse Color in other nomenclature.
  58061. */
  58062. albedoColor: Color3;
  58063. /**
  58064. * AKA Specular Color in other nomenclature.
  58065. */
  58066. reflectivityColor: Color3;
  58067. /**
  58068. * The color reflected from the material.
  58069. */
  58070. reflectionColor: Color3;
  58071. /**
  58072. * The color emitted from the material.
  58073. */
  58074. emissiveColor: Color3;
  58075. /**
  58076. * AKA Glossiness in other nomenclature.
  58077. */
  58078. microSurface: number;
  58079. /**
  58080. * Index of refraction of the material base layer.
  58081. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58082. *
  58083. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58084. *
  58085. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58086. */
  58087. get indexOfRefraction(): number;
  58088. set indexOfRefraction(value: number);
  58089. /**
  58090. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58091. */
  58092. get invertRefractionY(): boolean;
  58093. set invertRefractionY(value: boolean);
  58094. /**
  58095. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58096. * Materials half opaque for instance using refraction could benefit from this control.
  58097. */
  58098. get linkRefractionWithTransparency(): boolean;
  58099. set linkRefractionWithTransparency(value: boolean);
  58100. /**
  58101. * If true, the light map contains occlusion information instead of lighting info.
  58102. */
  58103. useLightmapAsShadowmap: boolean;
  58104. /**
  58105. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58106. */
  58107. useAlphaFromAlbedoTexture: boolean;
  58108. /**
  58109. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58110. */
  58111. forceAlphaTest: boolean;
  58112. /**
  58113. * Defines the alpha limits in alpha test mode.
  58114. */
  58115. alphaCutOff: number;
  58116. /**
  58117. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58118. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58119. */
  58120. useSpecularOverAlpha: boolean;
  58121. /**
  58122. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58123. */
  58124. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58125. /**
  58126. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58127. */
  58128. useRoughnessFromMetallicTextureAlpha: boolean;
  58129. /**
  58130. * Specifies if the metallic texture contains the roughness information in its green channel.
  58131. */
  58132. useRoughnessFromMetallicTextureGreen: boolean;
  58133. /**
  58134. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58135. */
  58136. useMetallnessFromMetallicTextureBlue: boolean;
  58137. /**
  58138. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58139. */
  58140. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58141. /**
  58142. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58143. */
  58144. useAmbientInGrayScale: boolean;
  58145. /**
  58146. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58147. * The material will try to infer what glossiness each pixel should be.
  58148. */
  58149. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58150. /**
  58151. * BJS is using an harcoded light falloff based on a manually sets up range.
  58152. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58153. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58154. */
  58155. get usePhysicalLightFalloff(): boolean;
  58156. /**
  58157. * BJS is using an harcoded light falloff based on a manually sets up range.
  58158. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58159. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58160. */
  58161. set usePhysicalLightFalloff(value: boolean);
  58162. /**
  58163. * In order to support the falloff compatibility with gltf, a special mode has been added
  58164. * to reproduce the gltf light falloff.
  58165. */
  58166. get useGLTFLightFalloff(): boolean;
  58167. /**
  58168. * In order to support the falloff compatibility with gltf, a special mode has been added
  58169. * to reproduce the gltf light falloff.
  58170. */
  58171. set useGLTFLightFalloff(value: boolean);
  58172. /**
  58173. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58174. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58175. */
  58176. useRadianceOverAlpha: boolean;
  58177. /**
  58178. * Allows using an object space normal map (instead of tangent space).
  58179. */
  58180. useObjectSpaceNormalMap: boolean;
  58181. /**
  58182. * Allows using the bump map in parallax mode.
  58183. */
  58184. useParallax: boolean;
  58185. /**
  58186. * Allows using the bump map in parallax occlusion mode.
  58187. */
  58188. useParallaxOcclusion: boolean;
  58189. /**
  58190. * Controls the scale bias of the parallax mode.
  58191. */
  58192. parallaxScaleBias: number;
  58193. /**
  58194. * If sets to true, disables all the lights affecting the material.
  58195. */
  58196. disableLighting: boolean;
  58197. /**
  58198. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58199. */
  58200. forceIrradianceInFragment: boolean;
  58201. /**
  58202. * Number of Simultaneous lights allowed on the material.
  58203. */
  58204. maxSimultaneousLights: number;
  58205. /**
  58206. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58207. */
  58208. invertNormalMapX: boolean;
  58209. /**
  58210. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58211. */
  58212. invertNormalMapY: boolean;
  58213. /**
  58214. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58215. */
  58216. twoSidedLighting: boolean;
  58217. /**
  58218. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58219. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58220. */
  58221. useAlphaFresnel: boolean;
  58222. /**
  58223. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58224. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58225. */
  58226. useLinearAlphaFresnel: boolean;
  58227. /**
  58228. * Let user defines the brdf lookup texture used for IBL.
  58229. * A default 8bit version is embedded but you could point at :
  58230. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58231. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58232. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58233. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58234. */
  58235. environmentBRDFTexture: Nullable<BaseTexture>;
  58236. /**
  58237. * Force normal to face away from face.
  58238. */
  58239. forceNormalForward: boolean;
  58240. /**
  58241. * Enables specular anti aliasing in the PBR shader.
  58242. * It will both interacts on the Geometry for analytical and IBL lighting.
  58243. * It also prefilter the roughness map based on the bump values.
  58244. */
  58245. enableSpecularAntiAliasing: boolean;
  58246. /**
  58247. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58248. * makes the reflect vector face the model (under horizon).
  58249. */
  58250. useHorizonOcclusion: boolean;
  58251. /**
  58252. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58253. * too much the area relying on ambient texture to define their ambient occlusion.
  58254. */
  58255. useRadianceOcclusion: boolean;
  58256. /**
  58257. * If set to true, no lighting calculations will be applied.
  58258. */
  58259. unlit: boolean;
  58260. /**
  58261. * Gets the image processing configuration used either in this material.
  58262. */
  58263. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58264. /**
  58265. * Sets the Default image processing configuration used either in the this material.
  58266. *
  58267. * If sets to null, the scene one is in use.
  58268. */
  58269. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58270. /**
  58271. * Gets wether the color curves effect is enabled.
  58272. */
  58273. get cameraColorCurvesEnabled(): boolean;
  58274. /**
  58275. * Sets wether the color curves effect is enabled.
  58276. */
  58277. set cameraColorCurvesEnabled(value: boolean);
  58278. /**
  58279. * Gets wether the color grading effect is enabled.
  58280. */
  58281. get cameraColorGradingEnabled(): boolean;
  58282. /**
  58283. * Gets wether the color grading effect is enabled.
  58284. */
  58285. set cameraColorGradingEnabled(value: boolean);
  58286. /**
  58287. * Gets wether tonemapping is enabled or not.
  58288. */
  58289. get cameraToneMappingEnabled(): boolean;
  58290. /**
  58291. * Sets wether tonemapping is enabled or not
  58292. */
  58293. set cameraToneMappingEnabled(value: boolean);
  58294. /**
  58295. * The camera exposure used on this material.
  58296. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58297. * This corresponds to a photographic exposure.
  58298. */
  58299. get cameraExposure(): number;
  58300. /**
  58301. * The camera exposure used on this material.
  58302. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58303. * This corresponds to a photographic exposure.
  58304. */
  58305. set cameraExposure(value: number);
  58306. /**
  58307. * Gets The camera contrast used on this material.
  58308. */
  58309. get cameraContrast(): number;
  58310. /**
  58311. * Sets The camera contrast used on this material.
  58312. */
  58313. set cameraContrast(value: number);
  58314. /**
  58315. * Gets the Color Grading 2D Lookup Texture.
  58316. */
  58317. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58318. /**
  58319. * Sets the Color Grading 2D Lookup Texture.
  58320. */
  58321. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58322. /**
  58323. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58324. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58325. * 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;
  58326. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58327. */
  58328. get cameraColorCurves(): Nullable<ColorCurves>;
  58329. /**
  58330. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58331. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58332. * 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;
  58333. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58334. */
  58335. set cameraColorCurves(value: Nullable<ColorCurves>);
  58336. /**
  58337. * Instantiates a new PBRMaterial instance.
  58338. *
  58339. * @param name The material name
  58340. * @param scene The scene the material will be use in.
  58341. */
  58342. constructor(name: string, scene: Scene);
  58343. /**
  58344. * Returns the name of this material class.
  58345. */
  58346. getClassName(): string;
  58347. /**
  58348. * Makes a duplicate of the current material.
  58349. * @param name - name to use for the new material.
  58350. */
  58351. clone(name: string): PBRMaterial;
  58352. /**
  58353. * Serializes this PBR Material.
  58354. * @returns - An object with the serialized material.
  58355. */
  58356. serialize(): any;
  58357. /**
  58358. * Parses a PBR Material from a serialized object.
  58359. * @param source - Serialized object.
  58360. * @param scene - BJS scene instance.
  58361. * @param rootUrl - url for the scene object
  58362. * @returns - PBRMaterial
  58363. */
  58364. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58365. }
  58366. }
  58367. declare module "babylonjs/Misc/dds" {
  58368. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58370. import { Nullable } from "babylonjs/types";
  58371. import { Scene } from "babylonjs/scene";
  58372. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58373. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58374. /**
  58375. * Direct draw surface info
  58376. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58377. */
  58378. export interface DDSInfo {
  58379. /**
  58380. * Width of the texture
  58381. */
  58382. width: number;
  58383. /**
  58384. * Width of the texture
  58385. */
  58386. height: number;
  58387. /**
  58388. * Number of Mipmaps for the texture
  58389. * @see https://en.wikipedia.org/wiki/Mipmap
  58390. */
  58391. mipmapCount: number;
  58392. /**
  58393. * If the textures format is a known fourCC format
  58394. * @see https://www.fourcc.org/
  58395. */
  58396. isFourCC: boolean;
  58397. /**
  58398. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58399. */
  58400. isRGB: boolean;
  58401. /**
  58402. * If the texture is a lumincance format
  58403. */
  58404. isLuminance: boolean;
  58405. /**
  58406. * If this is a cube texture
  58407. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58408. */
  58409. isCube: boolean;
  58410. /**
  58411. * If the texture is a compressed format eg. FOURCC_DXT1
  58412. */
  58413. isCompressed: boolean;
  58414. /**
  58415. * The dxgiFormat of the texture
  58416. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58417. */
  58418. dxgiFormat: number;
  58419. /**
  58420. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58421. */
  58422. textureType: number;
  58423. /**
  58424. * Sphericle polynomial created for the dds texture
  58425. */
  58426. sphericalPolynomial?: SphericalPolynomial;
  58427. }
  58428. /**
  58429. * Class used to provide DDS decompression tools
  58430. */
  58431. export class DDSTools {
  58432. /**
  58433. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58434. */
  58435. static StoreLODInAlphaChannel: boolean;
  58436. /**
  58437. * Gets DDS information from an array buffer
  58438. * @param data defines the array buffer view to read data from
  58439. * @returns the DDS information
  58440. */
  58441. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58442. private static _FloatView;
  58443. private static _Int32View;
  58444. private static _ToHalfFloat;
  58445. private static _FromHalfFloat;
  58446. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58447. private static _GetHalfFloatRGBAArrayBuffer;
  58448. private static _GetFloatRGBAArrayBuffer;
  58449. private static _GetFloatAsUIntRGBAArrayBuffer;
  58450. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58451. private static _GetRGBAArrayBuffer;
  58452. private static _ExtractLongWordOrder;
  58453. private static _GetRGBArrayBuffer;
  58454. private static _GetLuminanceArrayBuffer;
  58455. /**
  58456. * Uploads DDS Levels to a Babylon Texture
  58457. * @hidden
  58458. */
  58459. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58460. }
  58461. module "babylonjs/Engines/thinEngine" {
  58462. interface ThinEngine {
  58463. /**
  58464. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58465. * @param rootUrl defines the url where the file to load is located
  58466. * @param scene defines the current scene
  58467. * @param lodScale defines scale to apply to the mip map selection
  58468. * @param lodOffset defines offset to apply to the mip map selection
  58469. * @param onLoad defines an optional callback raised when the texture is loaded
  58470. * @param onError defines an optional callback raised if there is an issue to load the texture
  58471. * @param format defines the format of the data
  58472. * @param forcedExtension defines the extension to use to pick the right loader
  58473. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58474. * @returns the cube texture as an InternalTexture
  58475. */
  58476. 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;
  58477. }
  58478. }
  58479. }
  58480. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58481. import { Nullable } from "babylonjs/types";
  58482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58483. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58484. /**
  58485. * Implementation of the DDS Texture Loader.
  58486. * @hidden
  58487. */
  58488. export class _DDSTextureLoader implements IInternalTextureLoader {
  58489. /**
  58490. * Defines wether the loader supports cascade loading the different faces.
  58491. */
  58492. readonly supportCascades: boolean;
  58493. /**
  58494. * This returns if the loader support the current file information.
  58495. * @param extension defines the file extension of the file being loaded
  58496. * @returns true if the loader can load the specified file
  58497. */
  58498. canLoad(extension: string): boolean;
  58499. /**
  58500. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58501. * @param data contains the texture data
  58502. * @param texture defines the BabylonJS internal texture
  58503. * @param createPolynomials will be true if polynomials have been requested
  58504. * @param onLoad defines the callback to trigger once the texture is ready
  58505. * @param onError defines the callback to trigger in case of error
  58506. */
  58507. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58508. /**
  58509. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58510. * @param data contains the texture data
  58511. * @param texture defines the BabylonJS internal texture
  58512. * @param callback defines the method to call once ready to upload
  58513. */
  58514. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58515. }
  58516. }
  58517. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58518. import { Nullable } from "babylonjs/types";
  58519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58520. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58521. /**
  58522. * Implementation of the ENV Texture Loader.
  58523. * @hidden
  58524. */
  58525. export class _ENVTextureLoader implements IInternalTextureLoader {
  58526. /**
  58527. * Defines wether the loader supports cascade loading the different faces.
  58528. */
  58529. readonly supportCascades: boolean;
  58530. /**
  58531. * This returns if the loader support the current file information.
  58532. * @param extension defines the file extension of the file being loaded
  58533. * @returns true if the loader can load the specified file
  58534. */
  58535. canLoad(extension: string): boolean;
  58536. /**
  58537. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58538. * @param data contains the texture data
  58539. * @param texture defines the BabylonJS internal texture
  58540. * @param createPolynomials will be true if polynomials have been requested
  58541. * @param onLoad defines the callback to trigger once the texture is ready
  58542. * @param onError defines the callback to trigger in case of error
  58543. */
  58544. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58545. /**
  58546. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58547. * @param data contains the texture data
  58548. * @param texture defines the BabylonJS internal texture
  58549. * @param callback defines the method to call once ready to upload
  58550. */
  58551. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58552. }
  58553. }
  58554. declare module "babylonjs/Misc/khronosTextureContainer" {
  58555. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58556. /**
  58557. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58558. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58559. */
  58560. export class KhronosTextureContainer {
  58561. /** contents of the KTX container file */
  58562. data: ArrayBufferView;
  58563. private static HEADER_LEN;
  58564. private static COMPRESSED_2D;
  58565. private static COMPRESSED_3D;
  58566. private static TEX_2D;
  58567. private static TEX_3D;
  58568. /**
  58569. * Gets the openGL type
  58570. */
  58571. glType: number;
  58572. /**
  58573. * Gets the openGL type size
  58574. */
  58575. glTypeSize: number;
  58576. /**
  58577. * Gets the openGL format
  58578. */
  58579. glFormat: number;
  58580. /**
  58581. * Gets the openGL internal format
  58582. */
  58583. glInternalFormat: number;
  58584. /**
  58585. * Gets the base internal format
  58586. */
  58587. glBaseInternalFormat: number;
  58588. /**
  58589. * Gets image width in pixel
  58590. */
  58591. pixelWidth: number;
  58592. /**
  58593. * Gets image height in pixel
  58594. */
  58595. pixelHeight: number;
  58596. /**
  58597. * Gets image depth in pixels
  58598. */
  58599. pixelDepth: number;
  58600. /**
  58601. * Gets the number of array elements
  58602. */
  58603. numberOfArrayElements: number;
  58604. /**
  58605. * Gets the number of faces
  58606. */
  58607. numberOfFaces: number;
  58608. /**
  58609. * Gets the number of mipmap levels
  58610. */
  58611. numberOfMipmapLevels: number;
  58612. /**
  58613. * Gets the bytes of key value data
  58614. */
  58615. bytesOfKeyValueData: number;
  58616. /**
  58617. * Gets the load type
  58618. */
  58619. loadType: number;
  58620. /**
  58621. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58622. */
  58623. isInvalid: boolean;
  58624. /**
  58625. * Creates a new KhronosTextureContainer
  58626. * @param data contents of the KTX container file
  58627. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58628. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58629. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58630. */
  58631. constructor(
  58632. /** contents of the KTX container file */
  58633. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58634. /**
  58635. * Uploads KTX content to a Babylon Texture.
  58636. * It is assumed that the texture has already been created & is currently bound
  58637. * @hidden
  58638. */
  58639. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58640. private _upload2DCompressedLevels;
  58641. /**
  58642. * Checks if the given data starts with a KTX file identifier.
  58643. * @param data the data to check
  58644. * @returns true if the data is a KTX file or false otherwise
  58645. */
  58646. static IsValid(data: ArrayBufferView): boolean;
  58647. }
  58648. }
  58649. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58651. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58652. /**
  58653. * Class for loading KTX2 files
  58654. * !!! Experimental Extension Subject to Changes !!!
  58655. * @hidden
  58656. */
  58657. export class KhronosTextureContainer2 {
  58658. private static _ModulePromise;
  58659. private static _TranscodeFormat;
  58660. constructor(engine: ThinEngine);
  58661. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58662. private _determineTranscodeFormat;
  58663. /**
  58664. * Checks if the given data starts with a KTX2 file identifier.
  58665. * @param data the data to check
  58666. * @returns true if the data is a KTX2 file or false otherwise
  58667. */
  58668. static IsValid(data: ArrayBufferView): boolean;
  58669. }
  58670. }
  58671. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58672. import { Nullable } from "babylonjs/types";
  58673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58674. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58675. /**
  58676. * Implementation of the KTX Texture Loader.
  58677. * @hidden
  58678. */
  58679. export class _KTXTextureLoader implements IInternalTextureLoader {
  58680. /**
  58681. * Defines wether the loader supports cascade loading the different faces.
  58682. */
  58683. readonly supportCascades: boolean;
  58684. /**
  58685. * This returns if the loader support the current file information.
  58686. * @param extension defines the file extension of the file being loaded
  58687. * @returns true if the loader can load the specified file
  58688. */
  58689. canLoad(extension: string): boolean;
  58690. /**
  58691. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58692. * @param data contains the texture data
  58693. * @param texture defines the BabylonJS internal texture
  58694. * @param createPolynomials will be true if polynomials have been requested
  58695. * @param onLoad defines the callback to trigger once the texture is ready
  58696. * @param onError defines the callback to trigger in case of error
  58697. */
  58698. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58699. /**
  58700. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58701. * @param data contains the texture data
  58702. * @param texture defines the BabylonJS internal texture
  58703. * @param callback defines the method to call once ready to upload
  58704. */
  58705. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58706. }
  58707. }
  58708. declare module "babylonjs/Helpers/sceneHelpers" {
  58709. import { Nullable } from "babylonjs/types";
  58710. import { Mesh } from "babylonjs/Meshes/mesh";
  58711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58712. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58713. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58714. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58715. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58716. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58717. import "babylonjs/Meshes/Builders/boxBuilder";
  58718. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58719. /** @hidden */
  58720. export var _forceSceneHelpersToBundle: boolean;
  58721. module "babylonjs/scene" {
  58722. interface Scene {
  58723. /**
  58724. * Creates a default light for the scene.
  58725. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58726. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58727. */
  58728. createDefaultLight(replace?: boolean): void;
  58729. /**
  58730. * Creates a default camera for the scene.
  58731. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58732. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58733. * @param replace has default false, when true replaces the active camera in the scene
  58734. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58735. */
  58736. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58737. /**
  58738. * Creates a default camera and a default light.
  58739. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58740. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58741. * @param replace has the default false, when true replaces the active camera/light in the scene
  58742. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58743. */
  58744. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58745. /**
  58746. * Creates a new sky box
  58747. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58748. * @param environmentTexture defines the texture to use as environment texture
  58749. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58750. * @param scale defines the overall scale of the skybox
  58751. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58752. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58753. * @returns a new mesh holding the sky box
  58754. */
  58755. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58756. /**
  58757. * Creates a new environment
  58758. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58759. * @param options defines the options you can use to configure the environment
  58760. * @returns the new EnvironmentHelper
  58761. */
  58762. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58763. /**
  58764. * Creates a new VREXperienceHelper
  58765. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58766. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58767. * @returns a new VREXperienceHelper
  58768. */
  58769. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58770. /**
  58771. * Creates a new WebXRDefaultExperience
  58772. * @see http://doc.babylonjs.com/how_to/webxr
  58773. * @param options experience options
  58774. * @returns a promise for a new WebXRDefaultExperience
  58775. */
  58776. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58777. }
  58778. }
  58779. }
  58780. declare module "babylonjs/Helpers/videoDome" {
  58781. import { Scene } from "babylonjs/scene";
  58782. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58783. import { Mesh } from "babylonjs/Meshes/mesh";
  58784. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58785. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58786. import "babylonjs/Meshes/Builders/sphereBuilder";
  58787. /**
  58788. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58789. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58790. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58791. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58792. */
  58793. export class VideoDome extends TransformNode {
  58794. /**
  58795. * Define the video source as a Monoscopic panoramic 360 video.
  58796. */
  58797. static readonly MODE_MONOSCOPIC: number;
  58798. /**
  58799. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58800. */
  58801. static readonly MODE_TOPBOTTOM: number;
  58802. /**
  58803. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58804. */
  58805. static readonly MODE_SIDEBYSIDE: number;
  58806. private _halfDome;
  58807. private _useDirectMapping;
  58808. /**
  58809. * The video texture being displayed on the sphere
  58810. */
  58811. protected _videoTexture: VideoTexture;
  58812. /**
  58813. * Gets the video texture being displayed on the sphere
  58814. */
  58815. get videoTexture(): VideoTexture;
  58816. /**
  58817. * The skybox material
  58818. */
  58819. protected _material: BackgroundMaterial;
  58820. /**
  58821. * The surface used for the skybox
  58822. */
  58823. protected _mesh: Mesh;
  58824. /**
  58825. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  58826. */
  58827. private _halfDomeMask;
  58828. /**
  58829. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58830. * Also see the options.resolution property.
  58831. */
  58832. get fovMultiplier(): number;
  58833. set fovMultiplier(value: number);
  58834. private _videoMode;
  58835. /**
  58836. * Gets or set the current video mode for the video. It can be:
  58837. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  58838. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58839. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58840. */
  58841. get videoMode(): number;
  58842. set videoMode(value: number);
  58843. /**
  58844. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  58845. *
  58846. */
  58847. get halfDome(): boolean;
  58848. /**
  58849. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58850. */
  58851. set halfDome(enabled: boolean);
  58852. /**
  58853. * Oberserver used in Stereoscopic VR Mode.
  58854. */
  58855. private _onBeforeCameraRenderObserver;
  58856. /**
  58857. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  58858. * @param name Element's name, child elements will append suffixes for their own names.
  58859. * @param urlsOrVideo defines the url(s) or the video element to use
  58860. * @param options An object containing optional or exposed sub element properties
  58861. */
  58862. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  58863. resolution?: number;
  58864. clickToPlay?: boolean;
  58865. autoPlay?: boolean;
  58866. loop?: boolean;
  58867. size?: number;
  58868. poster?: string;
  58869. faceForward?: boolean;
  58870. useDirectMapping?: boolean;
  58871. halfDomeMode?: boolean;
  58872. }, scene: Scene);
  58873. private _changeVideoMode;
  58874. /**
  58875. * Releases resources associated with this node.
  58876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58878. */
  58879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58880. }
  58881. }
  58882. declare module "babylonjs/Helpers/index" {
  58883. export * from "babylonjs/Helpers/environmentHelper";
  58884. export * from "babylonjs/Helpers/photoDome";
  58885. export * from "babylonjs/Helpers/sceneHelpers";
  58886. export * from "babylonjs/Helpers/videoDome";
  58887. }
  58888. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  58889. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58890. import { IDisposable } from "babylonjs/scene";
  58891. import { Engine } from "babylonjs/Engines/engine";
  58892. /**
  58893. * This class can be used to get instrumentation data from a Babylon engine
  58894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58895. */
  58896. export class EngineInstrumentation implements IDisposable {
  58897. /**
  58898. * Define the instrumented engine.
  58899. */
  58900. engine: Engine;
  58901. private _captureGPUFrameTime;
  58902. private _gpuFrameTimeToken;
  58903. private _gpuFrameTime;
  58904. private _captureShaderCompilationTime;
  58905. private _shaderCompilationTime;
  58906. private _onBeginFrameObserver;
  58907. private _onEndFrameObserver;
  58908. private _onBeforeShaderCompilationObserver;
  58909. private _onAfterShaderCompilationObserver;
  58910. /**
  58911. * Gets the perf counter used for GPU frame time
  58912. */
  58913. get gpuFrameTimeCounter(): PerfCounter;
  58914. /**
  58915. * Gets the GPU frame time capture status
  58916. */
  58917. get captureGPUFrameTime(): boolean;
  58918. /**
  58919. * Enable or disable the GPU frame time capture
  58920. */
  58921. set captureGPUFrameTime(value: boolean);
  58922. /**
  58923. * Gets the perf counter used for shader compilation time
  58924. */
  58925. get shaderCompilationTimeCounter(): PerfCounter;
  58926. /**
  58927. * Gets the shader compilation time capture status
  58928. */
  58929. get captureShaderCompilationTime(): boolean;
  58930. /**
  58931. * Enable or disable the shader compilation time capture
  58932. */
  58933. set captureShaderCompilationTime(value: boolean);
  58934. /**
  58935. * Instantiates a new engine instrumentation.
  58936. * This class can be used to get instrumentation data from a Babylon engine
  58937. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58938. * @param engine Defines the engine to instrument
  58939. */
  58940. constructor(
  58941. /**
  58942. * Define the instrumented engine.
  58943. */
  58944. engine: Engine);
  58945. /**
  58946. * Dispose and release associated resources.
  58947. */
  58948. dispose(): void;
  58949. }
  58950. }
  58951. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  58952. import { Scene, IDisposable } from "babylonjs/scene";
  58953. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  58954. /**
  58955. * This class can be used to get instrumentation data from a Babylon engine
  58956. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58957. */
  58958. export class SceneInstrumentation implements IDisposable {
  58959. /**
  58960. * Defines the scene to instrument
  58961. */
  58962. scene: Scene;
  58963. private _captureActiveMeshesEvaluationTime;
  58964. private _activeMeshesEvaluationTime;
  58965. private _captureRenderTargetsRenderTime;
  58966. private _renderTargetsRenderTime;
  58967. private _captureFrameTime;
  58968. private _frameTime;
  58969. private _captureRenderTime;
  58970. private _renderTime;
  58971. private _captureInterFrameTime;
  58972. private _interFrameTime;
  58973. private _captureParticlesRenderTime;
  58974. private _particlesRenderTime;
  58975. private _captureSpritesRenderTime;
  58976. private _spritesRenderTime;
  58977. private _capturePhysicsTime;
  58978. private _physicsTime;
  58979. private _captureAnimationsTime;
  58980. private _animationsTime;
  58981. private _captureCameraRenderTime;
  58982. private _cameraRenderTime;
  58983. private _onBeforeActiveMeshesEvaluationObserver;
  58984. private _onAfterActiveMeshesEvaluationObserver;
  58985. private _onBeforeRenderTargetsRenderObserver;
  58986. private _onAfterRenderTargetsRenderObserver;
  58987. private _onAfterRenderObserver;
  58988. private _onBeforeDrawPhaseObserver;
  58989. private _onAfterDrawPhaseObserver;
  58990. private _onBeforeAnimationsObserver;
  58991. private _onBeforeParticlesRenderingObserver;
  58992. private _onAfterParticlesRenderingObserver;
  58993. private _onBeforeSpritesRenderingObserver;
  58994. private _onAfterSpritesRenderingObserver;
  58995. private _onBeforePhysicsObserver;
  58996. private _onAfterPhysicsObserver;
  58997. private _onAfterAnimationsObserver;
  58998. private _onBeforeCameraRenderObserver;
  58999. private _onAfterCameraRenderObserver;
  59000. /**
  59001. * Gets the perf counter used for active meshes evaluation time
  59002. */
  59003. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59004. /**
  59005. * Gets the active meshes evaluation time capture status
  59006. */
  59007. get captureActiveMeshesEvaluationTime(): boolean;
  59008. /**
  59009. * Enable or disable the active meshes evaluation time capture
  59010. */
  59011. set captureActiveMeshesEvaluationTime(value: boolean);
  59012. /**
  59013. * Gets the perf counter used for render targets render time
  59014. */
  59015. get renderTargetsRenderTimeCounter(): PerfCounter;
  59016. /**
  59017. * Gets the render targets render time capture status
  59018. */
  59019. get captureRenderTargetsRenderTime(): boolean;
  59020. /**
  59021. * Enable or disable the render targets render time capture
  59022. */
  59023. set captureRenderTargetsRenderTime(value: boolean);
  59024. /**
  59025. * Gets the perf counter used for particles render time
  59026. */
  59027. get particlesRenderTimeCounter(): PerfCounter;
  59028. /**
  59029. * Gets the particles render time capture status
  59030. */
  59031. get captureParticlesRenderTime(): boolean;
  59032. /**
  59033. * Enable or disable the particles render time capture
  59034. */
  59035. set captureParticlesRenderTime(value: boolean);
  59036. /**
  59037. * Gets the perf counter used for sprites render time
  59038. */
  59039. get spritesRenderTimeCounter(): PerfCounter;
  59040. /**
  59041. * Gets the sprites render time capture status
  59042. */
  59043. get captureSpritesRenderTime(): boolean;
  59044. /**
  59045. * Enable or disable the sprites render time capture
  59046. */
  59047. set captureSpritesRenderTime(value: boolean);
  59048. /**
  59049. * Gets the perf counter used for physics time
  59050. */
  59051. get physicsTimeCounter(): PerfCounter;
  59052. /**
  59053. * Gets the physics time capture status
  59054. */
  59055. get capturePhysicsTime(): boolean;
  59056. /**
  59057. * Enable or disable the physics time capture
  59058. */
  59059. set capturePhysicsTime(value: boolean);
  59060. /**
  59061. * Gets the perf counter used for animations time
  59062. */
  59063. get animationsTimeCounter(): PerfCounter;
  59064. /**
  59065. * Gets the animations time capture status
  59066. */
  59067. get captureAnimationsTime(): boolean;
  59068. /**
  59069. * Enable or disable the animations time capture
  59070. */
  59071. set captureAnimationsTime(value: boolean);
  59072. /**
  59073. * Gets the perf counter used for frame time capture
  59074. */
  59075. get frameTimeCounter(): PerfCounter;
  59076. /**
  59077. * Gets the frame time capture status
  59078. */
  59079. get captureFrameTime(): boolean;
  59080. /**
  59081. * Enable or disable the frame time capture
  59082. */
  59083. set captureFrameTime(value: boolean);
  59084. /**
  59085. * Gets the perf counter used for inter-frames time capture
  59086. */
  59087. get interFrameTimeCounter(): PerfCounter;
  59088. /**
  59089. * Gets the inter-frames time capture status
  59090. */
  59091. get captureInterFrameTime(): boolean;
  59092. /**
  59093. * Enable or disable the inter-frames time capture
  59094. */
  59095. set captureInterFrameTime(value: boolean);
  59096. /**
  59097. * Gets the perf counter used for render time capture
  59098. */
  59099. get renderTimeCounter(): PerfCounter;
  59100. /**
  59101. * Gets the render time capture status
  59102. */
  59103. get captureRenderTime(): boolean;
  59104. /**
  59105. * Enable or disable the render time capture
  59106. */
  59107. set captureRenderTime(value: boolean);
  59108. /**
  59109. * Gets the perf counter used for camera render time capture
  59110. */
  59111. get cameraRenderTimeCounter(): PerfCounter;
  59112. /**
  59113. * Gets the camera render time capture status
  59114. */
  59115. get captureCameraRenderTime(): boolean;
  59116. /**
  59117. * Enable or disable the camera render time capture
  59118. */
  59119. set captureCameraRenderTime(value: boolean);
  59120. /**
  59121. * Gets the perf counter used for draw calls
  59122. */
  59123. get drawCallsCounter(): PerfCounter;
  59124. /**
  59125. * Instantiates a new scene instrumentation.
  59126. * This class can be used to get instrumentation data from a Babylon engine
  59127. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59128. * @param scene Defines the scene to instrument
  59129. */
  59130. constructor(
  59131. /**
  59132. * Defines the scene to instrument
  59133. */
  59134. scene: Scene);
  59135. /**
  59136. * Dispose and release associated resources.
  59137. */
  59138. dispose(): void;
  59139. }
  59140. }
  59141. declare module "babylonjs/Instrumentation/index" {
  59142. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59143. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59144. export * from "babylonjs/Instrumentation/timeToken";
  59145. }
  59146. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59147. /** @hidden */
  59148. export var glowMapGenerationPixelShader: {
  59149. name: string;
  59150. shader: string;
  59151. };
  59152. }
  59153. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59154. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59155. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59156. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59157. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59158. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59159. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59160. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59161. /** @hidden */
  59162. export var glowMapGenerationVertexShader: {
  59163. name: string;
  59164. shader: string;
  59165. };
  59166. }
  59167. declare module "babylonjs/Layers/effectLayer" {
  59168. import { Observable } from "babylonjs/Misc/observable";
  59169. import { Nullable } from "babylonjs/types";
  59170. import { Camera } from "babylonjs/Cameras/camera";
  59171. import { Scene } from "babylonjs/scene";
  59172. import { ISize } from "babylonjs/Maths/math.size";
  59173. import { Color4 } from "babylonjs/Maths/math.color";
  59174. import { Engine } from "babylonjs/Engines/engine";
  59175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59177. import { Mesh } from "babylonjs/Meshes/mesh";
  59178. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59181. import { Effect } from "babylonjs/Materials/effect";
  59182. import { Material } from "babylonjs/Materials/material";
  59183. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59184. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59185. /**
  59186. * Effect layer options. This helps customizing the behaviour
  59187. * of the effect layer.
  59188. */
  59189. export interface IEffectLayerOptions {
  59190. /**
  59191. * Multiplication factor apply to the canvas size to compute the render target size
  59192. * used to generated the objects (the smaller the faster).
  59193. */
  59194. mainTextureRatio: number;
  59195. /**
  59196. * Enforces a fixed size texture to ensure effect stability across devices.
  59197. */
  59198. mainTextureFixedSize?: number;
  59199. /**
  59200. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59201. */
  59202. alphaBlendingMode: number;
  59203. /**
  59204. * The camera attached to the layer.
  59205. */
  59206. camera: Nullable<Camera>;
  59207. /**
  59208. * The rendering group to draw the layer in.
  59209. */
  59210. renderingGroupId: number;
  59211. }
  59212. /**
  59213. * The effect layer Helps adding post process effect blended with the main pass.
  59214. *
  59215. * This can be for instance use to generate glow or higlight effects on the scene.
  59216. *
  59217. * The effect layer class can not be used directly and is intented to inherited from to be
  59218. * customized per effects.
  59219. */
  59220. export abstract class EffectLayer {
  59221. private _vertexBuffers;
  59222. private _indexBuffer;
  59223. private _cachedDefines;
  59224. private _effectLayerMapGenerationEffect;
  59225. private _effectLayerOptions;
  59226. private _mergeEffect;
  59227. protected _scene: Scene;
  59228. protected _engine: Engine;
  59229. protected _maxSize: number;
  59230. protected _mainTextureDesiredSize: ISize;
  59231. protected _mainTexture: RenderTargetTexture;
  59232. protected _shouldRender: boolean;
  59233. protected _postProcesses: PostProcess[];
  59234. protected _textures: BaseTexture[];
  59235. protected _emissiveTextureAndColor: {
  59236. texture: Nullable<BaseTexture>;
  59237. color: Color4;
  59238. };
  59239. /**
  59240. * The name of the layer
  59241. */
  59242. name: string;
  59243. /**
  59244. * The clear color of the texture used to generate the glow map.
  59245. */
  59246. neutralColor: Color4;
  59247. /**
  59248. * Specifies whether the highlight layer is enabled or not.
  59249. */
  59250. isEnabled: boolean;
  59251. /**
  59252. * Gets the camera attached to the layer.
  59253. */
  59254. get camera(): Nullable<Camera>;
  59255. /**
  59256. * Gets the rendering group id the layer should render in.
  59257. */
  59258. get renderingGroupId(): number;
  59259. set renderingGroupId(renderingGroupId: number);
  59260. /**
  59261. * An event triggered when the effect layer has been disposed.
  59262. */
  59263. onDisposeObservable: Observable<EffectLayer>;
  59264. /**
  59265. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59266. */
  59267. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59268. /**
  59269. * An event triggered when the generated texture is being merged in the scene.
  59270. */
  59271. onBeforeComposeObservable: Observable<EffectLayer>;
  59272. /**
  59273. * An event triggered when the mesh is rendered into the effect render target.
  59274. */
  59275. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59276. /**
  59277. * An event triggered after the mesh has been rendered into the effect render target.
  59278. */
  59279. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59280. /**
  59281. * An event triggered when the generated texture has been merged in the scene.
  59282. */
  59283. onAfterComposeObservable: Observable<EffectLayer>;
  59284. /**
  59285. * An event triggered when the efffect layer changes its size.
  59286. */
  59287. onSizeChangedObservable: Observable<EffectLayer>;
  59288. /** @hidden */
  59289. static _SceneComponentInitialization: (scene: Scene) => void;
  59290. /**
  59291. * Instantiates a new effect Layer and references it in the scene.
  59292. * @param name The name of the layer
  59293. * @param scene The scene to use the layer in
  59294. */
  59295. constructor(
  59296. /** The Friendly of the effect in the scene */
  59297. name: string, scene: Scene);
  59298. /**
  59299. * Get the effect name of the layer.
  59300. * @return The effect name
  59301. */
  59302. abstract getEffectName(): string;
  59303. /**
  59304. * Checks for the readiness of the element composing the layer.
  59305. * @param subMesh the mesh to check for
  59306. * @param useInstances specify whether or not to use instances to render the mesh
  59307. * @return true if ready otherwise, false
  59308. */
  59309. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59310. /**
  59311. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59312. * @returns true if the effect requires stencil during the main canvas render pass.
  59313. */
  59314. abstract needStencil(): boolean;
  59315. /**
  59316. * Create the merge effect. This is the shader use to blit the information back
  59317. * to the main canvas at the end of the scene rendering.
  59318. * @returns The effect containing the shader used to merge the effect on the main canvas
  59319. */
  59320. protected abstract _createMergeEffect(): Effect;
  59321. /**
  59322. * Creates the render target textures and post processes used in the effect layer.
  59323. */
  59324. protected abstract _createTextureAndPostProcesses(): void;
  59325. /**
  59326. * Implementation specific of rendering the generating effect on the main canvas.
  59327. * @param effect The effect used to render through
  59328. */
  59329. protected abstract _internalRender(effect: Effect): void;
  59330. /**
  59331. * Sets the required values for both the emissive texture and and the main color.
  59332. */
  59333. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59334. /**
  59335. * Free any resources and references associated to a mesh.
  59336. * Internal use
  59337. * @param mesh The mesh to free.
  59338. */
  59339. abstract _disposeMesh(mesh: Mesh): void;
  59340. /**
  59341. * Serializes this layer (Glow or Highlight for example)
  59342. * @returns a serialized layer object
  59343. */
  59344. abstract serialize?(): any;
  59345. /**
  59346. * Initializes the effect layer with the required options.
  59347. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59348. */
  59349. protected _init(options: Partial<IEffectLayerOptions>): void;
  59350. /**
  59351. * Generates the index buffer of the full screen quad blending to the main canvas.
  59352. */
  59353. private _generateIndexBuffer;
  59354. /**
  59355. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59356. */
  59357. private _generateVertexBuffer;
  59358. /**
  59359. * Sets the main texture desired size which is the closest power of two
  59360. * of the engine canvas size.
  59361. */
  59362. private _setMainTextureSize;
  59363. /**
  59364. * Creates the main texture for the effect layer.
  59365. */
  59366. protected _createMainTexture(): void;
  59367. /**
  59368. * Adds specific effects defines.
  59369. * @param defines The defines to add specifics to.
  59370. */
  59371. protected _addCustomEffectDefines(defines: string[]): void;
  59372. /**
  59373. * Checks for the readiness of the element composing the layer.
  59374. * @param subMesh the mesh to check for
  59375. * @param useInstances specify whether or not to use instances to render the mesh
  59376. * @param emissiveTexture the associated emissive texture used to generate the glow
  59377. * @return true if ready otherwise, false
  59378. */
  59379. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59380. /**
  59381. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59382. */
  59383. render(): void;
  59384. /**
  59385. * Determine if a given mesh will be used in the current effect.
  59386. * @param mesh mesh to test
  59387. * @returns true if the mesh will be used
  59388. */
  59389. hasMesh(mesh: AbstractMesh): boolean;
  59390. /**
  59391. * Returns true if the layer contains information to display, otherwise false.
  59392. * @returns true if the glow layer should be rendered
  59393. */
  59394. shouldRender(): boolean;
  59395. /**
  59396. * Returns true if the mesh should render, otherwise false.
  59397. * @param mesh The mesh to render
  59398. * @returns true if it should render otherwise false
  59399. */
  59400. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59401. /**
  59402. * Returns true if the mesh can be rendered, otherwise false.
  59403. * @param mesh The mesh to render
  59404. * @param material The material used on the mesh
  59405. * @returns true if it can be rendered otherwise false
  59406. */
  59407. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59408. /**
  59409. * Returns true if the mesh should render, otherwise false.
  59410. * @param mesh The mesh to render
  59411. * @returns true if it should render otherwise false
  59412. */
  59413. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59414. /**
  59415. * Renders the submesh passed in parameter to the generation map.
  59416. */
  59417. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59418. /**
  59419. * Defines whether the current material of the mesh should be use to render the effect.
  59420. * @param mesh defines the current mesh to render
  59421. */
  59422. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59423. /**
  59424. * Rebuild the required buffers.
  59425. * @hidden Internal use only.
  59426. */
  59427. _rebuild(): void;
  59428. /**
  59429. * Dispose only the render target textures and post process.
  59430. */
  59431. private _disposeTextureAndPostProcesses;
  59432. /**
  59433. * Dispose the highlight layer and free resources.
  59434. */
  59435. dispose(): void;
  59436. /**
  59437. * Gets the class name of the effect layer
  59438. * @returns the string with the class name of the effect layer
  59439. */
  59440. getClassName(): string;
  59441. /**
  59442. * Creates an effect layer from parsed effect layer data
  59443. * @param parsedEffectLayer defines effect layer data
  59444. * @param scene defines the current scene
  59445. * @param rootUrl defines the root URL containing the effect layer information
  59446. * @returns a parsed effect Layer
  59447. */
  59448. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59449. }
  59450. }
  59451. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59452. import { Scene } from "babylonjs/scene";
  59453. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59454. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59455. import { AbstractScene } from "babylonjs/abstractScene";
  59456. module "babylonjs/abstractScene" {
  59457. interface AbstractScene {
  59458. /**
  59459. * The list of effect layers (highlights/glow) added to the scene
  59460. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59461. * @see http://doc.babylonjs.com/how_to/glow_layer
  59462. */
  59463. effectLayers: Array<EffectLayer>;
  59464. /**
  59465. * Removes the given effect layer from this scene.
  59466. * @param toRemove defines the effect layer to remove
  59467. * @returns the index of the removed effect layer
  59468. */
  59469. removeEffectLayer(toRemove: EffectLayer): number;
  59470. /**
  59471. * Adds the given effect layer to this scene
  59472. * @param newEffectLayer defines the effect layer to add
  59473. */
  59474. addEffectLayer(newEffectLayer: EffectLayer): void;
  59475. }
  59476. }
  59477. /**
  59478. * Defines the layer scene component responsible to manage any effect layers
  59479. * in a given scene.
  59480. */
  59481. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59482. /**
  59483. * The component name helpfull to identify the component in the list of scene components.
  59484. */
  59485. readonly name: string;
  59486. /**
  59487. * The scene the component belongs to.
  59488. */
  59489. scene: Scene;
  59490. private _engine;
  59491. private _renderEffects;
  59492. private _needStencil;
  59493. private _previousStencilState;
  59494. /**
  59495. * Creates a new instance of the component for the given scene
  59496. * @param scene Defines the scene to register the component in
  59497. */
  59498. constructor(scene: Scene);
  59499. /**
  59500. * Registers the component in a given scene
  59501. */
  59502. register(): void;
  59503. /**
  59504. * Rebuilds the elements related to this component in case of
  59505. * context lost for instance.
  59506. */
  59507. rebuild(): void;
  59508. /**
  59509. * Serializes the component data to the specified json object
  59510. * @param serializationObject The object to serialize to
  59511. */
  59512. serialize(serializationObject: any): void;
  59513. /**
  59514. * Adds all the elements from the container to the scene
  59515. * @param container the container holding the elements
  59516. */
  59517. addFromContainer(container: AbstractScene): void;
  59518. /**
  59519. * Removes all the elements in the container from the scene
  59520. * @param container contains the elements to remove
  59521. * @param dispose if the removed element should be disposed (default: false)
  59522. */
  59523. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59524. /**
  59525. * Disposes the component and the associated ressources.
  59526. */
  59527. dispose(): void;
  59528. private _isReadyForMesh;
  59529. private _renderMainTexture;
  59530. private _setStencil;
  59531. private _setStencilBack;
  59532. private _draw;
  59533. private _drawCamera;
  59534. private _drawRenderingGroup;
  59535. }
  59536. }
  59537. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59538. /** @hidden */
  59539. export var glowMapMergePixelShader: {
  59540. name: string;
  59541. shader: string;
  59542. };
  59543. }
  59544. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59545. /** @hidden */
  59546. export var glowMapMergeVertexShader: {
  59547. name: string;
  59548. shader: string;
  59549. };
  59550. }
  59551. declare module "babylonjs/Layers/glowLayer" {
  59552. import { Nullable } from "babylonjs/types";
  59553. import { Camera } from "babylonjs/Cameras/camera";
  59554. import { Scene } from "babylonjs/scene";
  59555. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59557. import { Mesh } from "babylonjs/Meshes/mesh";
  59558. import { Texture } from "babylonjs/Materials/Textures/texture";
  59559. import { Effect } from "babylonjs/Materials/effect";
  59560. import { Material } from "babylonjs/Materials/material";
  59561. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59562. import { Color4 } from "babylonjs/Maths/math.color";
  59563. import "babylonjs/Shaders/glowMapMerge.fragment";
  59564. import "babylonjs/Shaders/glowMapMerge.vertex";
  59565. import "babylonjs/Layers/effectLayerSceneComponent";
  59566. module "babylonjs/abstractScene" {
  59567. interface AbstractScene {
  59568. /**
  59569. * Return a the first highlight layer of the scene with a given name.
  59570. * @param name The name of the highlight layer to look for.
  59571. * @return The highlight layer if found otherwise null.
  59572. */
  59573. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59574. }
  59575. }
  59576. /**
  59577. * Glow layer options. This helps customizing the behaviour
  59578. * of the glow layer.
  59579. */
  59580. export interface IGlowLayerOptions {
  59581. /**
  59582. * Multiplication factor apply to the canvas size to compute the render target size
  59583. * used to generated the glowing objects (the smaller the faster).
  59584. */
  59585. mainTextureRatio: number;
  59586. /**
  59587. * Enforces a fixed size texture to ensure resize independant blur.
  59588. */
  59589. mainTextureFixedSize?: number;
  59590. /**
  59591. * How big is the kernel of the blur texture.
  59592. */
  59593. blurKernelSize: number;
  59594. /**
  59595. * The camera attached to the layer.
  59596. */
  59597. camera: Nullable<Camera>;
  59598. /**
  59599. * Enable MSAA by chosing the number of samples.
  59600. */
  59601. mainTextureSamples?: number;
  59602. /**
  59603. * The rendering group to draw the layer in.
  59604. */
  59605. renderingGroupId: number;
  59606. }
  59607. /**
  59608. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59609. *
  59610. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59611. *
  59612. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59613. */
  59614. export class GlowLayer extends EffectLayer {
  59615. /**
  59616. * Effect Name of the layer.
  59617. */
  59618. static readonly EffectName: string;
  59619. /**
  59620. * The default blur kernel size used for the glow.
  59621. */
  59622. static DefaultBlurKernelSize: number;
  59623. /**
  59624. * The default texture size ratio used for the glow.
  59625. */
  59626. static DefaultTextureRatio: number;
  59627. /**
  59628. * Sets the kernel size of the blur.
  59629. */
  59630. set blurKernelSize(value: number);
  59631. /**
  59632. * Gets the kernel size of the blur.
  59633. */
  59634. get blurKernelSize(): number;
  59635. /**
  59636. * Sets the glow intensity.
  59637. */
  59638. set intensity(value: number);
  59639. /**
  59640. * Gets the glow intensity.
  59641. */
  59642. get intensity(): number;
  59643. private _options;
  59644. private _intensity;
  59645. private _horizontalBlurPostprocess1;
  59646. private _verticalBlurPostprocess1;
  59647. private _horizontalBlurPostprocess2;
  59648. private _verticalBlurPostprocess2;
  59649. private _blurTexture1;
  59650. private _blurTexture2;
  59651. private _postProcesses1;
  59652. private _postProcesses2;
  59653. private _includedOnlyMeshes;
  59654. private _excludedMeshes;
  59655. private _meshesUsingTheirOwnMaterials;
  59656. /**
  59657. * Callback used to let the user override the color selection on a per mesh basis
  59658. */
  59659. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59660. /**
  59661. * Callback used to let the user override the texture selection on a per mesh basis
  59662. */
  59663. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59664. /**
  59665. * Instantiates a new glow Layer and references it to the scene.
  59666. * @param name The name of the layer
  59667. * @param scene The scene to use the layer in
  59668. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59669. */
  59670. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59671. /**
  59672. * Get the effect name of the layer.
  59673. * @return The effect name
  59674. */
  59675. getEffectName(): string;
  59676. /**
  59677. * Create the merge effect. This is the shader use to blit the information back
  59678. * to the main canvas at the end of the scene rendering.
  59679. */
  59680. protected _createMergeEffect(): Effect;
  59681. /**
  59682. * Creates the render target textures and post processes used in the glow layer.
  59683. */
  59684. protected _createTextureAndPostProcesses(): void;
  59685. /**
  59686. * Checks for the readiness of the element composing the layer.
  59687. * @param subMesh the mesh to check for
  59688. * @param useInstances specify wether or not to use instances to render the mesh
  59689. * @param emissiveTexture the associated emissive texture used to generate the glow
  59690. * @return true if ready otherwise, false
  59691. */
  59692. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59693. /**
  59694. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59695. */
  59696. needStencil(): boolean;
  59697. /**
  59698. * Returns true if the mesh can be rendered, otherwise false.
  59699. * @param mesh The mesh to render
  59700. * @param material The material used on the mesh
  59701. * @returns true if it can be rendered otherwise false
  59702. */
  59703. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59704. /**
  59705. * Implementation specific of rendering the generating effect on the main canvas.
  59706. * @param effect The effect used to render through
  59707. */
  59708. protected _internalRender(effect: Effect): void;
  59709. /**
  59710. * Sets the required values for both the emissive texture and and the main color.
  59711. */
  59712. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59713. /**
  59714. * Returns true if the mesh should render, otherwise false.
  59715. * @param mesh The mesh to render
  59716. * @returns true if it should render otherwise false
  59717. */
  59718. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59719. /**
  59720. * Adds specific effects defines.
  59721. * @param defines The defines to add specifics to.
  59722. */
  59723. protected _addCustomEffectDefines(defines: string[]): void;
  59724. /**
  59725. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59726. * @param mesh The mesh to exclude from the glow layer
  59727. */
  59728. addExcludedMesh(mesh: Mesh): void;
  59729. /**
  59730. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59731. * @param mesh The mesh to remove
  59732. */
  59733. removeExcludedMesh(mesh: Mesh): void;
  59734. /**
  59735. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59736. * @param mesh The mesh to include in the glow layer
  59737. */
  59738. addIncludedOnlyMesh(mesh: Mesh): void;
  59739. /**
  59740. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59741. * @param mesh The mesh to remove
  59742. */
  59743. removeIncludedOnlyMesh(mesh: Mesh): void;
  59744. /**
  59745. * Determine if a given mesh will be used in the glow layer
  59746. * @param mesh The mesh to test
  59747. * @returns true if the mesh will be highlighted by the current glow layer
  59748. */
  59749. hasMesh(mesh: AbstractMesh): boolean;
  59750. /**
  59751. * Defines whether the current material of the mesh should be use to render the effect.
  59752. * @param mesh defines the current mesh to render
  59753. */
  59754. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59755. /**
  59756. * Add a mesh to be rendered through its own material and not with emissive only.
  59757. * @param mesh The mesh for which we need to use its material
  59758. */
  59759. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59760. /**
  59761. * Remove a mesh from being rendered through its own material and not with emissive only.
  59762. * @param mesh The mesh for which we need to not use its material
  59763. */
  59764. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59765. /**
  59766. * Free any resources and references associated to a mesh.
  59767. * Internal use
  59768. * @param mesh The mesh to free.
  59769. * @hidden
  59770. */
  59771. _disposeMesh(mesh: Mesh): void;
  59772. /**
  59773. * Gets the class name of the effect layer
  59774. * @returns the string with the class name of the effect layer
  59775. */
  59776. getClassName(): string;
  59777. /**
  59778. * Serializes this glow layer
  59779. * @returns a serialized glow layer object
  59780. */
  59781. serialize(): any;
  59782. /**
  59783. * Creates a Glow Layer from parsed glow layer data
  59784. * @param parsedGlowLayer defines glow layer data
  59785. * @param scene defines the current scene
  59786. * @param rootUrl defines the root URL containing the glow layer information
  59787. * @returns a parsed Glow Layer
  59788. */
  59789. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59790. }
  59791. }
  59792. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59793. /** @hidden */
  59794. export var glowBlurPostProcessPixelShader: {
  59795. name: string;
  59796. shader: string;
  59797. };
  59798. }
  59799. declare module "babylonjs/Layers/highlightLayer" {
  59800. import { Observable } from "babylonjs/Misc/observable";
  59801. import { Nullable } from "babylonjs/types";
  59802. import { Camera } from "babylonjs/Cameras/camera";
  59803. import { Scene } from "babylonjs/scene";
  59804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59806. import { Mesh } from "babylonjs/Meshes/mesh";
  59807. import { Effect } from "babylonjs/Materials/effect";
  59808. import { Material } from "babylonjs/Materials/material";
  59809. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59810. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59811. import "babylonjs/Shaders/glowMapMerge.fragment";
  59812. import "babylonjs/Shaders/glowMapMerge.vertex";
  59813. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59814. module "babylonjs/abstractScene" {
  59815. interface AbstractScene {
  59816. /**
  59817. * Return a the first highlight layer of the scene with a given name.
  59818. * @param name The name of the highlight layer to look for.
  59819. * @return The highlight layer if found otherwise null.
  59820. */
  59821. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59822. }
  59823. }
  59824. /**
  59825. * Highlight layer options. This helps customizing the behaviour
  59826. * of the highlight layer.
  59827. */
  59828. export interface IHighlightLayerOptions {
  59829. /**
  59830. * Multiplication factor apply to the canvas size to compute the render target size
  59831. * used to generated the glowing objects (the smaller the faster).
  59832. */
  59833. mainTextureRatio: number;
  59834. /**
  59835. * Enforces a fixed size texture to ensure resize independant blur.
  59836. */
  59837. mainTextureFixedSize?: number;
  59838. /**
  59839. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59840. * of the picture to blur (the smaller the faster).
  59841. */
  59842. blurTextureSizeRatio: number;
  59843. /**
  59844. * How big in texel of the blur texture is the vertical blur.
  59845. */
  59846. blurVerticalSize: number;
  59847. /**
  59848. * How big in texel of the blur texture is the horizontal blur.
  59849. */
  59850. blurHorizontalSize: number;
  59851. /**
  59852. * Alpha blending mode used to apply the blur. Default is combine.
  59853. */
  59854. alphaBlendingMode: number;
  59855. /**
  59856. * The camera attached to the layer.
  59857. */
  59858. camera: Nullable<Camera>;
  59859. /**
  59860. * Should we display highlight as a solid stroke?
  59861. */
  59862. isStroke?: boolean;
  59863. /**
  59864. * The rendering group to draw the layer in.
  59865. */
  59866. renderingGroupId: number;
  59867. }
  59868. /**
  59869. * The highlight layer Helps adding a glow effect around a mesh.
  59870. *
  59871. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59872. * glowy meshes to your scene.
  59873. *
  59874. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59875. */
  59876. export class HighlightLayer extends EffectLayer {
  59877. name: string;
  59878. /**
  59879. * Effect Name of the highlight layer.
  59880. */
  59881. static readonly EffectName: string;
  59882. /**
  59883. * The neutral color used during the preparation of the glow effect.
  59884. * This is black by default as the blend operation is a blend operation.
  59885. */
  59886. static NeutralColor: Color4;
  59887. /**
  59888. * Stencil value used for glowing meshes.
  59889. */
  59890. static GlowingMeshStencilReference: number;
  59891. /**
  59892. * Stencil value used for the other meshes in the scene.
  59893. */
  59894. static NormalMeshStencilReference: number;
  59895. /**
  59896. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59897. */
  59898. innerGlow: boolean;
  59899. /**
  59900. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59901. */
  59902. outerGlow: boolean;
  59903. /**
  59904. * Specifies the horizontal size of the blur.
  59905. */
  59906. set blurHorizontalSize(value: number);
  59907. /**
  59908. * Specifies the vertical size of the blur.
  59909. */
  59910. set blurVerticalSize(value: number);
  59911. /**
  59912. * Gets the horizontal size of the blur.
  59913. */
  59914. get blurHorizontalSize(): number;
  59915. /**
  59916. * Gets the vertical size of the blur.
  59917. */
  59918. get blurVerticalSize(): number;
  59919. /**
  59920. * An event triggered when the highlight layer is being blurred.
  59921. */
  59922. onBeforeBlurObservable: Observable<HighlightLayer>;
  59923. /**
  59924. * An event triggered when the highlight layer has been blurred.
  59925. */
  59926. onAfterBlurObservable: Observable<HighlightLayer>;
  59927. private _instanceGlowingMeshStencilReference;
  59928. private _options;
  59929. private _downSamplePostprocess;
  59930. private _horizontalBlurPostprocess;
  59931. private _verticalBlurPostprocess;
  59932. private _blurTexture;
  59933. private _meshes;
  59934. private _excludedMeshes;
  59935. /**
  59936. * Instantiates a new highlight Layer and references it to the scene..
  59937. * @param name The name of the layer
  59938. * @param scene The scene to use the layer in
  59939. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59940. */
  59941. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59942. /**
  59943. * Get the effect name of the layer.
  59944. * @return The effect name
  59945. */
  59946. getEffectName(): string;
  59947. /**
  59948. * Create the merge effect. This is the shader use to blit the information back
  59949. * to the main canvas at the end of the scene rendering.
  59950. */
  59951. protected _createMergeEffect(): Effect;
  59952. /**
  59953. * Creates the render target textures and post processes used in the highlight layer.
  59954. */
  59955. protected _createTextureAndPostProcesses(): void;
  59956. /**
  59957. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59958. */
  59959. needStencil(): boolean;
  59960. /**
  59961. * Checks for the readiness of the element composing the layer.
  59962. * @param subMesh the mesh to check for
  59963. * @param useInstances specify wether or not to use instances to render the mesh
  59964. * @param emissiveTexture the associated emissive texture used to generate the glow
  59965. * @return true if ready otherwise, false
  59966. */
  59967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59968. /**
  59969. * Implementation specific of rendering the generating effect on the main canvas.
  59970. * @param effect The effect used to render through
  59971. */
  59972. protected _internalRender(effect: Effect): void;
  59973. /**
  59974. * Returns true if the layer contains information to display, otherwise false.
  59975. */
  59976. shouldRender(): boolean;
  59977. /**
  59978. * Returns true if the mesh should render, otherwise false.
  59979. * @param mesh The mesh to render
  59980. * @returns true if it should render otherwise false
  59981. */
  59982. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59983. /**
  59984. * Adds specific effects defines.
  59985. * @param defines The defines to add specifics to.
  59986. */
  59987. protected _addCustomEffectDefines(defines: string[]): void;
  59988. /**
  59989. * Sets the required values for both the emissive texture and and the main color.
  59990. */
  59991. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59992. /**
  59993. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59994. * @param mesh The mesh to exclude from the highlight layer
  59995. */
  59996. addExcludedMesh(mesh: Mesh): void;
  59997. /**
  59998. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59999. * @param mesh The mesh to highlight
  60000. */
  60001. removeExcludedMesh(mesh: Mesh): void;
  60002. /**
  60003. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60004. * @param mesh mesh to test
  60005. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60006. */
  60007. hasMesh(mesh: AbstractMesh): boolean;
  60008. /**
  60009. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60010. * @param mesh The mesh to highlight
  60011. * @param color The color of the highlight
  60012. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60013. */
  60014. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60015. /**
  60016. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60017. * @param mesh The mesh to highlight
  60018. */
  60019. removeMesh(mesh: Mesh): void;
  60020. /**
  60021. * Remove all the meshes currently referenced in the highlight layer
  60022. */
  60023. removeAllMeshes(): void;
  60024. /**
  60025. * Force the stencil to the normal expected value for none glowing parts
  60026. */
  60027. private _defaultStencilReference;
  60028. /**
  60029. * Free any resources and references associated to a mesh.
  60030. * Internal use
  60031. * @param mesh The mesh to free.
  60032. * @hidden
  60033. */
  60034. _disposeMesh(mesh: Mesh): void;
  60035. /**
  60036. * Dispose the highlight layer and free resources.
  60037. */
  60038. dispose(): void;
  60039. /**
  60040. * Gets the class name of the effect layer
  60041. * @returns the string with the class name of the effect layer
  60042. */
  60043. getClassName(): string;
  60044. /**
  60045. * Serializes this Highlight layer
  60046. * @returns a serialized Highlight layer object
  60047. */
  60048. serialize(): any;
  60049. /**
  60050. * Creates a Highlight layer from parsed Highlight layer data
  60051. * @param parsedHightlightLayer defines the Highlight layer data
  60052. * @param scene defines the current scene
  60053. * @param rootUrl defines the root URL containing the Highlight layer information
  60054. * @returns a parsed Highlight layer
  60055. */
  60056. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60057. }
  60058. }
  60059. declare module "babylonjs/Layers/layerSceneComponent" {
  60060. import { Scene } from "babylonjs/scene";
  60061. import { ISceneComponent } from "babylonjs/sceneComponent";
  60062. import { Layer } from "babylonjs/Layers/layer";
  60063. import { AbstractScene } from "babylonjs/abstractScene";
  60064. module "babylonjs/abstractScene" {
  60065. interface AbstractScene {
  60066. /**
  60067. * The list of layers (background and foreground) of the scene
  60068. */
  60069. layers: Array<Layer>;
  60070. }
  60071. }
  60072. /**
  60073. * Defines the layer scene component responsible to manage any layers
  60074. * in a given scene.
  60075. */
  60076. export class LayerSceneComponent implements ISceneComponent {
  60077. /**
  60078. * The component name helpfull to identify the component in the list of scene components.
  60079. */
  60080. readonly name: string;
  60081. /**
  60082. * The scene the component belongs to.
  60083. */
  60084. scene: Scene;
  60085. private _engine;
  60086. /**
  60087. * Creates a new instance of the component for the given scene
  60088. * @param scene Defines the scene to register the component in
  60089. */
  60090. constructor(scene: Scene);
  60091. /**
  60092. * Registers the component in a given scene
  60093. */
  60094. register(): void;
  60095. /**
  60096. * Rebuilds the elements related to this component in case of
  60097. * context lost for instance.
  60098. */
  60099. rebuild(): void;
  60100. /**
  60101. * Disposes the component and the associated ressources.
  60102. */
  60103. dispose(): void;
  60104. private _draw;
  60105. private _drawCameraPredicate;
  60106. private _drawCameraBackground;
  60107. private _drawCameraForeground;
  60108. private _drawRenderTargetPredicate;
  60109. private _drawRenderTargetBackground;
  60110. private _drawRenderTargetForeground;
  60111. /**
  60112. * Adds all the elements from the container to the scene
  60113. * @param container the container holding the elements
  60114. */
  60115. addFromContainer(container: AbstractScene): void;
  60116. /**
  60117. * Removes all the elements in the container from the scene
  60118. * @param container contains the elements to remove
  60119. * @param dispose if the removed element should be disposed (default: false)
  60120. */
  60121. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60122. }
  60123. }
  60124. declare module "babylonjs/Shaders/layer.fragment" {
  60125. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60126. /** @hidden */
  60127. export var layerPixelShader: {
  60128. name: string;
  60129. shader: string;
  60130. };
  60131. }
  60132. declare module "babylonjs/Shaders/layer.vertex" {
  60133. /** @hidden */
  60134. export var layerVertexShader: {
  60135. name: string;
  60136. shader: string;
  60137. };
  60138. }
  60139. declare module "babylonjs/Layers/layer" {
  60140. import { Observable } from "babylonjs/Misc/observable";
  60141. import { Nullable } from "babylonjs/types";
  60142. import { Scene } from "babylonjs/scene";
  60143. import { Vector2 } from "babylonjs/Maths/math.vector";
  60144. import { Color4 } from "babylonjs/Maths/math.color";
  60145. import { Texture } from "babylonjs/Materials/Textures/texture";
  60146. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60147. import "babylonjs/Shaders/layer.fragment";
  60148. import "babylonjs/Shaders/layer.vertex";
  60149. /**
  60150. * This represents a full screen 2d layer.
  60151. * This can be useful to display a picture in the background of your scene for instance.
  60152. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60153. */
  60154. export class Layer {
  60155. /**
  60156. * Define the name of the layer.
  60157. */
  60158. name: string;
  60159. /**
  60160. * Define the texture the layer should display.
  60161. */
  60162. texture: Nullable<Texture>;
  60163. /**
  60164. * Is the layer in background or foreground.
  60165. */
  60166. isBackground: boolean;
  60167. /**
  60168. * Define the color of the layer (instead of texture).
  60169. */
  60170. color: Color4;
  60171. /**
  60172. * Define the scale of the layer in order to zoom in out of the texture.
  60173. */
  60174. scale: Vector2;
  60175. /**
  60176. * Define an offset for the layer in order to shift the texture.
  60177. */
  60178. offset: Vector2;
  60179. /**
  60180. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60181. */
  60182. alphaBlendingMode: number;
  60183. /**
  60184. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60185. * Alpha test will not mix with the background color in case of transparency.
  60186. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60187. */
  60188. alphaTest: boolean;
  60189. /**
  60190. * Define a mask to restrict the layer to only some of the scene cameras.
  60191. */
  60192. layerMask: number;
  60193. /**
  60194. * Define the list of render target the layer is visible into.
  60195. */
  60196. renderTargetTextures: RenderTargetTexture[];
  60197. /**
  60198. * Define if the layer is only used in renderTarget or if it also
  60199. * renders in the main frame buffer of the canvas.
  60200. */
  60201. renderOnlyInRenderTargetTextures: boolean;
  60202. private _scene;
  60203. private _vertexBuffers;
  60204. private _indexBuffer;
  60205. private _effect;
  60206. private _previousDefines;
  60207. /**
  60208. * An event triggered when the layer is disposed.
  60209. */
  60210. onDisposeObservable: Observable<Layer>;
  60211. private _onDisposeObserver;
  60212. /**
  60213. * Back compatibility with callback before the onDisposeObservable existed.
  60214. * The set callback will be triggered when the layer has been disposed.
  60215. */
  60216. set onDispose(callback: () => void);
  60217. /**
  60218. * An event triggered before rendering the scene
  60219. */
  60220. onBeforeRenderObservable: Observable<Layer>;
  60221. private _onBeforeRenderObserver;
  60222. /**
  60223. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60224. * The set callback will be triggered just before rendering the layer.
  60225. */
  60226. set onBeforeRender(callback: () => void);
  60227. /**
  60228. * An event triggered after rendering the scene
  60229. */
  60230. onAfterRenderObservable: Observable<Layer>;
  60231. private _onAfterRenderObserver;
  60232. /**
  60233. * Back compatibility with callback before the onAfterRenderObservable existed.
  60234. * The set callback will be triggered just after rendering the layer.
  60235. */
  60236. set onAfterRender(callback: () => void);
  60237. /**
  60238. * Instantiates a new layer.
  60239. * This represents a full screen 2d layer.
  60240. * This can be useful to display a picture in the background of your scene for instance.
  60241. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60242. * @param name Define the name of the layer in the scene
  60243. * @param imgUrl Define the url of the texture to display in the layer
  60244. * @param scene Define the scene the layer belongs to
  60245. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60246. * @param color Defines a color for the layer
  60247. */
  60248. constructor(
  60249. /**
  60250. * Define the name of the layer.
  60251. */
  60252. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60253. private _createIndexBuffer;
  60254. /** @hidden */
  60255. _rebuild(): void;
  60256. /**
  60257. * Renders the layer in the scene.
  60258. */
  60259. render(): void;
  60260. /**
  60261. * Disposes and releases the associated ressources.
  60262. */
  60263. dispose(): void;
  60264. }
  60265. }
  60266. declare module "babylonjs/Layers/index" {
  60267. export * from "babylonjs/Layers/effectLayer";
  60268. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60269. export * from "babylonjs/Layers/glowLayer";
  60270. export * from "babylonjs/Layers/highlightLayer";
  60271. export * from "babylonjs/Layers/layer";
  60272. export * from "babylonjs/Layers/layerSceneComponent";
  60273. }
  60274. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60275. /** @hidden */
  60276. export var lensFlarePixelShader: {
  60277. name: string;
  60278. shader: string;
  60279. };
  60280. }
  60281. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60282. /** @hidden */
  60283. export var lensFlareVertexShader: {
  60284. name: string;
  60285. shader: string;
  60286. };
  60287. }
  60288. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60289. import { Scene } from "babylonjs/scene";
  60290. import { Vector3 } from "babylonjs/Maths/math.vector";
  60291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60292. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60293. import "babylonjs/Shaders/lensFlare.fragment";
  60294. import "babylonjs/Shaders/lensFlare.vertex";
  60295. import { Viewport } from "babylonjs/Maths/math.viewport";
  60296. /**
  60297. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60298. * It is usually composed of several `lensFlare`.
  60299. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60300. */
  60301. export class LensFlareSystem {
  60302. /**
  60303. * Define the name of the lens flare system
  60304. */
  60305. name: string;
  60306. /**
  60307. * List of lens flares used in this system.
  60308. */
  60309. lensFlares: LensFlare[];
  60310. /**
  60311. * Define a limit from the border the lens flare can be visible.
  60312. */
  60313. borderLimit: number;
  60314. /**
  60315. * Define a viewport border we do not want to see the lens flare in.
  60316. */
  60317. viewportBorder: number;
  60318. /**
  60319. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60320. */
  60321. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60322. /**
  60323. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60324. */
  60325. layerMask: number;
  60326. /**
  60327. * Define the id of the lens flare system in the scene.
  60328. * (equal to name by default)
  60329. */
  60330. id: string;
  60331. private _scene;
  60332. private _emitter;
  60333. private _vertexBuffers;
  60334. private _indexBuffer;
  60335. private _effect;
  60336. private _positionX;
  60337. private _positionY;
  60338. private _isEnabled;
  60339. /** @hidden */
  60340. static _SceneComponentInitialization: (scene: Scene) => void;
  60341. /**
  60342. * Instantiates a lens flare system.
  60343. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60344. * It is usually composed of several `lensFlare`.
  60345. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60346. * @param name Define the name of the lens flare system in the scene
  60347. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60348. * @param scene Define the scene the lens flare system belongs to
  60349. */
  60350. constructor(
  60351. /**
  60352. * Define the name of the lens flare system
  60353. */
  60354. name: string, emitter: any, scene: Scene);
  60355. /**
  60356. * Define if the lens flare system is enabled.
  60357. */
  60358. get isEnabled(): boolean;
  60359. set isEnabled(value: boolean);
  60360. /**
  60361. * Get the scene the effects belongs to.
  60362. * @returns the scene holding the lens flare system
  60363. */
  60364. getScene(): Scene;
  60365. /**
  60366. * Get the emitter of the lens flare system.
  60367. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60368. * @returns the emitter of the lens flare system
  60369. */
  60370. getEmitter(): any;
  60371. /**
  60372. * Set the emitter of the lens flare system.
  60373. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60374. * @param newEmitter Define the new emitter of the system
  60375. */
  60376. setEmitter(newEmitter: any): void;
  60377. /**
  60378. * Get the lens flare system emitter position.
  60379. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60380. * @returns the position
  60381. */
  60382. getEmitterPosition(): Vector3;
  60383. /**
  60384. * @hidden
  60385. */
  60386. computeEffectivePosition(globalViewport: Viewport): boolean;
  60387. /** @hidden */
  60388. _isVisible(): boolean;
  60389. /**
  60390. * @hidden
  60391. */
  60392. render(): boolean;
  60393. /**
  60394. * Dispose and release the lens flare with its associated resources.
  60395. */
  60396. dispose(): void;
  60397. /**
  60398. * Parse a lens flare system from a JSON repressentation
  60399. * @param parsedLensFlareSystem Define the JSON to parse
  60400. * @param scene Define the scene the parsed system should be instantiated in
  60401. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60402. * @returns the parsed system
  60403. */
  60404. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60405. /**
  60406. * Serialize the current Lens Flare System into a JSON representation.
  60407. * @returns the serialized JSON
  60408. */
  60409. serialize(): any;
  60410. }
  60411. }
  60412. declare module "babylonjs/LensFlares/lensFlare" {
  60413. import { Nullable } from "babylonjs/types";
  60414. import { Color3 } from "babylonjs/Maths/math.color";
  60415. import { Texture } from "babylonjs/Materials/Textures/texture";
  60416. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60417. /**
  60418. * This represents one of the lens effect in a `lensFlareSystem`.
  60419. * It controls one of the indiviual texture used in the effect.
  60420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60421. */
  60422. export class LensFlare {
  60423. /**
  60424. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60425. */
  60426. size: number;
  60427. /**
  60428. * 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.
  60429. */
  60430. position: number;
  60431. /**
  60432. * Define the lens color.
  60433. */
  60434. color: Color3;
  60435. /**
  60436. * Define the lens texture.
  60437. */
  60438. texture: Nullable<Texture>;
  60439. /**
  60440. * Define the alpha mode to render this particular lens.
  60441. */
  60442. alphaMode: number;
  60443. private _system;
  60444. /**
  60445. * Creates a new Lens Flare.
  60446. * This represents one of the lens effect in a `lensFlareSystem`.
  60447. * It controls one of the indiviual texture used in the effect.
  60448. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60449. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60450. * @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.
  60451. * @param color Define the lens color
  60452. * @param imgUrl Define the lens texture url
  60453. * @param system Define the `lensFlareSystem` this flare is part of
  60454. * @returns The newly created Lens Flare
  60455. */
  60456. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60457. /**
  60458. * Instantiates a new Lens Flare.
  60459. * This represents one of the lens effect in a `lensFlareSystem`.
  60460. * It controls one of the indiviual texture used in the effect.
  60461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60462. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60463. * @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.
  60464. * @param color Define the lens color
  60465. * @param imgUrl Define the lens texture url
  60466. * @param system Define the `lensFlareSystem` this flare is part of
  60467. */
  60468. constructor(
  60469. /**
  60470. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60471. */
  60472. size: number,
  60473. /**
  60474. * 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.
  60475. */
  60476. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60477. /**
  60478. * Dispose and release the lens flare with its associated resources.
  60479. */
  60480. dispose(): void;
  60481. }
  60482. }
  60483. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60484. import { Nullable } from "babylonjs/types";
  60485. import { Scene } from "babylonjs/scene";
  60486. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60487. import { AbstractScene } from "babylonjs/abstractScene";
  60488. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60489. module "babylonjs/abstractScene" {
  60490. interface AbstractScene {
  60491. /**
  60492. * The list of lens flare system added to the scene
  60493. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60494. */
  60495. lensFlareSystems: Array<LensFlareSystem>;
  60496. /**
  60497. * Removes the given lens flare system from this scene.
  60498. * @param toRemove The lens flare system to remove
  60499. * @returns The index of the removed lens flare system
  60500. */
  60501. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60502. /**
  60503. * Adds the given lens flare system to this scene
  60504. * @param newLensFlareSystem The lens flare system to add
  60505. */
  60506. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60507. /**
  60508. * Gets a lens flare system using its name
  60509. * @param name defines the name to look for
  60510. * @returns the lens flare system or null if not found
  60511. */
  60512. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60513. /**
  60514. * Gets a lens flare system using its id
  60515. * @param id defines the id to look for
  60516. * @returns the lens flare system or null if not found
  60517. */
  60518. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60519. }
  60520. }
  60521. /**
  60522. * Defines the lens flare scene component responsible to manage any lens flares
  60523. * in a given scene.
  60524. */
  60525. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60526. /**
  60527. * The component name helpfull to identify the component in the list of scene components.
  60528. */
  60529. readonly name: string;
  60530. /**
  60531. * The scene the component belongs to.
  60532. */
  60533. scene: Scene;
  60534. /**
  60535. * Creates a new instance of the component for the given scene
  60536. * @param scene Defines the scene to register the component in
  60537. */
  60538. constructor(scene: Scene);
  60539. /**
  60540. * Registers the component in a given scene
  60541. */
  60542. register(): void;
  60543. /**
  60544. * Rebuilds the elements related to this component in case of
  60545. * context lost for instance.
  60546. */
  60547. rebuild(): void;
  60548. /**
  60549. * Adds all the elements from the container to the scene
  60550. * @param container the container holding the elements
  60551. */
  60552. addFromContainer(container: AbstractScene): void;
  60553. /**
  60554. * Removes all the elements in the container from the scene
  60555. * @param container contains the elements to remove
  60556. * @param dispose if the removed element should be disposed (default: false)
  60557. */
  60558. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60559. /**
  60560. * Serializes the component data to the specified json object
  60561. * @param serializationObject The object to serialize to
  60562. */
  60563. serialize(serializationObject: any): void;
  60564. /**
  60565. * Disposes the component and the associated ressources.
  60566. */
  60567. dispose(): void;
  60568. private _draw;
  60569. }
  60570. }
  60571. declare module "babylonjs/LensFlares/index" {
  60572. export * from "babylonjs/LensFlares/lensFlare";
  60573. export * from "babylonjs/LensFlares/lensFlareSystem";
  60574. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60575. }
  60576. declare module "babylonjs/Shaders/depth.fragment" {
  60577. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60578. /** @hidden */
  60579. export var depthPixelShader: {
  60580. name: string;
  60581. shader: string;
  60582. };
  60583. }
  60584. declare module "babylonjs/Shaders/depth.vertex" {
  60585. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60586. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60588. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60590. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60591. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60592. /** @hidden */
  60593. export var depthVertexShader: {
  60594. name: string;
  60595. shader: string;
  60596. };
  60597. }
  60598. declare module "babylonjs/Rendering/depthRenderer" {
  60599. import { Nullable } from "babylonjs/types";
  60600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60601. import { Scene } from "babylonjs/scene";
  60602. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60603. import { Camera } from "babylonjs/Cameras/camera";
  60604. import "babylonjs/Shaders/depth.fragment";
  60605. import "babylonjs/Shaders/depth.vertex";
  60606. /**
  60607. * This represents a depth renderer in Babylon.
  60608. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60609. */
  60610. export class DepthRenderer {
  60611. private _scene;
  60612. private _depthMap;
  60613. private _effect;
  60614. private readonly _storeNonLinearDepth;
  60615. private readonly _clearColor;
  60616. /** Get if the depth renderer is using packed depth or not */
  60617. readonly isPacked: boolean;
  60618. private _cachedDefines;
  60619. private _camera;
  60620. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60621. enabled: boolean;
  60622. /**
  60623. * Specifiess that the depth renderer will only be used within
  60624. * the camera it is created for.
  60625. * This can help forcing its rendering during the camera processing.
  60626. */
  60627. useOnlyInActiveCamera: boolean;
  60628. /** @hidden */
  60629. static _SceneComponentInitialization: (scene: Scene) => void;
  60630. /**
  60631. * Instantiates a depth renderer
  60632. * @param scene The scene the renderer belongs to
  60633. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60634. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60635. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60636. */
  60637. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60638. /**
  60639. * Creates the depth rendering effect and checks if the effect is ready.
  60640. * @param subMesh The submesh to be used to render the depth map of
  60641. * @param useInstances If multiple world instances should be used
  60642. * @returns if the depth renderer is ready to render the depth map
  60643. */
  60644. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60645. /**
  60646. * Gets the texture which the depth map will be written to.
  60647. * @returns The depth map texture
  60648. */
  60649. getDepthMap(): RenderTargetTexture;
  60650. /**
  60651. * Disposes of the depth renderer.
  60652. */
  60653. dispose(): void;
  60654. }
  60655. }
  60656. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60657. /** @hidden */
  60658. export var minmaxReduxPixelShader: {
  60659. name: string;
  60660. shader: string;
  60661. };
  60662. }
  60663. declare module "babylonjs/Misc/minMaxReducer" {
  60664. import { Nullable } from "babylonjs/types";
  60665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60666. import { Camera } from "babylonjs/Cameras/camera";
  60667. import { Observer } from "babylonjs/Misc/observable";
  60668. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60669. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60670. import { Observable } from "babylonjs/Misc/observable";
  60671. import "babylonjs/Shaders/minmaxRedux.fragment";
  60672. /**
  60673. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60674. * and maximum values from all values of the texture.
  60675. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60676. * The source values are read from the red channel of the texture.
  60677. */
  60678. export class MinMaxReducer {
  60679. /**
  60680. * Observable triggered when the computation has been performed
  60681. */
  60682. onAfterReductionPerformed: Observable<{
  60683. min: number;
  60684. max: number;
  60685. }>;
  60686. protected _camera: Camera;
  60687. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60688. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60689. protected _postProcessManager: PostProcessManager;
  60690. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60691. protected _forceFullscreenViewport: boolean;
  60692. /**
  60693. * Creates a min/max reducer
  60694. * @param camera The camera to use for the post processes
  60695. */
  60696. constructor(camera: Camera);
  60697. /**
  60698. * Gets the texture used to read the values from.
  60699. */
  60700. get sourceTexture(): Nullable<RenderTargetTexture>;
  60701. /**
  60702. * Sets the source texture to read the values from.
  60703. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60704. * because in such textures '1' value must not be taken into account to compute the maximum
  60705. * as this value is used to clear the texture.
  60706. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60707. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60708. * @param depthRedux Indicates if the texture is a depth texture or not
  60709. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60710. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60711. */
  60712. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60713. /**
  60714. * Defines the refresh rate of the computation.
  60715. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60716. */
  60717. get refreshRate(): number;
  60718. set refreshRate(value: number);
  60719. protected _activated: boolean;
  60720. /**
  60721. * Gets the activation status of the reducer
  60722. */
  60723. get activated(): boolean;
  60724. /**
  60725. * Activates the reduction computation.
  60726. * When activated, the observers registered in onAfterReductionPerformed are
  60727. * called after the compuation is performed
  60728. */
  60729. activate(): void;
  60730. /**
  60731. * Deactivates the reduction computation.
  60732. */
  60733. deactivate(): void;
  60734. /**
  60735. * Disposes the min/max reducer
  60736. * @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.
  60737. */
  60738. dispose(disposeAll?: boolean): void;
  60739. }
  60740. }
  60741. declare module "babylonjs/Misc/depthReducer" {
  60742. import { Nullable } from "babylonjs/types";
  60743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60744. import { Camera } from "babylonjs/Cameras/camera";
  60745. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60746. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60747. /**
  60748. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60749. */
  60750. export class DepthReducer extends MinMaxReducer {
  60751. private _depthRenderer;
  60752. private _depthRendererId;
  60753. /**
  60754. * Gets the depth renderer used for the computation.
  60755. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60756. */
  60757. get depthRenderer(): Nullable<DepthRenderer>;
  60758. /**
  60759. * Creates a depth reducer
  60760. * @param camera The camera used to render the depth texture
  60761. */
  60762. constructor(camera: Camera);
  60763. /**
  60764. * Sets the depth renderer to use to generate the depth map
  60765. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60766. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60767. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60768. */
  60769. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60770. /** @hidden */
  60771. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60772. /**
  60773. * Activates the reduction computation.
  60774. * When activated, the observers registered in onAfterReductionPerformed are
  60775. * called after the compuation is performed
  60776. */
  60777. activate(): void;
  60778. /**
  60779. * Deactivates the reduction computation.
  60780. */
  60781. deactivate(): void;
  60782. /**
  60783. * Disposes the depth reducer
  60784. * @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.
  60785. */
  60786. dispose(disposeAll?: boolean): void;
  60787. }
  60788. }
  60789. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60790. import { Nullable } from "babylonjs/types";
  60791. import { Scene } from "babylonjs/scene";
  60792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60793. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60795. import { Effect } from "babylonjs/Materials/effect";
  60796. import "babylonjs/Shaders/shadowMap.fragment";
  60797. import "babylonjs/Shaders/shadowMap.vertex";
  60798. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60799. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60800. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60801. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60802. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60803. /**
  60804. * A CSM implementation allowing casting shadows on large scenes.
  60805. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60806. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60807. */
  60808. export class CascadedShadowGenerator extends ShadowGenerator {
  60809. private static readonly frustumCornersNDCSpace;
  60810. /**
  60811. * Name of the CSM class
  60812. */
  60813. static CLASSNAME: string;
  60814. /**
  60815. * Defines the default number of cascades used by the CSM.
  60816. */
  60817. static readonly DEFAULT_CASCADES_COUNT: number;
  60818. /**
  60819. * Defines the minimum number of cascades used by the CSM.
  60820. */
  60821. static readonly MIN_CASCADES_COUNT: number;
  60822. /**
  60823. * Defines the maximum number of cascades used by the CSM.
  60824. */
  60825. static readonly MAX_CASCADES_COUNT: number;
  60826. protected _validateFilter(filter: number): number;
  60827. /**
  60828. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60829. */
  60830. penumbraDarkness: number;
  60831. private _numCascades;
  60832. /**
  60833. * Gets or set the number of cascades used by the CSM.
  60834. */
  60835. get numCascades(): number;
  60836. set numCascades(value: number);
  60837. /**
  60838. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60839. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60840. */
  60841. stabilizeCascades: boolean;
  60842. private _freezeShadowCastersBoundingInfo;
  60843. private _freezeShadowCastersBoundingInfoObservable;
  60844. /**
  60845. * Enables or disables the shadow casters bounding info computation.
  60846. * If your shadow casters don't move, you can disable this feature.
  60847. * If it is enabled, the bounding box computation is done every frame.
  60848. */
  60849. get freezeShadowCastersBoundingInfo(): boolean;
  60850. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60851. private _scbiMin;
  60852. private _scbiMax;
  60853. protected _computeShadowCastersBoundingInfo(): void;
  60854. protected _shadowCastersBoundingInfo: BoundingInfo;
  60855. /**
  60856. * Gets or sets the shadow casters bounding info.
  60857. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60858. * so that the system won't overwrite the bounds you provide
  60859. */
  60860. get shadowCastersBoundingInfo(): BoundingInfo;
  60861. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60862. protected _breaksAreDirty: boolean;
  60863. protected _minDistance: number;
  60864. protected _maxDistance: number;
  60865. /**
  60866. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60867. *
  60868. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60869. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60870. * @param min minimal distance for the breaks (default to 0.)
  60871. * @param max maximal distance for the breaks (default to 1.)
  60872. */
  60873. setMinMaxDistance(min: number, max: number): void;
  60874. /** Gets the minimal distance used in the cascade break computation */
  60875. get minDistance(): number;
  60876. /** Gets the maximal distance used in the cascade break computation */
  60877. get maxDistance(): number;
  60878. /**
  60879. * Gets the class name of that object
  60880. * @returns "CascadedShadowGenerator"
  60881. */
  60882. getClassName(): string;
  60883. private _cascadeMinExtents;
  60884. private _cascadeMaxExtents;
  60885. /**
  60886. * Gets a cascade minimum extents
  60887. * @param cascadeIndex index of the cascade
  60888. * @returns the minimum cascade extents
  60889. */
  60890. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60891. /**
  60892. * Gets a cascade maximum extents
  60893. * @param cascadeIndex index of the cascade
  60894. * @returns the maximum cascade extents
  60895. */
  60896. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60897. private _cascades;
  60898. private _currentLayer;
  60899. private _viewSpaceFrustumsZ;
  60900. private _viewMatrices;
  60901. private _projectionMatrices;
  60902. private _transformMatrices;
  60903. private _transformMatricesAsArray;
  60904. private _frustumLengths;
  60905. private _lightSizeUVCorrection;
  60906. private _depthCorrection;
  60907. private _frustumCornersWorldSpace;
  60908. private _frustumCenter;
  60909. private _shadowCameraPos;
  60910. private _shadowMaxZ;
  60911. /**
  60912. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60913. * It defaults to camera.maxZ
  60914. */
  60915. get shadowMaxZ(): number;
  60916. /**
  60917. * Sets the shadow max z distance.
  60918. */
  60919. set shadowMaxZ(value: number);
  60920. protected _debug: boolean;
  60921. /**
  60922. * Gets or sets the debug flag.
  60923. * When enabled, the cascades are materialized by different colors on the screen.
  60924. */
  60925. get debug(): boolean;
  60926. set debug(dbg: boolean);
  60927. private _depthClamp;
  60928. /**
  60929. * Gets or sets the depth clamping value.
  60930. *
  60931. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60932. * to account for the shadow casters far away.
  60933. *
  60934. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60935. */
  60936. get depthClamp(): boolean;
  60937. set depthClamp(value: boolean);
  60938. private _cascadeBlendPercentage;
  60939. /**
  60940. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60941. * It defaults to 0.1 (10% blending).
  60942. */
  60943. get cascadeBlendPercentage(): number;
  60944. set cascadeBlendPercentage(value: number);
  60945. private _lambda;
  60946. /**
  60947. * Gets or set the lambda parameter.
  60948. * This parameter is used to split the camera frustum and create the cascades.
  60949. * 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.
  60950. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60951. */
  60952. get lambda(): number;
  60953. set lambda(value: number);
  60954. /**
  60955. * Gets the view matrix corresponding to a given cascade
  60956. * @param cascadeNum cascade to retrieve the view matrix from
  60957. * @returns the cascade view matrix
  60958. */
  60959. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60960. /**
  60961. * Gets the projection matrix corresponding to a given cascade
  60962. * @param cascadeNum cascade to retrieve the projection matrix from
  60963. * @returns the cascade projection matrix
  60964. */
  60965. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60966. /**
  60967. * Gets the transformation matrix corresponding to a given cascade
  60968. * @param cascadeNum cascade to retrieve the transformation matrix from
  60969. * @returns the cascade transformation matrix
  60970. */
  60971. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60972. private _depthRenderer;
  60973. /**
  60974. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60975. *
  60976. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60977. *
  60978. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60979. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60980. * @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
  60981. */
  60982. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60983. private _depthReducer;
  60984. private _autoCalcDepthBounds;
  60985. /**
  60986. * Gets or sets the autoCalcDepthBounds property.
  60987. *
  60988. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60989. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60990. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60991. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60992. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60993. */
  60994. get autoCalcDepthBounds(): boolean;
  60995. set autoCalcDepthBounds(value: boolean);
  60996. /**
  60997. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60998. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60999. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61000. * for setting the refresh rate on the renderer yourself!
  61001. */
  61002. get autoCalcDepthBoundsRefreshRate(): number;
  61003. set autoCalcDepthBoundsRefreshRate(value: number);
  61004. /**
  61005. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61006. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61007. * you change the camera near/far planes!
  61008. */
  61009. splitFrustum(): void;
  61010. private _splitFrustum;
  61011. private _computeMatrices;
  61012. private _computeFrustumInWorldSpace;
  61013. private _computeCascadeFrustum;
  61014. /**
  61015. * Support test.
  61016. */
  61017. static get IsSupported(): boolean;
  61018. /** @hidden */
  61019. static _SceneComponentInitialization: (scene: Scene) => void;
  61020. /**
  61021. * Creates a Cascaded Shadow Generator object.
  61022. * A ShadowGenerator is the required tool to use the shadows.
  61023. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61024. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61025. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61026. * @param light The directional light object generating the shadows.
  61027. * @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.
  61028. */
  61029. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61030. protected _initializeGenerator(): void;
  61031. protected _createTargetRenderTexture(): void;
  61032. protected _initializeShadowMap(): void;
  61033. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61034. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61035. /**
  61036. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61037. * @param defines Defines of the material we want to update
  61038. * @param lightIndex Index of the light in the enabled light list of the material
  61039. */
  61040. prepareDefines(defines: any, lightIndex: number): void;
  61041. /**
  61042. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61043. * defined in the generator but impacting the effect).
  61044. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61045. * @param effect The effect we are binfing the information for
  61046. */
  61047. bindShadowLight(lightIndex: string, effect: Effect): void;
  61048. /**
  61049. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61050. * (eq to view projection * shadow projection matrices)
  61051. * @returns The transform matrix used to create the shadow map
  61052. */
  61053. getTransformMatrix(): Matrix;
  61054. /**
  61055. * Disposes the ShadowGenerator.
  61056. * Returns nothing.
  61057. */
  61058. dispose(): void;
  61059. /**
  61060. * Serializes the shadow generator setup to a json object.
  61061. * @returns The serialized JSON object
  61062. */
  61063. serialize(): any;
  61064. /**
  61065. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61066. * @param parsedShadowGenerator The JSON object to parse
  61067. * @param scene The scene to create the shadow map for
  61068. * @returns The parsed shadow generator
  61069. */
  61070. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61071. }
  61072. }
  61073. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61074. import { Scene } from "babylonjs/scene";
  61075. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61076. import { AbstractScene } from "babylonjs/abstractScene";
  61077. /**
  61078. * Defines the shadow generator component responsible to manage any shadow generators
  61079. * in a given scene.
  61080. */
  61081. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61082. /**
  61083. * The component name helpfull to identify the component in the list of scene components.
  61084. */
  61085. readonly name: string;
  61086. /**
  61087. * The scene the component belongs to.
  61088. */
  61089. scene: Scene;
  61090. /**
  61091. * Creates a new instance of the component for the given scene
  61092. * @param scene Defines the scene to register the component in
  61093. */
  61094. constructor(scene: Scene);
  61095. /**
  61096. * Registers the component in a given scene
  61097. */
  61098. register(): void;
  61099. /**
  61100. * Rebuilds the elements related to this component in case of
  61101. * context lost for instance.
  61102. */
  61103. rebuild(): void;
  61104. /**
  61105. * Serializes the component data to the specified json object
  61106. * @param serializationObject The object to serialize to
  61107. */
  61108. serialize(serializationObject: any): void;
  61109. /**
  61110. * Adds all the elements from the container to the scene
  61111. * @param container the container holding the elements
  61112. */
  61113. addFromContainer(container: AbstractScene): void;
  61114. /**
  61115. * Removes all the elements in the container from the scene
  61116. * @param container contains the elements to remove
  61117. * @param dispose if the removed element should be disposed (default: false)
  61118. */
  61119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61120. /**
  61121. * Rebuilds the elements related to this component in case of
  61122. * context lost for instance.
  61123. */
  61124. dispose(): void;
  61125. private _gatherRenderTargets;
  61126. }
  61127. }
  61128. declare module "babylonjs/Lights/Shadows/index" {
  61129. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61130. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61131. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61132. }
  61133. declare module "babylonjs/Lights/pointLight" {
  61134. import { Scene } from "babylonjs/scene";
  61135. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61137. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61138. import { Effect } from "babylonjs/Materials/effect";
  61139. /**
  61140. * A point light is a light defined by an unique point in world space.
  61141. * The light is emitted in every direction from this point.
  61142. * A good example of a point light is a standard light bulb.
  61143. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61144. */
  61145. export class PointLight extends ShadowLight {
  61146. private _shadowAngle;
  61147. /**
  61148. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61149. * This specifies what angle the shadow will use to be created.
  61150. *
  61151. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61152. */
  61153. get shadowAngle(): number;
  61154. /**
  61155. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61156. * This specifies what angle the shadow will use to be created.
  61157. *
  61158. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61159. */
  61160. set shadowAngle(value: number);
  61161. /**
  61162. * Gets the direction if it has been set.
  61163. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61164. */
  61165. get direction(): Vector3;
  61166. /**
  61167. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61168. */
  61169. set direction(value: Vector3);
  61170. /**
  61171. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61172. * A PointLight emits the light in every direction.
  61173. * It can cast shadows.
  61174. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61175. * ```javascript
  61176. * var pointLight = new PointLight("pl", camera.position, scene);
  61177. * ```
  61178. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61179. * @param name The light friendly name
  61180. * @param position The position of the point light in the scene
  61181. * @param scene The scene the lights belongs to
  61182. */
  61183. constructor(name: string, position: Vector3, scene: Scene);
  61184. /**
  61185. * Returns the string "PointLight"
  61186. * @returns the class name
  61187. */
  61188. getClassName(): string;
  61189. /**
  61190. * Returns the integer 0.
  61191. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61192. */
  61193. getTypeID(): number;
  61194. /**
  61195. * Specifies wether or not the shadowmap should be a cube texture.
  61196. * @returns true if the shadowmap needs to be a cube texture.
  61197. */
  61198. needCube(): boolean;
  61199. /**
  61200. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61201. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61202. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61203. */
  61204. getShadowDirection(faceIndex?: number): Vector3;
  61205. /**
  61206. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61207. * - fov = PI / 2
  61208. * - aspect ratio : 1.0
  61209. * - z-near and far equal to the active camera minZ and maxZ.
  61210. * Returns the PointLight.
  61211. */
  61212. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61213. protected _buildUniformLayout(): void;
  61214. /**
  61215. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61216. * @param effect The effect to update
  61217. * @param lightIndex The index of the light in the effect to update
  61218. * @returns The point light
  61219. */
  61220. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61221. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61222. /**
  61223. * Prepares the list of defines specific to the light type.
  61224. * @param defines the list of defines
  61225. * @param lightIndex defines the index of the light for the effect
  61226. */
  61227. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61228. }
  61229. }
  61230. declare module "babylonjs/Lights/index" {
  61231. export * from "babylonjs/Lights/light";
  61232. export * from "babylonjs/Lights/shadowLight";
  61233. export * from "babylonjs/Lights/Shadows/index";
  61234. export * from "babylonjs/Lights/directionalLight";
  61235. export * from "babylonjs/Lights/hemisphericLight";
  61236. export * from "babylonjs/Lights/pointLight";
  61237. export * from "babylonjs/Lights/spotLight";
  61238. }
  61239. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61240. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61241. /**
  61242. * Header information of HDR texture files.
  61243. */
  61244. export interface HDRInfo {
  61245. /**
  61246. * The height of the texture in pixels.
  61247. */
  61248. height: number;
  61249. /**
  61250. * The width of the texture in pixels.
  61251. */
  61252. width: number;
  61253. /**
  61254. * The index of the beginning of the data in the binary file.
  61255. */
  61256. dataPosition: number;
  61257. }
  61258. /**
  61259. * This groups tools to convert HDR texture to native colors array.
  61260. */
  61261. export class HDRTools {
  61262. private static Ldexp;
  61263. private static Rgbe2float;
  61264. private static readStringLine;
  61265. /**
  61266. * Reads header information from an RGBE texture stored in a native array.
  61267. * More information on this format are available here:
  61268. * https://en.wikipedia.org/wiki/RGBE_image_format
  61269. *
  61270. * @param uint8array The binary file stored in native array.
  61271. * @return The header information.
  61272. */
  61273. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61274. /**
  61275. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61276. * This RGBE texture needs to store the information as a panorama.
  61277. *
  61278. * More information on this format are available here:
  61279. * https://en.wikipedia.org/wiki/RGBE_image_format
  61280. *
  61281. * @param buffer The binary file stored in an array buffer.
  61282. * @param size The expected size of the extracted cubemap.
  61283. * @return The Cube Map information.
  61284. */
  61285. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61286. /**
  61287. * Returns the pixels data extracted from an RGBE texture.
  61288. * This pixels will be stored left to right up to down in the R G B order in one array.
  61289. *
  61290. * More information on this format are available here:
  61291. * https://en.wikipedia.org/wiki/RGBE_image_format
  61292. *
  61293. * @param uint8array The binary file stored in an array buffer.
  61294. * @param hdrInfo The header information of the file.
  61295. * @return The pixels data in RGB right to left up to down order.
  61296. */
  61297. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61298. private static RGBE_ReadPixels_RLE;
  61299. }
  61300. }
  61301. declare module "babylonjs/Materials/effectRenderer" {
  61302. import { Nullable } from "babylonjs/types";
  61303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61304. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61305. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61306. import { Viewport } from "babylonjs/Maths/math.viewport";
  61307. import { Observable } from "babylonjs/Misc/observable";
  61308. import { Effect } from "babylonjs/Materials/effect";
  61309. import "babylonjs/Shaders/postprocess.vertex";
  61310. /**
  61311. * Effect Render Options
  61312. */
  61313. export interface IEffectRendererOptions {
  61314. /**
  61315. * Defines the vertices positions.
  61316. */
  61317. positions?: number[];
  61318. /**
  61319. * Defines the indices.
  61320. */
  61321. indices?: number[];
  61322. }
  61323. /**
  61324. * Helper class to render one or more effects.
  61325. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61326. */
  61327. export class EffectRenderer {
  61328. private engine;
  61329. private static _DefaultOptions;
  61330. private _vertexBuffers;
  61331. private _indexBuffer;
  61332. private _fullscreenViewport;
  61333. /**
  61334. * Creates an effect renderer
  61335. * @param engine the engine to use for rendering
  61336. * @param options defines the options of the effect renderer
  61337. */
  61338. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61339. /**
  61340. * Sets the current viewport in normalized coordinates 0-1
  61341. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61342. */
  61343. setViewport(viewport?: Viewport): void;
  61344. /**
  61345. * Binds the embedded attributes buffer to the effect.
  61346. * @param effect Defines the effect to bind the attributes for
  61347. */
  61348. bindBuffers(effect: Effect): void;
  61349. /**
  61350. * Sets the current effect wrapper to use during draw.
  61351. * The effect needs to be ready before calling this api.
  61352. * This also sets the default full screen position attribute.
  61353. * @param effectWrapper Defines the effect to draw with
  61354. */
  61355. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61356. /**
  61357. * Restores engine states
  61358. */
  61359. restoreStates(): void;
  61360. /**
  61361. * Draws a full screen quad.
  61362. */
  61363. draw(): void;
  61364. private isRenderTargetTexture;
  61365. /**
  61366. * renders one or more effects to a specified texture
  61367. * @param effectWrapper the effect to renderer
  61368. * @param outputTexture texture to draw to, if null it will render to the screen.
  61369. */
  61370. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61371. /**
  61372. * Disposes of the effect renderer
  61373. */
  61374. dispose(): void;
  61375. }
  61376. /**
  61377. * Options to create an EffectWrapper
  61378. */
  61379. interface EffectWrapperCreationOptions {
  61380. /**
  61381. * Engine to use to create the effect
  61382. */
  61383. engine: ThinEngine;
  61384. /**
  61385. * Fragment shader for the effect
  61386. */
  61387. fragmentShader: string;
  61388. /**
  61389. * Use the shader store instead of direct source code
  61390. */
  61391. useShaderStore?: boolean;
  61392. /**
  61393. * Vertex shader for the effect
  61394. */
  61395. vertexShader?: string;
  61396. /**
  61397. * Attributes to use in the shader
  61398. */
  61399. attributeNames?: Array<string>;
  61400. /**
  61401. * Uniforms to use in the shader
  61402. */
  61403. uniformNames?: Array<string>;
  61404. /**
  61405. * Texture sampler names to use in the shader
  61406. */
  61407. samplerNames?: Array<string>;
  61408. /**
  61409. * Defines to use in the shader
  61410. */
  61411. defines?: Array<string>;
  61412. /**
  61413. * Callback when effect is compiled
  61414. */
  61415. onCompiled?: Nullable<(effect: Effect) => void>;
  61416. /**
  61417. * The friendly name of the effect displayed in Spector.
  61418. */
  61419. name?: string;
  61420. }
  61421. /**
  61422. * Wraps an effect to be used for rendering
  61423. */
  61424. export class EffectWrapper {
  61425. /**
  61426. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61427. */
  61428. onApplyObservable: Observable<{}>;
  61429. /**
  61430. * The underlying effect
  61431. */
  61432. effect: Effect;
  61433. /**
  61434. * Creates an effect to be renderer
  61435. * @param creationOptions options to create the effect
  61436. */
  61437. constructor(creationOptions: EffectWrapperCreationOptions);
  61438. /**
  61439. * Disposes of the effect wrapper
  61440. */
  61441. dispose(): void;
  61442. }
  61443. }
  61444. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61445. /** @hidden */
  61446. export var hdrFilteringVertexShader: {
  61447. name: string;
  61448. shader: string;
  61449. };
  61450. }
  61451. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61453. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61454. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61455. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61456. /** @hidden */
  61457. export var hdrFilteringPixelShader: {
  61458. name: string;
  61459. shader: string;
  61460. };
  61461. }
  61462. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61464. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61465. import { Nullable } from "babylonjs/types";
  61466. import "babylonjs/Shaders/hdrFiltering.vertex";
  61467. import "babylonjs/Shaders/hdrFiltering.fragment";
  61468. /**
  61469. * Options for texture filtering
  61470. */
  61471. interface IHDRFilteringOptions {
  61472. /**
  61473. * Scales pixel intensity for the input HDR map.
  61474. */
  61475. hdrScale?: number;
  61476. /**
  61477. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61478. */
  61479. quality?: number;
  61480. }
  61481. /**
  61482. * Filters HDR maps to get correct renderings of PBR reflections
  61483. */
  61484. export class HDRFiltering {
  61485. private _engine;
  61486. private _effectRenderer;
  61487. private _effectWrapper;
  61488. private _lodGenerationOffset;
  61489. private _lodGenerationScale;
  61490. /**
  61491. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61492. * you care about baking speed.
  61493. */
  61494. quality: number;
  61495. /**
  61496. * Scales pixel intensity for the input HDR map.
  61497. */
  61498. hdrScale: number;
  61499. /**
  61500. * Instantiates HDR filter for reflection maps
  61501. *
  61502. * @param engine Thin engine
  61503. * @param options Options
  61504. */
  61505. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61506. private _createRenderTarget;
  61507. private _prefilterInternal;
  61508. private _createEffect;
  61509. /**
  61510. * Get a value indicating if the filter is ready to be used
  61511. * @param texture Texture to filter
  61512. * @returns true if the filter is ready
  61513. */
  61514. isReady(texture: BaseTexture): boolean;
  61515. /**
  61516. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61517. * Prefiltering will be invoked at the end of next rendering pass.
  61518. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61519. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61520. * @param texture Texture to filter
  61521. * @param onFinished Callback when filtering is done
  61522. * @return Promise called when prefiltering is done
  61523. */
  61524. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61525. }
  61526. }
  61527. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61528. import { Nullable } from "babylonjs/types";
  61529. import { Scene } from "babylonjs/scene";
  61530. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61532. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61533. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61534. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61535. /**
  61536. * This represents a texture coming from an HDR input.
  61537. *
  61538. * The only supported format is currently panorama picture stored in RGBE format.
  61539. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61540. */
  61541. export class HDRCubeTexture extends BaseTexture {
  61542. private static _facesMapping;
  61543. private _generateHarmonics;
  61544. private _noMipmap;
  61545. private _prefilterOnLoad;
  61546. private _textureMatrix;
  61547. private _size;
  61548. private _onLoad;
  61549. private _onError;
  61550. /**
  61551. * The texture URL.
  61552. */
  61553. url: string;
  61554. /**
  61555. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61556. */
  61557. coordinatesMode: number;
  61558. protected _isBlocking: boolean;
  61559. /**
  61560. * Sets wether or not the texture is blocking during loading.
  61561. */
  61562. set isBlocking(value: boolean);
  61563. /**
  61564. * Gets wether or not the texture is blocking during loading.
  61565. */
  61566. get isBlocking(): boolean;
  61567. protected _rotationY: number;
  61568. /**
  61569. * Sets texture matrix rotation angle around Y axis in radians.
  61570. */
  61571. set rotationY(value: number);
  61572. /**
  61573. * Gets texture matrix rotation angle around Y axis radians.
  61574. */
  61575. get rotationY(): number;
  61576. /**
  61577. * Gets or sets the center of the bounding box associated with the cube texture
  61578. * It must define where the camera used to render the texture was set
  61579. */
  61580. boundingBoxPosition: Vector3;
  61581. private _boundingBoxSize;
  61582. /**
  61583. * Gets or sets the size of the bounding box associated with the cube texture
  61584. * When defined, the cubemap will switch to local mode
  61585. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61586. * @example https://www.babylonjs-playground.com/#RNASML
  61587. */
  61588. set boundingBoxSize(value: Vector3);
  61589. get boundingBoxSize(): Vector3;
  61590. /**
  61591. * Instantiates an HDRTexture from the following parameters.
  61592. *
  61593. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61594. * @param sceneOrEngine The scene or engine the texture will be used in
  61595. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61596. * @param noMipmap Forces to not generate the mipmap if true
  61597. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61598. * @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)
  61599. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61600. */
  61601. 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>);
  61602. /**
  61603. * Get the current class name of the texture useful for serialization or dynamic coding.
  61604. * @returns "HDRCubeTexture"
  61605. */
  61606. getClassName(): string;
  61607. /**
  61608. * Occurs when the file is raw .hdr file.
  61609. */
  61610. private loadTexture;
  61611. clone(): HDRCubeTexture;
  61612. delayLoad(): void;
  61613. /**
  61614. * Get the texture reflection matrix used to rotate/transform the reflection.
  61615. * @returns the reflection matrix
  61616. */
  61617. getReflectionTextureMatrix(): Matrix;
  61618. /**
  61619. * Set the texture reflection matrix used to rotate/transform the reflection.
  61620. * @param value Define the reflection matrix to set
  61621. */
  61622. setReflectionTextureMatrix(value: Matrix): void;
  61623. /**
  61624. * Parses a JSON representation of an HDR Texture in order to create the texture
  61625. * @param parsedTexture Define the JSON representation
  61626. * @param scene Define the scene the texture should be created in
  61627. * @param rootUrl Define the root url in case we need to load relative dependencies
  61628. * @returns the newly created texture after parsing
  61629. */
  61630. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61631. serialize(): any;
  61632. }
  61633. }
  61634. declare module "babylonjs/Physics/physicsEngine" {
  61635. import { Nullable } from "babylonjs/types";
  61636. import { Vector3 } from "babylonjs/Maths/math.vector";
  61637. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61638. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61639. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61640. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61641. /**
  61642. * Class used to control physics engine
  61643. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61644. */
  61645. export class PhysicsEngine implements IPhysicsEngine {
  61646. private _physicsPlugin;
  61647. /**
  61648. * Global value used to control the smallest number supported by the simulation
  61649. */
  61650. static Epsilon: number;
  61651. private _impostors;
  61652. private _joints;
  61653. private _subTimeStep;
  61654. /**
  61655. * Gets the gravity vector used by the simulation
  61656. */
  61657. gravity: Vector3;
  61658. /**
  61659. * Factory used to create the default physics plugin.
  61660. * @returns The default physics plugin
  61661. */
  61662. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61663. /**
  61664. * Creates a new Physics Engine
  61665. * @param gravity defines the gravity vector used by the simulation
  61666. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61667. */
  61668. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61669. /**
  61670. * Sets the gravity vector used by the simulation
  61671. * @param gravity defines the gravity vector to use
  61672. */
  61673. setGravity(gravity: Vector3): void;
  61674. /**
  61675. * Set the time step of the physics engine.
  61676. * Default is 1/60.
  61677. * To slow it down, enter 1/600 for example.
  61678. * To speed it up, 1/30
  61679. * @param newTimeStep defines the new timestep to apply to this world.
  61680. */
  61681. setTimeStep(newTimeStep?: number): void;
  61682. /**
  61683. * Get the time step of the physics engine.
  61684. * @returns the current time step
  61685. */
  61686. getTimeStep(): number;
  61687. /**
  61688. * Set the sub time step of the physics engine.
  61689. * Default is 0 meaning there is no sub steps
  61690. * To increase physics resolution precision, set a small value (like 1 ms)
  61691. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61692. */
  61693. setSubTimeStep(subTimeStep?: number): void;
  61694. /**
  61695. * Get the sub time step of the physics engine.
  61696. * @returns the current sub time step
  61697. */
  61698. getSubTimeStep(): number;
  61699. /**
  61700. * Release all resources
  61701. */
  61702. dispose(): void;
  61703. /**
  61704. * Gets the name of the current physics plugin
  61705. * @returns the name of the plugin
  61706. */
  61707. getPhysicsPluginName(): string;
  61708. /**
  61709. * Adding a new impostor for the impostor tracking.
  61710. * This will be done by the impostor itself.
  61711. * @param impostor the impostor to add
  61712. */
  61713. addImpostor(impostor: PhysicsImpostor): void;
  61714. /**
  61715. * Remove an impostor from the engine.
  61716. * This impostor and its mesh will not longer be updated by the physics engine.
  61717. * @param impostor the impostor to remove
  61718. */
  61719. removeImpostor(impostor: PhysicsImpostor): void;
  61720. /**
  61721. * Add a joint to the physics engine
  61722. * @param mainImpostor defines the main impostor to which the joint is added.
  61723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61724. * @param joint defines the joint that will connect both impostors.
  61725. */
  61726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61727. /**
  61728. * Removes a joint from the simulation
  61729. * @param mainImpostor defines the impostor used with the joint
  61730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61731. * @param joint defines the joint to remove
  61732. */
  61733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61734. /**
  61735. * Called by the scene. No need to call it.
  61736. * @param delta defines the timespam between frames
  61737. */
  61738. _step(delta: number): void;
  61739. /**
  61740. * Gets the current plugin used to run the simulation
  61741. * @returns current plugin
  61742. */
  61743. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61744. /**
  61745. * Gets the list of physic impostors
  61746. * @returns an array of PhysicsImpostor
  61747. */
  61748. getImpostors(): Array<PhysicsImpostor>;
  61749. /**
  61750. * Gets the impostor for a physics enabled object
  61751. * @param object defines the object impersonated by the impostor
  61752. * @returns the PhysicsImpostor or null if not found
  61753. */
  61754. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61755. /**
  61756. * Gets the impostor for a physics body object
  61757. * @param body defines physics body used by the impostor
  61758. * @returns the PhysicsImpostor or null if not found
  61759. */
  61760. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61761. /**
  61762. * Does a raycast in the physics world
  61763. * @param from when should the ray start?
  61764. * @param to when should the ray end?
  61765. * @returns PhysicsRaycastResult
  61766. */
  61767. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61768. }
  61769. }
  61770. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61771. import { Nullable } from "babylonjs/types";
  61772. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61774. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61775. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61776. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61777. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61778. /** @hidden */
  61779. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61780. private _useDeltaForWorldStep;
  61781. world: any;
  61782. name: string;
  61783. private _physicsMaterials;
  61784. private _fixedTimeStep;
  61785. private _cannonRaycastResult;
  61786. private _raycastResult;
  61787. private _physicsBodysToRemoveAfterStep;
  61788. private _firstFrame;
  61789. BJSCANNON: any;
  61790. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61791. setGravity(gravity: Vector3): void;
  61792. setTimeStep(timeStep: number): void;
  61793. getTimeStep(): number;
  61794. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61795. private _removeMarkedPhysicsBodiesFromWorld;
  61796. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61797. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61798. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61799. private _processChildMeshes;
  61800. removePhysicsBody(impostor: PhysicsImpostor): void;
  61801. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61802. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61803. private _addMaterial;
  61804. private _checkWithEpsilon;
  61805. private _createShape;
  61806. private _createHeightmap;
  61807. private _minus90X;
  61808. private _plus90X;
  61809. private _tmpPosition;
  61810. private _tmpDeltaPosition;
  61811. private _tmpUnityRotation;
  61812. private _updatePhysicsBodyTransformation;
  61813. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61814. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61815. isSupported(): boolean;
  61816. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61817. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61818. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61819. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61820. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61821. getBodyMass(impostor: PhysicsImpostor): number;
  61822. getBodyFriction(impostor: PhysicsImpostor): number;
  61823. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61824. getBodyRestitution(impostor: PhysicsImpostor): number;
  61825. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61826. sleepBody(impostor: PhysicsImpostor): void;
  61827. wakeUpBody(impostor: PhysicsImpostor): void;
  61828. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61829. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61830. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61831. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61832. getRadius(impostor: PhysicsImpostor): number;
  61833. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61834. dispose(): void;
  61835. private _extendNamespace;
  61836. /**
  61837. * Does a raycast in the physics world
  61838. * @param from when should the ray start?
  61839. * @param to when should the ray end?
  61840. * @returns PhysicsRaycastResult
  61841. */
  61842. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61843. }
  61844. }
  61845. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  61846. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61847. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61848. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61850. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61851. import { Nullable } from "babylonjs/types";
  61852. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61853. /** @hidden */
  61854. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61855. private _useDeltaForWorldStep;
  61856. world: any;
  61857. name: string;
  61858. BJSOIMO: any;
  61859. private _raycastResult;
  61860. private _fixedTimeStep;
  61861. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61862. setGravity(gravity: Vector3): void;
  61863. setTimeStep(timeStep: number): void;
  61864. getTimeStep(): number;
  61865. private _tmpImpostorsArray;
  61866. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61867. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61868. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61869. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61870. private _tmpPositionVector;
  61871. removePhysicsBody(impostor: PhysicsImpostor): void;
  61872. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61873. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61874. isSupported(): boolean;
  61875. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61876. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61877. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61878. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61879. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61880. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61881. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61882. getBodyMass(impostor: PhysicsImpostor): number;
  61883. getBodyFriction(impostor: PhysicsImpostor): number;
  61884. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61885. getBodyRestitution(impostor: PhysicsImpostor): number;
  61886. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61887. sleepBody(impostor: PhysicsImpostor): void;
  61888. wakeUpBody(impostor: PhysicsImpostor): void;
  61889. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61890. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61891. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61892. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61893. getRadius(impostor: PhysicsImpostor): number;
  61894. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61895. dispose(): void;
  61896. /**
  61897. * Does a raycast in the physics world
  61898. * @param from when should the ray start?
  61899. * @param to when should the ray end?
  61900. * @returns PhysicsRaycastResult
  61901. */
  61902. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61903. }
  61904. }
  61905. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  61906. import { Nullable } from "babylonjs/types";
  61907. import { Scene } from "babylonjs/scene";
  61908. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  61909. import { Color4 } from "babylonjs/Maths/math.color";
  61910. import { Mesh } from "babylonjs/Meshes/mesh";
  61911. /**
  61912. * Class containing static functions to help procedurally build meshes
  61913. */
  61914. export class RibbonBuilder {
  61915. /**
  61916. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61917. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61918. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61919. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61920. * * 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
  61921. * * 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
  61922. * * 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
  61923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61926. * * 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
  61927. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61928. * * 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
  61929. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61931. * @param name defines the name of the mesh
  61932. * @param options defines the options used to create the mesh
  61933. * @param scene defines the hosting scene
  61934. * @returns the ribbon mesh
  61935. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61937. */
  61938. static CreateRibbon(name: string, options: {
  61939. pathArray: Vector3[][];
  61940. closeArray?: boolean;
  61941. closePath?: boolean;
  61942. offset?: number;
  61943. updatable?: boolean;
  61944. sideOrientation?: number;
  61945. frontUVs?: Vector4;
  61946. backUVs?: Vector4;
  61947. instance?: Mesh;
  61948. invertUV?: boolean;
  61949. uvs?: Vector2[];
  61950. colors?: Color4[];
  61951. }, scene?: Nullable<Scene>): Mesh;
  61952. }
  61953. }
  61954. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  61955. import { Nullable } from "babylonjs/types";
  61956. import { Scene } from "babylonjs/scene";
  61957. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61958. import { Mesh } from "babylonjs/Meshes/mesh";
  61959. /**
  61960. * Class containing static functions to help procedurally build meshes
  61961. */
  61962. export class ShapeBuilder {
  61963. /**
  61964. * 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.
  61965. * * 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.
  61966. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61967. * * 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.
  61968. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61969. * * 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
  61970. * * 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
  61971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61976. * @param name defines the name of the mesh
  61977. * @param options defines the options used to create the mesh
  61978. * @param scene defines the hosting scene
  61979. * @returns the extruded shape mesh
  61980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61982. */
  61983. static ExtrudeShape(name: string, options: {
  61984. shape: Vector3[];
  61985. path: Vector3[];
  61986. scale?: number;
  61987. rotation?: number;
  61988. cap?: number;
  61989. updatable?: boolean;
  61990. sideOrientation?: number;
  61991. frontUVs?: Vector4;
  61992. backUVs?: Vector4;
  61993. instance?: Mesh;
  61994. invertUV?: boolean;
  61995. }, scene?: Nullable<Scene>): Mesh;
  61996. /**
  61997. * Creates an custom extruded shape mesh.
  61998. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61999. * * 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.
  62000. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62001. * * 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
  62002. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62003. * * 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
  62004. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62005. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62006. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62007. * * 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
  62008. * * 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
  62009. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62014. * @param name defines the name of the mesh
  62015. * @param options defines the options used to create the mesh
  62016. * @param scene defines the hosting scene
  62017. * @returns the custom extruded shape mesh
  62018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62021. */
  62022. static ExtrudeShapeCustom(name: string, options: {
  62023. shape: Vector3[];
  62024. path: Vector3[];
  62025. scaleFunction?: any;
  62026. rotationFunction?: any;
  62027. ribbonCloseArray?: boolean;
  62028. ribbonClosePath?: boolean;
  62029. cap?: number;
  62030. updatable?: boolean;
  62031. sideOrientation?: number;
  62032. frontUVs?: Vector4;
  62033. backUVs?: Vector4;
  62034. instance?: Mesh;
  62035. invertUV?: boolean;
  62036. }, scene?: Nullable<Scene>): Mesh;
  62037. private static _ExtrudeShapeGeneric;
  62038. }
  62039. }
  62040. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62041. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62042. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62043. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62044. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62045. import { Nullable } from "babylonjs/types";
  62046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62047. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62048. /**
  62049. * AmmoJS Physics plugin
  62050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62051. * @see https://github.com/kripken/ammo.js/
  62052. */
  62053. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62054. private _useDeltaForWorldStep;
  62055. /**
  62056. * Reference to the Ammo library
  62057. */
  62058. bjsAMMO: any;
  62059. /**
  62060. * Created ammoJS world which physics bodies are added to
  62061. */
  62062. world: any;
  62063. /**
  62064. * Name of the plugin
  62065. */
  62066. name: string;
  62067. private _timeStep;
  62068. private _fixedTimeStep;
  62069. private _maxSteps;
  62070. private _tmpQuaternion;
  62071. private _tmpAmmoTransform;
  62072. private _tmpAmmoQuaternion;
  62073. private _tmpAmmoConcreteContactResultCallback;
  62074. private _collisionConfiguration;
  62075. private _dispatcher;
  62076. private _overlappingPairCache;
  62077. private _solver;
  62078. private _softBodySolver;
  62079. private _tmpAmmoVectorA;
  62080. private _tmpAmmoVectorB;
  62081. private _tmpAmmoVectorC;
  62082. private _tmpAmmoVectorD;
  62083. private _tmpContactCallbackResult;
  62084. private _tmpAmmoVectorRCA;
  62085. private _tmpAmmoVectorRCB;
  62086. private _raycastResult;
  62087. private static readonly DISABLE_COLLISION_FLAG;
  62088. private static readonly KINEMATIC_FLAG;
  62089. private static readonly DISABLE_DEACTIVATION_FLAG;
  62090. /**
  62091. * Initializes the ammoJS plugin
  62092. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62093. * @param ammoInjection can be used to inject your own ammo reference
  62094. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62095. */
  62096. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62097. /**
  62098. * Sets the gravity of the physics world (m/(s^2))
  62099. * @param gravity Gravity to set
  62100. */
  62101. setGravity(gravity: Vector3): void;
  62102. /**
  62103. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62104. * @param timeStep timestep to use in seconds
  62105. */
  62106. setTimeStep(timeStep: number): void;
  62107. /**
  62108. * 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)
  62109. * @param fixedTimeStep fixedTimeStep to use in seconds
  62110. */
  62111. setFixedTimeStep(fixedTimeStep: number): void;
  62112. /**
  62113. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62114. * @param maxSteps the maximum number of steps by the physics engine per frame
  62115. */
  62116. setMaxSteps(maxSteps: number): void;
  62117. /**
  62118. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62119. * @returns the current timestep in seconds
  62120. */
  62121. getTimeStep(): number;
  62122. /**
  62123. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62124. */
  62125. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62126. private _isImpostorInContact;
  62127. private _isImpostorPairInContact;
  62128. private _stepSimulation;
  62129. /**
  62130. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62131. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62132. * After the step the babylon meshes are set to the position of the physics imposters
  62133. * @param delta amount of time to step forward
  62134. * @param impostors array of imposters to update before/after the step
  62135. */
  62136. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62137. /**
  62138. * Update babylon mesh to match physics world object
  62139. * @param impostor imposter to match
  62140. */
  62141. private _afterSoftStep;
  62142. /**
  62143. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62144. * @param impostor imposter to match
  62145. */
  62146. private _ropeStep;
  62147. /**
  62148. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62149. * @param impostor imposter to match
  62150. */
  62151. private _softbodyOrClothStep;
  62152. private _tmpMatrix;
  62153. /**
  62154. * Applies an impulse on the imposter
  62155. * @param impostor imposter to apply impulse to
  62156. * @param force amount of force to be applied to the imposter
  62157. * @param contactPoint the location to apply the impulse on the imposter
  62158. */
  62159. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62160. /**
  62161. * Applies a force on the imposter
  62162. * @param impostor imposter to apply force
  62163. * @param force amount of force to be applied to the imposter
  62164. * @param contactPoint the location to apply the force on the imposter
  62165. */
  62166. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62167. /**
  62168. * Creates a physics body using the plugin
  62169. * @param impostor the imposter to create the physics body on
  62170. */
  62171. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62172. /**
  62173. * Removes the physics body from the imposter and disposes of the body's memory
  62174. * @param impostor imposter to remove the physics body from
  62175. */
  62176. removePhysicsBody(impostor: PhysicsImpostor): void;
  62177. /**
  62178. * Generates a joint
  62179. * @param impostorJoint the imposter joint to create the joint with
  62180. */
  62181. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62182. /**
  62183. * Removes a joint
  62184. * @param impostorJoint the imposter joint to remove the joint from
  62185. */
  62186. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62187. private _addMeshVerts;
  62188. /**
  62189. * Initialise the soft body vertices to match its object's (mesh) vertices
  62190. * Softbody vertices (nodes) are in world space and to match this
  62191. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62192. * @param impostor to create the softbody for
  62193. */
  62194. private _softVertexData;
  62195. /**
  62196. * Create an impostor's soft body
  62197. * @param impostor to create the softbody for
  62198. */
  62199. private _createSoftbody;
  62200. /**
  62201. * Create cloth for an impostor
  62202. * @param impostor to create the softbody for
  62203. */
  62204. private _createCloth;
  62205. /**
  62206. * Create rope for an impostor
  62207. * @param impostor to create the softbody for
  62208. */
  62209. private _createRope;
  62210. /**
  62211. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62212. * @param impostor to create the custom physics shape for
  62213. */
  62214. private _createCustom;
  62215. private _addHullVerts;
  62216. private _createShape;
  62217. /**
  62218. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62219. * @param impostor imposter containing the physics body and babylon object
  62220. */
  62221. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62222. /**
  62223. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62224. * @param impostor imposter containing the physics body and babylon object
  62225. * @param newPosition new position
  62226. * @param newRotation new rotation
  62227. */
  62228. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62229. /**
  62230. * If this plugin is supported
  62231. * @returns true if its supported
  62232. */
  62233. isSupported(): boolean;
  62234. /**
  62235. * Sets the linear velocity of the physics body
  62236. * @param impostor imposter to set the velocity on
  62237. * @param velocity velocity to set
  62238. */
  62239. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62240. /**
  62241. * Sets the angular velocity of the physics body
  62242. * @param impostor imposter to set the velocity on
  62243. * @param velocity velocity to set
  62244. */
  62245. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62246. /**
  62247. * gets the linear velocity
  62248. * @param impostor imposter to get linear velocity from
  62249. * @returns linear velocity
  62250. */
  62251. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62252. /**
  62253. * gets the angular velocity
  62254. * @param impostor imposter to get angular velocity from
  62255. * @returns angular velocity
  62256. */
  62257. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62258. /**
  62259. * Sets the mass of physics body
  62260. * @param impostor imposter to set the mass on
  62261. * @param mass mass to set
  62262. */
  62263. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62264. /**
  62265. * Gets the mass of the physics body
  62266. * @param impostor imposter to get the mass from
  62267. * @returns mass
  62268. */
  62269. getBodyMass(impostor: PhysicsImpostor): number;
  62270. /**
  62271. * Gets friction of the impostor
  62272. * @param impostor impostor to get friction from
  62273. * @returns friction value
  62274. */
  62275. getBodyFriction(impostor: PhysicsImpostor): number;
  62276. /**
  62277. * Sets friction of the impostor
  62278. * @param impostor impostor to set friction on
  62279. * @param friction friction value
  62280. */
  62281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62282. /**
  62283. * Gets restitution of the impostor
  62284. * @param impostor impostor to get restitution from
  62285. * @returns restitution value
  62286. */
  62287. getBodyRestitution(impostor: PhysicsImpostor): number;
  62288. /**
  62289. * Sets resitution of the impostor
  62290. * @param impostor impostor to set resitution on
  62291. * @param restitution resitution value
  62292. */
  62293. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62294. /**
  62295. * Gets pressure inside the impostor
  62296. * @param impostor impostor to get pressure from
  62297. * @returns pressure value
  62298. */
  62299. getBodyPressure(impostor: PhysicsImpostor): number;
  62300. /**
  62301. * Sets pressure inside a soft body impostor
  62302. * Cloth and rope must remain 0 pressure
  62303. * @param impostor impostor to set pressure on
  62304. * @param pressure pressure value
  62305. */
  62306. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62307. /**
  62308. * Gets stiffness of the impostor
  62309. * @param impostor impostor to get stiffness from
  62310. * @returns pressure value
  62311. */
  62312. getBodyStiffness(impostor: PhysicsImpostor): number;
  62313. /**
  62314. * Sets stiffness of the impostor
  62315. * @param impostor impostor to set stiffness on
  62316. * @param stiffness stiffness value from 0 to 1
  62317. */
  62318. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62319. /**
  62320. * Gets velocityIterations of the impostor
  62321. * @param impostor impostor to get velocity iterations from
  62322. * @returns velocityIterations value
  62323. */
  62324. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62325. /**
  62326. * Sets velocityIterations of the impostor
  62327. * @param impostor impostor to set velocity iterations on
  62328. * @param velocityIterations velocityIterations value
  62329. */
  62330. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62331. /**
  62332. * Gets positionIterations of the impostor
  62333. * @param impostor impostor to get position iterations from
  62334. * @returns positionIterations value
  62335. */
  62336. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62337. /**
  62338. * Sets positionIterations of the impostor
  62339. * @param impostor impostor to set position on
  62340. * @param positionIterations positionIterations value
  62341. */
  62342. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62343. /**
  62344. * Append an anchor to a cloth object
  62345. * @param impostor is the cloth impostor to add anchor to
  62346. * @param otherImpostor is the rigid impostor to anchor to
  62347. * @param width ratio across width from 0 to 1
  62348. * @param height ratio up height from 0 to 1
  62349. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62350. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62351. */
  62352. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62353. /**
  62354. * Append an hook to a rope object
  62355. * @param impostor is the rope impostor to add hook to
  62356. * @param otherImpostor is the rigid impostor to hook to
  62357. * @param length ratio along the rope from 0 to 1
  62358. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62359. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62360. */
  62361. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62362. /**
  62363. * Sleeps the physics body and stops it from being active
  62364. * @param impostor impostor to sleep
  62365. */
  62366. sleepBody(impostor: PhysicsImpostor): void;
  62367. /**
  62368. * Activates the physics body
  62369. * @param impostor impostor to activate
  62370. */
  62371. wakeUpBody(impostor: PhysicsImpostor): void;
  62372. /**
  62373. * Updates the distance parameters of the joint
  62374. * @param joint joint to update
  62375. * @param maxDistance maximum distance of the joint
  62376. * @param minDistance minimum distance of the joint
  62377. */
  62378. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62379. /**
  62380. * Sets a motor on the joint
  62381. * @param joint joint to set motor on
  62382. * @param speed speed of the motor
  62383. * @param maxForce maximum force of the motor
  62384. * @param motorIndex index of the motor
  62385. */
  62386. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62387. /**
  62388. * Sets the motors limit
  62389. * @param joint joint to set limit on
  62390. * @param upperLimit upper limit
  62391. * @param lowerLimit lower limit
  62392. */
  62393. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62394. /**
  62395. * Syncs the position and rotation of a mesh with the impostor
  62396. * @param mesh mesh to sync
  62397. * @param impostor impostor to update the mesh with
  62398. */
  62399. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62400. /**
  62401. * Gets the radius of the impostor
  62402. * @param impostor impostor to get radius from
  62403. * @returns the radius
  62404. */
  62405. getRadius(impostor: PhysicsImpostor): number;
  62406. /**
  62407. * Gets the box size of the impostor
  62408. * @param impostor impostor to get box size from
  62409. * @param result the resulting box size
  62410. */
  62411. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62412. /**
  62413. * Disposes of the impostor
  62414. */
  62415. dispose(): void;
  62416. /**
  62417. * Does a raycast in the physics world
  62418. * @param from when should the ray start?
  62419. * @param to when should the ray end?
  62420. * @returns PhysicsRaycastResult
  62421. */
  62422. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62423. }
  62424. }
  62425. declare module "babylonjs/Probes/reflectionProbe" {
  62426. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62427. import { Vector3 } from "babylonjs/Maths/math.vector";
  62428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62429. import { Nullable } from "babylonjs/types";
  62430. import { Scene } from "babylonjs/scene";
  62431. module "babylonjs/abstractScene" {
  62432. interface AbstractScene {
  62433. /**
  62434. * The list of reflection probes added to the scene
  62435. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62436. */
  62437. reflectionProbes: Array<ReflectionProbe>;
  62438. /**
  62439. * Removes the given reflection probe from this scene.
  62440. * @param toRemove The reflection probe to remove
  62441. * @returns The index of the removed reflection probe
  62442. */
  62443. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62444. /**
  62445. * Adds the given reflection probe to this scene.
  62446. * @param newReflectionProbe The reflection probe to add
  62447. */
  62448. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62449. }
  62450. }
  62451. /**
  62452. * Class used to generate realtime reflection / refraction cube textures
  62453. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62454. */
  62455. export class ReflectionProbe {
  62456. /** defines the name of the probe */
  62457. name: string;
  62458. private _scene;
  62459. private _renderTargetTexture;
  62460. private _projectionMatrix;
  62461. private _viewMatrix;
  62462. private _target;
  62463. private _add;
  62464. private _attachedMesh;
  62465. private _invertYAxis;
  62466. /** Gets or sets probe position (center of the cube map) */
  62467. position: Vector3;
  62468. /**
  62469. * Creates a new reflection probe
  62470. * @param name defines the name of the probe
  62471. * @param size defines the texture resolution (for each face)
  62472. * @param scene defines the hosting scene
  62473. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62474. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62475. */
  62476. constructor(
  62477. /** defines the name of the probe */
  62478. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62479. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62480. get samples(): number;
  62481. set samples(value: number);
  62482. /** Gets or sets the refresh rate to use (on every frame by default) */
  62483. get refreshRate(): number;
  62484. set refreshRate(value: number);
  62485. /**
  62486. * Gets the hosting scene
  62487. * @returns a Scene
  62488. */
  62489. getScene(): Scene;
  62490. /** Gets the internal CubeTexture used to render to */
  62491. get cubeTexture(): RenderTargetTexture;
  62492. /** Gets the list of meshes to render */
  62493. get renderList(): Nullable<AbstractMesh[]>;
  62494. /**
  62495. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62496. * @param mesh defines the mesh to attach to
  62497. */
  62498. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62499. /**
  62500. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62501. * @param renderingGroupId The rendering group id corresponding to its index
  62502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62503. */
  62504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62505. /**
  62506. * Clean all associated resources
  62507. */
  62508. dispose(): void;
  62509. /**
  62510. * Converts the reflection probe information to a readable string for debug purpose.
  62511. * @param fullDetails Supports for multiple levels of logging within scene loading
  62512. * @returns the human readable reflection probe info
  62513. */
  62514. toString(fullDetails?: boolean): string;
  62515. /**
  62516. * Get the class name of the relfection probe.
  62517. * @returns "ReflectionProbe"
  62518. */
  62519. getClassName(): string;
  62520. /**
  62521. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62522. * @returns The JSON representation of the texture
  62523. */
  62524. serialize(): any;
  62525. /**
  62526. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62527. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62528. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62529. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62530. * @returns The parsed reflection probe if successful
  62531. */
  62532. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62533. }
  62534. }
  62535. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62536. /** @hidden */
  62537. export var _BabylonLoaderRegistered: boolean;
  62538. /**
  62539. * Helps setting up some configuration for the babylon file loader.
  62540. */
  62541. export class BabylonFileLoaderConfiguration {
  62542. /**
  62543. * The loader does not allow injecting custom physix engine into the plugins.
  62544. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62545. * So you could set this variable to your engine import to make it work.
  62546. */
  62547. static LoaderInjectedPhysicsEngine: any;
  62548. }
  62549. }
  62550. declare module "babylonjs/Loading/Plugins/index" {
  62551. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62552. }
  62553. declare module "babylonjs/Loading/index" {
  62554. export * from "babylonjs/Loading/loadingScreen";
  62555. export * from "babylonjs/Loading/Plugins/index";
  62556. export * from "babylonjs/Loading/sceneLoader";
  62557. export * from "babylonjs/Loading/sceneLoaderFlags";
  62558. }
  62559. declare module "babylonjs/Materials/Background/index" {
  62560. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62561. }
  62562. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62563. import { Scene } from "babylonjs/scene";
  62564. import { Color3 } from "babylonjs/Maths/math.color";
  62565. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62567. /**
  62568. * The Physically based simple base material of BJS.
  62569. *
  62570. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62571. * It is used as the base class for both the specGloss and metalRough conventions.
  62572. */
  62573. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62574. /**
  62575. * Number of Simultaneous lights allowed on the material.
  62576. */
  62577. maxSimultaneousLights: number;
  62578. /**
  62579. * If sets to true, disables all the lights affecting the material.
  62580. */
  62581. disableLighting: boolean;
  62582. /**
  62583. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62584. */
  62585. environmentTexture: BaseTexture;
  62586. /**
  62587. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62588. */
  62589. invertNormalMapX: boolean;
  62590. /**
  62591. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62592. */
  62593. invertNormalMapY: boolean;
  62594. /**
  62595. * Normal map used in the model.
  62596. */
  62597. normalTexture: BaseTexture;
  62598. /**
  62599. * Emissivie color used to self-illuminate the model.
  62600. */
  62601. emissiveColor: Color3;
  62602. /**
  62603. * Emissivie texture used to self-illuminate the model.
  62604. */
  62605. emissiveTexture: BaseTexture;
  62606. /**
  62607. * Occlusion Channel Strenght.
  62608. */
  62609. occlusionStrength: number;
  62610. /**
  62611. * Occlusion Texture of the material (adding extra occlusion effects).
  62612. */
  62613. occlusionTexture: BaseTexture;
  62614. /**
  62615. * Defines the alpha limits in alpha test mode.
  62616. */
  62617. alphaCutOff: number;
  62618. /**
  62619. * Gets the current double sided mode.
  62620. */
  62621. get doubleSided(): boolean;
  62622. /**
  62623. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62624. */
  62625. set doubleSided(value: boolean);
  62626. /**
  62627. * Stores the pre-calculated light information of a mesh in a texture.
  62628. */
  62629. lightmapTexture: BaseTexture;
  62630. /**
  62631. * If true, the light map contains occlusion information instead of lighting info.
  62632. */
  62633. useLightmapAsShadowmap: boolean;
  62634. /**
  62635. * Instantiates a new PBRMaterial instance.
  62636. *
  62637. * @param name The material name
  62638. * @param scene The scene the material will be use in.
  62639. */
  62640. constructor(name: string, scene: Scene);
  62641. getClassName(): string;
  62642. }
  62643. }
  62644. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62645. import { Scene } from "babylonjs/scene";
  62646. import { Color3 } from "babylonjs/Maths/math.color";
  62647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62648. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62649. /**
  62650. * The PBR material of BJS following the metal roughness convention.
  62651. *
  62652. * This fits to the PBR convention in the GLTF definition:
  62653. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62654. */
  62655. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62656. /**
  62657. * The base color has two different interpretations depending on the value of metalness.
  62658. * When the material is a metal, the base color is the specific measured reflectance value
  62659. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62660. * of the material.
  62661. */
  62662. baseColor: Color3;
  62663. /**
  62664. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62665. * well as opacity information in the alpha channel.
  62666. */
  62667. baseTexture: BaseTexture;
  62668. /**
  62669. * Specifies the metallic scalar value of the material.
  62670. * Can also be used to scale the metalness values of the metallic texture.
  62671. */
  62672. metallic: number;
  62673. /**
  62674. * Specifies the roughness scalar value of the material.
  62675. * Can also be used to scale the roughness values of the metallic texture.
  62676. */
  62677. roughness: number;
  62678. /**
  62679. * Texture containing both the metallic value in the B channel and the
  62680. * roughness value in the G channel to keep better precision.
  62681. */
  62682. metallicRoughnessTexture: BaseTexture;
  62683. /**
  62684. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62685. *
  62686. * @param name The material name
  62687. * @param scene The scene the material will be use in.
  62688. */
  62689. constructor(name: string, scene: Scene);
  62690. /**
  62691. * Return the currrent class name of the material.
  62692. */
  62693. getClassName(): string;
  62694. /**
  62695. * Makes a duplicate of the current material.
  62696. * @param name - name to use for the new material.
  62697. */
  62698. clone(name: string): PBRMetallicRoughnessMaterial;
  62699. /**
  62700. * Serialize the material to a parsable JSON object.
  62701. */
  62702. serialize(): any;
  62703. /**
  62704. * Parses a JSON object correponding to the serialize function.
  62705. */
  62706. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62707. }
  62708. }
  62709. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62710. import { Scene } from "babylonjs/scene";
  62711. import { Color3 } from "babylonjs/Maths/math.color";
  62712. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62713. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62714. /**
  62715. * The PBR material of BJS following the specular glossiness convention.
  62716. *
  62717. * This fits to the PBR convention in the GLTF definition:
  62718. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62719. */
  62720. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62721. /**
  62722. * Specifies the diffuse color of the material.
  62723. */
  62724. diffuseColor: Color3;
  62725. /**
  62726. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62727. * channel.
  62728. */
  62729. diffuseTexture: BaseTexture;
  62730. /**
  62731. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62732. */
  62733. specularColor: Color3;
  62734. /**
  62735. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62736. */
  62737. glossiness: number;
  62738. /**
  62739. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62740. */
  62741. specularGlossinessTexture: BaseTexture;
  62742. /**
  62743. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62744. *
  62745. * @param name The material name
  62746. * @param scene The scene the material will be use in.
  62747. */
  62748. constructor(name: string, scene: Scene);
  62749. /**
  62750. * Return the currrent class name of the material.
  62751. */
  62752. getClassName(): string;
  62753. /**
  62754. * Makes a duplicate of the current material.
  62755. * @param name - name to use for the new material.
  62756. */
  62757. clone(name: string): PBRSpecularGlossinessMaterial;
  62758. /**
  62759. * Serialize the material to a parsable JSON object.
  62760. */
  62761. serialize(): any;
  62762. /**
  62763. * Parses a JSON object correponding to the serialize function.
  62764. */
  62765. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62766. }
  62767. }
  62768. declare module "babylonjs/Materials/PBR/index" {
  62769. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62770. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62771. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62772. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62773. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62774. }
  62775. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62776. import { Nullable } from "babylonjs/types";
  62777. import { Scene } from "babylonjs/scene";
  62778. import { Matrix } from "babylonjs/Maths/math.vector";
  62779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62780. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62781. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62782. /**
  62783. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62784. * It can help converting any input color in a desired output one. This can then be used to create effects
  62785. * from sepia, black and white to sixties or futuristic rendering...
  62786. *
  62787. * The only supported format is currently 3dl.
  62788. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62789. */
  62790. export class ColorGradingTexture extends BaseTexture {
  62791. /**
  62792. * The texture URL.
  62793. */
  62794. url: string;
  62795. /**
  62796. * Empty line regex stored for GC.
  62797. */
  62798. private static _noneEmptyLineRegex;
  62799. private _textureMatrix;
  62800. private _onLoad;
  62801. /**
  62802. * Instantiates a ColorGradingTexture from the following parameters.
  62803. *
  62804. * @param url The location of the color gradind data (currently only supporting 3dl)
  62805. * @param sceneOrEngine The scene or engine the texture will be used in
  62806. * @param onLoad defines a callback triggered when the texture has been loaded
  62807. */
  62808. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62809. /**
  62810. * Fires the onload event from the constructor if requested.
  62811. */
  62812. private _triggerOnLoad;
  62813. /**
  62814. * Returns the texture matrix used in most of the material.
  62815. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62816. */
  62817. getTextureMatrix(): Matrix;
  62818. /**
  62819. * Occurs when the file being loaded is a .3dl LUT file.
  62820. */
  62821. private load3dlTexture;
  62822. /**
  62823. * Starts the loading process of the texture.
  62824. */
  62825. private loadTexture;
  62826. /**
  62827. * Clones the color gradind texture.
  62828. */
  62829. clone(): ColorGradingTexture;
  62830. /**
  62831. * Called during delayed load for textures.
  62832. */
  62833. delayLoad(): void;
  62834. /**
  62835. * Parses a color grading texture serialized by Babylon.
  62836. * @param parsedTexture The texture information being parsedTexture
  62837. * @param scene The scene to load the texture in
  62838. * @param rootUrl The root url of the data assets to load
  62839. * @return A color gradind texture
  62840. */
  62841. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62842. /**
  62843. * Serializes the LUT texture to json format.
  62844. */
  62845. serialize(): any;
  62846. }
  62847. }
  62848. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  62849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62850. import { Scene } from "babylonjs/scene";
  62851. import { Nullable } from "babylonjs/types";
  62852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62853. /**
  62854. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62855. */
  62856. export class EquiRectangularCubeTexture extends BaseTexture {
  62857. /** The six faces of the cube. */
  62858. private static _FacesMapping;
  62859. private _noMipmap;
  62860. private _onLoad;
  62861. private _onError;
  62862. /** The size of the cubemap. */
  62863. private _size;
  62864. /** The buffer of the image. */
  62865. private _buffer;
  62866. /** The width of the input image. */
  62867. private _width;
  62868. /** The height of the input image. */
  62869. private _height;
  62870. /** The URL to the image. */
  62871. url: string;
  62872. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  62873. coordinatesMode: number;
  62874. /**
  62875. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62876. * @param url The location of the image
  62877. * @param scene The scene the texture will be used in
  62878. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62879. * @param noMipmap Forces to not generate the mipmap if true
  62880. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62881. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62882. * @param onLoad — defines a callback called when texture is loaded
  62883. * @param onError — defines a callback called if there is an error
  62884. */
  62885. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62886. /**
  62887. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62888. */
  62889. private loadImage;
  62890. /**
  62891. * Convert the image buffer into a cubemap and create a CubeTexture.
  62892. */
  62893. private loadTexture;
  62894. /**
  62895. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62896. * @param buffer The ArrayBuffer that should be converted.
  62897. * @returns The buffer as Float32Array.
  62898. */
  62899. private getFloat32ArrayFromArrayBuffer;
  62900. /**
  62901. * Get the current class name of the texture useful for serialization or dynamic coding.
  62902. * @returns "EquiRectangularCubeTexture"
  62903. */
  62904. getClassName(): string;
  62905. /**
  62906. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62907. * @returns A clone of the current EquiRectangularCubeTexture.
  62908. */
  62909. clone(): EquiRectangularCubeTexture;
  62910. }
  62911. }
  62912. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  62913. import { Nullable } from "babylonjs/types";
  62914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62915. import { Matrix } from "babylonjs/Maths/math.vector";
  62916. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  62917. import "babylonjs/Engines/Extensions/engine.videoTexture";
  62918. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62919. import { Scene } from "babylonjs/scene";
  62920. /**
  62921. * Defines the options related to the creation of an HtmlElementTexture
  62922. */
  62923. export interface IHtmlElementTextureOptions {
  62924. /**
  62925. * Defines wether mip maps should be created or not.
  62926. */
  62927. generateMipMaps?: boolean;
  62928. /**
  62929. * Defines the sampling mode of the texture.
  62930. */
  62931. samplingMode?: number;
  62932. /**
  62933. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62934. */
  62935. engine: Nullable<ThinEngine>;
  62936. /**
  62937. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62938. */
  62939. scene: Nullable<Scene>;
  62940. }
  62941. /**
  62942. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62943. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62944. * is automatically managed.
  62945. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62946. * in your application.
  62947. *
  62948. * As the update is not automatic, you need to call them manually.
  62949. */
  62950. export class HtmlElementTexture extends BaseTexture {
  62951. /**
  62952. * The texture URL.
  62953. */
  62954. element: HTMLVideoElement | HTMLCanvasElement;
  62955. private static readonly DefaultOptions;
  62956. private _textureMatrix;
  62957. private _isVideo;
  62958. private _generateMipMaps;
  62959. private _samplingMode;
  62960. /**
  62961. * Instantiates a HtmlElementTexture from the following parameters.
  62962. *
  62963. * @param name Defines the name of the texture
  62964. * @param element Defines the video or canvas the texture is filled with
  62965. * @param options Defines the other none mandatory texture creation options
  62966. */
  62967. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62968. private _createInternalTexture;
  62969. /**
  62970. * Returns the texture matrix used in most of the material.
  62971. */
  62972. getTextureMatrix(): Matrix;
  62973. /**
  62974. * Updates the content of the texture.
  62975. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62976. */
  62977. update(invertY?: Nullable<boolean>): void;
  62978. }
  62979. }
  62980. declare module "babylonjs/Misc/tga" {
  62981. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62982. /**
  62983. * Based on jsTGALoader - Javascript loader for TGA file
  62984. * By Vincent Thibault
  62985. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62986. */
  62987. export class TGATools {
  62988. private static _TYPE_INDEXED;
  62989. private static _TYPE_RGB;
  62990. private static _TYPE_GREY;
  62991. private static _TYPE_RLE_INDEXED;
  62992. private static _TYPE_RLE_RGB;
  62993. private static _TYPE_RLE_GREY;
  62994. private static _ORIGIN_MASK;
  62995. private static _ORIGIN_SHIFT;
  62996. private static _ORIGIN_BL;
  62997. private static _ORIGIN_BR;
  62998. private static _ORIGIN_UL;
  62999. private static _ORIGIN_UR;
  63000. /**
  63001. * Gets the header of a TGA file
  63002. * @param data defines the TGA data
  63003. * @returns the header
  63004. */
  63005. static GetTGAHeader(data: Uint8Array): any;
  63006. /**
  63007. * Uploads TGA content to a Babylon Texture
  63008. * @hidden
  63009. */
  63010. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63011. /** @hidden */
  63012. 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;
  63013. /** @hidden */
  63014. 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;
  63015. /** @hidden */
  63016. 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;
  63017. /** @hidden */
  63018. 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;
  63019. /** @hidden */
  63020. 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;
  63021. /** @hidden */
  63022. 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;
  63023. }
  63024. }
  63025. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63026. import { Nullable } from "babylonjs/types";
  63027. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63028. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63029. /**
  63030. * Implementation of the TGA Texture Loader.
  63031. * @hidden
  63032. */
  63033. export class _TGATextureLoader implements IInternalTextureLoader {
  63034. /**
  63035. * Defines wether the loader supports cascade loading the different faces.
  63036. */
  63037. readonly supportCascades: boolean;
  63038. /**
  63039. * This returns if the loader support the current file information.
  63040. * @param extension defines the file extension of the file being loaded
  63041. * @returns true if the loader can load the specified file
  63042. */
  63043. canLoad(extension: string): boolean;
  63044. /**
  63045. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63046. * @param data contains the texture data
  63047. * @param texture defines the BabylonJS internal texture
  63048. * @param createPolynomials will be true if polynomials have been requested
  63049. * @param onLoad defines the callback to trigger once the texture is ready
  63050. * @param onError defines the callback to trigger in case of error
  63051. */
  63052. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63053. /**
  63054. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63055. * @param data contains the texture data
  63056. * @param texture defines the BabylonJS internal texture
  63057. * @param callback defines the method to call once ready to upload
  63058. */
  63059. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63060. }
  63061. }
  63062. declare module "babylonjs/Misc/basis" {
  63063. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63064. /**
  63065. * Info about the .basis files
  63066. */
  63067. class BasisFileInfo {
  63068. /**
  63069. * If the file has alpha
  63070. */
  63071. hasAlpha: boolean;
  63072. /**
  63073. * Info about each image of the basis file
  63074. */
  63075. images: Array<{
  63076. levels: Array<{
  63077. width: number;
  63078. height: number;
  63079. transcodedPixels: ArrayBufferView;
  63080. }>;
  63081. }>;
  63082. }
  63083. /**
  63084. * Result of transcoding a basis file
  63085. */
  63086. class TranscodeResult {
  63087. /**
  63088. * Info about the .basis file
  63089. */
  63090. fileInfo: BasisFileInfo;
  63091. /**
  63092. * Format to use when loading the file
  63093. */
  63094. format: number;
  63095. }
  63096. /**
  63097. * Configuration options for the Basis transcoder
  63098. */
  63099. export class BasisTranscodeConfiguration {
  63100. /**
  63101. * Supported compression formats used to determine the supported output format of the transcoder
  63102. */
  63103. supportedCompressionFormats?: {
  63104. /**
  63105. * etc1 compression format
  63106. */
  63107. etc1?: boolean;
  63108. /**
  63109. * s3tc compression format
  63110. */
  63111. s3tc?: boolean;
  63112. /**
  63113. * pvrtc compression format
  63114. */
  63115. pvrtc?: boolean;
  63116. /**
  63117. * etc2 compression format
  63118. */
  63119. etc2?: boolean;
  63120. };
  63121. /**
  63122. * If mipmap levels should be loaded for transcoded images (Default: true)
  63123. */
  63124. loadMipmapLevels?: boolean;
  63125. /**
  63126. * Index of a single image to load (Default: all images)
  63127. */
  63128. loadSingleImage?: number;
  63129. }
  63130. /**
  63131. * Used to load .Basis files
  63132. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63133. */
  63134. export class BasisTools {
  63135. private static _IgnoreSupportedFormats;
  63136. /**
  63137. * URL to use when loading the basis transcoder
  63138. */
  63139. static JSModuleURL: string;
  63140. /**
  63141. * URL to use when loading the wasm module for the transcoder
  63142. */
  63143. static WasmModuleURL: string;
  63144. /**
  63145. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63146. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63147. * @returns internal format corresponding to the Basis format
  63148. */
  63149. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63150. private static _WorkerPromise;
  63151. private static _Worker;
  63152. private static _actionId;
  63153. private static _CreateWorkerAsync;
  63154. /**
  63155. * Transcodes a loaded image file to compressed pixel data
  63156. * @param data image data to transcode
  63157. * @param config configuration options for the transcoding
  63158. * @returns a promise resulting in the transcoded image
  63159. */
  63160. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63161. /**
  63162. * Loads a texture from the transcode result
  63163. * @param texture texture load to
  63164. * @param transcodeResult the result of transcoding the basis file to load from
  63165. */
  63166. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63167. }
  63168. }
  63169. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63170. import { Nullable } from "babylonjs/types";
  63171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63172. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63173. /**
  63174. * Loader for .basis file format
  63175. */
  63176. export class _BasisTextureLoader implements IInternalTextureLoader {
  63177. /**
  63178. * Defines whether the loader supports cascade loading the different faces.
  63179. */
  63180. readonly supportCascades: boolean;
  63181. /**
  63182. * This returns if the loader support the current file information.
  63183. * @param extension defines the file extension of the file being loaded
  63184. * @returns true if the loader can load the specified file
  63185. */
  63186. canLoad(extension: string): boolean;
  63187. /**
  63188. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63189. * @param data contains the texture data
  63190. * @param texture defines the BabylonJS internal texture
  63191. * @param createPolynomials will be true if polynomials have been requested
  63192. * @param onLoad defines the callback to trigger once the texture is ready
  63193. * @param onError defines the callback to trigger in case of error
  63194. */
  63195. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63196. /**
  63197. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63198. * @param data contains the texture data
  63199. * @param texture defines the BabylonJS internal texture
  63200. * @param callback defines the method to call once ready to upload
  63201. */
  63202. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63203. }
  63204. }
  63205. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63206. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63207. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63208. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63209. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63210. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63211. }
  63212. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63213. import { Vector2 } from "babylonjs/Maths/math.vector";
  63214. /**
  63215. * Defines the basic options interface of a TexturePacker Frame
  63216. */
  63217. export interface ITexturePackerFrame {
  63218. /**
  63219. * The frame ID
  63220. */
  63221. id: number;
  63222. /**
  63223. * The frames Scale
  63224. */
  63225. scale: Vector2;
  63226. /**
  63227. * The Frames offset
  63228. */
  63229. offset: Vector2;
  63230. }
  63231. /**
  63232. * This is a support class for frame Data on texture packer sets.
  63233. */
  63234. export class TexturePackerFrame implements ITexturePackerFrame {
  63235. /**
  63236. * The frame ID
  63237. */
  63238. id: number;
  63239. /**
  63240. * The frames Scale
  63241. */
  63242. scale: Vector2;
  63243. /**
  63244. * The Frames offset
  63245. */
  63246. offset: Vector2;
  63247. /**
  63248. * Initializes a texture package frame.
  63249. * @param id The numerical frame identifier
  63250. * @param scale Scalar Vector2 for UV frame
  63251. * @param offset Vector2 for the frame position in UV units.
  63252. * @returns TexturePackerFrame
  63253. */
  63254. constructor(id: number, scale: Vector2, offset: Vector2);
  63255. }
  63256. }
  63257. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63259. import { Scene } from "babylonjs/scene";
  63260. import { Nullable } from "babylonjs/types";
  63261. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63262. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63263. /**
  63264. * Defines the basic options interface of a TexturePacker
  63265. */
  63266. export interface ITexturePackerOptions {
  63267. /**
  63268. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63269. */
  63270. map?: string[];
  63271. /**
  63272. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63273. */
  63274. uvsIn?: string;
  63275. /**
  63276. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63277. */
  63278. uvsOut?: string;
  63279. /**
  63280. * number representing the layout style. Defaults to LAYOUT_STRIP
  63281. */
  63282. layout?: number;
  63283. /**
  63284. * number of columns if using custom column count layout(2). This defaults to 4.
  63285. */
  63286. colnum?: number;
  63287. /**
  63288. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63289. */
  63290. updateInputMeshes?: boolean;
  63291. /**
  63292. * boolean flag to dispose all the source textures. Defaults to true.
  63293. */
  63294. disposeSources?: boolean;
  63295. /**
  63296. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63297. */
  63298. fillBlanks?: boolean;
  63299. /**
  63300. * string value representing the context fill style color. Defaults to 'black'.
  63301. */
  63302. customFillColor?: string;
  63303. /**
  63304. * Width and Height Value of each Frame in the TexturePacker Sets
  63305. */
  63306. frameSize?: number;
  63307. /**
  63308. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63309. */
  63310. paddingRatio?: number;
  63311. /**
  63312. * Number that declares the fill method for the padding gutter.
  63313. */
  63314. paddingMode?: number;
  63315. /**
  63316. * If in SUBUV_COLOR padding mode what color to use.
  63317. */
  63318. paddingColor?: Color3 | Color4;
  63319. }
  63320. /**
  63321. * Defines the basic interface of a TexturePacker JSON File
  63322. */
  63323. export interface ITexturePackerJSON {
  63324. /**
  63325. * The frame ID
  63326. */
  63327. name: string;
  63328. /**
  63329. * The base64 channel data
  63330. */
  63331. sets: any;
  63332. /**
  63333. * The options of the Packer
  63334. */
  63335. options: ITexturePackerOptions;
  63336. /**
  63337. * The frame data of the Packer
  63338. */
  63339. frames: Array<number>;
  63340. }
  63341. /**
  63342. * This is a support class that generates a series of packed texture sets.
  63343. * @see https://doc.babylonjs.com/babylon101/materials
  63344. */
  63345. export class TexturePacker {
  63346. /** Packer Layout Constant 0 */
  63347. static readonly LAYOUT_STRIP: number;
  63348. /** Packer Layout Constant 1 */
  63349. static readonly LAYOUT_POWER2: number;
  63350. /** Packer Layout Constant 2 */
  63351. static readonly LAYOUT_COLNUM: number;
  63352. /** Packer Layout Constant 0 */
  63353. static readonly SUBUV_WRAP: number;
  63354. /** Packer Layout Constant 1 */
  63355. static readonly SUBUV_EXTEND: number;
  63356. /** Packer Layout Constant 2 */
  63357. static readonly SUBUV_COLOR: number;
  63358. /** The Name of the Texture Package */
  63359. name: string;
  63360. /** The scene scope of the TexturePacker */
  63361. scene: Scene;
  63362. /** The Meshes to target */
  63363. meshes: AbstractMesh[];
  63364. /** Arguments passed with the Constructor */
  63365. options: ITexturePackerOptions;
  63366. /** The promise that is started upon initialization */
  63367. promise: Nullable<Promise<TexturePacker | string>>;
  63368. /** The Container object for the channel sets that are generated */
  63369. sets: object;
  63370. /** The Container array for the frames that are generated */
  63371. frames: TexturePackerFrame[];
  63372. /** The expected number of textures the system is parsing. */
  63373. private _expecting;
  63374. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63375. private _paddingValue;
  63376. /**
  63377. * Initializes a texture package series from an array of meshes or a single mesh.
  63378. * @param name The name of the package
  63379. * @param meshes The target meshes to compose the package from
  63380. * @param options The arguments that texture packer should follow while building.
  63381. * @param scene The scene which the textures are scoped to.
  63382. * @returns TexturePacker
  63383. */
  63384. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63385. /**
  63386. * Starts the package process
  63387. * @param resolve The promises resolution function
  63388. * @returns TexturePacker
  63389. */
  63390. private _createFrames;
  63391. /**
  63392. * Calculates the Size of the Channel Sets
  63393. * @returns Vector2
  63394. */
  63395. private _calculateSize;
  63396. /**
  63397. * Calculates the UV data for the frames.
  63398. * @param baseSize the base frameSize
  63399. * @param padding the base frame padding
  63400. * @param dtSize size of the Dynamic Texture for that channel
  63401. * @param dtUnits is 1/dtSize
  63402. * @param update flag to update the input meshes
  63403. */
  63404. private _calculateMeshUVFrames;
  63405. /**
  63406. * Calculates the frames Offset.
  63407. * @param index of the frame
  63408. * @returns Vector2
  63409. */
  63410. private _getFrameOffset;
  63411. /**
  63412. * Updates a Mesh to the frame data
  63413. * @param mesh that is the target
  63414. * @param frameID or the frame index
  63415. */
  63416. private _updateMeshUV;
  63417. /**
  63418. * Updates a Meshes materials to use the texture packer channels
  63419. * @param m is the mesh to target
  63420. * @param force all channels on the packer to be set.
  63421. */
  63422. private _updateTextureReferences;
  63423. /**
  63424. * Public method to set a Mesh to a frame
  63425. * @param m that is the target
  63426. * @param frameID or the frame index
  63427. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63428. */
  63429. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63430. /**
  63431. * Starts the async promise to compile the texture packer.
  63432. * @returns Promise<void>
  63433. */
  63434. processAsync(): Promise<void>;
  63435. /**
  63436. * Disposes all textures associated with this packer
  63437. */
  63438. dispose(): void;
  63439. /**
  63440. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63441. * @param imageType is the image type to use.
  63442. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63443. */
  63444. download(imageType?: string, quality?: number): void;
  63445. /**
  63446. * Public method to load a texturePacker JSON file.
  63447. * @param data of the JSON file in string format.
  63448. */
  63449. updateFromJSON(data: string): void;
  63450. }
  63451. }
  63452. declare module "babylonjs/Materials/Textures/Packer/index" {
  63453. export * from "babylonjs/Materials/Textures/Packer/packer";
  63454. export * from "babylonjs/Materials/Textures/Packer/frame";
  63455. }
  63456. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63457. import { Scene } from "babylonjs/scene";
  63458. import { Texture } from "babylonjs/Materials/Textures/texture";
  63459. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63460. /**
  63461. * 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.
  63462. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63463. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63464. */
  63465. export class CustomProceduralTexture extends ProceduralTexture {
  63466. private _animate;
  63467. private _time;
  63468. private _config;
  63469. private _texturePath;
  63470. /**
  63471. * Instantiates a new Custom Procedural Texture.
  63472. * 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.
  63473. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63474. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63475. * @param name Define the name of the texture
  63476. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63477. * @param size Define the size of the texture to create
  63478. * @param scene Define the scene the texture belongs to
  63479. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63480. * @param generateMipMaps Define if the texture should creates mip maps or not
  63481. */
  63482. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63483. private _loadJson;
  63484. /**
  63485. * Is the texture ready to be used ? (rendered at least once)
  63486. * @returns true if ready, otherwise, false.
  63487. */
  63488. isReady(): boolean;
  63489. /**
  63490. * Render the texture to its associated render target.
  63491. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63492. */
  63493. render(useCameraPostProcess?: boolean): void;
  63494. /**
  63495. * Update the list of dependant textures samplers in the shader.
  63496. */
  63497. updateTextures(): void;
  63498. /**
  63499. * Update the uniform values of the procedural texture in the shader.
  63500. */
  63501. updateShaderUniforms(): void;
  63502. /**
  63503. * Define if the texture animates or not.
  63504. */
  63505. get animate(): boolean;
  63506. set animate(value: boolean);
  63507. }
  63508. }
  63509. declare module "babylonjs/Shaders/noise.fragment" {
  63510. /** @hidden */
  63511. export var noisePixelShader: {
  63512. name: string;
  63513. shader: string;
  63514. };
  63515. }
  63516. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63517. import { Nullable } from "babylonjs/types";
  63518. import { Scene } from "babylonjs/scene";
  63519. import { Texture } from "babylonjs/Materials/Textures/texture";
  63520. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63521. import "babylonjs/Shaders/noise.fragment";
  63522. /**
  63523. * Class used to generate noise procedural textures
  63524. */
  63525. export class NoiseProceduralTexture extends ProceduralTexture {
  63526. private _time;
  63527. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63528. brightness: number;
  63529. /** Defines the number of octaves to process */
  63530. octaves: number;
  63531. /** Defines the level of persistence (0.8 by default) */
  63532. persistence: number;
  63533. /** Gets or sets animation speed factor (default is 1) */
  63534. animationSpeedFactor: number;
  63535. /**
  63536. * Creates a new NoiseProceduralTexture
  63537. * @param name defines the name fo the texture
  63538. * @param size defines the size of the texture (default is 256)
  63539. * @param scene defines the hosting scene
  63540. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63541. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63542. */
  63543. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63544. private _updateShaderUniforms;
  63545. protected _getDefines(): string;
  63546. /** Generate the current state of the procedural texture */
  63547. render(useCameraPostProcess?: boolean): void;
  63548. /**
  63549. * Serializes this noise procedural texture
  63550. * @returns a serialized noise procedural texture object
  63551. */
  63552. serialize(): any;
  63553. /**
  63554. * Clone the texture.
  63555. * @returns the cloned texture
  63556. */
  63557. clone(): NoiseProceduralTexture;
  63558. /**
  63559. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63560. * @param parsedTexture defines parsed texture data
  63561. * @param scene defines the current scene
  63562. * @param rootUrl defines the root URL containing noise procedural texture information
  63563. * @returns a parsed NoiseProceduralTexture
  63564. */
  63565. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63566. }
  63567. }
  63568. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63569. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63570. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63571. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63572. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63573. }
  63574. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63575. import { Nullable } from "babylonjs/types";
  63576. import { Scene } from "babylonjs/scene";
  63577. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63579. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63580. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63581. /**
  63582. * Raw cube texture where the raw buffers are passed in
  63583. */
  63584. export class RawCubeTexture extends CubeTexture {
  63585. /**
  63586. * Creates a cube texture where the raw buffers are passed in.
  63587. * @param scene defines the scene the texture is attached to
  63588. * @param data defines the array of data to use to create each face
  63589. * @param size defines the size of the textures
  63590. * @param format defines the format of the data
  63591. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63592. * @param generateMipMaps defines if the engine should generate the mip levels
  63593. * @param invertY defines if data must be stored with Y axis inverted
  63594. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63595. * @param compression defines the compression used (null by default)
  63596. */
  63597. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63598. /**
  63599. * Updates the raw cube texture.
  63600. * @param data defines the data to store
  63601. * @param format defines the data format
  63602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63603. * @param invertY defines if data must be stored with Y axis inverted
  63604. * @param compression defines the compression used (null by default)
  63605. * @param level defines which level of the texture to update
  63606. */
  63607. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63608. /**
  63609. * Updates a raw cube texture with RGBD encoded data.
  63610. * @param data defines the array of data [mipmap][face] to use to create each face
  63611. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63614. * @returns a promsie that resolves when the operation is complete
  63615. */
  63616. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63617. /**
  63618. * Clones the raw cube texture.
  63619. * @return a new cube texture
  63620. */
  63621. clone(): CubeTexture;
  63622. /** @hidden */
  63623. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63624. }
  63625. }
  63626. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63627. import { Scene } from "babylonjs/scene";
  63628. import { Texture } from "babylonjs/Materials/Textures/texture";
  63629. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63630. /**
  63631. * Class used to store 2D array textures containing user data
  63632. */
  63633. export class RawTexture2DArray extends Texture {
  63634. /** Gets or sets the texture format to use */
  63635. format: number;
  63636. /**
  63637. * Create a new RawTexture2DArray
  63638. * @param data defines the data of the texture
  63639. * @param width defines the width of the texture
  63640. * @param height defines the height of the texture
  63641. * @param depth defines the number of layers of the texture
  63642. * @param format defines the texture format to use
  63643. * @param scene defines the hosting scene
  63644. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63645. * @param invertY defines if texture must be stored with Y axis inverted
  63646. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63648. */
  63649. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63650. /** Gets or sets the texture format to use */
  63651. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63652. /**
  63653. * Update the texture with new data
  63654. * @param data defines the data to store in the texture
  63655. */
  63656. update(data: ArrayBufferView): void;
  63657. }
  63658. }
  63659. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63660. import { Scene } from "babylonjs/scene";
  63661. import { Texture } from "babylonjs/Materials/Textures/texture";
  63662. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63663. /**
  63664. * Class used to store 3D textures containing user data
  63665. */
  63666. export class RawTexture3D extends Texture {
  63667. /** Gets or sets the texture format to use */
  63668. format: number;
  63669. /**
  63670. * Create a new RawTexture3D
  63671. * @param data defines the data of the texture
  63672. * @param width defines the width of the texture
  63673. * @param height defines the height of the texture
  63674. * @param depth defines the depth of the texture
  63675. * @param format defines the texture format to use
  63676. * @param scene defines the hosting scene
  63677. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63678. * @param invertY defines if texture must be stored with Y axis inverted
  63679. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63681. */
  63682. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63683. /** Gets or sets the texture format to use */
  63684. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63685. /**
  63686. * Update the texture with new data
  63687. * @param data defines the data to store in the texture
  63688. */
  63689. update(data: ArrayBufferView): void;
  63690. }
  63691. }
  63692. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63693. import { Scene } from "babylonjs/scene";
  63694. import { Plane } from "babylonjs/Maths/math.plane";
  63695. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63696. /**
  63697. * Creates a refraction texture used by refraction channel of the standard material.
  63698. * It is like a mirror but to see through a material.
  63699. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63700. */
  63701. export class RefractionTexture extends RenderTargetTexture {
  63702. /**
  63703. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63704. * 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.
  63705. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63706. */
  63707. refractionPlane: Plane;
  63708. /**
  63709. * Define how deep under the surface we should see.
  63710. */
  63711. depth: number;
  63712. /**
  63713. * Creates a refraction texture used by refraction channel of the standard material.
  63714. * It is like a mirror but to see through a material.
  63715. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63716. * @param name Define the texture name
  63717. * @param size Define the size of the underlying texture
  63718. * @param scene Define the scene the refraction belongs to
  63719. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63720. */
  63721. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63722. /**
  63723. * Clone the refraction texture.
  63724. * @returns the cloned texture
  63725. */
  63726. clone(): RefractionTexture;
  63727. /**
  63728. * Serialize the texture to a JSON representation you could use in Parse later on
  63729. * @returns the serialized JSON representation
  63730. */
  63731. serialize(): any;
  63732. }
  63733. }
  63734. declare module "babylonjs/Materials/Textures/index" {
  63735. export * from "babylonjs/Materials/Textures/baseTexture";
  63736. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63737. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63738. export * from "babylonjs/Materials/Textures/cubeTexture";
  63739. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63740. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63741. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63742. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63743. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63744. export * from "babylonjs/Materials/Textures/internalTexture";
  63745. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63746. export * from "babylonjs/Materials/Textures/Loaders/index";
  63747. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63748. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63749. export * from "babylonjs/Materials/Textures/Packer/index";
  63750. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63751. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63752. export * from "babylonjs/Materials/Textures/rawTexture";
  63753. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63754. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63755. export * from "babylonjs/Materials/Textures/refractionTexture";
  63756. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63757. export * from "babylonjs/Materials/Textures/texture";
  63758. export * from "babylonjs/Materials/Textures/videoTexture";
  63759. }
  63760. declare module "babylonjs/Materials/Node/Enums/index" {
  63761. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63762. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63763. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63764. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63765. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63766. }
  63767. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63771. import { Mesh } from "babylonjs/Meshes/mesh";
  63772. import { Effect } from "babylonjs/Materials/effect";
  63773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63774. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63775. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63776. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63777. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63778. /**
  63779. * Block used to add support for vertex skinning (bones)
  63780. */
  63781. export class BonesBlock extends NodeMaterialBlock {
  63782. /**
  63783. * Creates a new BonesBlock
  63784. * @param name defines the block name
  63785. */
  63786. constructor(name: string);
  63787. /**
  63788. * Initialize the block and prepare the context for build
  63789. * @param state defines the state that will be used for the build
  63790. */
  63791. initialize(state: NodeMaterialBuildState): void;
  63792. /**
  63793. * Gets the current class name
  63794. * @returns the class name
  63795. */
  63796. getClassName(): string;
  63797. /**
  63798. * Gets the matrix indices input component
  63799. */
  63800. get matricesIndices(): NodeMaterialConnectionPoint;
  63801. /**
  63802. * Gets the matrix weights input component
  63803. */
  63804. get matricesWeights(): NodeMaterialConnectionPoint;
  63805. /**
  63806. * Gets the extra matrix indices input component
  63807. */
  63808. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63809. /**
  63810. * Gets the extra matrix weights input component
  63811. */
  63812. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63813. /**
  63814. * Gets the world input component
  63815. */
  63816. get world(): NodeMaterialConnectionPoint;
  63817. /**
  63818. * Gets the output component
  63819. */
  63820. get output(): NodeMaterialConnectionPoint;
  63821. autoConfigure(material: NodeMaterial): void;
  63822. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63823. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63825. protected _buildBlock(state: NodeMaterialBuildState): this;
  63826. }
  63827. }
  63828. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  63829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63833. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63835. /**
  63836. * Block used to add support for instances
  63837. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63838. */
  63839. export class InstancesBlock extends NodeMaterialBlock {
  63840. /**
  63841. * Creates a new InstancesBlock
  63842. * @param name defines the block name
  63843. */
  63844. constructor(name: string);
  63845. /**
  63846. * Gets the current class name
  63847. * @returns the class name
  63848. */
  63849. getClassName(): string;
  63850. /**
  63851. * Gets the first world row input component
  63852. */
  63853. get world0(): NodeMaterialConnectionPoint;
  63854. /**
  63855. * Gets the second world row input component
  63856. */
  63857. get world1(): NodeMaterialConnectionPoint;
  63858. /**
  63859. * Gets the third world row input component
  63860. */
  63861. get world2(): NodeMaterialConnectionPoint;
  63862. /**
  63863. * Gets the forth world row input component
  63864. */
  63865. get world3(): NodeMaterialConnectionPoint;
  63866. /**
  63867. * Gets the world input component
  63868. */
  63869. get world(): NodeMaterialConnectionPoint;
  63870. /**
  63871. * Gets the output component
  63872. */
  63873. get output(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the isntanceID component
  63876. */
  63877. get instanceID(): NodeMaterialConnectionPoint;
  63878. autoConfigure(material: NodeMaterial): void;
  63879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63880. protected _buildBlock(state: NodeMaterialBuildState): this;
  63881. }
  63882. }
  63883. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  63884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  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 { Effect } from "babylonjs/Materials/effect";
  63890. import { Mesh } from "babylonjs/Meshes/mesh";
  63891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63892. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63893. /**
  63894. * Block used to add morph targets support to vertex shader
  63895. */
  63896. export class MorphTargetsBlock extends NodeMaterialBlock {
  63897. private _repeatableContentAnchor;
  63898. /**
  63899. * Create a new MorphTargetsBlock
  63900. * @param name defines the block name
  63901. */
  63902. constructor(name: string);
  63903. /**
  63904. * Gets the current class name
  63905. * @returns the class name
  63906. */
  63907. getClassName(): string;
  63908. /**
  63909. * Gets the position input component
  63910. */
  63911. get position(): NodeMaterialConnectionPoint;
  63912. /**
  63913. * Gets the normal input component
  63914. */
  63915. get normal(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the tangent input component
  63918. */
  63919. get tangent(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the tangent input component
  63922. */
  63923. get uv(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the position output component
  63926. */
  63927. get positionOutput(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the normal output component
  63930. */
  63931. get normalOutput(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the tangent output component
  63934. */
  63935. get tangentOutput(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the tangent output component
  63938. */
  63939. get uvOutput(): NodeMaterialConnectionPoint;
  63940. initialize(state: NodeMaterialBuildState): void;
  63941. autoConfigure(material: NodeMaterial): void;
  63942. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63944. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63945. protected _buildBlock(state: NodeMaterialBuildState): this;
  63946. }
  63947. }
  63948. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  63949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63950. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63952. import { Nullable } from "babylonjs/types";
  63953. import { Scene } from "babylonjs/scene";
  63954. import { Effect } from "babylonjs/Materials/effect";
  63955. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63956. import { Mesh } from "babylonjs/Meshes/mesh";
  63957. import { Light } from "babylonjs/Lights/light";
  63958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63959. /**
  63960. * Block used to get data information from a light
  63961. */
  63962. export class LightInformationBlock extends NodeMaterialBlock {
  63963. private _lightDataUniformName;
  63964. private _lightColorUniformName;
  63965. private _lightTypeDefineName;
  63966. /**
  63967. * Gets or sets the light associated with this block
  63968. */
  63969. light: Nullable<Light>;
  63970. /**
  63971. * Creates a new LightInformationBlock
  63972. * @param name defines the block name
  63973. */
  63974. constructor(name: string);
  63975. /**
  63976. * Gets the current class name
  63977. * @returns the class name
  63978. */
  63979. getClassName(): string;
  63980. /**
  63981. * Gets the world position input component
  63982. */
  63983. get worldPosition(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the direction output component
  63986. */
  63987. get direction(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the direction output component
  63990. */
  63991. get color(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the direction output component
  63994. */
  63995. get intensity(): NodeMaterialConnectionPoint;
  63996. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63998. protected _buildBlock(state: NodeMaterialBuildState): this;
  63999. serialize(): any;
  64000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64001. }
  64002. }
  64003. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64004. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64005. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64006. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64007. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64008. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64009. }
  64010. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64015. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64016. import { Effect } from "babylonjs/Materials/effect";
  64017. import { Mesh } from "babylonjs/Meshes/mesh";
  64018. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64019. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64020. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64021. /**
  64022. * Block used to add image processing support to fragment shader
  64023. */
  64024. export class ImageProcessingBlock extends NodeMaterialBlock {
  64025. /**
  64026. * Create a new ImageProcessingBlock
  64027. * @param name defines the block name
  64028. */
  64029. constructor(name: string);
  64030. /**
  64031. * Gets the current class name
  64032. * @returns the class name
  64033. */
  64034. getClassName(): string;
  64035. /**
  64036. * Gets the color input component
  64037. */
  64038. get color(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the output component
  64041. */
  64042. get output(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Initialize the block and prepare the context for build
  64045. * @param state defines the state that will be used for the build
  64046. */
  64047. initialize(state: NodeMaterialBuildState): void;
  64048. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64050. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64051. protected _buildBlock(state: NodeMaterialBuildState): this;
  64052. }
  64053. }
  64054. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64055. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64056. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64057. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64058. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64060. import { Effect } from "babylonjs/Materials/effect";
  64061. import { Mesh } from "babylonjs/Meshes/mesh";
  64062. import { Scene } from "babylonjs/scene";
  64063. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64064. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64065. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64066. /**
  64067. * Block used to pertub normals based on a normal map
  64068. */
  64069. export class PerturbNormalBlock extends NodeMaterialBlock {
  64070. private _tangentSpaceParameterName;
  64071. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64072. invertX: boolean;
  64073. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64074. invertY: boolean;
  64075. /**
  64076. * Create a new PerturbNormalBlock
  64077. * @param name defines the block name
  64078. */
  64079. constructor(name: string);
  64080. /**
  64081. * Gets the current class name
  64082. * @returns the class name
  64083. */
  64084. getClassName(): string;
  64085. /**
  64086. * Gets the world position input component
  64087. */
  64088. get worldPosition(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the world normal input component
  64091. */
  64092. get worldNormal(): NodeMaterialConnectionPoint;
  64093. /**
  64094. * Gets the world tangent input component
  64095. */
  64096. get worldTangent(): NodeMaterialConnectionPoint;
  64097. /**
  64098. * Gets the uv input component
  64099. */
  64100. get uv(): NodeMaterialConnectionPoint;
  64101. /**
  64102. * Gets the normal map color input component
  64103. */
  64104. get normalMapColor(): NodeMaterialConnectionPoint;
  64105. /**
  64106. * Gets the strength input component
  64107. */
  64108. get strength(): NodeMaterialConnectionPoint;
  64109. /**
  64110. * Gets the output component
  64111. */
  64112. get output(): NodeMaterialConnectionPoint;
  64113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64115. autoConfigure(material: NodeMaterial): void;
  64116. protected _buildBlock(state: NodeMaterialBuildState): this;
  64117. protected _dumpPropertiesCode(): string;
  64118. serialize(): any;
  64119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64120. }
  64121. }
  64122. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64126. /**
  64127. * Block used to discard a pixel if a value is smaller than a cutoff
  64128. */
  64129. export class DiscardBlock extends NodeMaterialBlock {
  64130. /**
  64131. * Create a new DiscardBlock
  64132. * @param name defines the block name
  64133. */
  64134. constructor(name: string);
  64135. /**
  64136. * Gets the current class name
  64137. * @returns the class name
  64138. */
  64139. getClassName(): string;
  64140. /**
  64141. * Gets the color input component
  64142. */
  64143. get value(): NodeMaterialConnectionPoint;
  64144. /**
  64145. * Gets the cutoff input component
  64146. */
  64147. get cutoff(): NodeMaterialConnectionPoint;
  64148. protected _buildBlock(state: NodeMaterialBuildState): this;
  64149. }
  64150. }
  64151. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64155. /**
  64156. * Block used to test if the fragment shader is front facing
  64157. */
  64158. export class FrontFacingBlock extends NodeMaterialBlock {
  64159. /**
  64160. * Creates a new FrontFacingBlock
  64161. * @param name defines the block name
  64162. */
  64163. constructor(name: string);
  64164. /**
  64165. * Gets the current class name
  64166. * @returns the class name
  64167. */
  64168. getClassName(): string;
  64169. /**
  64170. * Gets the output component
  64171. */
  64172. get output(): NodeMaterialConnectionPoint;
  64173. protected _buildBlock(state: NodeMaterialBuildState): this;
  64174. }
  64175. }
  64176. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64180. /**
  64181. * Block used to get the derivative value on x and y of a given input
  64182. */
  64183. export class DerivativeBlock extends NodeMaterialBlock {
  64184. /**
  64185. * Create a new DerivativeBlock
  64186. * @param name defines the block name
  64187. */
  64188. constructor(name: string);
  64189. /**
  64190. * Gets the current class name
  64191. * @returns the class name
  64192. */
  64193. getClassName(): string;
  64194. /**
  64195. * Gets the input component
  64196. */
  64197. get input(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the derivative output on x
  64200. */
  64201. get dx(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the derivative output on y
  64204. */
  64205. get dy(): NodeMaterialConnectionPoint;
  64206. protected _buildBlock(state: NodeMaterialBuildState): this;
  64207. }
  64208. }
  64209. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64213. /**
  64214. * Block used to make gl_FragCoord available
  64215. */
  64216. export class FragCoordBlock extends NodeMaterialBlock {
  64217. /**
  64218. * Creates a new FragCoordBlock
  64219. * @param name defines the block name
  64220. */
  64221. constructor(name: string);
  64222. /**
  64223. * Gets the current class name
  64224. * @returns the class name
  64225. */
  64226. getClassName(): string;
  64227. /**
  64228. * Gets the xy component
  64229. */
  64230. get xy(): NodeMaterialConnectionPoint;
  64231. /**
  64232. * Gets the xyz component
  64233. */
  64234. get xyz(): NodeMaterialConnectionPoint;
  64235. /**
  64236. * Gets the xyzw component
  64237. */
  64238. get xyzw(): NodeMaterialConnectionPoint;
  64239. /**
  64240. * Gets the x component
  64241. */
  64242. get x(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the y component
  64245. */
  64246. get y(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the z component
  64249. */
  64250. get z(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the w component
  64253. */
  64254. get output(): NodeMaterialConnectionPoint;
  64255. protected writeOutputs(state: NodeMaterialBuildState): string;
  64256. protected _buildBlock(state: NodeMaterialBuildState): this;
  64257. }
  64258. }
  64259. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64262. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64263. import { Effect } from "babylonjs/Materials/effect";
  64264. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64265. import { Mesh } from "babylonjs/Meshes/mesh";
  64266. /**
  64267. * Block used to get the screen sizes
  64268. */
  64269. export class ScreenSizeBlock extends NodeMaterialBlock {
  64270. private _varName;
  64271. private _scene;
  64272. /**
  64273. * Creates a new ScreenSizeBlock
  64274. * @param name defines the block name
  64275. */
  64276. constructor(name: string);
  64277. /**
  64278. * Gets the current class name
  64279. * @returns the class name
  64280. */
  64281. getClassName(): string;
  64282. /**
  64283. * Gets the xy component
  64284. */
  64285. get xy(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the x component
  64288. */
  64289. get x(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the y component
  64292. */
  64293. get y(): NodeMaterialConnectionPoint;
  64294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64295. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64296. protected _buildBlock(state: NodeMaterialBuildState): this;
  64297. }
  64298. }
  64299. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64300. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64301. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64302. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64303. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64304. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64305. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64306. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64307. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64308. }
  64309. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64311. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64312. import { Mesh } from "babylonjs/Meshes/mesh";
  64313. import { Effect } from "babylonjs/Materials/effect";
  64314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64316. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64317. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64318. /**
  64319. * Block used to add support for scene fog
  64320. */
  64321. export class FogBlock extends NodeMaterialBlock {
  64322. private _fogDistanceName;
  64323. private _fogParameters;
  64324. /**
  64325. * Create a new FogBlock
  64326. * @param name defines the block name
  64327. */
  64328. constructor(name: string);
  64329. /**
  64330. * Gets the current class name
  64331. * @returns the class name
  64332. */
  64333. getClassName(): string;
  64334. /**
  64335. * Gets the world position input component
  64336. */
  64337. get worldPosition(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the view input component
  64340. */
  64341. get view(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the color input component
  64344. */
  64345. get input(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the fog color input component
  64348. */
  64349. get fogColor(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the output component
  64352. */
  64353. get output(): NodeMaterialConnectionPoint;
  64354. autoConfigure(material: NodeMaterial): void;
  64355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64357. protected _buildBlock(state: NodeMaterialBuildState): this;
  64358. }
  64359. }
  64360. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64365. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64366. import { Effect } from "babylonjs/Materials/effect";
  64367. import { Mesh } from "babylonjs/Meshes/mesh";
  64368. import { Light } from "babylonjs/Lights/light";
  64369. import { Nullable } from "babylonjs/types";
  64370. import { Scene } from "babylonjs/scene";
  64371. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64372. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64373. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64374. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64375. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64376. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64377. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64378. /**
  64379. * Block used to add light in the fragment shader
  64380. */
  64381. export class LightBlock extends NodeMaterialBlock {
  64382. private _lightId;
  64383. /**
  64384. * Gets or sets the light associated with this block
  64385. */
  64386. light: Nullable<Light>;
  64387. /**
  64388. * Create a new LightBlock
  64389. * @param name defines the block name
  64390. */
  64391. constructor(name: string);
  64392. /**
  64393. * Gets the current class name
  64394. * @returns the class name
  64395. */
  64396. getClassName(): string;
  64397. /**
  64398. * Gets the world position input component
  64399. */
  64400. get worldPosition(): NodeMaterialConnectionPoint;
  64401. /**
  64402. * Gets the world normal input component
  64403. */
  64404. get worldNormal(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the camera (or eye) position component
  64407. */
  64408. get cameraPosition(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the glossiness component
  64411. */
  64412. get glossiness(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the glossinness power component
  64415. */
  64416. get glossPower(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the diffuse color component
  64419. */
  64420. get diffuseColor(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the specular color component
  64423. */
  64424. get specularColor(): NodeMaterialConnectionPoint;
  64425. /**
  64426. * Gets the diffuse output component
  64427. */
  64428. get diffuseOutput(): NodeMaterialConnectionPoint;
  64429. /**
  64430. * Gets the specular output component
  64431. */
  64432. get specularOutput(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the shadow output component
  64435. */
  64436. get shadow(): NodeMaterialConnectionPoint;
  64437. autoConfigure(material: NodeMaterial): void;
  64438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64439. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64441. private _injectVertexCode;
  64442. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64443. serialize(): any;
  64444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64445. }
  64446. }
  64447. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64450. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64451. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64452. /**
  64453. * Block used to read a reflection texture from a sampler
  64454. */
  64455. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64456. /**
  64457. * Create a new ReflectionTextureBlock
  64458. * @param name defines the block name
  64459. */
  64460. constructor(name: string);
  64461. /**
  64462. * Gets the current class name
  64463. * @returns the class name
  64464. */
  64465. getClassName(): string;
  64466. /**
  64467. * Gets the world position input component
  64468. */
  64469. get position(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the world position input component
  64472. */
  64473. get worldPosition(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the world normal input component
  64476. */
  64477. get worldNormal(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the world input component
  64480. */
  64481. get world(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the camera (or eye) position component
  64484. */
  64485. get cameraPosition(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the view input component
  64488. */
  64489. get view(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the rgb output component
  64492. */
  64493. get rgb(): NodeMaterialConnectionPoint;
  64494. /**
  64495. * Gets the r output component
  64496. */
  64497. get r(): NodeMaterialConnectionPoint;
  64498. /**
  64499. * Gets the g output component
  64500. */
  64501. get g(): NodeMaterialConnectionPoint;
  64502. /**
  64503. * Gets the b output component
  64504. */
  64505. get b(): NodeMaterialConnectionPoint;
  64506. autoConfigure(material: NodeMaterial): void;
  64507. protected _buildBlock(state: NodeMaterialBuildState): this;
  64508. }
  64509. }
  64510. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64511. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64512. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64513. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64514. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64515. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64516. }
  64517. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64518. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64519. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64520. }
  64521. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64523. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64525. /**
  64526. * Block used to add 2 vectors
  64527. */
  64528. export class AddBlock extends NodeMaterialBlock {
  64529. /**
  64530. * Creates a new AddBlock
  64531. * @param name defines the block name
  64532. */
  64533. constructor(name: string);
  64534. /**
  64535. * Gets the current class name
  64536. * @returns the class name
  64537. */
  64538. getClassName(): string;
  64539. /**
  64540. * Gets the left operand input component
  64541. */
  64542. get left(): NodeMaterialConnectionPoint;
  64543. /**
  64544. * Gets the right operand input component
  64545. */
  64546. get right(): NodeMaterialConnectionPoint;
  64547. /**
  64548. * Gets the output component
  64549. */
  64550. get output(): NodeMaterialConnectionPoint;
  64551. protected _buildBlock(state: NodeMaterialBuildState): this;
  64552. }
  64553. }
  64554. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64558. /**
  64559. * Block used to scale a vector by a float
  64560. */
  64561. export class ScaleBlock extends NodeMaterialBlock {
  64562. /**
  64563. * Creates a new ScaleBlock
  64564. * @param name defines the block name
  64565. */
  64566. constructor(name: string);
  64567. /**
  64568. * Gets the current class name
  64569. * @returns the class name
  64570. */
  64571. getClassName(): string;
  64572. /**
  64573. * Gets the input component
  64574. */
  64575. get input(): NodeMaterialConnectionPoint;
  64576. /**
  64577. * Gets the factor input component
  64578. */
  64579. get factor(): NodeMaterialConnectionPoint;
  64580. /**
  64581. * Gets the output component
  64582. */
  64583. get output(): NodeMaterialConnectionPoint;
  64584. protected _buildBlock(state: NodeMaterialBuildState): this;
  64585. }
  64586. }
  64587. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64591. import { Scene } from "babylonjs/scene";
  64592. /**
  64593. * Block used to clamp a float
  64594. */
  64595. export class ClampBlock extends NodeMaterialBlock {
  64596. /** Gets or sets the minimum range */
  64597. minimum: number;
  64598. /** Gets or sets the maximum range */
  64599. maximum: number;
  64600. /**
  64601. * Creates a new ClampBlock
  64602. * @param name defines the block name
  64603. */
  64604. constructor(name: string);
  64605. /**
  64606. * Gets the current class name
  64607. * @returns the class name
  64608. */
  64609. getClassName(): string;
  64610. /**
  64611. * Gets the value input component
  64612. */
  64613. get value(): NodeMaterialConnectionPoint;
  64614. /**
  64615. * Gets the output component
  64616. */
  64617. get output(): NodeMaterialConnectionPoint;
  64618. protected _buildBlock(state: NodeMaterialBuildState): this;
  64619. protected _dumpPropertiesCode(): string;
  64620. serialize(): any;
  64621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64622. }
  64623. }
  64624. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64628. /**
  64629. * Block used to apply a cross product between 2 vectors
  64630. */
  64631. export class CrossBlock extends NodeMaterialBlock {
  64632. /**
  64633. * Creates a new CrossBlock
  64634. * @param name defines the block name
  64635. */
  64636. constructor(name: string);
  64637. /**
  64638. * Gets the current class name
  64639. * @returns the class name
  64640. */
  64641. getClassName(): string;
  64642. /**
  64643. * Gets the left operand input component
  64644. */
  64645. get left(): NodeMaterialConnectionPoint;
  64646. /**
  64647. * Gets the right operand input component
  64648. */
  64649. get right(): NodeMaterialConnectionPoint;
  64650. /**
  64651. * Gets the output component
  64652. */
  64653. get output(): NodeMaterialConnectionPoint;
  64654. protected _buildBlock(state: NodeMaterialBuildState): this;
  64655. }
  64656. }
  64657. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64661. /**
  64662. * Block used to apply a dot product between 2 vectors
  64663. */
  64664. export class DotBlock extends NodeMaterialBlock {
  64665. /**
  64666. * Creates a new DotBlock
  64667. * @param name defines the block name
  64668. */
  64669. constructor(name: string);
  64670. /**
  64671. * Gets the current class name
  64672. * @returns the class name
  64673. */
  64674. getClassName(): string;
  64675. /**
  64676. * Gets the left operand input component
  64677. */
  64678. get left(): NodeMaterialConnectionPoint;
  64679. /**
  64680. * Gets the right operand input component
  64681. */
  64682. get right(): NodeMaterialConnectionPoint;
  64683. /**
  64684. * Gets the output component
  64685. */
  64686. get output(): NodeMaterialConnectionPoint;
  64687. protected _buildBlock(state: NodeMaterialBuildState): this;
  64688. }
  64689. }
  64690. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64694. /**
  64695. * Block used to normalize a vector
  64696. */
  64697. export class NormalizeBlock extends NodeMaterialBlock {
  64698. /**
  64699. * Creates a new NormalizeBlock
  64700. * @param name defines the block name
  64701. */
  64702. constructor(name: string);
  64703. /**
  64704. * Gets the current class name
  64705. * @returns the class name
  64706. */
  64707. getClassName(): string;
  64708. /**
  64709. * Gets the input component
  64710. */
  64711. get input(): NodeMaterialConnectionPoint;
  64712. /**
  64713. * Gets the output component
  64714. */
  64715. get output(): NodeMaterialConnectionPoint;
  64716. protected _buildBlock(state: NodeMaterialBuildState): this;
  64717. }
  64718. }
  64719. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64723. import { Scene } from "babylonjs/scene";
  64724. /**
  64725. * Operations supported by the Trigonometry block
  64726. */
  64727. export enum TrigonometryBlockOperations {
  64728. /** Cos */
  64729. Cos = 0,
  64730. /** Sin */
  64731. Sin = 1,
  64732. /** Abs */
  64733. Abs = 2,
  64734. /** Exp */
  64735. Exp = 3,
  64736. /** Exp2 */
  64737. Exp2 = 4,
  64738. /** Round */
  64739. Round = 5,
  64740. /** Floor */
  64741. Floor = 6,
  64742. /** Ceiling */
  64743. Ceiling = 7,
  64744. /** Square root */
  64745. Sqrt = 8,
  64746. /** Log */
  64747. Log = 9,
  64748. /** Tangent */
  64749. Tan = 10,
  64750. /** Arc tangent */
  64751. ArcTan = 11,
  64752. /** Arc cosinus */
  64753. ArcCos = 12,
  64754. /** Arc sinus */
  64755. ArcSin = 13,
  64756. /** Fraction */
  64757. Fract = 14,
  64758. /** Sign */
  64759. Sign = 15,
  64760. /** To radians (from degrees) */
  64761. Radians = 16,
  64762. /** To degrees (from radians) */
  64763. Degrees = 17
  64764. }
  64765. /**
  64766. * Block used to apply trigonometry operation to floats
  64767. */
  64768. export class TrigonometryBlock extends NodeMaterialBlock {
  64769. /**
  64770. * Gets or sets the operation applied by the block
  64771. */
  64772. operation: TrigonometryBlockOperations;
  64773. /**
  64774. * Creates a new TrigonometryBlock
  64775. * @param name defines the block name
  64776. */
  64777. constructor(name: string);
  64778. /**
  64779. * Gets the current class name
  64780. * @returns the class name
  64781. */
  64782. getClassName(): string;
  64783. /**
  64784. * Gets the input component
  64785. */
  64786. get input(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the output component
  64789. */
  64790. get output(): NodeMaterialConnectionPoint;
  64791. protected _buildBlock(state: NodeMaterialBuildState): this;
  64792. serialize(): any;
  64793. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64794. protected _dumpPropertiesCode(): string;
  64795. }
  64796. }
  64797. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64801. /**
  64802. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64803. */
  64804. export class ColorMergerBlock extends NodeMaterialBlock {
  64805. /**
  64806. * Create a new ColorMergerBlock
  64807. * @param name defines the block name
  64808. */
  64809. constructor(name: string);
  64810. /**
  64811. * Gets the current class name
  64812. * @returns the class name
  64813. */
  64814. getClassName(): string;
  64815. /**
  64816. * Gets the rgb component (input)
  64817. */
  64818. get rgbIn(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the r component (input)
  64821. */
  64822. get r(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the g component (input)
  64825. */
  64826. get g(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the b component (input)
  64829. */
  64830. get b(): NodeMaterialConnectionPoint;
  64831. /**
  64832. * Gets the a component (input)
  64833. */
  64834. get a(): NodeMaterialConnectionPoint;
  64835. /**
  64836. * Gets the rgba component (output)
  64837. */
  64838. get rgba(): NodeMaterialConnectionPoint;
  64839. /**
  64840. * Gets the rgb component (output)
  64841. */
  64842. get rgbOut(): NodeMaterialConnectionPoint;
  64843. /**
  64844. * Gets the rgb component (output)
  64845. * @deprecated Please use rgbOut instead.
  64846. */
  64847. get rgb(): NodeMaterialConnectionPoint;
  64848. protected _buildBlock(state: NodeMaterialBuildState): this;
  64849. }
  64850. }
  64851. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  64852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64855. /**
  64856. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64857. */
  64858. export class VectorSplitterBlock extends NodeMaterialBlock {
  64859. /**
  64860. * Create a new VectorSplitterBlock
  64861. * @param name defines the block name
  64862. */
  64863. constructor(name: string);
  64864. /**
  64865. * Gets the current class name
  64866. * @returns the class name
  64867. */
  64868. getClassName(): string;
  64869. /**
  64870. * Gets the xyzw component (input)
  64871. */
  64872. get xyzw(): NodeMaterialConnectionPoint;
  64873. /**
  64874. * Gets the xyz component (input)
  64875. */
  64876. get xyzIn(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the xy component (input)
  64879. */
  64880. get xyIn(): NodeMaterialConnectionPoint;
  64881. /**
  64882. * Gets the xyz component (output)
  64883. */
  64884. get xyzOut(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the xy component (output)
  64887. */
  64888. get xyOut(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the x component (output)
  64891. */
  64892. get x(): NodeMaterialConnectionPoint;
  64893. /**
  64894. * Gets the y component (output)
  64895. */
  64896. get y(): NodeMaterialConnectionPoint;
  64897. /**
  64898. * Gets the z component (output)
  64899. */
  64900. get z(): NodeMaterialConnectionPoint;
  64901. /**
  64902. * Gets the w component (output)
  64903. */
  64904. get w(): NodeMaterialConnectionPoint;
  64905. protected _inputRename(name: string): string;
  64906. protected _outputRename(name: string): string;
  64907. protected _buildBlock(state: NodeMaterialBuildState): this;
  64908. }
  64909. }
  64910. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  64911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64912. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64913. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64914. /**
  64915. * Block used to lerp between 2 values
  64916. */
  64917. export class LerpBlock extends NodeMaterialBlock {
  64918. /**
  64919. * Creates a new LerpBlock
  64920. * @param name defines the block name
  64921. */
  64922. constructor(name: string);
  64923. /**
  64924. * Gets the current class name
  64925. * @returns the class name
  64926. */
  64927. getClassName(): string;
  64928. /**
  64929. * Gets the left operand input component
  64930. */
  64931. get left(): NodeMaterialConnectionPoint;
  64932. /**
  64933. * Gets the right operand input component
  64934. */
  64935. get right(): NodeMaterialConnectionPoint;
  64936. /**
  64937. * Gets the gradient operand input component
  64938. */
  64939. get gradient(): NodeMaterialConnectionPoint;
  64940. /**
  64941. * Gets the output component
  64942. */
  64943. get output(): NodeMaterialConnectionPoint;
  64944. protected _buildBlock(state: NodeMaterialBuildState): this;
  64945. }
  64946. }
  64947. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  64948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64951. /**
  64952. * Block used to divide 2 vectors
  64953. */
  64954. export class DivideBlock extends NodeMaterialBlock {
  64955. /**
  64956. * Creates a new DivideBlock
  64957. * @param name defines the block name
  64958. */
  64959. constructor(name: string);
  64960. /**
  64961. * Gets the current class name
  64962. * @returns the class name
  64963. */
  64964. getClassName(): string;
  64965. /**
  64966. * Gets the left operand input component
  64967. */
  64968. get left(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the right operand input component
  64971. */
  64972. get right(): NodeMaterialConnectionPoint;
  64973. /**
  64974. * Gets the output component
  64975. */
  64976. get output(): NodeMaterialConnectionPoint;
  64977. protected _buildBlock(state: NodeMaterialBuildState): this;
  64978. }
  64979. }
  64980. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  64981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64984. /**
  64985. * Block used to subtract 2 vectors
  64986. */
  64987. export class SubtractBlock extends NodeMaterialBlock {
  64988. /**
  64989. * Creates a new SubtractBlock
  64990. * @param name defines the block name
  64991. */
  64992. constructor(name: string);
  64993. /**
  64994. * Gets the current class name
  64995. * @returns the class name
  64996. */
  64997. getClassName(): string;
  64998. /**
  64999. * Gets the left operand input component
  65000. */
  65001. get left(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the right operand input component
  65004. */
  65005. get right(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the output component
  65008. */
  65009. get output(): NodeMaterialConnectionPoint;
  65010. protected _buildBlock(state: NodeMaterialBuildState): this;
  65011. }
  65012. }
  65013. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65017. /**
  65018. * Block used to step a value
  65019. */
  65020. export class StepBlock extends NodeMaterialBlock {
  65021. /**
  65022. * Creates a new StepBlock
  65023. * @param name defines the block name
  65024. */
  65025. constructor(name: string);
  65026. /**
  65027. * Gets the current class name
  65028. * @returns the class name
  65029. */
  65030. getClassName(): string;
  65031. /**
  65032. * Gets the value operand input component
  65033. */
  65034. get value(): NodeMaterialConnectionPoint;
  65035. /**
  65036. * Gets the edge operand input component
  65037. */
  65038. get edge(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the output component
  65041. */
  65042. get output(): NodeMaterialConnectionPoint;
  65043. protected _buildBlock(state: NodeMaterialBuildState): this;
  65044. }
  65045. }
  65046. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65050. /**
  65051. * Block used to get the opposite (1 - x) of a value
  65052. */
  65053. export class OneMinusBlock extends NodeMaterialBlock {
  65054. /**
  65055. * Creates a new OneMinusBlock
  65056. * @param name defines the block name
  65057. */
  65058. constructor(name: string);
  65059. /**
  65060. * Gets the current class name
  65061. * @returns the class name
  65062. */
  65063. getClassName(): string;
  65064. /**
  65065. * Gets the input component
  65066. */
  65067. get input(): NodeMaterialConnectionPoint;
  65068. /**
  65069. * Gets the output component
  65070. */
  65071. get output(): NodeMaterialConnectionPoint;
  65072. protected _buildBlock(state: NodeMaterialBuildState): this;
  65073. }
  65074. }
  65075. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65079. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65080. /**
  65081. * Block used to get the view direction
  65082. */
  65083. export class ViewDirectionBlock extends NodeMaterialBlock {
  65084. /**
  65085. * Creates a new ViewDirectionBlock
  65086. * @param name defines the block name
  65087. */
  65088. constructor(name: string);
  65089. /**
  65090. * Gets the current class name
  65091. * @returns the class name
  65092. */
  65093. getClassName(): string;
  65094. /**
  65095. * Gets the world position component
  65096. */
  65097. get worldPosition(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the camera position component
  65100. */
  65101. get cameraPosition(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the output component
  65104. */
  65105. get output(): NodeMaterialConnectionPoint;
  65106. autoConfigure(material: NodeMaterial): void;
  65107. protected _buildBlock(state: NodeMaterialBuildState): this;
  65108. }
  65109. }
  65110. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65114. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65115. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65116. /**
  65117. * Block used to compute fresnel value
  65118. */
  65119. export class FresnelBlock extends NodeMaterialBlock {
  65120. /**
  65121. * Create a new FresnelBlock
  65122. * @param name defines the block name
  65123. */
  65124. constructor(name: string);
  65125. /**
  65126. * Gets the current class name
  65127. * @returns the class name
  65128. */
  65129. getClassName(): string;
  65130. /**
  65131. * Gets the world normal input component
  65132. */
  65133. get worldNormal(): NodeMaterialConnectionPoint;
  65134. /**
  65135. * Gets the view direction input component
  65136. */
  65137. get viewDirection(): NodeMaterialConnectionPoint;
  65138. /**
  65139. * Gets the bias input component
  65140. */
  65141. get bias(): NodeMaterialConnectionPoint;
  65142. /**
  65143. * Gets the camera (or eye) position component
  65144. */
  65145. get power(): NodeMaterialConnectionPoint;
  65146. /**
  65147. * Gets the fresnel output component
  65148. */
  65149. get fresnel(): NodeMaterialConnectionPoint;
  65150. autoConfigure(material: NodeMaterial): void;
  65151. protected _buildBlock(state: NodeMaterialBuildState): this;
  65152. }
  65153. }
  65154. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65158. /**
  65159. * Block used to get the max of 2 values
  65160. */
  65161. export class MaxBlock extends NodeMaterialBlock {
  65162. /**
  65163. * Creates a new MaxBlock
  65164. * @param name defines the block name
  65165. */
  65166. constructor(name: string);
  65167. /**
  65168. * Gets the current class name
  65169. * @returns the class name
  65170. */
  65171. getClassName(): string;
  65172. /**
  65173. * Gets the left operand input component
  65174. */
  65175. get left(): NodeMaterialConnectionPoint;
  65176. /**
  65177. * Gets the right operand input component
  65178. */
  65179. get right(): NodeMaterialConnectionPoint;
  65180. /**
  65181. * Gets the output component
  65182. */
  65183. get output(): NodeMaterialConnectionPoint;
  65184. protected _buildBlock(state: NodeMaterialBuildState): this;
  65185. }
  65186. }
  65187. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65191. /**
  65192. * Block used to get the min of 2 values
  65193. */
  65194. export class MinBlock extends NodeMaterialBlock {
  65195. /**
  65196. * Creates a new MinBlock
  65197. * @param name defines the block name
  65198. */
  65199. constructor(name: string);
  65200. /**
  65201. * Gets the current class name
  65202. * @returns the class name
  65203. */
  65204. getClassName(): string;
  65205. /**
  65206. * Gets the left operand input component
  65207. */
  65208. get left(): NodeMaterialConnectionPoint;
  65209. /**
  65210. * Gets the right operand input component
  65211. */
  65212. get right(): NodeMaterialConnectionPoint;
  65213. /**
  65214. * Gets the output component
  65215. */
  65216. get output(): NodeMaterialConnectionPoint;
  65217. protected _buildBlock(state: NodeMaterialBuildState): this;
  65218. }
  65219. }
  65220. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65224. /**
  65225. * Block used to get the distance between 2 values
  65226. */
  65227. export class DistanceBlock extends NodeMaterialBlock {
  65228. /**
  65229. * Creates a new DistanceBlock
  65230. * @param name defines the block name
  65231. */
  65232. constructor(name: string);
  65233. /**
  65234. * Gets the current class name
  65235. * @returns the class name
  65236. */
  65237. getClassName(): string;
  65238. /**
  65239. * Gets the left operand input component
  65240. */
  65241. get left(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the right operand input component
  65244. */
  65245. get right(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the output component
  65248. */
  65249. get output(): NodeMaterialConnectionPoint;
  65250. protected _buildBlock(state: NodeMaterialBuildState): this;
  65251. }
  65252. }
  65253. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65257. /**
  65258. * Block used to get the length of a vector
  65259. */
  65260. export class LengthBlock extends NodeMaterialBlock {
  65261. /**
  65262. * Creates a new LengthBlock
  65263. * @param name defines the block name
  65264. */
  65265. constructor(name: string);
  65266. /**
  65267. * Gets the current class name
  65268. * @returns the class name
  65269. */
  65270. getClassName(): string;
  65271. /**
  65272. * Gets the value input component
  65273. */
  65274. get value(): NodeMaterialConnectionPoint;
  65275. /**
  65276. * Gets the output component
  65277. */
  65278. get output(): NodeMaterialConnectionPoint;
  65279. protected _buildBlock(state: NodeMaterialBuildState): this;
  65280. }
  65281. }
  65282. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65286. /**
  65287. * Block used to get negative version of a value (i.e. x * -1)
  65288. */
  65289. export class NegateBlock extends NodeMaterialBlock {
  65290. /**
  65291. * Creates a new NegateBlock
  65292. * @param name defines the block name
  65293. */
  65294. constructor(name: string);
  65295. /**
  65296. * Gets the current class name
  65297. * @returns the class name
  65298. */
  65299. getClassName(): string;
  65300. /**
  65301. * Gets the value input component
  65302. */
  65303. get value(): NodeMaterialConnectionPoint;
  65304. /**
  65305. * Gets the output component
  65306. */
  65307. get output(): NodeMaterialConnectionPoint;
  65308. protected _buildBlock(state: NodeMaterialBuildState): this;
  65309. }
  65310. }
  65311. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65315. /**
  65316. * Block used to get the value of the first parameter raised to the power of the second
  65317. */
  65318. export class PowBlock extends NodeMaterialBlock {
  65319. /**
  65320. * Creates a new PowBlock
  65321. * @param name defines the block name
  65322. */
  65323. constructor(name: string);
  65324. /**
  65325. * Gets the current class name
  65326. * @returns the class name
  65327. */
  65328. getClassName(): string;
  65329. /**
  65330. * Gets the value operand input component
  65331. */
  65332. get value(): NodeMaterialConnectionPoint;
  65333. /**
  65334. * Gets the power operand input component
  65335. */
  65336. get power(): NodeMaterialConnectionPoint;
  65337. /**
  65338. * Gets the output component
  65339. */
  65340. get output(): NodeMaterialConnectionPoint;
  65341. protected _buildBlock(state: NodeMaterialBuildState): this;
  65342. }
  65343. }
  65344. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65348. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65349. /**
  65350. * Block used to get a random number
  65351. */
  65352. export class RandomNumberBlock extends NodeMaterialBlock {
  65353. /**
  65354. * Creates a new RandomNumberBlock
  65355. * @param name defines the block name
  65356. */
  65357. constructor(name: string);
  65358. /**
  65359. * Gets the current class name
  65360. * @returns the class name
  65361. */
  65362. getClassName(): string;
  65363. /**
  65364. * Gets the seed input component
  65365. */
  65366. get seed(): NodeMaterialConnectionPoint;
  65367. /**
  65368. * Gets the output component
  65369. */
  65370. get output(): NodeMaterialConnectionPoint;
  65371. protected _buildBlock(state: NodeMaterialBuildState): this;
  65372. }
  65373. }
  65374. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65378. /**
  65379. * Block used to compute arc tangent of 2 values
  65380. */
  65381. export class ArcTan2Block extends NodeMaterialBlock {
  65382. /**
  65383. * Creates a new ArcTan2Block
  65384. * @param name defines the block name
  65385. */
  65386. constructor(name: string);
  65387. /**
  65388. * Gets the current class name
  65389. * @returns the class name
  65390. */
  65391. getClassName(): string;
  65392. /**
  65393. * Gets the x operand input component
  65394. */
  65395. get x(): NodeMaterialConnectionPoint;
  65396. /**
  65397. * Gets the y operand input component
  65398. */
  65399. get y(): NodeMaterialConnectionPoint;
  65400. /**
  65401. * Gets the output component
  65402. */
  65403. get output(): NodeMaterialConnectionPoint;
  65404. protected _buildBlock(state: NodeMaterialBuildState): this;
  65405. }
  65406. }
  65407. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65411. /**
  65412. * Block used to smooth step a value
  65413. */
  65414. export class SmoothStepBlock extends NodeMaterialBlock {
  65415. /**
  65416. * Creates a new SmoothStepBlock
  65417. * @param name defines the block name
  65418. */
  65419. constructor(name: string);
  65420. /**
  65421. * Gets the current class name
  65422. * @returns the class name
  65423. */
  65424. getClassName(): string;
  65425. /**
  65426. * Gets the value operand input component
  65427. */
  65428. get value(): NodeMaterialConnectionPoint;
  65429. /**
  65430. * Gets the first edge operand input component
  65431. */
  65432. get edge0(): NodeMaterialConnectionPoint;
  65433. /**
  65434. * Gets the second edge operand input component
  65435. */
  65436. get edge1(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the output component
  65439. */
  65440. get output(): NodeMaterialConnectionPoint;
  65441. protected _buildBlock(state: NodeMaterialBuildState): this;
  65442. }
  65443. }
  65444. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65448. /**
  65449. * Block used to get the reciprocal (1 / x) of a value
  65450. */
  65451. export class ReciprocalBlock extends NodeMaterialBlock {
  65452. /**
  65453. * Creates a new ReciprocalBlock
  65454. * @param name defines the block name
  65455. */
  65456. constructor(name: string);
  65457. /**
  65458. * Gets the current class name
  65459. * @returns the class name
  65460. */
  65461. getClassName(): string;
  65462. /**
  65463. * Gets the input component
  65464. */
  65465. get input(): NodeMaterialConnectionPoint;
  65466. /**
  65467. * Gets the output component
  65468. */
  65469. get output(): NodeMaterialConnectionPoint;
  65470. protected _buildBlock(state: NodeMaterialBuildState): this;
  65471. }
  65472. }
  65473. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65477. /**
  65478. * Block used to replace a color by another one
  65479. */
  65480. export class ReplaceColorBlock extends NodeMaterialBlock {
  65481. /**
  65482. * Creates a new ReplaceColorBlock
  65483. * @param name defines the block name
  65484. */
  65485. constructor(name: string);
  65486. /**
  65487. * Gets the current class name
  65488. * @returns the class name
  65489. */
  65490. getClassName(): string;
  65491. /**
  65492. * Gets the value input component
  65493. */
  65494. get value(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the reference input component
  65497. */
  65498. get reference(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the distance input component
  65501. */
  65502. get distance(): NodeMaterialConnectionPoint;
  65503. /**
  65504. * Gets the replacement input component
  65505. */
  65506. get replacement(): NodeMaterialConnectionPoint;
  65507. /**
  65508. * Gets the output component
  65509. */
  65510. get output(): NodeMaterialConnectionPoint;
  65511. protected _buildBlock(state: NodeMaterialBuildState): this;
  65512. }
  65513. }
  65514. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65518. /**
  65519. * Block used to posterize a value
  65520. * @see https://en.wikipedia.org/wiki/Posterization
  65521. */
  65522. export class PosterizeBlock extends NodeMaterialBlock {
  65523. /**
  65524. * Creates a new PosterizeBlock
  65525. * @param name defines the block name
  65526. */
  65527. constructor(name: string);
  65528. /**
  65529. * Gets the current class name
  65530. * @returns the class name
  65531. */
  65532. getClassName(): string;
  65533. /**
  65534. * Gets the value input component
  65535. */
  65536. get value(): NodeMaterialConnectionPoint;
  65537. /**
  65538. * Gets the steps input component
  65539. */
  65540. get steps(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the output component
  65543. */
  65544. get output(): NodeMaterialConnectionPoint;
  65545. protected _buildBlock(state: NodeMaterialBuildState): this;
  65546. }
  65547. }
  65548. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65552. import { Scene } from "babylonjs/scene";
  65553. /**
  65554. * Operations supported by the Wave block
  65555. */
  65556. export enum WaveBlockKind {
  65557. /** SawTooth */
  65558. SawTooth = 0,
  65559. /** Square */
  65560. Square = 1,
  65561. /** Triangle */
  65562. Triangle = 2
  65563. }
  65564. /**
  65565. * Block used to apply wave operation to floats
  65566. */
  65567. export class WaveBlock extends NodeMaterialBlock {
  65568. /**
  65569. * Gets or sets the kibnd of wave to be applied by the block
  65570. */
  65571. kind: WaveBlockKind;
  65572. /**
  65573. * Creates a new WaveBlock
  65574. * @param name defines the block name
  65575. */
  65576. constructor(name: string);
  65577. /**
  65578. * Gets the current class name
  65579. * @returns the class name
  65580. */
  65581. getClassName(): string;
  65582. /**
  65583. * Gets the input component
  65584. */
  65585. get input(): NodeMaterialConnectionPoint;
  65586. /**
  65587. * Gets the output component
  65588. */
  65589. get output(): NodeMaterialConnectionPoint;
  65590. protected _buildBlock(state: NodeMaterialBuildState): this;
  65591. serialize(): any;
  65592. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65593. }
  65594. }
  65595. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65599. import { Color3 } from "babylonjs/Maths/math.color";
  65600. import { Scene } from "babylonjs/scene";
  65601. /**
  65602. * Class used to store a color step for the GradientBlock
  65603. */
  65604. export class GradientBlockColorStep {
  65605. /**
  65606. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65607. */
  65608. step: number;
  65609. /**
  65610. * Gets or sets the color associated with this step
  65611. */
  65612. color: Color3;
  65613. /**
  65614. * Creates a new GradientBlockColorStep
  65615. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65616. * @param color defines the color associated with this step
  65617. */
  65618. constructor(
  65619. /**
  65620. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65621. */
  65622. step: number,
  65623. /**
  65624. * Gets or sets the color associated with this step
  65625. */
  65626. color: Color3);
  65627. }
  65628. /**
  65629. * Block used to return a color from a gradient based on an input value between 0 and 1
  65630. */
  65631. export class GradientBlock extends NodeMaterialBlock {
  65632. /**
  65633. * Gets or sets the list of color steps
  65634. */
  65635. colorSteps: GradientBlockColorStep[];
  65636. /**
  65637. * Creates a new GradientBlock
  65638. * @param name defines the block name
  65639. */
  65640. constructor(name: string);
  65641. /**
  65642. * Gets the current class name
  65643. * @returns the class name
  65644. */
  65645. getClassName(): string;
  65646. /**
  65647. * Gets the gradient input component
  65648. */
  65649. get gradient(): NodeMaterialConnectionPoint;
  65650. /**
  65651. * Gets the output component
  65652. */
  65653. get output(): NodeMaterialConnectionPoint;
  65654. private _writeColorConstant;
  65655. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65656. serialize(): any;
  65657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65658. protected _dumpPropertiesCode(): string;
  65659. }
  65660. }
  65661. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65665. /**
  65666. * Block used to normalize lerp between 2 values
  65667. */
  65668. export class NLerpBlock extends NodeMaterialBlock {
  65669. /**
  65670. * Creates a new NLerpBlock
  65671. * @param name defines the block name
  65672. */
  65673. constructor(name: string);
  65674. /**
  65675. * Gets the current class name
  65676. * @returns the class name
  65677. */
  65678. getClassName(): string;
  65679. /**
  65680. * Gets the left operand input component
  65681. */
  65682. get left(): NodeMaterialConnectionPoint;
  65683. /**
  65684. * Gets the right operand input component
  65685. */
  65686. get right(): NodeMaterialConnectionPoint;
  65687. /**
  65688. * Gets the gradient operand input component
  65689. */
  65690. get gradient(): NodeMaterialConnectionPoint;
  65691. /**
  65692. * Gets the output component
  65693. */
  65694. get output(): NodeMaterialConnectionPoint;
  65695. protected _buildBlock(state: NodeMaterialBuildState): this;
  65696. }
  65697. }
  65698. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65702. import { Scene } from "babylonjs/scene";
  65703. /**
  65704. * block used to Generate a Worley Noise 3D Noise Pattern
  65705. */
  65706. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65707. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65708. manhattanDistance: boolean;
  65709. /**
  65710. * Creates a new WorleyNoise3DBlock
  65711. * @param name defines the block name
  65712. */
  65713. constructor(name: string);
  65714. /**
  65715. * Gets the current class name
  65716. * @returns the class name
  65717. */
  65718. getClassName(): string;
  65719. /**
  65720. * Gets the seed input component
  65721. */
  65722. get seed(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the jitter input component
  65725. */
  65726. get jitter(): NodeMaterialConnectionPoint;
  65727. /**
  65728. * Gets the output component
  65729. */
  65730. get output(): NodeMaterialConnectionPoint;
  65731. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65732. /**
  65733. * Exposes the properties to the UI?
  65734. */
  65735. protected _dumpPropertiesCode(): string;
  65736. /**
  65737. * Exposes the properties to the Seralize?
  65738. */
  65739. serialize(): any;
  65740. /**
  65741. * Exposes the properties to the deseralize?
  65742. */
  65743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65744. }
  65745. }
  65746. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65750. /**
  65751. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65752. */
  65753. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65754. /**
  65755. * Creates a new SimplexPerlin3DBlock
  65756. * @param name defines the block name
  65757. */
  65758. constructor(name: string);
  65759. /**
  65760. * Gets the current class name
  65761. * @returns the class name
  65762. */
  65763. getClassName(): string;
  65764. /**
  65765. * Gets the seed operand input component
  65766. */
  65767. get seed(): NodeMaterialConnectionPoint;
  65768. /**
  65769. * Gets the output component
  65770. */
  65771. get output(): NodeMaterialConnectionPoint;
  65772. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65773. }
  65774. }
  65775. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65779. /**
  65780. * Block used to blend normals
  65781. */
  65782. export class NormalBlendBlock extends NodeMaterialBlock {
  65783. /**
  65784. * Creates a new NormalBlendBlock
  65785. * @param name defines the block name
  65786. */
  65787. constructor(name: string);
  65788. /**
  65789. * Gets the current class name
  65790. * @returns the class name
  65791. */
  65792. getClassName(): string;
  65793. /**
  65794. * Gets the first input component
  65795. */
  65796. get normalMap0(): NodeMaterialConnectionPoint;
  65797. /**
  65798. * Gets the second input component
  65799. */
  65800. get normalMap1(): NodeMaterialConnectionPoint;
  65801. /**
  65802. * Gets the output component
  65803. */
  65804. get output(): NodeMaterialConnectionPoint;
  65805. protected _buildBlock(state: NodeMaterialBuildState): this;
  65806. }
  65807. }
  65808. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65812. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65813. /**
  65814. * Block used to rotate a 2d vector by a given angle
  65815. */
  65816. export class Rotate2dBlock extends NodeMaterialBlock {
  65817. /**
  65818. * Creates a new Rotate2dBlock
  65819. * @param name defines the block name
  65820. */
  65821. constructor(name: string);
  65822. /**
  65823. * Gets the current class name
  65824. * @returns the class name
  65825. */
  65826. getClassName(): string;
  65827. /**
  65828. * Gets the input vector
  65829. */
  65830. get input(): NodeMaterialConnectionPoint;
  65831. /**
  65832. * Gets the input angle
  65833. */
  65834. get angle(): NodeMaterialConnectionPoint;
  65835. /**
  65836. * Gets the output component
  65837. */
  65838. get output(): NodeMaterialConnectionPoint;
  65839. autoConfigure(material: NodeMaterial): void;
  65840. protected _buildBlock(state: NodeMaterialBuildState): this;
  65841. }
  65842. }
  65843. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  65844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65847. /**
  65848. * Block used to get the reflected vector from a direction and a normal
  65849. */
  65850. export class ReflectBlock extends NodeMaterialBlock {
  65851. /**
  65852. * Creates a new ReflectBlock
  65853. * @param name defines the block name
  65854. */
  65855. constructor(name: string);
  65856. /**
  65857. * Gets the current class name
  65858. * @returns the class name
  65859. */
  65860. getClassName(): string;
  65861. /**
  65862. * Gets the incident component
  65863. */
  65864. get incident(): NodeMaterialConnectionPoint;
  65865. /**
  65866. * Gets the normal component
  65867. */
  65868. get normal(): NodeMaterialConnectionPoint;
  65869. /**
  65870. * Gets the output component
  65871. */
  65872. get output(): NodeMaterialConnectionPoint;
  65873. protected _buildBlock(state: NodeMaterialBuildState): this;
  65874. }
  65875. }
  65876. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  65877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65880. /**
  65881. * Block used to get the refracted vector from a direction and a normal
  65882. */
  65883. export class RefractBlock extends NodeMaterialBlock {
  65884. /**
  65885. * Creates a new RefractBlock
  65886. * @param name defines the block name
  65887. */
  65888. constructor(name: string);
  65889. /**
  65890. * Gets the current class name
  65891. * @returns the class name
  65892. */
  65893. getClassName(): string;
  65894. /**
  65895. * Gets the incident component
  65896. */
  65897. get incident(): NodeMaterialConnectionPoint;
  65898. /**
  65899. * Gets the normal component
  65900. */
  65901. get normal(): NodeMaterialConnectionPoint;
  65902. /**
  65903. * Gets the index of refraction component
  65904. */
  65905. get ior(): NodeMaterialConnectionPoint;
  65906. /**
  65907. * Gets the output component
  65908. */
  65909. get output(): NodeMaterialConnectionPoint;
  65910. protected _buildBlock(state: NodeMaterialBuildState): this;
  65911. }
  65912. }
  65913. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  65914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65917. /**
  65918. * Block used to desaturate a color
  65919. */
  65920. export class DesaturateBlock extends NodeMaterialBlock {
  65921. /**
  65922. * Creates a new DesaturateBlock
  65923. * @param name defines the block name
  65924. */
  65925. constructor(name: string);
  65926. /**
  65927. * Gets the current class name
  65928. * @returns the class name
  65929. */
  65930. getClassName(): string;
  65931. /**
  65932. * Gets the color operand input component
  65933. */
  65934. get color(): NodeMaterialConnectionPoint;
  65935. /**
  65936. * Gets the level operand input component
  65937. */
  65938. get level(): NodeMaterialConnectionPoint;
  65939. /**
  65940. * Gets the output component
  65941. */
  65942. get output(): NodeMaterialConnectionPoint;
  65943. protected _buildBlock(state: NodeMaterialBuildState): this;
  65944. }
  65945. }
  65946. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  65947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65950. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65951. import { Nullable } from "babylonjs/types";
  65952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65953. import { Scene } from "babylonjs/scene";
  65954. /**
  65955. * Block used to implement the ambient occlusion module of the PBR material
  65956. */
  65957. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65958. /**
  65959. * Create a new AmbientOcclusionBlock
  65960. * @param name defines the block name
  65961. */
  65962. constructor(name: string);
  65963. /**
  65964. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65965. */
  65966. useAmbientInGrayScale: boolean;
  65967. /**
  65968. * Initialize the block and prepare the context for build
  65969. * @param state defines the state that will be used for the build
  65970. */
  65971. initialize(state: NodeMaterialBuildState): void;
  65972. /**
  65973. * Gets the current class name
  65974. * @returns the class name
  65975. */
  65976. getClassName(): string;
  65977. /**
  65978. * Gets the texture input component
  65979. */
  65980. get texture(): NodeMaterialConnectionPoint;
  65981. /**
  65982. * Gets the texture intensity component
  65983. */
  65984. get intensity(): NodeMaterialConnectionPoint;
  65985. /**
  65986. * Gets the direct light intensity input component
  65987. */
  65988. get directLightIntensity(): NodeMaterialConnectionPoint;
  65989. /**
  65990. * Gets the ambient occlusion object output component
  65991. */
  65992. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65993. /**
  65994. * Gets the main code of the block (fragment side)
  65995. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65996. * @returns the shader code
  65997. */
  65998. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66000. protected _buildBlock(state: NodeMaterialBuildState): this;
  66001. protected _dumpPropertiesCode(): string;
  66002. serialize(): any;
  66003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66004. }
  66005. }
  66006. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66009. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66010. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66012. import { Nullable } from "babylonjs/types";
  66013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66014. import { Mesh } from "babylonjs/Meshes/mesh";
  66015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66016. import { Effect } from "babylonjs/Materials/effect";
  66017. import { Scene } from "babylonjs/scene";
  66018. /**
  66019. * Block used to implement the reflection module of the PBR material
  66020. */
  66021. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66022. /** @hidden */
  66023. _defineLODReflectionAlpha: string;
  66024. /** @hidden */
  66025. _defineLinearSpecularReflection: string;
  66026. private _vEnvironmentIrradianceName;
  66027. /** @hidden */
  66028. _vReflectionMicrosurfaceInfosName: string;
  66029. /** @hidden */
  66030. _vReflectionInfosName: string;
  66031. /** @hidden */
  66032. _vReflectionFilteringInfoName: string;
  66033. private _scene;
  66034. /**
  66035. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66036. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66037. * It's less burden on the user side in the editor part.
  66038. */
  66039. /** @hidden */
  66040. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66041. /** @hidden */
  66042. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66043. /** @hidden */
  66044. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66045. /**
  66046. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66047. * diffuse part of the IBL.
  66048. */
  66049. useSphericalHarmonics: boolean;
  66050. /**
  66051. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66052. */
  66053. forceIrradianceInFragment: boolean;
  66054. /**
  66055. * Create a new ReflectionBlock
  66056. * @param name defines the block name
  66057. */
  66058. constructor(name: string);
  66059. /**
  66060. * Gets the current class name
  66061. * @returns the class name
  66062. */
  66063. getClassName(): string;
  66064. /**
  66065. * Gets the position input component
  66066. */
  66067. get position(): NodeMaterialConnectionPoint;
  66068. /**
  66069. * Gets the world position input component
  66070. */
  66071. get worldPosition(): NodeMaterialConnectionPoint;
  66072. /**
  66073. * Gets the world normal input component
  66074. */
  66075. get worldNormal(): NodeMaterialConnectionPoint;
  66076. /**
  66077. * Gets the world input component
  66078. */
  66079. get world(): NodeMaterialConnectionPoint;
  66080. /**
  66081. * Gets the camera (or eye) position component
  66082. */
  66083. get cameraPosition(): NodeMaterialConnectionPoint;
  66084. /**
  66085. * Gets the view input component
  66086. */
  66087. get view(): NodeMaterialConnectionPoint;
  66088. /**
  66089. * Gets the color input component
  66090. */
  66091. get color(): NodeMaterialConnectionPoint;
  66092. /**
  66093. * Gets the reflection object output component
  66094. */
  66095. get reflection(): NodeMaterialConnectionPoint;
  66096. /**
  66097. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66098. */
  66099. get hasTexture(): boolean;
  66100. /**
  66101. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66102. */
  66103. get reflectionColor(): string;
  66104. protected _getTexture(): Nullable<BaseTexture>;
  66105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66107. /**
  66108. * Gets the code to inject in the vertex shader
  66109. * @param state current state of the node material building
  66110. * @returns the shader code
  66111. */
  66112. handleVertexSide(state: NodeMaterialBuildState): string;
  66113. /**
  66114. * Gets the main code of the block (fragment side)
  66115. * @param state current state of the node material building
  66116. * @param normalVarName name of the existing variable corresponding to the normal
  66117. * @returns the shader code
  66118. */
  66119. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66120. protected _buildBlock(state: NodeMaterialBuildState): this;
  66121. protected _dumpPropertiesCode(): string;
  66122. serialize(): any;
  66123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66124. }
  66125. }
  66126. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66130. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66132. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66133. import { Scene } from "babylonjs/scene";
  66134. import { Nullable } from "babylonjs/types";
  66135. /**
  66136. * Block used to implement the sheen module of the PBR material
  66137. */
  66138. export class SheenBlock extends NodeMaterialBlock {
  66139. /**
  66140. * Create a new SheenBlock
  66141. * @param name defines the block name
  66142. */
  66143. constructor(name: string);
  66144. /**
  66145. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66146. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66147. * making it easier to setup and tweak the effect
  66148. */
  66149. albedoScaling: boolean;
  66150. /**
  66151. * Defines if the sheen is linked to the sheen color.
  66152. */
  66153. linkSheenWithAlbedo: boolean;
  66154. /**
  66155. * Initialize the block and prepare the context for build
  66156. * @param state defines the state that will be used for the build
  66157. */
  66158. initialize(state: NodeMaterialBuildState): void;
  66159. /**
  66160. * Gets the current class name
  66161. * @returns the class name
  66162. */
  66163. getClassName(): string;
  66164. /**
  66165. * Gets the intensity input component
  66166. */
  66167. get intensity(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the color input component
  66170. */
  66171. get color(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the roughness input component
  66174. */
  66175. get roughness(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the sheen object output component
  66178. */
  66179. get sheen(): NodeMaterialConnectionPoint;
  66180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66181. /**
  66182. * Gets the main code of the block (fragment side)
  66183. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66184. * @returns the shader code
  66185. */
  66186. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66187. protected _buildBlock(state: NodeMaterialBuildState): this;
  66188. protected _dumpPropertiesCode(): string;
  66189. serialize(): any;
  66190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66191. }
  66192. }
  66193. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66199. import { Scene } from "babylonjs/scene";
  66200. import { Nullable } from "babylonjs/types";
  66201. import { Mesh } from "babylonjs/Meshes/mesh";
  66202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66203. import { Effect } from "babylonjs/Materials/effect";
  66204. /**
  66205. * Block used to implement the reflectivity module of the PBR material
  66206. */
  66207. export class ReflectivityBlock extends NodeMaterialBlock {
  66208. private _metallicReflectanceColor;
  66209. private _metallicF0Factor;
  66210. /** @hidden */
  66211. _vMetallicReflectanceFactorsName: string;
  66212. /**
  66213. * The property below is set by the main PBR block prior to calling methods of this class.
  66214. */
  66215. /** @hidden */
  66216. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66217. /**
  66218. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66219. */
  66220. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66221. /**
  66222. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66223. */
  66224. useMetallnessFromMetallicTextureBlue: boolean;
  66225. /**
  66226. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66227. */
  66228. useRoughnessFromMetallicTextureAlpha: boolean;
  66229. /**
  66230. * Specifies if the metallic texture contains the roughness information in its green channel.
  66231. */
  66232. useRoughnessFromMetallicTextureGreen: boolean;
  66233. /**
  66234. * Create a new ReflectivityBlock
  66235. * @param name defines the block name
  66236. */
  66237. constructor(name: string);
  66238. /**
  66239. * Initialize the block and prepare the context for build
  66240. * @param state defines the state that will be used for the build
  66241. */
  66242. initialize(state: NodeMaterialBuildState): void;
  66243. /**
  66244. * Gets the current class name
  66245. * @returns the class name
  66246. */
  66247. getClassName(): string;
  66248. /**
  66249. * Gets the metallic input component
  66250. */
  66251. get metallic(): NodeMaterialConnectionPoint;
  66252. /**
  66253. * Gets the roughness input component
  66254. */
  66255. get roughness(): NodeMaterialConnectionPoint;
  66256. /**
  66257. * Gets the texture input component
  66258. */
  66259. get texture(): NodeMaterialConnectionPoint;
  66260. /**
  66261. * Gets the reflectivity object output component
  66262. */
  66263. get reflectivity(): NodeMaterialConnectionPoint;
  66264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66265. /**
  66266. * Gets the main code of the block (fragment side)
  66267. * @param state current state of the node material building
  66268. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66269. * @returns the shader code
  66270. */
  66271. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66273. protected _buildBlock(state: NodeMaterialBuildState): this;
  66274. protected _dumpPropertiesCode(): string;
  66275. serialize(): any;
  66276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66277. }
  66278. }
  66279. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66280. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66285. /**
  66286. * Block used to implement the anisotropy module of the PBR material
  66287. */
  66288. export class AnisotropyBlock extends NodeMaterialBlock {
  66289. /**
  66290. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66291. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66292. * It's less burden on the user side in the editor part.
  66293. */
  66294. /** @hidden */
  66295. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66296. /** @hidden */
  66297. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66298. /**
  66299. * Create a new AnisotropyBlock
  66300. * @param name defines the block name
  66301. */
  66302. constructor(name: string);
  66303. /**
  66304. * Initialize the block and prepare the context for build
  66305. * @param state defines the state that will be used for the build
  66306. */
  66307. initialize(state: NodeMaterialBuildState): void;
  66308. /**
  66309. * Gets the current class name
  66310. * @returns the class name
  66311. */
  66312. getClassName(): string;
  66313. /**
  66314. * Gets the intensity input component
  66315. */
  66316. get intensity(): NodeMaterialConnectionPoint;
  66317. /**
  66318. * Gets the direction input component
  66319. */
  66320. get direction(): NodeMaterialConnectionPoint;
  66321. /**
  66322. * Gets the texture input component
  66323. */
  66324. get texture(): NodeMaterialConnectionPoint;
  66325. /**
  66326. * Gets the uv input component
  66327. */
  66328. get uv(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the worldTangent input component
  66331. */
  66332. get worldTangent(): NodeMaterialConnectionPoint;
  66333. /**
  66334. * Gets the anisotropy object output component
  66335. */
  66336. get anisotropy(): NodeMaterialConnectionPoint;
  66337. private _generateTBNSpace;
  66338. /**
  66339. * Gets the main code of the block (fragment side)
  66340. * @param state current state of the node material building
  66341. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66342. * @returns the shader code
  66343. */
  66344. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66346. protected _buildBlock(state: NodeMaterialBuildState): this;
  66347. }
  66348. }
  66349. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66353. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66355. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66356. import { Nullable } from "babylonjs/types";
  66357. import { Mesh } from "babylonjs/Meshes/mesh";
  66358. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66359. import { Effect } from "babylonjs/Materials/effect";
  66360. /**
  66361. * Block used to implement the clear coat module of the PBR material
  66362. */
  66363. export class ClearCoatBlock extends NodeMaterialBlock {
  66364. private _scene;
  66365. /**
  66366. * Create a new ClearCoatBlock
  66367. * @param name defines the block name
  66368. */
  66369. constructor(name: string);
  66370. /**
  66371. * Initialize the block and prepare the context for build
  66372. * @param state defines the state that will be used for the build
  66373. */
  66374. initialize(state: NodeMaterialBuildState): void;
  66375. /**
  66376. * Gets the current class name
  66377. * @returns the class name
  66378. */
  66379. getClassName(): string;
  66380. /**
  66381. * Gets the intensity input component
  66382. */
  66383. get intensity(): NodeMaterialConnectionPoint;
  66384. /**
  66385. * Gets the roughness input component
  66386. */
  66387. get roughness(): NodeMaterialConnectionPoint;
  66388. /**
  66389. * Gets the ior input component
  66390. */
  66391. get ior(): NodeMaterialConnectionPoint;
  66392. /**
  66393. * Gets the texture input component
  66394. */
  66395. get texture(): NodeMaterialConnectionPoint;
  66396. /**
  66397. * Gets the bump texture input component
  66398. */
  66399. get bumpTexture(): NodeMaterialConnectionPoint;
  66400. /**
  66401. * Gets the uv input component
  66402. */
  66403. get uv(): NodeMaterialConnectionPoint;
  66404. /**
  66405. * Gets the tint color input component
  66406. */
  66407. get tintColor(): NodeMaterialConnectionPoint;
  66408. /**
  66409. * Gets the tint "at distance" input component
  66410. */
  66411. get tintAtDistance(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the tint thickness input component
  66414. */
  66415. get tintThickness(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the world tangent input component
  66418. */
  66419. get worldTangent(): NodeMaterialConnectionPoint;
  66420. /**
  66421. * Gets the clear coat object output component
  66422. */
  66423. get clearcoat(): NodeMaterialConnectionPoint;
  66424. autoConfigure(material: NodeMaterial): void;
  66425. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66426. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66427. private _generateTBNSpace;
  66428. /**
  66429. * Gets the main code of the block (fragment side)
  66430. * @param state current state of the node material building
  66431. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66432. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66433. * @param worldPosVarName name of the variable holding the world position
  66434. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66435. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66436. * @param worldNormalVarName name of the variable holding the world normal
  66437. * @returns the shader code
  66438. */
  66439. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66440. protected _buildBlock(state: NodeMaterialBuildState): this;
  66441. }
  66442. }
  66443. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66447. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66449. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66450. import { Nullable } from "babylonjs/types";
  66451. /**
  66452. * Block used to implement the sub surface module of the PBR material
  66453. */
  66454. export class SubSurfaceBlock extends NodeMaterialBlock {
  66455. /**
  66456. * Create a new SubSurfaceBlock
  66457. * @param name defines the block name
  66458. */
  66459. constructor(name: string);
  66460. /**
  66461. * Stores the intensity of the different subsurface effects in the thickness texture.
  66462. * * the green channel is the translucency intensity.
  66463. * * the blue channel is the scattering intensity.
  66464. * * the alpha channel is the refraction intensity.
  66465. */
  66466. useMaskFromThicknessTexture: boolean;
  66467. /**
  66468. * Initialize the block and prepare the context for build
  66469. * @param state defines the state that will be used for the build
  66470. */
  66471. initialize(state: NodeMaterialBuildState): void;
  66472. /**
  66473. * Gets the current class name
  66474. * @returns the class name
  66475. */
  66476. getClassName(): string;
  66477. /**
  66478. * Gets the min thickness input component
  66479. */
  66480. get minThickness(): NodeMaterialConnectionPoint;
  66481. /**
  66482. * Gets the max thickness input component
  66483. */
  66484. get maxThickness(): NodeMaterialConnectionPoint;
  66485. /**
  66486. * Gets the thickness texture component
  66487. */
  66488. get thicknessTexture(): NodeMaterialConnectionPoint;
  66489. /**
  66490. * Gets the tint color input component
  66491. */
  66492. get tintColor(): NodeMaterialConnectionPoint;
  66493. /**
  66494. * Gets the translucency intensity input component
  66495. */
  66496. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66497. /**
  66498. * Gets the translucency diffusion distance input component
  66499. */
  66500. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66501. /**
  66502. * Gets the refraction object parameters
  66503. */
  66504. get refraction(): NodeMaterialConnectionPoint;
  66505. /**
  66506. * Gets the sub surface object output component
  66507. */
  66508. get subsurface(): NodeMaterialConnectionPoint;
  66509. autoConfigure(material: NodeMaterial): void;
  66510. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66511. /**
  66512. * Gets the main code of the block (fragment side)
  66513. * @param state current state of the node material building
  66514. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66515. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66516. * @param worldPosVarName name of the variable holding the world position
  66517. * @returns the shader code
  66518. */
  66519. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66520. protected _buildBlock(state: NodeMaterialBuildState): this;
  66521. }
  66522. }
  66523. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66527. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66528. import { Light } from "babylonjs/Lights/light";
  66529. import { Nullable } from "babylonjs/types";
  66530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66531. import { Effect } from "babylonjs/Materials/effect";
  66532. import { Mesh } from "babylonjs/Meshes/mesh";
  66533. import { Scene } from "babylonjs/scene";
  66534. /**
  66535. * Block used to implement the PBR metallic/roughness model
  66536. */
  66537. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66538. /**
  66539. * Gets or sets the light associated with this block
  66540. */
  66541. light: Nullable<Light>;
  66542. private _lightId;
  66543. private _scene;
  66544. private _environmentBRDFTexture;
  66545. private _environmentBrdfSamplerName;
  66546. private _vNormalWName;
  66547. private _invertNormalName;
  66548. /**
  66549. * Create a new ReflectionBlock
  66550. * @param name defines the block name
  66551. */
  66552. constructor(name: string);
  66553. /**
  66554. * Intensity of the direct lights e.g. the four lights available in your scene.
  66555. * This impacts both the direct diffuse and specular highlights.
  66556. */
  66557. directIntensity: number;
  66558. /**
  66559. * Intensity of the environment e.g. how much the environment will light the object
  66560. * either through harmonics for rough material or through the refelction for shiny ones.
  66561. */
  66562. environmentIntensity: number;
  66563. /**
  66564. * This is a special control allowing the reduction of the specular highlights coming from the
  66565. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66566. */
  66567. specularIntensity: number;
  66568. /**
  66569. * Defines the falloff type used in this material.
  66570. * It by default is Physical.
  66571. */
  66572. lightFalloff: number;
  66573. /**
  66574. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66575. */
  66576. useAlphaFromAlbedoTexture: boolean;
  66577. /**
  66578. * Specifies that alpha test should be used
  66579. */
  66580. useAlphaTest: boolean;
  66581. /**
  66582. * Defines the alpha limits in alpha test mode.
  66583. */
  66584. alphaTestCutoff: number;
  66585. /**
  66586. * Specifies that alpha blending should be used
  66587. */
  66588. useAlphaBlending: boolean;
  66589. /**
  66590. * Defines if the alpha value should be determined via the rgb values.
  66591. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66592. */
  66593. opacityRGB: boolean;
  66594. /**
  66595. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66596. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66597. */
  66598. useRadianceOverAlpha: boolean;
  66599. /**
  66600. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66601. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66602. */
  66603. useSpecularOverAlpha: boolean;
  66604. /**
  66605. * Enables specular anti aliasing in the PBR shader.
  66606. * It will both interacts on the Geometry for analytical and IBL lighting.
  66607. * It also prefilter the roughness map based on the bump values.
  66608. */
  66609. enableSpecularAntiAliasing: boolean;
  66610. /**
  66611. * Enables realtime filtering on the texture.
  66612. */
  66613. realTimeFiltering: boolean;
  66614. /**
  66615. * Quality switch for realtime filtering
  66616. */
  66617. realTimeFilteringQuality: number;
  66618. /**
  66619. * Defines if the material uses energy conservation.
  66620. */
  66621. useEnergyConservation: boolean;
  66622. /**
  66623. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66624. * too much the area relying on ambient texture to define their ambient occlusion.
  66625. */
  66626. useRadianceOcclusion: boolean;
  66627. /**
  66628. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66629. * makes the reflect vector face the model (under horizon).
  66630. */
  66631. useHorizonOcclusion: boolean;
  66632. /**
  66633. * If set to true, no lighting calculations will be applied.
  66634. */
  66635. unlit: boolean;
  66636. /**
  66637. * Force normal to face away from face.
  66638. */
  66639. forceNormalForward: boolean;
  66640. /**
  66641. * Defines the material debug mode.
  66642. * It helps seeing only some components of the material while troubleshooting.
  66643. */
  66644. debugMode: number;
  66645. /**
  66646. * Specify from where on screen the debug mode should start.
  66647. * The value goes from -1 (full screen) to 1 (not visible)
  66648. * It helps with side by side comparison against the final render
  66649. * This defaults to 0
  66650. */
  66651. debugLimit: number;
  66652. /**
  66653. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66654. * You can use the factor to better multiply the final value.
  66655. */
  66656. debugFactor: number;
  66657. /**
  66658. * Initialize the block and prepare the context for build
  66659. * @param state defines the state that will be used for the build
  66660. */
  66661. initialize(state: NodeMaterialBuildState): void;
  66662. /**
  66663. * Gets the current class name
  66664. * @returns the class name
  66665. */
  66666. getClassName(): string;
  66667. /**
  66668. * Gets the world position input component
  66669. */
  66670. get worldPosition(): NodeMaterialConnectionPoint;
  66671. /**
  66672. * Gets the world normal input component
  66673. */
  66674. get worldNormal(): NodeMaterialConnectionPoint;
  66675. /**
  66676. * Gets the perturbed normal input component
  66677. */
  66678. get perturbedNormal(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the camera position input component
  66681. */
  66682. get cameraPosition(): NodeMaterialConnectionPoint;
  66683. /**
  66684. * Gets the base color input component
  66685. */
  66686. get baseColor(): NodeMaterialConnectionPoint;
  66687. /**
  66688. * Gets the opacity texture input component
  66689. */
  66690. get opacityTexture(): NodeMaterialConnectionPoint;
  66691. /**
  66692. * Gets the ambient color input component
  66693. */
  66694. get ambientColor(): NodeMaterialConnectionPoint;
  66695. /**
  66696. * Gets the reflectivity object parameters
  66697. */
  66698. get reflectivity(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the ambient occlusion object parameters
  66701. */
  66702. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66703. /**
  66704. * Gets the reflection object parameters
  66705. */
  66706. get reflection(): NodeMaterialConnectionPoint;
  66707. /**
  66708. * Gets the sheen object parameters
  66709. */
  66710. get sheen(): NodeMaterialConnectionPoint;
  66711. /**
  66712. * Gets the clear coat object parameters
  66713. */
  66714. get clearcoat(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the sub surface object parameters
  66717. */
  66718. get subsurface(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the anisotropy object parameters
  66721. */
  66722. get anisotropy(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Gets the ambient output component
  66725. */
  66726. get ambient(): NodeMaterialConnectionPoint;
  66727. /**
  66728. * Gets the diffuse output component
  66729. */
  66730. get diffuse(): NodeMaterialConnectionPoint;
  66731. /**
  66732. * Gets the specular output component
  66733. */
  66734. get specular(): NodeMaterialConnectionPoint;
  66735. /**
  66736. * Gets the sheen output component
  66737. */
  66738. get sheenDir(): NodeMaterialConnectionPoint;
  66739. /**
  66740. * Gets the clear coat output component
  66741. */
  66742. get clearcoatDir(): NodeMaterialConnectionPoint;
  66743. /**
  66744. * Gets the indirect diffuse output component
  66745. */
  66746. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66747. /**
  66748. * Gets the indirect specular output component
  66749. */
  66750. get specularIndirect(): NodeMaterialConnectionPoint;
  66751. /**
  66752. * Gets the indirect sheen output component
  66753. */
  66754. get sheenIndirect(): NodeMaterialConnectionPoint;
  66755. /**
  66756. * Gets the indirect clear coat output component
  66757. */
  66758. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66759. /**
  66760. * Gets the refraction output component
  66761. */
  66762. get refraction(): NodeMaterialConnectionPoint;
  66763. /**
  66764. * Gets the global lighting output component
  66765. */
  66766. get lighting(): NodeMaterialConnectionPoint;
  66767. /**
  66768. * Gets the shadow output component
  66769. */
  66770. get shadow(): NodeMaterialConnectionPoint;
  66771. /**
  66772. * Gets the alpha output component
  66773. */
  66774. get alpha(): NodeMaterialConnectionPoint;
  66775. autoConfigure(material: NodeMaterial): void;
  66776. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66777. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66779. private _injectVertexCode;
  66780. /**
  66781. * Gets the code corresponding to the albedo/opacity module
  66782. * @returns the shader code
  66783. */
  66784. getAlbedoOpacityCode(): string;
  66785. protected _buildBlock(state: NodeMaterialBuildState): this;
  66786. protected _dumpPropertiesCode(): string;
  66787. serialize(): any;
  66788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66789. }
  66790. }
  66791. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66792. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66793. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66794. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66795. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66796. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66797. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66798. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66799. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66800. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66801. }
  66802. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66803. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66804. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66805. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66806. }
  66807. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66811. /**
  66812. * Block used to compute value of one parameter modulo another
  66813. */
  66814. export class ModBlock extends NodeMaterialBlock {
  66815. /**
  66816. * Creates a new ModBlock
  66817. * @param name defines the block name
  66818. */
  66819. constructor(name: string);
  66820. /**
  66821. * Gets the current class name
  66822. * @returns the class name
  66823. */
  66824. getClassName(): string;
  66825. /**
  66826. * Gets the left operand input component
  66827. */
  66828. get left(): NodeMaterialConnectionPoint;
  66829. /**
  66830. * Gets the right operand input component
  66831. */
  66832. get right(): NodeMaterialConnectionPoint;
  66833. /**
  66834. * Gets the output component
  66835. */
  66836. get output(): NodeMaterialConnectionPoint;
  66837. protected _buildBlock(state: NodeMaterialBuildState): this;
  66838. }
  66839. }
  66840. declare module "babylonjs/Materials/Node/Blocks/index" {
  66841. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  66842. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  66843. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  66844. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  66845. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  66846. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  66847. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  66848. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  66849. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  66850. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  66851. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  66852. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  66853. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  66854. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  66855. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  66856. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  66857. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  66858. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  66859. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  66860. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  66861. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  66862. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  66863. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  66864. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  66865. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  66866. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  66867. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  66868. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  66869. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  66870. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  66871. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  66872. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  66873. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  66874. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  66875. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  66876. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  66877. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  66878. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  66879. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  66880. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  66881. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  66882. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  66883. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  66884. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  66885. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  66886. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  66887. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  66888. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  66889. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  66890. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  66891. }
  66892. declare module "babylonjs/Materials/Node/Optimizers/index" {
  66893. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  66894. }
  66895. declare module "babylonjs/Materials/Node/index" {
  66896. export * from "babylonjs/Materials/Node/Enums/index";
  66897. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66898. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  66899. export * from "babylonjs/Materials/Node/nodeMaterial";
  66900. export * from "babylonjs/Materials/Node/Blocks/index";
  66901. export * from "babylonjs/Materials/Node/Optimizers/index";
  66902. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  66903. }
  66904. declare module "babylonjs/Materials/index" {
  66905. export * from "babylonjs/Materials/Background/index";
  66906. export * from "babylonjs/Materials/colorCurves";
  66907. export * from "babylonjs/Materials/iEffectFallbacks";
  66908. export * from "babylonjs/Materials/effectFallbacks";
  66909. export * from "babylonjs/Materials/effect";
  66910. export * from "babylonjs/Materials/fresnelParameters";
  66911. export * from "babylonjs/Materials/imageProcessingConfiguration";
  66912. export * from "babylonjs/Materials/material";
  66913. export * from "babylonjs/Materials/materialDefines";
  66914. export * from "babylonjs/Materials/materialHelper";
  66915. export * from "babylonjs/Materials/multiMaterial";
  66916. export * from "babylonjs/Materials/PBR/index";
  66917. export * from "babylonjs/Materials/pushMaterial";
  66918. export * from "babylonjs/Materials/shaderMaterial";
  66919. export * from "babylonjs/Materials/standardMaterial";
  66920. export * from "babylonjs/Materials/Textures/index";
  66921. export * from "babylonjs/Materials/uniformBuffer";
  66922. export * from "babylonjs/Materials/materialFlags";
  66923. export * from "babylonjs/Materials/Node/index";
  66924. export * from "babylonjs/Materials/effectRenderer";
  66925. export * from "babylonjs/Materials/shadowDepthWrapper";
  66926. }
  66927. declare module "babylonjs/Maths/index" {
  66928. export * from "babylonjs/Maths/math.scalar";
  66929. export * from "babylonjs/Maths/math";
  66930. export * from "babylonjs/Maths/sphericalPolynomial";
  66931. }
  66932. declare module "babylonjs/Misc/workerPool" {
  66933. import { IDisposable } from "babylonjs/scene";
  66934. /**
  66935. * Helper class to push actions to a pool of workers.
  66936. */
  66937. export class WorkerPool implements IDisposable {
  66938. private _workerInfos;
  66939. private _pendingActions;
  66940. /**
  66941. * Constructor
  66942. * @param workers Array of workers to use for actions
  66943. */
  66944. constructor(workers: Array<Worker>);
  66945. /**
  66946. * Terminates all workers and clears any pending actions.
  66947. */
  66948. dispose(): void;
  66949. /**
  66950. * Pushes an action to the worker pool. If all the workers are active, the action will be
  66951. * pended until a worker has completed its action.
  66952. * @param action The action to perform. Call onComplete when the action is complete.
  66953. */
  66954. push(action: (worker: Worker, onComplete: () => void) => void): void;
  66955. private _execute;
  66956. }
  66957. }
  66958. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  66959. import { IDisposable } from "babylonjs/scene";
  66960. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  66961. /**
  66962. * Configuration for Draco compression
  66963. */
  66964. export interface IDracoCompressionConfiguration {
  66965. /**
  66966. * Configuration for the decoder.
  66967. */
  66968. decoder: {
  66969. /**
  66970. * The url to the WebAssembly module.
  66971. */
  66972. wasmUrl?: string;
  66973. /**
  66974. * The url to the WebAssembly binary.
  66975. */
  66976. wasmBinaryUrl?: string;
  66977. /**
  66978. * The url to the fallback JavaScript module.
  66979. */
  66980. fallbackUrl?: string;
  66981. };
  66982. }
  66983. /**
  66984. * Draco compression (https://google.github.io/draco/)
  66985. *
  66986. * This class wraps the Draco module.
  66987. *
  66988. * **Encoder**
  66989. *
  66990. * The encoder is not currently implemented.
  66991. *
  66992. * **Decoder**
  66993. *
  66994. * 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.
  66995. *
  66996. * To update the configuration, use the following code:
  66997. * ```javascript
  66998. * DracoCompression.Configuration = {
  66999. * decoder: {
  67000. * wasmUrl: "<url to the WebAssembly library>",
  67001. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67002. * fallbackUrl: "<url to the fallback JavaScript library>",
  67003. * }
  67004. * };
  67005. * ```
  67006. *
  67007. * 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.
  67008. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67009. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67010. *
  67011. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67012. * ```javascript
  67013. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67014. * ```
  67015. *
  67016. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67017. */
  67018. export class DracoCompression implements IDisposable {
  67019. private _workerPoolPromise?;
  67020. private _decoderModulePromise?;
  67021. /**
  67022. * The configuration. Defaults to the following urls:
  67023. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67024. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67025. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67026. */
  67027. static Configuration: IDracoCompressionConfiguration;
  67028. /**
  67029. * Returns true if the decoder configuration is available.
  67030. */
  67031. static get DecoderAvailable(): boolean;
  67032. /**
  67033. * Default number of workers to create when creating the draco compression object.
  67034. */
  67035. static DefaultNumWorkers: number;
  67036. private static GetDefaultNumWorkers;
  67037. private static _Default;
  67038. /**
  67039. * Default instance for the draco compression object.
  67040. */
  67041. static get Default(): DracoCompression;
  67042. /**
  67043. * Constructor
  67044. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67045. */
  67046. constructor(numWorkers?: number);
  67047. /**
  67048. * Stop all async operations and release resources.
  67049. */
  67050. dispose(): void;
  67051. /**
  67052. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67053. * @returns a promise that resolves when ready
  67054. */
  67055. whenReadyAsync(): Promise<void>;
  67056. /**
  67057. * Decode Draco compressed mesh data to vertex data.
  67058. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67059. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67060. * @returns A promise that resolves with the decoded vertex data
  67061. */
  67062. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67063. [kind: string]: number;
  67064. }): Promise<VertexData>;
  67065. }
  67066. }
  67067. declare module "babylonjs/Meshes/Compression/index" {
  67068. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67069. }
  67070. declare module "babylonjs/Meshes/csg" {
  67071. import { Nullable } from "babylonjs/types";
  67072. import { Scene } from "babylonjs/scene";
  67073. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67074. import { Mesh } from "babylonjs/Meshes/mesh";
  67075. import { Material } from "babylonjs/Materials/material";
  67076. /**
  67077. * Class for building Constructive Solid Geometry
  67078. */
  67079. export class CSG {
  67080. private polygons;
  67081. /**
  67082. * The world matrix
  67083. */
  67084. matrix: Matrix;
  67085. /**
  67086. * Stores the position
  67087. */
  67088. position: Vector3;
  67089. /**
  67090. * Stores the rotation
  67091. */
  67092. rotation: Vector3;
  67093. /**
  67094. * Stores the rotation quaternion
  67095. */
  67096. rotationQuaternion: Nullable<Quaternion>;
  67097. /**
  67098. * Stores the scaling vector
  67099. */
  67100. scaling: Vector3;
  67101. /**
  67102. * Convert the Mesh to CSG
  67103. * @param mesh The Mesh to convert to CSG
  67104. * @returns A new CSG from the Mesh
  67105. */
  67106. static FromMesh(mesh: Mesh): CSG;
  67107. /**
  67108. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67109. * @param polygons Polygons used to construct a CSG solid
  67110. */
  67111. private static FromPolygons;
  67112. /**
  67113. * Clones, or makes a deep copy, of the CSG
  67114. * @returns A new CSG
  67115. */
  67116. clone(): CSG;
  67117. /**
  67118. * Unions this CSG with another CSG
  67119. * @param csg The CSG to union against this CSG
  67120. * @returns The unioned CSG
  67121. */
  67122. union(csg: CSG): CSG;
  67123. /**
  67124. * Unions this CSG with another CSG in place
  67125. * @param csg The CSG to union against this CSG
  67126. */
  67127. unionInPlace(csg: CSG): void;
  67128. /**
  67129. * Subtracts this CSG with another CSG
  67130. * @param csg The CSG to subtract against this CSG
  67131. * @returns A new CSG
  67132. */
  67133. subtract(csg: CSG): CSG;
  67134. /**
  67135. * Subtracts this CSG with another CSG in place
  67136. * @param csg The CSG to subtact against this CSG
  67137. */
  67138. subtractInPlace(csg: CSG): void;
  67139. /**
  67140. * Intersect this CSG with another CSG
  67141. * @param csg The CSG to intersect against this CSG
  67142. * @returns A new CSG
  67143. */
  67144. intersect(csg: CSG): CSG;
  67145. /**
  67146. * Intersects this CSG with another CSG in place
  67147. * @param csg The CSG to intersect against this CSG
  67148. */
  67149. intersectInPlace(csg: CSG): void;
  67150. /**
  67151. * Return a new CSG solid with solid and empty space switched. This solid is
  67152. * not modified.
  67153. * @returns A new CSG solid with solid and empty space switched
  67154. */
  67155. inverse(): CSG;
  67156. /**
  67157. * Inverses the CSG in place
  67158. */
  67159. inverseInPlace(): void;
  67160. /**
  67161. * This is used to keep meshes transformations so they can be restored
  67162. * when we build back a Babylon Mesh
  67163. * NB : All CSG operations are performed in world coordinates
  67164. * @param csg The CSG to copy the transform attributes from
  67165. * @returns This CSG
  67166. */
  67167. copyTransformAttributes(csg: CSG): CSG;
  67168. /**
  67169. * Build Raw mesh from CSG
  67170. * Coordinates here are in world space
  67171. * @param name The name of the mesh geometry
  67172. * @param scene The Scene
  67173. * @param keepSubMeshes Specifies if the submeshes should be kept
  67174. * @returns A new Mesh
  67175. */
  67176. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67177. /**
  67178. * Build Mesh from CSG taking material and transforms into account
  67179. * @param name The name of the Mesh
  67180. * @param material The material of the Mesh
  67181. * @param scene The Scene
  67182. * @param keepSubMeshes Specifies if submeshes should be kept
  67183. * @returns The new Mesh
  67184. */
  67185. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67186. }
  67187. }
  67188. declare module "babylonjs/Meshes/trailMesh" {
  67189. import { Mesh } from "babylonjs/Meshes/mesh";
  67190. import { Scene } from "babylonjs/scene";
  67191. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67192. /**
  67193. * Class used to create a trail following a mesh
  67194. */
  67195. export class TrailMesh extends Mesh {
  67196. private _generator;
  67197. private _autoStart;
  67198. private _running;
  67199. private _diameter;
  67200. private _length;
  67201. private _sectionPolygonPointsCount;
  67202. private _sectionVectors;
  67203. private _sectionNormalVectors;
  67204. private _beforeRenderObserver;
  67205. /**
  67206. * @constructor
  67207. * @param name The value used by scene.getMeshByName() to do a lookup.
  67208. * @param generator The mesh or transform node to generate a trail.
  67209. * @param scene The scene to add this mesh to.
  67210. * @param diameter Diameter of trailing mesh. Default is 1.
  67211. * @param length Length of trailing mesh. Default is 60.
  67212. * @param autoStart Automatically start trailing mesh. Default true.
  67213. */
  67214. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67215. /**
  67216. * "TrailMesh"
  67217. * @returns "TrailMesh"
  67218. */
  67219. getClassName(): string;
  67220. private _createMesh;
  67221. /**
  67222. * Start trailing mesh.
  67223. */
  67224. start(): void;
  67225. /**
  67226. * Stop trailing mesh.
  67227. */
  67228. stop(): void;
  67229. /**
  67230. * Update trailing mesh geometry.
  67231. */
  67232. update(): void;
  67233. /**
  67234. * Returns a new TrailMesh object.
  67235. * @param name is a string, the name given to the new mesh
  67236. * @param newGenerator use new generator object for cloned trail mesh
  67237. * @returns a new mesh
  67238. */
  67239. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67240. /**
  67241. * Serializes this trail mesh
  67242. * @param serializationObject object to write serialization to
  67243. */
  67244. serialize(serializationObject: any): void;
  67245. /**
  67246. * Parses a serialized trail mesh
  67247. * @param parsedMesh the serialized mesh
  67248. * @param scene the scene to create the trail mesh in
  67249. * @returns the created trail mesh
  67250. */
  67251. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67252. }
  67253. }
  67254. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67255. import { Nullable } from "babylonjs/types";
  67256. import { Scene } from "babylonjs/scene";
  67257. import { Vector4 } from "babylonjs/Maths/math.vector";
  67258. import { Color4 } from "babylonjs/Maths/math.color";
  67259. import { Mesh } from "babylonjs/Meshes/mesh";
  67260. /**
  67261. * Class containing static functions to help procedurally build meshes
  67262. */
  67263. export class TiledBoxBuilder {
  67264. /**
  67265. * Creates a box mesh
  67266. * 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)
  67267. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67271. * @param name defines the name of the mesh
  67272. * @param options defines the options used to create the mesh
  67273. * @param scene defines the hosting scene
  67274. * @returns the box mesh
  67275. */
  67276. static CreateTiledBox(name: string, options: {
  67277. pattern?: number;
  67278. width?: number;
  67279. height?: number;
  67280. depth?: number;
  67281. tileSize?: number;
  67282. tileWidth?: number;
  67283. tileHeight?: number;
  67284. alignHorizontal?: number;
  67285. alignVertical?: number;
  67286. faceUV?: Vector4[];
  67287. faceColors?: Color4[];
  67288. sideOrientation?: number;
  67289. updatable?: boolean;
  67290. }, scene?: Nullable<Scene>): Mesh;
  67291. }
  67292. }
  67293. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67294. import { Vector4 } from "babylonjs/Maths/math.vector";
  67295. import { Mesh } from "babylonjs/Meshes/mesh";
  67296. /**
  67297. * Class containing static functions to help procedurally build meshes
  67298. */
  67299. export class TorusKnotBuilder {
  67300. /**
  67301. * Creates a torus knot mesh
  67302. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67303. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67304. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67305. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67309. * @param name defines the name of the mesh
  67310. * @param options defines the options used to create the mesh
  67311. * @param scene defines the hosting scene
  67312. * @returns the torus knot mesh
  67313. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67314. */
  67315. static CreateTorusKnot(name: string, options: {
  67316. radius?: number;
  67317. tube?: number;
  67318. radialSegments?: number;
  67319. tubularSegments?: number;
  67320. p?: number;
  67321. q?: number;
  67322. updatable?: boolean;
  67323. sideOrientation?: number;
  67324. frontUVs?: Vector4;
  67325. backUVs?: Vector4;
  67326. }, scene: any): Mesh;
  67327. }
  67328. }
  67329. declare module "babylonjs/Meshes/polygonMesh" {
  67330. import { Scene } from "babylonjs/scene";
  67331. import { Vector2 } from "babylonjs/Maths/math.vector";
  67332. import { Mesh } from "babylonjs/Meshes/mesh";
  67333. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67334. import { Path2 } from "babylonjs/Maths/math.path";
  67335. /**
  67336. * Polygon
  67337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67338. */
  67339. export class Polygon {
  67340. /**
  67341. * Creates a rectangle
  67342. * @param xmin bottom X coord
  67343. * @param ymin bottom Y coord
  67344. * @param xmax top X coord
  67345. * @param ymax top Y coord
  67346. * @returns points that make the resulting rectation
  67347. */
  67348. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67349. /**
  67350. * Creates a circle
  67351. * @param radius radius of circle
  67352. * @param cx scale in x
  67353. * @param cy scale in y
  67354. * @param numberOfSides number of sides that make up the circle
  67355. * @returns points that make the resulting circle
  67356. */
  67357. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67358. /**
  67359. * Creates a polygon from input string
  67360. * @param input Input polygon data
  67361. * @returns the parsed points
  67362. */
  67363. static Parse(input: string): Vector2[];
  67364. /**
  67365. * Starts building a polygon from x and y coordinates
  67366. * @param x x coordinate
  67367. * @param y y coordinate
  67368. * @returns the started path2
  67369. */
  67370. static StartingAt(x: number, y: number): Path2;
  67371. }
  67372. /**
  67373. * Builds a polygon
  67374. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67375. */
  67376. export class PolygonMeshBuilder {
  67377. private _points;
  67378. private _outlinepoints;
  67379. private _holes;
  67380. private _name;
  67381. private _scene;
  67382. private _epoints;
  67383. private _eholes;
  67384. private _addToepoint;
  67385. /**
  67386. * Babylon reference to the earcut plugin.
  67387. */
  67388. bjsEarcut: any;
  67389. /**
  67390. * Creates a PolygonMeshBuilder
  67391. * @param name name of the builder
  67392. * @param contours Path of the polygon
  67393. * @param scene scene to add to when creating the mesh
  67394. * @param earcutInjection can be used to inject your own earcut reference
  67395. */
  67396. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67397. /**
  67398. * Adds a whole within the polygon
  67399. * @param hole Array of points defining the hole
  67400. * @returns this
  67401. */
  67402. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67403. /**
  67404. * Creates the polygon
  67405. * @param updatable If the mesh should be updatable
  67406. * @param depth The depth of the mesh created
  67407. * @returns the created mesh
  67408. */
  67409. build(updatable?: boolean, depth?: number): Mesh;
  67410. /**
  67411. * Creates the polygon
  67412. * @param depth The depth of the mesh created
  67413. * @returns the created VertexData
  67414. */
  67415. buildVertexData(depth?: number): VertexData;
  67416. /**
  67417. * Adds a side to the polygon
  67418. * @param positions points that make the polygon
  67419. * @param normals normals of the polygon
  67420. * @param uvs uvs of the polygon
  67421. * @param indices indices of the polygon
  67422. * @param bounds bounds of the polygon
  67423. * @param points points of the polygon
  67424. * @param depth depth of the polygon
  67425. * @param flip flip of the polygon
  67426. */
  67427. private addSide;
  67428. }
  67429. }
  67430. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67431. import { Scene } from "babylonjs/scene";
  67432. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67433. import { Color4 } from "babylonjs/Maths/math.color";
  67434. import { Mesh } from "babylonjs/Meshes/mesh";
  67435. import { Nullable } from "babylonjs/types";
  67436. /**
  67437. * Class containing static functions to help procedurally build meshes
  67438. */
  67439. export class PolygonBuilder {
  67440. /**
  67441. * Creates a polygon mesh
  67442. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67443. * * 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
  67444. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67447. * * Remember you can only change the shape positions, not their number when updating a polygon
  67448. * @param name defines the name of the mesh
  67449. * @param options defines the options used to create the mesh
  67450. * @param scene defines the hosting scene
  67451. * @param earcutInjection can be used to inject your own earcut reference
  67452. * @returns the polygon mesh
  67453. */
  67454. static CreatePolygon(name: string, options: {
  67455. shape: Vector3[];
  67456. holes?: Vector3[][];
  67457. depth?: number;
  67458. faceUV?: Vector4[];
  67459. faceColors?: Color4[];
  67460. updatable?: boolean;
  67461. sideOrientation?: number;
  67462. frontUVs?: Vector4;
  67463. backUVs?: Vector4;
  67464. wrap?: boolean;
  67465. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67466. /**
  67467. * Creates an extruded polygon mesh, with depth in the Y direction.
  67468. * * 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)
  67469. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67470. * @param name defines the name of the mesh
  67471. * @param options defines the options used to create the mesh
  67472. * @param scene defines the hosting scene
  67473. * @param earcutInjection can be used to inject your own earcut reference
  67474. * @returns the polygon mesh
  67475. */
  67476. static ExtrudePolygon(name: string, options: {
  67477. shape: Vector3[];
  67478. holes?: Vector3[][];
  67479. depth?: number;
  67480. faceUV?: Vector4[];
  67481. faceColors?: Color4[];
  67482. updatable?: boolean;
  67483. sideOrientation?: number;
  67484. frontUVs?: Vector4;
  67485. backUVs?: Vector4;
  67486. wrap?: boolean;
  67487. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67488. }
  67489. }
  67490. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67491. import { Scene } from "babylonjs/scene";
  67492. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67493. import { Mesh } from "babylonjs/Meshes/mesh";
  67494. import { Nullable } from "babylonjs/types";
  67495. /**
  67496. * Class containing static functions to help procedurally build meshes
  67497. */
  67498. export class LatheBuilder {
  67499. /**
  67500. * Creates lathe mesh.
  67501. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67502. * * 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
  67503. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67504. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67505. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67506. * * 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
  67507. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67508. * * 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
  67509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67513. * @param name defines the name of the mesh
  67514. * @param options defines the options used to create the mesh
  67515. * @param scene defines the hosting scene
  67516. * @returns the lathe mesh
  67517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67518. */
  67519. static CreateLathe(name: string, options: {
  67520. shape: Vector3[];
  67521. radius?: number;
  67522. tessellation?: number;
  67523. clip?: number;
  67524. arc?: number;
  67525. closed?: boolean;
  67526. updatable?: boolean;
  67527. sideOrientation?: number;
  67528. frontUVs?: Vector4;
  67529. backUVs?: Vector4;
  67530. cap?: number;
  67531. invertUV?: boolean;
  67532. }, scene?: Nullable<Scene>): Mesh;
  67533. }
  67534. }
  67535. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67536. import { Nullable } from "babylonjs/types";
  67537. import { Scene } from "babylonjs/scene";
  67538. import { Vector4 } from "babylonjs/Maths/math.vector";
  67539. import { Mesh } from "babylonjs/Meshes/mesh";
  67540. /**
  67541. * Class containing static functions to help procedurally build meshes
  67542. */
  67543. export class TiledPlaneBuilder {
  67544. /**
  67545. * Creates a tiled plane mesh
  67546. * * The parameter `pattern` will, depending on value, do nothing or
  67547. * * * flip (reflect about central vertical) alternate tiles across and up
  67548. * * * flip every tile on alternate rows
  67549. * * * rotate (180 degs) alternate tiles across and up
  67550. * * * rotate every tile on alternate rows
  67551. * * * flip and rotate alternate tiles across and up
  67552. * * * flip and rotate every tile on alternate rows
  67553. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67554. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67557. * * 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)
  67558. * * 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)
  67559. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67560. * @param name defines the name of the mesh
  67561. * @param options defines the options used to create the mesh
  67562. * @param scene defines the hosting scene
  67563. * @returns the box mesh
  67564. */
  67565. static CreateTiledPlane(name: string, options: {
  67566. pattern?: number;
  67567. tileSize?: number;
  67568. tileWidth?: number;
  67569. tileHeight?: number;
  67570. size?: number;
  67571. width?: number;
  67572. height?: number;
  67573. alignHorizontal?: number;
  67574. alignVertical?: number;
  67575. sideOrientation?: number;
  67576. frontUVs?: Vector4;
  67577. backUVs?: Vector4;
  67578. updatable?: boolean;
  67579. }, scene?: Nullable<Scene>): Mesh;
  67580. }
  67581. }
  67582. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67583. import { Nullable } from "babylonjs/types";
  67584. import { Scene } from "babylonjs/scene";
  67585. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67586. import { Mesh } from "babylonjs/Meshes/mesh";
  67587. /**
  67588. * Class containing static functions to help procedurally build meshes
  67589. */
  67590. export class TubeBuilder {
  67591. /**
  67592. * Creates a tube mesh.
  67593. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67594. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67595. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67596. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67597. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67598. * * 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)
  67599. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67600. * * 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
  67601. * * 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
  67602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67606. * @param name defines the name of the mesh
  67607. * @param options defines the options used to create the mesh
  67608. * @param scene defines the hosting scene
  67609. * @returns the tube mesh
  67610. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67611. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67612. */
  67613. static CreateTube(name: string, options: {
  67614. path: Vector3[];
  67615. radius?: number;
  67616. tessellation?: number;
  67617. radiusFunction?: {
  67618. (i: number, distance: number): number;
  67619. };
  67620. cap?: number;
  67621. arc?: number;
  67622. updatable?: boolean;
  67623. sideOrientation?: number;
  67624. frontUVs?: Vector4;
  67625. backUVs?: Vector4;
  67626. instance?: Mesh;
  67627. invertUV?: boolean;
  67628. }, scene?: Nullable<Scene>): Mesh;
  67629. }
  67630. }
  67631. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67632. import { Scene } from "babylonjs/scene";
  67633. import { Vector4 } from "babylonjs/Maths/math.vector";
  67634. import { Mesh } from "babylonjs/Meshes/mesh";
  67635. import { Nullable } from "babylonjs/types";
  67636. /**
  67637. * Class containing static functions to help procedurally build meshes
  67638. */
  67639. export class IcoSphereBuilder {
  67640. /**
  67641. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67642. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67643. * * 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`)
  67644. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67645. * * 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
  67646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67649. * @param name defines the name of the mesh
  67650. * @param options defines the options used to create the mesh
  67651. * @param scene defines the hosting scene
  67652. * @returns the icosahedron mesh
  67653. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67654. */
  67655. static CreateIcoSphere(name: string, options: {
  67656. radius?: number;
  67657. radiusX?: number;
  67658. radiusY?: number;
  67659. radiusZ?: number;
  67660. flat?: boolean;
  67661. subdivisions?: number;
  67662. sideOrientation?: number;
  67663. frontUVs?: Vector4;
  67664. backUVs?: Vector4;
  67665. updatable?: boolean;
  67666. }, scene?: Nullable<Scene>): Mesh;
  67667. }
  67668. }
  67669. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67670. import { Vector3 } from "babylonjs/Maths/math.vector";
  67671. import { Mesh } from "babylonjs/Meshes/mesh";
  67672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67673. /**
  67674. * Class containing static functions to help procedurally build meshes
  67675. */
  67676. export class DecalBuilder {
  67677. /**
  67678. * Creates a decal mesh.
  67679. * 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
  67680. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67681. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67682. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67683. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67684. * @param name defines the name of the mesh
  67685. * @param sourceMesh defines the mesh where the decal must be applied
  67686. * @param options defines the options used to create the mesh
  67687. * @param scene defines the hosting scene
  67688. * @returns the decal mesh
  67689. * @see https://doc.babylonjs.com/how_to/decals
  67690. */
  67691. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67692. position?: Vector3;
  67693. normal?: Vector3;
  67694. size?: Vector3;
  67695. angle?: number;
  67696. }): Mesh;
  67697. }
  67698. }
  67699. declare module "babylonjs/Meshes/meshBuilder" {
  67700. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67701. import { Nullable } from "babylonjs/types";
  67702. import { Scene } from "babylonjs/scene";
  67703. import { Mesh } from "babylonjs/Meshes/mesh";
  67704. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67705. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67707. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67708. import { Plane } from "babylonjs/Maths/math.plane";
  67709. /**
  67710. * Class containing static functions to help procedurally build meshes
  67711. */
  67712. export class MeshBuilder {
  67713. /**
  67714. * Creates a box mesh
  67715. * * The parameter `size` sets the size (float) of each box side (default 1)
  67716. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67717. * * 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)
  67718. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67722. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67723. * @param name defines the name of the mesh
  67724. * @param options defines the options used to create the mesh
  67725. * @param scene defines the hosting scene
  67726. * @returns the box mesh
  67727. */
  67728. static CreateBox(name: string, options: {
  67729. size?: number;
  67730. width?: number;
  67731. height?: number;
  67732. depth?: number;
  67733. faceUV?: Vector4[];
  67734. faceColors?: Color4[];
  67735. sideOrientation?: number;
  67736. frontUVs?: Vector4;
  67737. backUVs?: Vector4;
  67738. wrap?: boolean;
  67739. topBaseAt?: number;
  67740. bottomBaseAt?: number;
  67741. updatable?: boolean;
  67742. }, scene?: Nullable<Scene>): Mesh;
  67743. /**
  67744. * Creates a tiled box mesh
  67745. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67747. * @param name defines the name of the mesh
  67748. * @param options defines the options used to create the mesh
  67749. * @param scene defines the hosting scene
  67750. * @returns the tiled box mesh
  67751. */
  67752. static CreateTiledBox(name: string, options: {
  67753. pattern?: number;
  67754. size?: number;
  67755. width?: number;
  67756. height?: number;
  67757. depth: number;
  67758. tileSize?: number;
  67759. tileWidth?: number;
  67760. tileHeight?: number;
  67761. faceUV?: Vector4[];
  67762. faceColors?: Color4[];
  67763. alignHorizontal?: number;
  67764. alignVertical?: number;
  67765. sideOrientation?: number;
  67766. updatable?: boolean;
  67767. }, scene?: Nullable<Scene>): Mesh;
  67768. /**
  67769. * Creates a sphere mesh
  67770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67771. * * 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`)
  67772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67773. * * 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
  67774. * * 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)
  67775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67778. * @param name defines the name of the mesh
  67779. * @param options defines the options used to create the mesh
  67780. * @param scene defines the hosting scene
  67781. * @returns the sphere mesh
  67782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67783. */
  67784. static CreateSphere(name: string, options: {
  67785. segments?: number;
  67786. diameter?: number;
  67787. diameterX?: number;
  67788. diameterY?: number;
  67789. diameterZ?: number;
  67790. arc?: number;
  67791. slice?: number;
  67792. sideOrientation?: number;
  67793. frontUVs?: Vector4;
  67794. backUVs?: Vector4;
  67795. updatable?: boolean;
  67796. }, scene?: Nullable<Scene>): Mesh;
  67797. /**
  67798. * Creates a plane polygonal mesh. By default, this is a disc
  67799. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67800. * * 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
  67801. * * 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
  67802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67805. * @param name defines the name of the mesh
  67806. * @param options defines the options used to create the mesh
  67807. * @param scene defines the hosting scene
  67808. * @returns the plane polygonal mesh
  67809. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67810. */
  67811. static CreateDisc(name: string, options: {
  67812. radius?: number;
  67813. tessellation?: number;
  67814. arc?: number;
  67815. updatable?: boolean;
  67816. sideOrientation?: number;
  67817. frontUVs?: Vector4;
  67818. backUVs?: Vector4;
  67819. }, scene?: Nullable<Scene>): Mesh;
  67820. /**
  67821. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67822. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67823. * * 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`)
  67824. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67825. * * 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
  67826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67829. * @param name defines the name of the mesh
  67830. * @param options defines the options used to create the mesh
  67831. * @param scene defines the hosting scene
  67832. * @returns the icosahedron mesh
  67833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67834. */
  67835. static CreateIcoSphere(name: string, options: {
  67836. radius?: number;
  67837. radiusX?: number;
  67838. radiusY?: number;
  67839. radiusZ?: number;
  67840. flat?: boolean;
  67841. subdivisions?: number;
  67842. sideOrientation?: number;
  67843. frontUVs?: Vector4;
  67844. backUVs?: Vector4;
  67845. updatable?: boolean;
  67846. }, scene?: Nullable<Scene>): Mesh;
  67847. /**
  67848. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67849. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67850. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67851. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67852. * * 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
  67853. * * 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
  67854. * * 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
  67855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67858. * * 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
  67859. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67860. * * 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
  67861. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67863. * @param name defines the name of the mesh
  67864. * @param options defines the options used to create the mesh
  67865. * @param scene defines the hosting scene
  67866. * @returns the ribbon mesh
  67867. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67869. */
  67870. static CreateRibbon(name: string, options: {
  67871. pathArray: Vector3[][];
  67872. closeArray?: boolean;
  67873. closePath?: boolean;
  67874. offset?: number;
  67875. updatable?: boolean;
  67876. sideOrientation?: number;
  67877. frontUVs?: Vector4;
  67878. backUVs?: Vector4;
  67879. instance?: Mesh;
  67880. invertUV?: boolean;
  67881. uvs?: Vector2[];
  67882. colors?: Color4[];
  67883. }, scene?: Nullable<Scene>): Mesh;
  67884. /**
  67885. * Creates a cylinder or a cone mesh
  67886. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67887. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67888. * * 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.
  67889. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67890. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67891. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67892. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67893. * * 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).
  67894. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67895. * * 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).
  67896. * * 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
  67897. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67898. * * 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
  67899. * * 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.
  67900. * * If `enclose` is false, a ring surface is one element.
  67901. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67902. * * 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
  67903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67906. * @param name defines the name of the mesh
  67907. * @param options defines the options used to create the mesh
  67908. * @param scene defines the hosting scene
  67909. * @returns the cylinder mesh
  67910. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67911. */
  67912. static CreateCylinder(name: string, options: {
  67913. height?: number;
  67914. diameterTop?: number;
  67915. diameterBottom?: number;
  67916. diameter?: number;
  67917. tessellation?: number;
  67918. subdivisions?: number;
  67919. arc?: number;
  67920. faceColors?: Color4[];
  67921. faceUV?: Vector4[];
  67922. updatable?: boolean;
  67923. hasRings?: boolean;
  67924. enclose?: boolean;
  67925. cap?: number;
  67926. sideOrientation?: number;
  67927. frontUVs?: Vector4;
  67928. backUVs?: Vector4;
  67929. }, scene?: Nullable<Scene>): Mesh;
  67930. /**
  67931. * Creates a torus mesh
  67932. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67933. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67934. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67938. * @param name defines the name of the mesh
  67939. * @param options defines the options used to create the mesh
  67940. * @param scene defines the hosting scene
  67941. * @returns the torus mesh
  67942. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67943. */
  67944. static CreateTorus(name: string, options: {
  67945. diameter?: number;
  67946. thickness?: number;
  67947. tessellation?: number;
  67948. updatable?: boolean;
  67949. sideOrientation?: number;
  67950. frontUVs?: Vector4;
  67951. backUVs?: Vector4;
  67952. }, scene?: Nullable<Scene>): Mesh;
  67953. /**
  67954. * Creates a torus knot mesh
  67955. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67956. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67957. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67958. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67962. * @param name defines the name of the mesh
  67963. * @param options defines the options used to create the mesh
  67964. * @param scene defines the hosting scene
  67965. * @returns the torus knot mesh
  67966. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67967. */
  67968. static CreateTorusKnot(name: string, options: {
  67969. radius?: number;
  67970. tube?: number;
  67971. radialSegments?: number;
  67972. tubularSegments?: number;
  67973. p?: number;
  67974. q?: number;
  67975. updatable?: boolean;
  67976. sideOrientation?: number;
  67977. frontUVs?: Vector4;
  67978. backUVs?: Vector4;
  67979. }, scene?: Nullable<Scene>): Mesh;
  67980. /**
  67981. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67982. * * 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
  67983. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67984. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67985. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67986. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67987. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67988. * * 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
  67989. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67992. * @param name defines the name of the new line system
  67993. * @param options defines the options used to create the line system
  67994. * @param scene defines the hosting scene
  67995. * @returns a new line system mesh
  67996. */
  67997. static CreateLineSystem(name: string, options: {
  67998. lines: Vector3[][];
  67999. updatable?: boolean;
  68000. instance?: Nullable<LinesMesh>;
  68001. colors?: Nullable<Color4[][]>;
  68002. useVertexAlpha?: boolean;
  68003. }, scene: Nullable<Scene>): LinesMesh;
  68004. /**
  68005. * Creates a line mesh
  68006. * 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
  68007. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68008. * * The parameter `points` is an array successive Vector3
  68009. * * 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
  68010. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68011. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68012. * * When updating an instance, remember that only point positions can change, not the number of points
  68013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68015. * @param name defines the name of the new line system
  68016. * @param options defines the options used to create the line system
  68017. * @param scene defines the hosting scene
  68018. * @returns a new line mesh
  68019. */
  68020. static CreateLines(name: string, options: {
  68021. points: Vector3[];
  68022. updatable?: boolean;
  68023. instance?: Nullable<LinesMesh>;
  68024. colors?: Color4[];
  68025. useVertexAlpha?: boolean;
  68026. }, scene?: Nullable<Scene>): LinesMesh;
  68027. /**
  68028. * Creates a dashed line mesh
  68029. * * 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
  68030. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68031. * * The parameter `points` is an array successive Vector3
  68032. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68033. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68034. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68035. * * 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
  68036. * * When updating an instance, remember that only point positions can change, not the number of points
  68037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68038. * @param name defines the name of the mesh
  68039. * @param options defines the options used to create the mesh
  68040. * @param scene defines the hosting scene
  68041. * @returns the dashed line mesh
  68042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68043. */
  68044. static CreateDashedLines(name: string, options: {
  68045. points: Vector3[];
  68046. dashSize?: number;
  68047. gapSize?: number;
  68048. dashNb?: number;
  68049. updatable?: boolean;
  68050. instance?: LinesMesh;
  68051. }, scene?: Nullable<Scene>): LinesMesh;
  68052. /**
  68053. * 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.
  68054. * * 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.
  68055. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68056. * * 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.
  68057. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68058. * * 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
  68059. * * 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
  68060. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68065. * @param name defines the name of the mesh
  68066. * @param options defines the options used to create the mesh
  68067. * @param scene defines the hosting scene
  68068. * @returns the extruded shape mesh
  68069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68071. */
  68072. static ExtrudeShape(name: string, options: {
  68073. shape: Vector3[];
  68074. path: Vector3[];
  68075. scale?: number;
  68076. rotation?: number;
  68077. cap?: number;
  68078. updatable?: boolean;
  68079. sideOrientation?: number;
  68080. frontUVs?: Vector4;
  68081. backUVs?: Vector4;
  68082. instance?: Mesh;
  68083. invertUV?: boolean;
  68084. }, scene?: Nullable<Scene>): Mesh;
  68085. /**
  68086. * Creates an custom extruded shape mesh.
  68087. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68088. * * 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.
  68089. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68090. * * 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
  68091. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68092. * * 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
  68093. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68094. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68095. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68096. * * 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
  68097. * * 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
  68098. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68103. * @param name defines the name of the mesh
  68104. * @param options defines the options used to create the mesh
  68105. * @param scene defines the hosting scene
  68106. * @returns the custom extruded shape mesh
  68107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68108. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68110. */
  68111. static ExtrudeShapeCustom(name: string, options: {
  68112. shape: Vector3[];
  68113. path: Vector3[];
  68114. scaleFunction?: any;
  68115. rotationFunction?: any;
  68116. ribbonCloseArray?: boolean;
  68117. ribbonClosePath?: boolean;
  68118. cap?: number;
  68119. updatable?: boolean;
  68120. sideOrientation?: number;
  68121. frontUVs?: Vector4;
  68122. backUVs?: Vector4;
  68123. instance?: Mesh;
  68124. invertUV?: boolean;
  68125. }, scene?: Nullable<Scene>): Mesh;
  68126. /**
  68127. * Creates lathe mesh.
  68128. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68129. * * 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
  68130. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68131. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68132. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68133. * * 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
  68134. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68135. * * 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
  68136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68137. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68140. * @param name defines the name of the mesh
  68141. * @param options defines the options used to create the mesh
  68142. * @param scene defines the hosting scene
  68143. * @returns the lathe mesh
  68144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68145. */
  68146. static CreateLathe(name: string, options: {
  68147. shape: Vector3[];
  68148. radius?: number;
  68149. tessellation?: number;
  68150. clip?: number;
  68151. arc?: number;
  68152. closed?: boolean;
  68153. updatable?: boolean;
  68154. sideOrientation?: number;
  68155. frontUVs?: Vector4;
  68156. backUVs?: Vector4;
  68157. cap?: number;
  68158. invertUV?: boolean;
  68159. }, scene?: Nullable<Scene>): Mesh;
  68160. /**
  68161. * Creates a tiled plane mesh
  68162. * * You can set a limited pattern arrangement with the tiles
  68163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68166. * @param name defines the name of the mesh
  68167. * @param options defines the options used to create the mesh
  68168. * @param scene defines the hosting scene
  68169. * @returns the plane mesh
  68170. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68171. */
  68172. static CreateTiledPlane(name: string, options: {
  68173. pattern?: number;
  68174. tileSize?: number;
  68175. tileWidth?: number;
  68176. tileHeight?: number;
  68177. size?: number;
  68178. width?: number;
  68179. height?: number;
  68180. alignHorizontal?: number;
  68181. alignVertical?: number;
  68182. sideOrientation?: number;
  68183. frontUVs?: Vector4;
  68184. backUVs?: Vector4;
  68185. updatable?: boolean;
  68186. }, scene?: Nullable<Scene>): Mesh;
  68187. /**
  68188. * Creates a plane mesh
  68189. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68190. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68191. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68195. * @param name defines the name of the mesh
  68196. * @param options defines the options used to create the mesh
  68197. * @param scene defines the hosting scene
  68198. * @returns the plane mesh
  68199. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68200. */
  68201. static CreatePlane(name: string, options: {
  68202. size?: number;
  68203. width?: number;
  68204. height?: number;
  68205. sideOrientation?: number;
  68206. frontUVs?: Vector4;
  68207. backUVs?: Vector4;
  68208. updatable?: boolean;
  68209. sourcePlane?: Plane;
  68210. }, scene?: Nullable<Scene>): Mesh;
  68211. /**
  68212. * Creates a ground mesh
  68213. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68214. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68216. * @param name defines the name of the mesh
  68217. * @param options defines the options used to create the mesh
  68218. * @param scene defines the hosting scene
  68219. * @returns the ground mesh
  68220. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68221. */
  68222. static CreateGround(name: string, options: {
  68223. width?: number;
  68224. height?: number;
  68225. subdivisions?: number;
  68226. subdivisionsX?: number;
  68227. subdivisionsY?: number;
  68228. updatable?: boolean;
  68229. }, scene?: Nullable<Scene>): Mesh;
  68230. /**
  68231. * Creates a tiled ground mesh
  68232. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68233. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68234. * * 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
  68235. * * 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
  68236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68237. * @param name defines the name of the mesh
  68238. * @param options defines the options used to create the mesh
  68239. * @param scene defines the hosting scene
  68240. * @returns the tiled ground mesh
  68241. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68242. */
  68243. static CreateTiledGround(name: string, options: {
  68244. xmin: number;
  68245. zmin: number;
  68246. xmax: number;
  68247. zmax: number;
  68248. subdivisions?: {
  68249. w: number;
  68250. h: number;
  68251. };
  68252. precision?: {
  68253. w: number;
  68254. h: number;
  68255. };
  68256. updatable?: boolean;
  68257. }, scene?: Nullable<Scene>): Mesh;
  68258. /**
  68259. * Creates a ground mesh from a height map
  68260. * * The parameter `url` sets the URL of the height map image resource.
  68261. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68262. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68263. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68264. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68265. * * 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.
  68266. * * 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).
  68267. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68269. * @param name defines the name of the mesh
  68270. * @param url defines the url to the height map
  68271. * @param options defines the options used to create the mesh
  68272. * @param scene defines the hosting scene
  68273. * @returns the ground mesh
  68274. * @see https://doc.babylonjs.com/babylon101/height_map
  68275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68276. */
  68277. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68278. width?: number;
  68279. height?: number;
  68280. subdivisions?: number;
  68281. minHeight?: number;
  68282. maxHeight?: number;
  68283. colorFilter?: Color3;
  68284. alphaFilter?: number;
  68285. updatable?: boolean;
  68286. onReady?: (mesh: GroundMesh) => void;
  68287. }, scene?: Nullable<Scene>): GroundMesh;
  68288. /**
  68289. * Creates a polygon mesh
  68290. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68291. * * 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
  68292. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68295. * * Remember you can only change the shape positions, not their number when updating a polygon
  68296. * @param name defines the name of the mesh
  68297. * @param options defines the options used to create the mesh
  68298. * @param scene defines the hosting scene
  68299. * @param earcutInjection can be used to inject your own earcut reference
  68300. * @returns the polygon mesh
  68301. */
  68302. static CreatePolygon(name: string, options: {
  68303. shape: Vector3[];
  68304. holes?: Vector3[][];
  68305. depth?: number;
  68306. faceUV?: Vector4[];
  68307. faceColors?: Color4[];
  68308. updatable?: boolean;
  68309. sideOrientation?: number;
  68310. frontUVs?: Vector4;
  68311. backUVs?: Vector4;
  68312. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68313. /**
  68314. * Creates an extruded polygon mesh, with depth in the Y direction.
  68315. * * 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)
  68316. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68317. * @param name defines the name of the mesh
  68318. * @param options defines the options used to create the mesh
  68319. * @param scene defines the hosting scene
  68320. * @param earcutInjection can be used to inject your own earcut reference
  68321. * @returns the polygon mesh
  68322. */
  68323. static ExtrudePolygon(name: string, options: {
  68324. shape: Vector3[];
  68325. holes?: Vector3[][];
  68326. depth?: number;
  68327. faceUV?: Vector4[];
  68328. faceColors?: Color4[];
  68329. updatable?: boolean;
  68330. sideOrientation?: number;
  68331. frontUVs?: Vector4;
  68332. backUVs?: Vector4;
  68333. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68334. /**
  68335. * Creates a tube mesh.
  68336. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68337. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68338. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68339. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68340. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68341. * * 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)
  68342. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68343. * * 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
  68344. * * 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
  68345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68349. * @param name defines the name of the mesh
  68350. * @param options defines the options used to create the mesh
  68351. * @param scene defines the hosting scene
  68352. * @returns the tube mesh
  68353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68354. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68355. */
  68356. static CreateTube(name: string, options: {
  68357. path: Vector3[];
  68358. radius?: number;
  68359. tessellation?: number;
  68360. radiusFunction?: {
  68361. (i: number, distance: number): number;
  68362. };
  68363. cap?: number;
  68364. arc?: number;
  68365. updatable?: boolean;
  68366. sideOrientation?: number;
  68367. frontUVs?: Vector4;
  68368. backUVs?: Vector4;
  68369. instance?: Mesh;
  68370. invertUV?: boolean;
  68371. }, scene?: Nullable<Scene>): Mesh;
  68372. /**
  68373. * Creates a polyhedron mesh
  68374. * * 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
  68375. * * The parameter `size` (positive float, default 1) sets the polygon size
  68376. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68377. * * 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`
  68378. * * 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
  68379. * * 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)`)
  68380. * * 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
  68381. * * 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
  68382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68385. * @param name defines the name of the mesh
  68386. * @param options defines the options used to create the mesh
  68387. * @param scene defines the hosting scene
  68388. * @returns the polyhedron mesh
  68389. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68390. */
  68391. static CreatePolyhedron(name: string, options: {
  68392. type?: number;
  68393. size?: number;
  68394. sizeX?: number;
  68395. sizeY?: number;
  68396. sizeZ?: number;
  68397. custom?: any;
  68398. faceUV?: Vector4[];
  68399. faceColors?: Color4[];
  68400. flat?: boolean;
  68401. updatable?: boolean;
  68402. sideOrientation?: number;
  68403. frontUVs?: Vector4;
  68404. backUVs?: Vector4;
  68405. }, scene?: Nullable<Scene>): Mesh;
  68406. /**
  68407. * Creates a decal mesh.
  68408. * 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
  68409. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68410. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68411. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68412. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68413. * @param name defines the name of the mesh
  68414. * @param sourceMesh defines the mesh where the decal must be applied
  68415. * @param options defines the options used to create the mesh
  68416. * @param scene defines the hosting scene
  68417. * @returns the decal mesh
  68418. * @see https://doc.babylonjs.com/how_to/decals
  68419. */
  68420. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68421. position?: Vector3;
  68422. normal?: Vector3;
  68423. size?: Vector3;
  68424. angle?: number;
  68425. }): Mesh;
  68426. }
  68427. }
  68428. declare module "babylonjs/Meshes/meshSimplification" {
  68429. import { Mesh } from "babylonjs/Meshes/mesh";
  68430. /**
  68431. * A simplifier interface for future simplification implementations
  68432. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68433. */
  68434. export interface ISimplifier {
  68435. /**
  68436. * Simplification of a given mesh according to the given settings.
  68437. * Since this requires computation, it is assumed that the function runs async.
  68438. * @param settings The settings of the simplification, including quality and distance
  68439. * @param successCallback A callback that will be called after the mesh was simplified.
  68440. * @param errorCallback in case of an error, this callback will be called. optional.
  68441. */
  68442. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68443. }
  68444. /**
  68445. * Expected simplification settings.
  68446. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68447. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68448. */
  68449. export interface ISimplificationSettings {
  68450. /**
  68451. * Gets or sets the expected quality
  68452. */
  68453. quality: number;
  68454. /**
  68455. * Gets or sets the distance when this optimized version should be used
  68456. */
  68457. distance: number;
  68458. /**
  68459. * Gets an already optimized mesh
  68460. */
  68461. optimizeMesh?: boolean;
  68462. }
  68463. /**
  68464. * Class used to specify simplification options
  68465. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68466. */
  68467. export class SimplificationSettings implements ISimplificationSettings {
  68468. /** expected quality */
  68469. quality: number;
  68470. /** distance when this optimized version should be used */
  68471. distance: number;
  68472. /** already optimized mesh */
  68473. optimizeMesh?: boolean | undefined;
  68474. /**
  68475. * Creates a SimplificationSettings
  68476. * @param quality expected quality
  68477. * @param distance distance when this optimized version should be used
  68478. * @param optimizeMesh already optimized mesh
  68479. */
  68480. constructor(
  68481. /** expected quality */
  68482. quality: number,
  68483. /** distance when this optimized version should be used */
  68484. distance: number,
  68485. /** already optimized mesh */
  68486. optimizeMesh?: boolean | undefined);
  68487. }
  68488. /**
  68489. * Interface used to define a simplification task
  68490. */
  68491. export interface ISimplificationTask {
  68492. /**
  68493. * Array of settings
  68494. */
  68495. settings: Array<ISimplificationSettings>;
  68496. /**
  68497. * Simplification type
  68498. */
  68499. simplificationType: SimplificationType;
  68500. /**
  68501. * Mesh to simplify
  68502. */
  68503. mesh: Mesh;
  68504. /**
  68505. * Callback called on success
  68506. */
  68507. successCallback?: () => void;
  68508. /**
  68509. * Defines if parallel processing can be used
  68510. */
  68511. parallelProcessing: boolean;
  68512. }
  68513. /**
  68514. * Queue used to order the simplification tasks
  68515. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68516. */
  68517. export class SimplificationQueue {
  68518. private _simplificationArray;
  68519. /**
  68520. * Gets a boolean indicating that the process is still running
  68521. */
  68522. running: boolean;
  68523. /**
  68524. * Creates a new queue
  68525. */
  68526. constructor();
  68527. /**
  68528. * Adds a new simplification task
  68529. * @param task defines a task to add
  68530. */
  68531. addTask(task: ISimplificationTask): void;
  68532. /**
  68533. * Execute next task
  68534. */
  68535. executeNext(): void;
  68536. /**
  68537. * Execute a simplification task
  68538. * @param task defines the task to run
  68539. */
  68540. runSimplification(task: ISimplificationTask): void;
  68541. private getSimplifier;
  68542. }
  68543. /**
  68544. * The implemented types of simplification
  68545. * At the moment only Quadratic Error Decimation is implemented
  68546. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68547. */
  68548. export enum SimplificationType {
  68549. /** Quadratic error decimation */
  68550. QUADRATIC = 0
  68551. }
  68552. /**
  68553. * An implementation of the Quadratic Error simplification algorithm.
  68554. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68555. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68556. * @author RaananW
  68557. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68558. */
  68559. export class QuadraticErrorSimplification implements ISimplifier {
  68560. private _mesh;
  68561. private triangles;
  68562. private vertices;
  68563. private references;
  68564. private _reconstructedMesh;
  68565. /** Gets or sets the number pf sync interations */
  68566. syncIterations: number;
  68567. /** Gets or sets the aggressiveness of the simplifier */
  68568. aggressiveness: number;
  68569. /** Gets or sets the number of allowed iterations for decimation */
  68570. decimationIterations: number;
  68571. /** Gets or sets the espilon to use for bounding box computation */
  68572. boundingBoxEpsilon: number;
  68573. /**
  68574. * Creates a new QuadraticErrorSimplification
  68575. * @param _mesh defines the target mesh
  68576. */
  68577. constructor(_mesh: Mesh);
  68578. /**
  68579. * Simplification of a given mesh according to the given settings.
  68580. * Since this requires computation, it is assumed that the function runs async.
  68581. * @param settings The settings of the simplification, including quality and distance
  68582. * @param successCallback A callback that will be called after the mesh was simplified.
  68583. */
  68584. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68585. private runDecimation;
  68586. private initWithMesh;
  68587. private init;
  68588. private reconstructMesh;
  68589. private initDecimatedMesh;
  68590. private isFlipped;
  68591. private updateTriangles;
  68592. private identifyBorder;
  68593. private updateMesh;
  68594. private vertexError;
  68595. private calculateError;
  68596. }
  68597. }
  68598. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68599. import { Scene } from "babylonjs/scene";
  68600. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68601. import { ISceneComponent } from "babylonjs/sceneComponent";
  68602. module "babylonjs/scene" {
  68603. interface Scene {
  68604. /** @hidden (Backing field) */
  68605. _simplificationQueue: SimplificationQueue;
  68606. /**
  68607. * Gets or sets the simplification queue attached to the scene
  68608. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68609. */
  68610. simplificationQueue: SimplificationQueue;
  68611. }
  68612. }
  68613. module "babylonjs/Meshes/mesh" {
  68614. interface Mesh {
  68615. /**
  68616. * Simplify the mesh according to the given array of settings.
  68617. * Function will return immediately and will simplify async
  68618. * @param settings a collection of simplification settings
  68619. * @param parallelProcessing should all levels calculate parallel or one after the other
  68620. * @param simplificationType the type of simplification to run
  68621. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68622. * @returns the current mesh
  68623. */
  68624. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68625. }
  68626. }
  68627. /**
  68628. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68629. * created in a scene
  68630. */
  68631. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68632. /**
  68633. * The component name helpfull to identify the component in the list of scene components.
  68634. */
  68635. readonly name: string;
  68636. /**
  68637. * The scene the component belongs to.
  68638. */
  68639. scene: Scene;
  68640. /**
  68641. * Creates a new instance of the component for the given scene
  68642. * @param scene Defines the scene to register the component in
  68643. */
  68644. constructor(scene: Scene);
  68645. /**
  68646. * Registers the component in a given scene
  68647. */
  68648. register(): void;
  68649. /**
  68650. * Rebuilds the elements related to this component in case of
  68651. * context lost for instance.
  68652. */
  68653. rebuild(): void;
  68654. /**
  68655. * Disposes the component and the associated ressources
  68656. */
  68657. dispose(): void;
  68658. private _beforeCameraUpdate;
  68659. }
  68660. }
  68661. declare module "babylonjs/Meshes/Builders/index" {
  68662. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68663. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68664. export * from "babylonjs/Meshes/Builders/discBuilder";
  68665. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68666. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68667. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68668. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68669. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68670. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68671. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68672. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68673. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68674. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68675. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68676. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68677. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68678. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68679. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68680. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68681. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68682. }
  68683. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68684. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68685. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68686. import { Matrix } from "babylonjs/Maths/math.vector";
  68687. module "babylonjs/Meshes/mesh" {
  68688. interface Mesh {
  68689. /**
  68690. * Creates a new thin instance
  68691. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68692. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68693. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68694. */
  68695. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68696. /**
  68697. * Adds the transformation (matrix) of the current mesh as a thin instance
  68698. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68699. * @returns the thin instance index number
  68700. */
  68701. thinInstanceAddSelf(refresh: boolean): number;
  68702. /**
  68703. * Registers a custom attribute to be used with thin instances
  68704. * @param kind name of the attribute
  68705. * @param stride size in floats of the attribute
  68706. */
  68707. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68708. /**
  68709. * Sets the matrix of a thin instance
  68710. * @param index index of the thin instance
  68711. * @param matrix matrix to set
  68712. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68713. */
  68714. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68715. /**
  68716. * Sets the value of a custom attribute for a thin instance
  68717. * @param kind name of the attribute
  68718. * @param index index of the thin instance
  68719. * @param value value to set
  68720. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68721. */
  68722. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68723. /**
  68724. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  68725. */
  68726. thinInstanceCount: number;
  68727. /**
  68728. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68729. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68730. * @param buffer buffer to set
  68731. * @param stride size in floats of each value of the buffer
  68732. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68733. */
  68734. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68735. /**
  68736. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68737. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68738. */
  68739. thinInstanceBufferUpdated(kind: string): void;
  68740. /**
  68741. * Refreshes the bounding info, taking into account all the thin instances defined
  68742. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68743. */
  68744. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68745. /** @hidden */
  68746. _thinInstanceInitializeUserStorage(): void;
  68747. /** @hidden */
  68748. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68749. /** @hidden */
  68750. _userThinInstanceBuffersStorage: {
  68751. data: {
  68752. [key: string]: Float32Array;
  68753. };
  68754. sizes: {
  68755. [key: string]: number;
  68756. };
  68757. vertexBuffers: {
  68758. [key: string]: Nullable<VertexBuffer>;
  68759. };
  68760. strides: {
  68761. [key: string]: number;
  68762. };
  68763. };
  68764. }
  68765. }
  68766. }
  68767. declare module "babylonjs/Meshes/index" {
  68768. export * from "babylonjs/Meshes/abstractMesh";
  68769. export * from "babylonjs/Meshes/buffer";
  68770. export * from "babylonjs/Meshes/Compression/index";
  68771. export * from "babylonjs/Meshes/csg";
  68772. export * from "babylonjs/Meshes/geometry";
  68773. export * from "babylonjs/Meshes/groundMesh";
  68774. export * from "babylonjs/Meshes/trailMesh";
  68775. export * from "babylonjs/Meshes/instancedMesh";
  68776. export * from "babylonjs/Meshes/linesMesh";
  68777. export * from "babylonjs/Meshes/mesh";
  68778. export * from "babylonjs/Meshes/mesh.vertexData";
  68779. export * from "babylonjs/Meshes/meshBuilder";
  68780. export * from "babylonjs/Meshes/meshSimplification";
  68781. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68782. export * from "babylonjs/Meshes/polygonMesh";
  68783. export * from "babylonjs/Meshes/subMesh";
  68784. export * from "babylonjs/Meshes/meshLODLevel";
  68785. export * from "babylonjs/Meshes/transformNode";
  68786. export * from "babylonjs/Meshes/Builders/index";
  68787. export * from "babylonjs/Meshes/dataBuffer";
  68788. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68789. import "babylonjs/Meshes/thinInstanceMesh";
  68790. export * from "babylonjs/Meshes/thinInstanceMesh";
  68791. }
  68792. declare module "babylonjs/Morph/index" {
  68793. export * from "babylonjs/Morph/morphTarget";
  68794. export * from "babylonjs/Morph/morphTargetManager";
  68795. }
  68796. declare module "babylonjs/Navigation/INavigationEngine" {
  68797. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68798. import { Vector3 } from "babylonjs/Maths/math";
  68799. import { Mesh } from "babylonjs/Meshes/mesh";
  68800. import { Scene } from "babylonjs/scene";
  68801. /**
  68802. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68803. */
  68804. export interface INavigationEnginePlugin {
  68805. /**
  68806. * plugin name
  68807. */
  68808. name: string;
  68809. /**
  68810. * Creates a navigation mesh
  68811. * @param meshes array of all the geometry used to compute the navigatio mesh
  68812. * @param parameters bunch of parameters used to filter geometry
  68813. */
  68814. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68815. /**
  68816. * Create a navigation mesh debug mesh
  68817. * @param scene is where the mesh will be added
  68818. * @returns debug display mesh
  68819. */
  68820. createDebugNavMesh(scene: Scene): Mesh;
  68821. /**
  68822. * Get a navigation mesh constrained position, closest to the parameter position
  68823. * @param position world position
  68824. * @returns the closest point to position constrained by the navigation mesh
  68825. */
  68826. getClosestPoint(position: Vector3): Vector3;
  68827. /**
  68828. * Get a navigation mesh constrained position, closest to the parameter position
  68829. * @param position world position
  68830. * @param result output the closest point to position constrained by the navigation mesh
  68831. */
  68832. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68833. /**
  68834. * Get a navigation mesh constrained position, within a particular radius
  68835. * @param position world position
  68836. * @param maxRadius the maximum distance to the constrained world position
  68837. * @returns the closest point to position constrained by the navigation mesh
  68838. */
  68839. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68840. /**
  68841. * Get a navigation mesh constrained position, within a particular radius
  68842. * @param position world position
  68843. * @param maxRadius the maximum distance to the constrained world position
  68844. * @param result output the closest point to position constrained by the navigation mesh
  68845. */
  68846. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68847. /**
  68848. * Compute the final position from a segment made of destination-position
  68849. * @param position world position
  68850. * @param destination world position
  68851. * @returns the resulting point along the navmesh
  68852. */
  68853. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68854. /**
  68855. * Compute the final position from a segment made of destination-position
  68856. * @param position world position
  68857. * @param destination world position
  68858. * @param result output the resulting point along the navmesh
  68859. */
  68860. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68861. /**
  68862. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68863. * @param start world position
  68864. * @param end world position
  68865. * @returns array containing world position composing the path
  68866. */
  68867. computePath(start: Vector3, end: Vector3): Vector3[];
  68868. /**
  68869. * If this plugin is supported
  68870. * @returns true if plugin is supported
  68871. */
  68872. isSupported(): boolean;
  68873. /**
  68874. * Create a new Crowd so you can add agents
  68875. * @param maxAgents the maximum agent count in the crowd
  68876. * @param maxAgentRadius the maximum radius an agent can have
  68877. * @param scene to attach the crowd to
  68878. * @returns the crowd you can add agents to
  68879. */
  68880. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68881. /**
  68882. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68883. * The queries will try to find a solution within those bounds
  68884. * default is (1,1,1)
  68885. * @param extent x,y,z value that define the extent around the queries point of reference
  68886. */
  68887. setDefaultQueryExtent(extent: Vector3): void;
  68888. /**
  68889. * Get the Bounding box extent specified by setDefaultQueryExtent
  68890. * @returns the box extent values
  68891. */
  68892. getDefaultQueryExtent(): Vector3;
  68893. /**
  68894. * build the navmesh from a previously saved state using getNavmeshData
  68895. * @param data the Uint8Array returned by getNavmeshData
  68896. */
  68897. buildFromNavmeshData(data: Uint8Array): void;
  68898. /**
  68899. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68900. * @returns data the Uint8Array that can be saved and reused
  68901. */
  68902. getNavmeshData(): Uint8Array;
  68903. /**
  68904. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68905. * @param result output the box extent values
  68906. */
  68907. getDefaultQueryExtentToRef(result: Vector3): void;
  68908. /**
  68909. * Release all resources
  68910. */
  68911. dispose(): void;
  68912. }
  68913. /**
  68914. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68915. */
  68916. export interface ICrowd {
  68917. /**
  68918. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68919. * You can attach anything to that node. The node position is updated in the scene update tick.
  68920. * @param pos world position that will be constrained by the navigation mesh
  68921. * @param parameters agent parameters
  68922. * @param transform hooked to the agent that will be update by the scene
  68923. * @returns agent index
  68924. */
  68925. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68926. /**
  68927. * Returns the agent position in world space
  68928. * @param index agent index returned by addAgent
  68929. * @returns world space position
  68930. */
  68931. getAgentPosition(index: number): Vector3;
  68932. /**
  68933. * Gets the agent position result in world space
  68934. * @param index agent index returned by addAgent
  68935. * @param result output world space position
  68936. */
  68937. getAgentPositionToRef(index: number, result: Vector3): void;
  68938. /**
  68939. * Gets the agent velocity in world space
  68940. * @param index agent index returned by addAgent
  68941. * @returns world space velocity
  68942. */
  68943. getAgentVelocity(index: number): Vector3;
  68944. /**
  68945. * Gets the agent velocity result in world space
  68946. * @param index agent index returned by addAgent
  68947. * @param result output world space velocity
  68948. */
  68949. getAgentVelocityToRef(index: number, result: Vector3): void;
  68950. /**
  68951. * remove a particular agent previously created
  68952. * @param index agent index returned by addAgent
  68953. */
  68954. removeAgent(index: number): void;
  68955. /**
  68956. * get the list of all agents attached to this crowd
  68957. * @returns list of agent indices
  68958. */
  68959. getAgents(): number[];
  68960. /**
  68961. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68962. * @param deltaTime in seconds
  68963. */
  68964. update(deltaTime: number): void;
  68965. /**
  68966. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68967. * @param index agent index returned by addAgent
  68968. * @param destination targeted world position
  68969. */
  68970. agentGoto(index: number, destination: Vector3): void;
  68971. /**
  68972. * Teleport the agent to a new position
  68973. * @param index agent index returned by addAgent
  68974. * @param destination targeted world position
  68975. */
  68976. agentTeleport(index: number, destination: Vector3): void;
  68977. /**
  68978. * Update agent parameters
  68979. * @param index agent index returned by addAgent
  68980. * @param parameters agent parameters
  68981. */
  68982. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68983. /**
  68984. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68985. * The queries will try to find a solution within those bounds
  68986. * default is (1,1,1)
  68987. * @param extent x,y,z value that define the extent around the queries point of reference
  68988. */
  68989. setDefaultQueryExtent(extent: Vector3): void;
  68990. /**
  68991. * Get the Bounding box extent specified by setDefaultQueryExtent
  68992. * @returns the box extent values
  68993. */
  68994. getDefaultQueryExtent(): Vector3;
  68995. /**
  68996. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68997. * @param result output the box extent values
  68998. */
  68999. getDefaultQueryExtentToRef(result: Vector3): void;
  69000. /**
  69001. * Release all resources
  69002. */
  69003. dispose(): void;
  69004. }
  69005. /**
  69006. * Configures an agent
  69007. */
  69008. export interface IAgentParameters {
  69009. /**
  69010. * Agent radius. [Limit: >= 0]
  69011. */
  69012. radius: number;
  69013. /**
  69014. * Agent height. [Limit: > 0]
  69015. */
  69016. height: number;
  69017. /**
  69018. * Maximum allowed acceleration. [Limit: >= 0]
  69019. */
  69020. maxAcceleration: number;
  69021. /**
  69022. * Maximum allowed speed. [Limit: >= 0]
  69023. */
  69024. maxSpeed: number;
  69025. /**
  69026. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69027. */
  69028. collisionQueryRange: number;
  69029. /**
  69030. * The path visibility optimization range. [Limit: > 0]
  69031. */
  69032. pathOptimizationRange: number;
  69033. /**
  69034. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69035. */
  69036. separationWeight: number;
  69037. }
  69038. /**
  69039. * Configures the navigation mesh creation
  69040. */
  69041. export interface INavMeshParameters {
  69042. /**
  69043. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69044. */
  69045. cs: number;
  69046. /**
  69047. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69048. */
  69049. ch: number;
  69050. /**
  69051. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69052. */
  69053. walkableSlopeAngle: number;
  69054. /**
  69055. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69056. * be considered walkable. [Limit: >= 3] [Units: vx]
  69057. */
  69058. walkableHeight: number;
  69059. /**
  69060. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69061. */
  69062. walkableClimb: number;
  69063. /**
  69064. * The distance to erode/shrink the walkable area of the heightfield away from
  69065. * obstructions. [Limit: >=0] [Units: vx]
  69066. */
  69067. walkableRadius: number;
  69068. /**
  69069. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69070. */
  69071. maxEdgeLen: number;
  69072. /**
  69073. * The maximum distance a simplfied contour's border edges should deviate
  69074. * the original raw contour. [Limit: >=0] [Units: vx]
  69075. */
  69076. maxSimplificationError: number;
  69077. /**
  69078. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69079. */
  69080. minRegionArea: number;
  69081. /**
  69082. * Any regions with a span count smaller than this value will, if possible,
  69083. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69084. */
  69085. mergeRegionArea: number;
  69086. /**
  69087. * The maximum number of vertices allowed for polygons generated during the
  69088. * contour to polygon conversion process. [Limit: >= 3]
  69089. */
  69090. maxVertsPerPoly: number;
  69091. /**
  69092. * Sets the sampling distance to use when generating the detail mesh.
  69093. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69094. */
  69095. detailSampleDist: number;
  69096. /**
  69097. * The maximum distance the detail mesh surface should deviate from heightfield
  69098. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69099. */
  69100. detailSampleMaxError: number;
  69101. }
  69102. }
  69103. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69104. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69105. import { Mesh } from "babylonjs/Meshes/mesh";
  69106. import { Scene } from "babylonjs/scene";
  69107. import { Vector3 } from "babylonjs/Maths/math";
  69108. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69109. /**
  69110. * RecastJS navigation plugin
  69111. */
  69112. export class RecastJSPlugin implements INavigationEnginePlugin {
  69113. /**
  69114. * Reference to the Recast library
  69115. */
  69116. bjsRECAST: any;
  69117. /**
  69118. * plugin name
  69119. */
  69120. name: string;
  69121. /**
  69122. * the first navmesh created. We might extend this to support multiple navmeshes
  69123. */
  69124. navMesh: any;
  69125. /**
  69126. * Initializes the recastJS plugin
  69127. * @param recastInjection can be used to inject your own recast reference
  69128. */
  69129. constructor(recastInjection?: any);
  69130. /**
  69131. * Creates a navigation mesh
  69132. * @param meshes array of all the geometry used to compute the navigatio mesh
  69133. * @param parameters bunch of parameters used to filter geometry
  69134. */
  69135. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69136. /**
  69137. * Create a navigation mesh debug mesh
  69138. * @param scene is where the mesh will be added
  69139. * @returns debug display mesh
  69140. */
  69141. createDebugNavMesh(scene: Scene): Mesh;
  69142. /**
  69143. * Get a navigation mesh constrained position, closest to the parameter position
  69144. * @param position world position
  69145. * @returns the closest point to position constrained by the navigation mesh
  69146. */
  69147. getClosestPoint(position: Vector3): Vector3;
  69148. /**
  69149. * Get a navigation mesh constrained position, closest to the parameter position
  69150. * @param position world position
  69151. * @param result output the closest point to position constrained by the navigation mesh
  69152. */
  69153. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69154. /**
  69155. * Get a navigation mesh constrained position, within a particular radius
  69156. * @param position world position
  69157. * @param maxRadius the maximum distance to the constrained world position
  69158. * @returns the closest point to position constrained by the navigation mesh
  69159. */
  69160. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69161. /**
  69162. * Get a navigation mesh constrained position, within a particular radius
  69163. * @param position world position
  69164. * @param maxRadius the maximum distance to the constrained world position
  69165. * @param result output the closest point to position constrained by the navigation mesh
  69166. */
  69167. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69168. /**
  69169. * Compute the final position from a segment made of destination-position
  69170. * @param position world position
  69171. * @param destination world position
  69172. * @returns the resulting point along the navmesh
  69173. */
  69174. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69175. /**
  69176. * Compute the final position from a segment made of destination-position
  69177. * @param position world position
  69178. * @param destination world position
  69179. * @param result output the resulting point along the navmesh
  69180. */
  69181. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69182. /**
  69183. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69184. * @param start world position
  69185. * @param end world position
  69186. * @returns array containing world position composing the path
  69187. */
  69188. computePath(start: Vector3, end: Vector3): Vector3[];
  69189. /**
  69190. * Create a new Crowd so you can add agents
  69191. * @param maxAgents the maximum agent count in the crowd
  69192. * @param maxAgentRadius the maximum radius an agent can have
  69193. * @param scene to attach the crowd to
  69194. * @returns the crowd you can add agents to
  69195. */
  69196. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69197. /**
  69198. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69199. * The queries will try to find a solution within those bounds
  69200. * default is (1,1,1)
  69201. * @param extent x,y,z value that define the extent around the queries point of reference
  69202. */
  69203. setDefaultQueryExtent(extent: Vector3): void;
  69204. /**
  69205. * Get the Bounding box extent specified by setDefaultQueryExtent
  69206. * @returns the box extent values
  69207. */
  69208. getDefaultQueryExtent(): Vector3;
  69209. /**
  69210. * build the navmesh from a previously saved state using getNavmeshData
  69211. * @param data the Uint8Array returned by getNavmeshData
  69212. */
  69213. buildFromNavmeshData(data: Uint8Array): void;
  69214. /**
  69215. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69216. * @returns data the Uint8Array that can be saved and reused
  69217. */
  69218. getNavmeshData(): Uint8Array;
  69219. /**
  69220. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69221. * @param result output the box extent values
  69222. */
  69223. getDefaultQueryExtentToRef(result: Vector3): void;
  69224. /**
  69225. * Disposes
  69226. */
  69227. dispose(): void;
  69228. /**
  69229. * If this plugin is supported
  69230. * @returns true if plugin is supported
  69231. */
  69232. isSupported(): boolean;
  69233. }
  69234. /**
  69235. * Recast detour crowd implementation
  69236. */
  69237. export class RecastJSCrowd implements ICrowd {
  69238. /**
  69239. * Recast/detour plugin
  69240. */
  69241. bjsRECASTPlugin: RecastJSPlugin;
  69242. /**
  69243. * Link to the detour crowd
  69244. */
  69245. recastCrowd: any;
  69246. /**
  69247. * One transform per agent
  69248. */
  69249. transforms: TransformNode[];
  69250. /**
  69251. * All agents created
  69252. */
  69253. agents: number[];
  69254. /**
  69255. * Link to the scene is kept to unregister the crowd from the scene
  69256. */
  69257. private _scene;
  69258. /**
  69259. * Observer for crowd updates
  69260. */
  69261. private _onBeforeAnimationsObserver;
  69262. /**
  69263. * Constructor
  69264. * @param plugin recastJS plugin
  69265. * @param maxAgents the maximum agent count in the crowd
  69266. * @param maxAgentRadius the maximum radius an agent can have
  69267. * @param scene to attach the crowd to
  69268. * @returns the crowd you can add agents to
  69269. */
  69270. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69271. /**
  69272. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69273. * You can attach anything to that node. The node position is updated in the scene update tick.
  69274. * @param pos world position that will be constrained by the navigation mesh
  69275. * @param parameters agent parameters
  69276. * @param transform hooked to the agent that will be update by the scene
  69277. * @returns agent index
  69278. */
  69279. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69280. /**
  69281. * Returns the agent position in world space
  69282. * @param index agent index returned by addAgent
  69283. * @returns world space position
  69284. */
  69285. getAgentPosition(index: number): Vector3;
  69286. /**
  69287. * Returns the agent position result in world space
  69288. * @param index agent index returned by addAgent
  69289. * @param result output world space position
  69290. */
  69291. getAgentPositionToRef(index: number, result: Vector3): void;
  69292. /**
  69293. * Returns the agent velocity in world space
  69294. * @param index agent index returned by addAgent
  69295. * @returns world space velocity
  69296. */
  69297. getAgentVelocity(index: number): Vector3;
  69298. /**
  69299. * Returns the agent velocity result in world space
  69300. * @param index agent index returned by addAgent
  69301. * @param result output world space velocity
  69302. */
  69303. getAgentVelocityToRef(index: number, result: Vector3): void;
  69304. /**
  69305. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69306. * @param index agent index returned by addAgent
  69307. * @param destination targeted world position
  69308. */
  69309. agentGoto(index: number, destination: Vector3): void;
  69310. /**
  69311. * Teleport the agent to a new position
  69312. * @param index agent index returned by addAgent
  69313. * @param destination targeted world position
  69314. */
  69315. agentTeleport(index: number, destination: Vector3): void;
  69316. /**
  69317. * Update agent parameters
  69318. * @param index agent index returned by addAgent
  69319. * @param parameters agent parameters
  69320. */
  69321. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69322. /**
  69323. * remove a particular agent previously created
  69324. * @param index agent index returned by addAgent
  69325. */
  69326. removeAgent(index: number): void;
  69327. /**
  69328. * get the list of all agents attached to this crowd
  69329. * @returns list of agent indices
  69330. */
  69331. getAgents(): number[];
  69332. /**
  69333. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69334. * @param deltaTime in seconds
  69335. */
  69336. update(deltaTime: number): void;
  69337. /**
  69338. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69339. * The queries will try to find a solution within those bounds
  69340. * default is (1,1,1)
  69341. * @param extent x,y,z value that define the extent around the queries point of reference
  69342. */
  69343. setDefaultQueryExtent(extent: Vector3): void;
  69344. /**
  69345. * Get the Bounding box extent specified by setDefaultQueryExtent
  69346. * @returns the box extent values
  69347. */
  69348. getDefaultQueryExtent(): Vector3;
  69349. /**
  69350. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69351. * @param result output the box extent values
  69352. */
  69353. getDefaultQueryExtentToRef(result: Vector3): void;
  69354. /**
  69355. * Release all resources
  69356. */
  69357. dispose(): void;
  69358. }
  69359. }
  69360. declare module "babylonjs/Navigation/Plugins/index" {
  69361. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69362. }
  69363. declare module "babylonjs/Navigation/index" {
  69364. export * from "babylonjs/Navigation/INavigationEngine";
  69365. export * from "babylonjs/Navigation/Plugins/index";
  69366. }
  69367. declare module "babylonjs/Offline/database" {
  69368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69369. /**
  69370. * Class used to enable access to IndexedDB
  69371. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69372. */
  69373. export class Database implements IOfflineProvider {
  69374. private _callbackManifestChecked;
  69375. private _currentSceneUrl;
  69376. private _db;
  69377. private _enableSceneOffline;
  69378. private _enableTexturesOffline;
  69379. private _manifestVersionFound;
  69380. private _mustUpdateRessources;
  69381. private _hasReachedQuota;
  69382. private _isSupported;
  69383. private _idbFactory;
  69384. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69385. private static IsUASupportingBlobStorage;
  69386. /**
  69387. * Gets a boolean indicating if Database storate is enabled (off by default)
  69388. */
  69389. static IDBStorageEnabled: boolean;
  69390. /**
  69391. * Gets a boolean indicating if scene must be saved in the database
  69392. */
  69393. get enableSceneOffline(): boolean;
  69394. /**
  69395. * Gets a boolean indicating if textures must be saved in the database
  69396. */
  69397. get enableTexturesOffline(): boolean;
  69398. /**
  69399. * Creates a new Database
  69400. * @param urlToScene defines the url to load the scene
  69401. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69402. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69403. */
  69404. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69405. private static _ParseURL;
  69406. private static _ReturnFullUrlLocation;
  69407. private _checkManifestFile;
  69408. /**
  69409. * Open the database and make it available
  69410. * @param successCallback defines the callback to call on success
  69411. * @param errorCallback defines the callback to call on error
  69412. */
  69413. open(successCallback: () => void, errorCallback: () => void): void;
  69414. /**
  69415. * Loads an image from the database
  69416. * @param url defines the url to load from
  69417. * @param image defines the target DOM image
  69418. */
  69419. loadImage(url: string, image: HTMLImageElement): void;
  69420. private _loadImageFromDBAsync;
  69421. private _saveImageIntoDBAsync;
  69422. private _checkVersionFromDB;
  69423. private _loadVersionFromDBAsync;
  69424. private _saveVersionIntoDBAsync;
  69425. /**
  69426. * Loads a file from database
  69427. * @param url defines the URL to load from
  69428. * @param sceneLoaded defines a callback to call on success
  69429. * @param progressCallBack defines a callback to call when progress changed
  69430. * @param errorCallback defines a callback to call on error
  69431. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69432. */
  69433. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69434. private _loadFileAsync;
  69435. private _saveFileAsync;
  69436. /**
  69437. * Validates if xhr data is correct
  69438. * @param xhr defines the request to validate
  69439. * @param dataType defines the expected data type
  69440. * @returns true if data is correct
  69441. */
  69442. private static _ValidateXHRData;
  69443. }
  69444. }
  69445. declare module "babylonjs/Offline/index" {
  69446. export * from "babylonjs/Offline/database";
  69447. export * from "babylonjs/Offline/IOfflineProvider";
  69448. }
  69449. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69450. /** @hidden */
  69451. export var gpuUpdateParticlesPixelShader: {
  69452. name: string;
  69453. shader: string;
  69454. };
  69455. }
  69456. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69457. /** @hidden */
  69458. export var gpuUpdateParticlesVertexShader: {
  69459. name: string;
  69460. shader: string;
  69461. };
  69462. }
  69463. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69464. /** @hidden */
  69465. export var clipPlaneFragmentDeclaration2: {
  69466. name: string;
  69467. shader: string;
  69468. };
  69469. }
  69470. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69471. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69472. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69474. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69475. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69476. /** @hidden */
  69477. export var gpuRenderParticlesPixelShader: {
  69478. name: string;
  69479. shader: string;
  69480. };
  69481. }
  69482. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69483. /** @hidden */
  69484. export var clipPlaneVertexDeclaration2: {
  69485. name: string;
  69486. shader: string;
  69487. };
  69488. }
  69489. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69490. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69491. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69492. /** @hidden */
  69493. export var gpuRenderParticlesVertexShader: {
  69494. name: string;
  69495. shader: string;
  69496. };
  69497. }
  69498. declare module "babylonjs/Particles/gpuParticleSystem" {
  69499. import { Nullable } from "babylonjs/types";
  69500. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69501. import { Observable } from "babylonjs/Misc/observable";
  69502. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69503. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69504. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69505. import { Scene, IDisposable } from "babylonjs/scene";
  69506. import { Effect } from "babylonjs/Materials/effect";
  69507. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69508. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69509. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69510. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69511. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69512. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69513. /**
  69514. * This represents a GPU particle system in Babylon
  69515. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69516. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69517. */
  69518. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69519. /**
  69520. * The layer mask we are rendering the particles through.
  69521. */
  69522. layerMask: number;
  69523. private _capacity;
  69524. private _activeCount;
  69525. private _currentActiveCount;
  69526. private _accumulatedCount;
  69527. private _renderEffect;
  69528. private _updateEffect;
  69529. private _buffer0;
  69530. private _buffer1;
  69531. private _spriteBuffer;
  69532. private _updateVAO;
  69533. private _renderVAO;
  69534. private _targetIndex;
  69535. private _sourceBuffer;
  69536. private _targetBuffer;
  69537. private _engine;
  69538. private _currentRenderId;
  69539. private _started;
  69540. private _stopped;
  69541. private _timeDelta;
  69542. private _randomTexture;
  69543. private _randomTexture2;
  69544. private _attributesStrideSize;
  69545. private _updateEffectOptions;
  69546. private _randomTextureSize;
  69547. private _actualFrame;
  69548. private _customEffect;
  69549. private readonly _rawTextureWidth;
  69550. /**
  69551. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69552. */
  69553. static get IsSupported(): boolean;
  69554. /**
  69555. * An event triggered when the system is disposed.
  69556. */
  69557. onDisposeObservable: Observable<IParticleSystem>;
  69558. /**
  69559. * Gets the maximum number of particles active at the same time.
  69560. * @returns The max number of active particles.
  69561. */
  69562. getCapacity(): number;
  69563. /**
  69564. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69565. * to override the particles.
  69566. */
  69567. forceDepthWrite: boolean;
  69568. /**
  69569. * Gets or set the number of active particles
  69570. */
  69571. get activeParticleCount(): number;
  69572. set activeParticleCount(value: number);
  69573. private _preWarmDone;
  69574. /**
  69575. * Specifies if the particles are updated in emitter local space or world space.
  69576. */
  69577. isLocal: boolean;
  69578. /**
  69579. * Is this system ready to be used/rendered
  69580. * @return true if the system is ready
  69581. */
  69582. isReady(): boolean;
  69583. /**
  69584. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69585. * @returns True if it has been started, otherwise false.
  69586. */
  69587. isStarted(): boolean;
  69588. /**
  69589. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69590. * @returns True if it has been stopped, otherwise false.
  69591. */
  69592. isStopped(): boolean;
  69593. /**
  69594. * Gets a boolean indicating that the system is stopping
  69595. * @returns true if the system is currently stopping
  69596. */
  69597. isStopping(): boolean;
  69598. /**
  69599. * Gets the number of particles active at the same time.
  69600. * @returns The number of active particles.
  69601. */
  69602. getActiveCount(): number;
  69603. /**
  69604. * Starts the particle system and begins to emit
  69605. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69606. */
  69607. start(delay?: number): void;
  69608. /**
  69609. * Stops the particle system.
  69610. */
  69611. stop(): void;
  69612. /**
  69613. * Remove all active particles
  69614. */
  69615. reset(): void;
  69616. /**
  69617. * Returns the string "GPUParticleSystem"
  69618. * @returns a string containing the class name
  69619. */
  69620. getClassName(): string;
  69621. /**
  69622. * Gets the custom effect used to render the particles
  69623. * @param blendMode Blend mode for which the effect should be retrieved
  69624. * @returns The effect
  69625. */
  69626. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69627. /**
  69628. * Sets the custom effect used to render the particles
  69629. * @param effect The effect to set
  69630. * @param blendMode Blend mode for which the effect should be set
  69631. */
  69632. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69633. /** @hidden */
  69634. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69635. /**
  69636. * Observable that will be called just before the particles are drawn
  69637. */
  69638. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69639. /**
  69640. * Gets the name of the particle vertex shader
  69641. */
  69642. get vertexShaderName(): string;
  69643. private _colorGradientsTexture;
  69644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69645. /**
  69646. * Adds a new color gradient
  69647. * @param gradient defines the gradient to use (between 0 and 1)
  69648. * @param color1 defines the color to affect to the specified gradient
  69649. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69650. * @returns the current particle system
  69651. */
  69652. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69653. private _refreshColorGradient;
  69654. /** Force the system to rebuild all gradients that need to be resync */
  69655. forceRefreshGradients(): void;
  69656. /**
  69657. * Remove a specific color gradient
  69658. * @param gradient defines the gradient to remove
  69659. * @returns the current particle system
  69660. */
  69661. removeColorGradient(gradient: number): GPUParticleSystem;
  69662. private _angularSpeedGradientsTexture;
  69663. private _sizeGradientsTexture;
  69664. private _velocityGradientsTexture;
  69665. private _limitVelocityGradientsTexture;
  69666. private _dragGradientsTexture;
  69667. private _addFactorGradient;
  69668. /**
  69669. * Adds a new size gradient
  69670. * @param gradient defines the gradient to use (between 0 and 1)
  69671. * @param factor defines the size factor to affect to the specified gradient
  69672. * @returns the current particle system
  69673. */
  69674. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69675. /**
  69676. * Remove a specific size gradient
  69677. * @param gradient defines the gradient to remove
  69678. * @returns the current particle system
  69679. */
  69680. removeSizeGradient(gradient: number): GPUParticleSystem;
  69681. private _refreshFactorGradient;
  69682. /**
  69683. * Adds a new angular speed gradient
  69684. * @param gradient defines the gradient to use (between 0 and 1)
  69685. * @param factor defines the angular speed to affect to the specified gradient
  69686. * @returns the current particle system
  69687. */
  69688. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69689. /**
  69690. * Remove a specific angular speed gradient
  69691. * @param gradient defines the gradient to remove
  69692. * @returns the current particle system
  69693. */
  69694. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69695. /**
  69696. * Adds a new velocity gradient
  69697. * @param gradient defines the gradient to use (between 0 and 1)
  69698. * @param factor defines the velocity to affect to the specified gradient
  69699. * @returns the current particle system
  69700. */
  69701. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69702. /**
  69703. * Remove a specific velocity gradient
  69704. * @param gradient defines the gradient to remove
  69705. * @returns the current particle system
  69706. */
  69707. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69708. /**
  69709. * Adds a new limit velocity gradient
  69710. * @param gradient defines the gradient to use (between 0 and 1)
  69711. * @param factor defines the limit velocity value to affect to the specified gradient
  69712. * @returns the current particle system
  69713. */
  69714. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69715. /**
  69716. * Remove a specific limit velocity gradient
  69717. * @param gradient defines the gradient to remove
  69718. * @returns the current particle system
  69719. */
  69720. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69721. /**
  69722. * Adds a new drag gradient
  69723. * @param gradient defines the gradient to use (between 0 and 1)
  69724. * @param factor defines the drag value to affect to the specified gradient
  69725. * @returns the current particle system
  69726. */
  69727. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69728. /**
  69729. * Remove a specific drag gradient
  69730. * @param gradient defines the gradient to remove
  69731. * @returns the current particle system
  69732. */
  69733. removeDragGradient(gradient: number): GPUParticleSystem;
  69734. /**
  69735. * Not supported by GPUParticleSystem
  69736. * @param gradient defines the gradient to use (between 0 and 1)
  69737. * @param factor defines the emit rate value to affect to the specified gradient
  69738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69739. * @returns the current particle system
  69740. */
  69741. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69742. /**
  69743. * Not supported by GPUParticleSystem
  69744. * @param gradient defines the gradient to remove
  69745. * @returns the current particle system
  69746. */
  69747. removeEmitRateGradient(gradient: number): IParticleSystem;
  69748. /**
  69749. * Not supported by GPUParticleSystem
  69750. * @param gradient defines the gradient to use (between 0 and 1)
  69751. * @param factor defines the start size value to affect to the specified gradient
  69752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69753. * @returns the current particle system
  69754. */
  69755. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69756. /**
  69757. * Not supported by GPUParticleSystem
  69758. * @param gradient defines the gradient to remove
  69759. * @returns the current particle system
  69760. */
  69761. removeStartSizeGradient(gradient: number): IParticleSystem;
  69762. /**
  69763. * Not supported by GPUParticleSystem
  69764. * @param gradient defines the gradient to use (between 0 and 1)
  69765. * @param min defines the color remap minimal range
  69766. * @param max defines the color remap maximal range
  69767. * @returns the current particle system
  69768. */
  69769. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69770. /**
  69771. * Not supported by GPUParticleSystem
  69772. * @param gradient defines the gradient to remove
  69773. * @returns the current particle system
  69774. */
  69775. removeColorRemapGradient(): IParticleSystem;
  69776. /**
  69777. * Not supported by GPUParticleSystem
  69778. * @param gradient defines the gradient to use (between 0 and 1)
  69779. * @param min defines the alpha remap minimal range
  69780. * @param max defines the alpha remap maximal range
  69781. * @returns the current particle system
  69782. */
  69783. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69784. /**
  69785. * Not supported by GPUParticleSystem
  69786. * @param gradient defines the gradient to remove
  69787. * @returns the current particle system
  69788. */
  69789. removeAlphaRemapGradient(): IParticleSystem;
  69790. /**
  69791. * Not supported by GPUParticleSystem
  69792. * @param gradient defines the gradient to use (between 0 and 1)
  69793. * @param color defines the color to affect to the specified gradient
  69794. * @returns the current particle system
  69795. */
  69796. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69797. /**
  69798. * Not supported by GPUParticleSystem
  69799. * @param gradient defines the gradient to remove
  69800. * @returns the current particle system
  69801. */
  69802. removeRampGradient(): IParticleSystem;
  69803. /**
  69804. * Not supported by GPUParticleSystem
  69805. * @returns the list of ramp gradients
  69806. */
  69807. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69808. /**
  69809. * Not supported by GPUParticleSystem
  69810. * Gets or sets a boolean indicating that ramp gradients must be used
  69811. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69812. */
  69813. get useRampGradients(): boolean;
  69814. set useRampGradients(value: boolean);
  69815. /**
  69816. * Not supported by GPUParticleSystem
  69817. * @param gradient defines the gradient to use (between 0 and 1)
  69818. * @param factor defines the life time factor to affect to the specified gradient
  69819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69820. * @returns the current particle system
  69821. */
  69822. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69823. /**
  69824. * Not supported by GPUParticleSystem
  69825. * @param gradient defines the gradient to remove
  69826. * @returns the current particle system
  69827. */
  69828. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69829. /**
  69830. * Instantiates a GPU particle system.
  69831. * 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.
  69832. * @param name The name of the particle system
  69833. * @param options The options used to create the system
  69834. * @param scene The scene the particle system belongs to
  69835. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69836. * @param customEffect a custom effect used to change the way particles are rendered by default
  69837. */
  69838. constructor(name: string, options: Partial<{
  69839. capacity: number;
  69840. randomTextureSize: number;
  69841. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69842. protected _reset(): void;
  69843. private _createUpdateVAO;
  69844. private _createRenderVAO;
  69845. private _initialize;
  69846. /** @hidden */
  69847. _recreateUpdateEffect(): void;
  69848. private _getEffect;
  69849. /**
  69850. * Fill the defines array according to the current settings of the particle system
  69851. * @param defines Array to be updated
  69852. * @param blendMode blend mode to take into account when updating the array
  69853. */
  69854. fillDefines(defines: Array<string>, blendMode?: number): void;
  69855. /**
  69856. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69857. * @param uniforms Uniforms array to fill
  69858. * @param attributes Attributes array to fill
  69859. * @param samplers Samplers array to fill
  69860. */
  69861. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69862. /** @hidden */
  69863. _recreateRenderEffect(): Effect;
  69864. /**
  69865. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69866. * @param preWarm defines if we are in the pre-warmimg phase
  69867. */
  69868. animate(preWarm?: boolean): void;
  69869. private _createFactorGradientTexture;
  69870. private _createSizeGradientTexture;
  69871. private _createAngularSpeedGradientTexture;
  69872. private _createVelocityGradientTexture;
  69873. private _createLimitVelocityGradientTexture;
  69874. private _createDragGradientTexture;
  69875. private _createColorGradientTexture;
  69876. /**
  69877. * Renders the particle system in its current state
  69878. * @param preWarm defines if the system should only update the particles but not render them
  69879. * @returns the current number of particles
  69880. */
  69881. render(preWarm?: boolean): number;
  69882. /**
  69883. * Rebuilds the particle system
  69884. */
  69885. rebuild(): void;
  69886. private _releaseBuffers;
  69887. private _releaseVAOs;
  69888. /**
  69889. * Disposes the particle system and free the associated resources
  69890. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69891. */
  69892. dispose(disposeTexture?: boolean): void;
  69893. /**
  69894. * Clones the particle system.
  69895. * @param name The name of the cloned object
  69896. * @param newEmitter The new emitter to use
  69897. * @returns the cloned particle system
  69898. */
  69899. clone(name: string, newEmitter: any): GPUParticleSystem;
  69900. /**
  69901. * Serializes the particle system to a JSON object
  69902. * @param serializeTexture defines if the texture must be serialized as well
  69903. * @returns the JSON object
  69904. */
  69905. serialize(serializeTexture?: boolean): any;
  69906. /**
  69907. * Parses a JSON object to create a GPU particle system.
  69908. * @param parsedParticleSystem The JSON object to parse
  69909. * @param scene The scene to create the particle system in
  69910. * @param rootUrl The root url to use to load external dependencies like texture
  69911. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69912. * @returns the parsed GPU particle system
  69913. */
  69914. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69915. }
  69916. }
  69917. declare module "babylonjs/Particles/particleSystemSet" {
  69918. import { Nullable } from "babylonjs/types";
  69919. import { Color3 } from "babylonjs/Maths/math.color";
  69920. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69922. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69923. import { Scene, IDisposable } from "babylonjs/scene";
  69924. /**
  69925. * Represents a set of particle systems working together to create a specific effect
  69926. */
  69927. export class ParticleSystemSet implements IDisposable {
  69928. /**
  69929. * Gets or sets base Assets URL
  69930. */
  69931. static BaseAssetsUrl: string;
  69932. private _emitterCreationOptions;
  69933. private _emitterNode;
  69934. /**
  69935. * Gets the particle system list
  69936. */
  69937. systems: IParticleSystem[];
  69938. /**
  69939. * Gets the emitter node used with this set
  69940. */
  69941. get emitterNode(): Nullable<TransformNode>;
  69942. /**
  69943. * Creates a new emitter mesh as a sphere
  69944. * @param options defines the options used to create the sphere
  69945. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69946. * @param scene defines the hosting scene
  69947. */
  69948. setEmitterAsSphere(options: {
  69949. diameter: number;
  69950. segments: number;
  69951. color: Color3;
  69952. }, renderingGroupId: number, scene: Scene): void;
  69953. /**
  69954. * Starts all particle systems of the set
  69955. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69956. */
  69957. start(emitter?: AbstractMesh): void;
  69958. /**
  69959. * Release all associated resources
  69960. */
  69961. dispose(): void;
  69962. /**
  69963. * Serialize the set into a JSON compatible object
  69964. * @param serializeTexture defines if the texture must be serialized as well
  69965. * @returns a JSON compatible representation of the set
  69966. */
  69967. serialize(serializeTexture?: boolean): any;
  69968. /**
  69969. * Parse a new ParticleSystemSet from a serialized source
  69970. * @param data defines a JSON compatible representation of the set
  69971. * @param scene defines the hosting scene
  69972. * @param gpu defines if we want GPU particles or CPU particles
  69973. * @returns a new ParticleSystemSet
  69974. */
  69975. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69976. }
  69977. }
  69978. declare module "babylonjs/Particles/particleHelper" {
  69979. import { Nullable } from "babylonjs/types";
  69980. import { Scene } from "babylonjs/scene";
  69981. import { Vector3 } from "babylonjs/Maths/math.vector";
  69982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69983. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69984. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  69985. /**
  69986. * This class is made for on one-liner static method to help creating particle system set.
  69987. */
  69988. export class ParticleHelper {
  69989. /**
  69990. * Gets or sets base Assets URL
  69991. */
  69992. static BaseAssetsUrl: string;
  69993. /** Define the Url to load snippets */
  69994. static SnippetUrl: string;
  69995. /**
  69996. * Create a default particle system that you can tweak
  69997. * @param emitter defines the emitter to use
  69998. * @param capacity defines the system capacity (default is 500 particles)
  69999. * @param scene defines the hosting scene
  70000. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70001. * @returns the new Particle system
  70002. */
  70003. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70004. /**
  70005. * This is the main static method (one-liner) of this helper to create different particle systems
  70006. * @param type This string represents the type to the particle system to create
  70007. * @param scene The scene where the particle system should live
  70008. * @param gpu If the system will use gpu
  70009. * @returns the ParticleSystemSet created
  70010. */
  70011. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70012. /**
  70013. * Static function used to export a particle system to a ParticleSystemSet variable.
  70014. * Please note that the emitter shape is not exported
  70015. * @param systems defines the particle systems to export
  70016. * @returns the created particle system set
  70017. */
  70018. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70019. /**
  70020. * Creates a particle system from a snippet saved in a remote file
  70021. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70022. * @param url defines the url to load from
  70023. * @param scene defines the hosting scene
  70024. * @param gpu If the system will use gpu
  70025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70026. * @returns a promise that will resolve to the new particle system
  70027. */
  70028. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70029. /**
  70030. * Creates a particle system from a snippet saved by the particle system editor
  70031. * @param snippetId defines the snippet to load
  70032. * @param scene defines the hosting scene
  70033. * @param gpu If the system will use gpu
  70034. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70035. * @returns a promise that will resolve to the new particle system
  70036. */
  70037. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70038. }
  70039. }
  70040. declare module "babylonjs/Particles/particleSystemComponent" {
  70041. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70042. import { Effect } from "babylonjs/Materials/effect";
  70043. import "babylonjs/Shaders/particles.vertex";
  70044. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70045. module "babylonjs/Engines/engine" {
  70046. interface Engine {
  70047. /**
  70048. * Create an effect to use with particle systems.
  70049. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70050. * the particle system for which you want to create a custom effect in the last parameter
  70051. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70052. * @param uniformsNames defines a list of attribute names
  70053. * @param samplers defines an array of string used to represent textures
  70054. * @param defines defines the string containing the defines to use to compile the shaders
  70055. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70056. * @param onCompiled defines a function to call when the effect creation is successful
  70057. * @param onError defines a function to call when the effect creation has failed
  70058. * @param particleSystem the particle system you want to create the effect for
  70059. * @returns the new Effect
  70060. */
  70061. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70062. }
  70063. }
  70064. module "babylonjs/Meshes/mesh" {
  70065. interface Mesh {
  70066. /**
  70067. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70068. * @returns an array of IParticleSystem
  70069. */
  70070. getEmittedParticleSystems(): IParticleSystem[];
  70071. /**
  70072. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70073. * @returns an array of IParticleSystem
  70074. */
  70075. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70076. }
  70077. }
  70078. }
  70079. declare module "babylonjs/Particles/pointsCloudSystem" {
  70080. import { Color4 } from "babylonjs/Maths/math";
  70081. import { Mesh } from "babylonjs/Meshes/mesh";
  70082. import { Scene, IDisposable } from "babylonjs/scene";
  70083. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70084. /** Defines the 4 color options */
  70085. export enum PointColor {
  70086. /** color value */
  70087. Color = 2,
  70088. /** uv value */
  70089. UV = 1,
  70090. /** random value */
  70091. Random = 0,
  70092. /** stated value */
  70093. Stated = 3
  70094. }
  70095. /**
  70096. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70097. * 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.
  70098. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70099. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70100. *
  70101. * Full documentation here : TO BE ENTERED
  70102. */
  70103. export class PointsCloudSystem implements IDisposable {
  70104. /**
  70105. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70106. * Example : var p = SPS.particles[i];
  70107. */
  70108. particles: CloudPoint[];
  70109. /**
  70110. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70111. */
  70112. nbParticles: number;
  70113. /**
  70114. * This a counter for your own usage. It's not set by any SPS functions.
  70115. */
  70116. counter: number;
  70117. /**
  70118. * The PCS name. This name is also given to the underlying mesh.
  70119. */
  70120. name: string;
  70121. /**
  70122. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70123. */
  70124. mesh: Mesh;
  70125. /**
  70126. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70127. * Please read :
  70128. */
  70129. vars: any;
  70130. /**
  70131. * @hidden
  70132. */
  70133. _size: number;
  70134. private _scene;
  70135. private _promises;
  70136. private _positions;
  70137. private _indices;
  70138. private _normals;
  70139. private _colors;
  70140. private _uvs;
  70141. private _indices32;
  70142. private _positions32;
  70143. private _colors32;
  70144. private _uvs32;
  70145. private _updatable;
  70146. private _isVisibilityBoxLocked;
  70147. private _alwaysVisible;
  70148. private _groups;
  70149. private _groupCounter;
  70150. private _computeParticleColor;
  70151. private _computeParticleTexture;
  70152. private _computeParticleRotation;
  70153. private _computeBoundingBox;
  70154. private _isReady;
  70155. /**
  70156. * Creates a PCS (Points Cloud System) object
  70157. * @param name (String) is the PCS name, this will be the underlying mesh name
  70158. * @param pointSize (number) is the size for each point
  70159. * @param scene (Scene) is the scene in which the PCS is added
  70160. * @param options defines the options of the PCS e.g.
  70161. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70162. */
  70163. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70164. updatable?: boolean;
  70165. });
  70166. /**
  70167. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70168. * If no points were added to the PCS, the returned mesh is just a single point.
  70169. * @returns a promise for the created mesh
  70170. */
  70171. buildMeshAsync(): Promise<Mesh>;
  70172. /**
  70173. * @hidden
  70174. */
  70175. private _buildMesh;
  70176. private _addParticle;
  70177. private _randomUnitVector;
  70178. private _getColorIndicesForCoord;
  70179. private _setPointsColorOrUV;
  70180. private _colorFromTexture;
  70181. private _calculateDensity;
  70182. /**
  70183. * Adds points to the PCS in random positions within a unit sphere
  70184. * @param nb (positive integer) the number of particles to be created from this model
  70185. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70186. * @returns the number of groups in the system
  70187. */
  70188. addPoints(nb: number, pointFunction?: any): number;
  70189. /**
  70190. * Adds points to the PCS from the surface of the model shape
  70191. * @param mesh is any Mesh object that will be used as a surface model for the points
  70192. * @param nb (positive integer) the number of particles to be created from this model
  70193. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70194. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70195. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70196. * @returns the number of groups in the system
  70197. */
  70198. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70199. /**
  70200. * Adds points to the PCS inside the model shape
  70201. * @param mesh is any Mesh object that will be used as a surface model for the points
  70202. * @param nb (positive integer) the number of particles to be created from this model
  70203. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70204. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70205. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70206. * @returns the number of groups in the system
  70207. */
  70208. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70209. /**
  70210. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70211. * This method calls `updateParticle()` for each particle of the SPS.
  70212. * For an animated SPS, it is usually called within the render loop.
  70213. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70214. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70215. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70216. * @returns the PCS.
  70217. */
  70218. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70219. /**
  70220. * Disposes the PCS.
  70221. */
  70222. dispose(): void;
  70223. /**
  70224. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70225. * doc :
  70226. * @returns the PCS.
  70227. */
  70228. refreshVisibleSize(): PointsCloudSystem;
  70229. /**
  70230. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70231. * @param size the size (float) of the visibility box
  70232. * note : this doesn't lock the PCS mesh bounding box.
  70233. * doc :
  70234. */
  70235. setVisibilityBox(size: number): void;
  70236. /**
  70237. * Gets whether the PCS is always visible or not
  70238. * doc :
  70239. */
  70240. get isAlwaysVisible(): boolean;
  70241. /**
  70242. * Sets the PCS as always visible or not
  70243. * doc :
  70244. */
  70245. set isAlwaysVisible(val: boolean);
  70246. /**
  70247. * Tells to `setParticles()` to compute the particle rotations or not
  70248. * Default value : false. The PCS is faster when it's set to false
  70249. * Note : particle rotations are only applied to parent particles
  70250. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70251. */
  70252. set computeParticleRotation(val: boolean);
  70253. /**
  70254. * Tells to `setParticles()` to compute the particle colors or not.
  70255. * Default value : true. The PCS is faster when it's set to false.
  70256. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70257. */
  70258. set computeParticleColor(val: boolean);
  70259. set computeParticleTexture(val: boolean);
  70260. /**
  70261. * Gets if `setParticles()` computes the particle colors or not.
  70262. * Default value : false. The PCS is faster when it's set to false.
  70263. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70264. */
  70265. get computeParticleColor(): boolean;
  70266. /**
  70267. * Gets if `setParticles()` computes the particle textures or not.
  70268. * Default value : false. The PCS is faster when it's set to false.
  70269. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70270. */
  70271. get computeParticleTexture(): boolean;
  70272. /**
  70273. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70274. */
  70275. set computeBoundingBox(val: boolean);
  70276. /**
  70277. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70278. */
  70279. get computeBoundingBox(): boolean;
  70280. /**
  70281. * This function does nothing. It may be overwritten to set all the particle first values.
  70282. * The PCS doesn't call this function, you may have to call it by your own.
  70283. * doc :
  70284. */
  70285. initParticles(): void;
  70286. /**
  70287. * This function does nothing. It may be overwritten to recycle a particle
  70288. * The PCS doesn't call this function, you can to call it
  70289. * doc :
  70290. * @param particle The particle to recycle
  70291. * @returns the recycled particle
  70292. */
  70293. recycleParticle(particle: CloudPoint): CloudPoint;
  70294. /**
  70295. * Updates a particle : this function should be overwritten by the user.
  70296. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70297. * doc :
  70298. * @example : just set a particle position or velocity and recycle conditions
  70299. * @param particle The particle to update
  70300. * @returns the updated particle
  70301. */
  70302. updateParticle(particle: CloudPoint): CloudPoint;
  70303. /**
  70304. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70305. * This does nothing and may be overwritten by the user.
  70306. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70307. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70308. * @param update the boolean update value actually passed to setParticles()
  70309. */
  70310. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70311. /**
  70312. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70313. * This will be passed three parameters.
  70314. * This does nothing and may be overwritten by the user.
  70315. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70316. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70317. * @param update the boolean update value actually passed to setParticles()
  70318. */
  70319. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70320. }
  70321. }
  70322. declare module "babylonjs/Particles/cloudPoint" {
  70323. import { Nullable } from "babylonjs/types";
  70324. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70325. import { Mesh } from "babylonjs/Meshes/mesh";
  70326. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70327. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70328. /**
  70329. * Represents one particle of a points cloud system.
  70330. */
  70331. export class CloudPoint {
  70332. /**
  70333. * particle global index
  70334. */
  70335. idx: number;
  70336. /**
  70337. * The color of the particle
  70338. */
  70339. color: Nullable<Color4>;
  70340. /**
  70341. * The world space position of the particle.
  70342. */
  70343. position: Vector3;
  70344. /**
  70345. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70346. */
  70347. rotation: Vector3;
  70348. /**
  70349. * The world space rotation quaternion of the particle.
  70350. */
  70351. rotationQuaternion: Nullable<Quaternion>;
  70352. /**
  70353. * The uv of the particle.
  70354. */
  70355. uv: Nullable<Vector2>;
  70356. /**
  70357. * The current speed of the particle.
  70358. */
  70359. velocity: Vector3;
  70360. /**
  70361. * The pivot point in the particle local space.
  70362. */
  70363. pivot: Vector3;
  70364. /**
  70365. * Must the particle be translated from its pivot point in its local space ?
  70366. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70367. * Default : false
  70368. */
  70369. translateFromPivot: boolean;
  70370. /**
  70371. * Index of this particle in the global "positions" array (Internal use)
  70372. * @hidden
  70373. */
  70374. _pos: number;
  70375. /**
  70376. * @hidden Index of this particle in the global "indices" array (Internal use)
  70377. */
  70378. _ind: number;
  70379. /**
  70380. * Group this particle belongs to
  70381. */
  70382. _group: PointsGroup;
  70383. /**
  70384. * Group id of this particle
  70385. */
  70386. groupId: number;
  70387. /**
  70388. * Index of the particle in its group id (Internal use)
  70389. */
  70390. idxInGroup: number;
  70391. /**
  70392. * @hidden Particle BoundingInfo object (Internal use)
  70393. */
  70394. _boundingInfo: BoundingInfo;
  70395. /**
  70396. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70397. */
  70398. _pcs: PointsCloudSystem;
  70399. /**
  70400. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70401. */
  70402. _stillInvisible: boolean;
  70403. /**
  70404. * @hidden Last computed particle rotation matrix
  70405. */
  70406. _rotationMatrix: number[];
  70407. /**
  70408. * Parent particle Id, if any.
  70409. * Default null.
  70410. */
  70411. parentId: Nullable<number>;
  70412. /**
  70413. * @hidden Internal global position in the PCS.
  70414. */
  70415. _globalPosition: Vector3;
  70416. /**
  70417. * Creates a Point Cloud object.
  70418. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70419. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70420. * @param group (PointsGroup) is the group the particle belongs to
  70421. * @param groupId (integer) is the group identifier in the PCS.
  70422. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70423. * @param pcs defines the PCS it is associated to
  70424. */
  70425. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70426. /**
  70427. * get point size
  70428. */
  70429. get size(): Vector3;
  70430. /**
  70431. * Set point size
  70432. */
  70433. set size(scale: Vector3);
  70434. /**
  70435. * Legacy support, changed quaternion to rotationQuaternion
  70436. */
  70437. get quaternion(): Nullable<Quaternion>;
  70438. /**
  70439. * Legacy support, changed quaternion to rotationQuaternion
  70440. */
  70441. set quaternion(q: Nullable<Quaternion>);
  70442. /**
  70443. * Returns a boolean. True if the particle intersects a mesh, else false
  70444. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70445. * @param target is the object (point or mesh) what the intersection is computed against
  70446. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70447. * @returns true if it intersects
  70448. */
  70449. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70450. /**
  70451. * get the rotation matrix of the particle
  70452. * @hidden
  70453. */
  70454. getRotationMatrix(m: Matrix): void;
  70455. }
  70456. /**
  70457. * Represents a group of points in a points cloud system
  70458. * * PCS internal tool, don't use it manually.
  70459. */
  70460. export class PointsGroup {
  70461. /**
  70462. * The group id
  70463. * @hidden
  70464. */
  70465. groupID: number;
  70466. /**
  70467. * image data for group (internal use)
  70468. * @hidden
  70469. */
  70470. _groupImageData: Nullable<ArrayBufferView>;
  70471. /**
  70472. * Image Width (internal use)
  70473. * @hidden
  70474. */
  70475. _groupImgWidth: number;
  70476. /**
  70477. * Image Height (internal use)
  70478. * @hidden
  70479. */
  70480. _groupImgHeight: number;
  70481. /**
  70482. * Custom position function (internal use)
  70483. * @hidden
  70484. */
  70485. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70486. /**
  70487. * density per facet for surface points
  70488. * @hidden
  70489. */
  70490. _groupDensity: number[];
  70491. /**
  70492. * Only when points are colored by texture carries pointer to texture list array
  70493. * @hidden
  70494. */
  70495. _textureNb: number;
  70496. /**
  70497. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70498. * PCS internal tool, don't use it manually.
  70499. * @hidden
  70500. */
  70501. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70502. }
  70503. }
  70504. declare module "babylonjs/Particles/index" {
  70505. export * from "babylonjs/Particles/baseParticleSystem";
  70506. export * from "babylonjs/Particles/EmitterTypes/index";
  70507. export * from "babylonjs/Particles/gpuParticleSystem";
  70508. export * from "babylonjs/Particles/IParticleSystem";
  70509. export * from "babylonjs/Particles/particle";
  70510. export * from "babylonjs/Particles/particleHelper";
  70511. export * from "babylonjs/Particles/particleSystem";
  70512. import "babylonjs/Particles/particleSystemComponent";
  70513. export * from "babylonjs/Particles/particleSystemComponent";
  70514. export * from "babylonjs/Particles/particleSystemSet";
  70515. export * from "babylonjs/Particles/solidParticle";
  70516. export * from "babylonjs/Particles/solidParticleSystem";
  70517. export * from "babylonjs/Particles/cloudPoint";
  70518. export * from "babylonjs/Particles/pointsCloudSystem";
  70519. export * from "babylonjs/Particles/subEmitter";
  70520. }
  70521. declare module "babylonjs/Physics/physicsEngineComponent" {
  70522. import { Nullable } from "babylonjs/types";
  70523. import { Observable, Observer } from "babylonjs/Misc/observable";
  70524. import { Vector3 } from "babylonjs/Maths/math.vector";
  70525. import { Mesh } from "babylonjs/Meshes/mesh";
  70526. import { ISceneComponent } from "babylonjs/sceneComponent";
  70527. import { Scene } from "babylonjs/scene";
  70528. import { Node } from "babylonjs/node";
  70529. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70530. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70531. module "babylonjs/scene" {
  70532. interface Scene {
  70533. /** @hidden (Backing field) */
  70534. _physicsEngine: Nullable<IPhysicsEngine>;
  70535. /** @hidden */
  70536. _physicsTimeAccumulator: number;
  70537. /**
  70538. * Gets the current physics engine
  70539. * @returns a IPhysicsEngine or null if none attached
  70540. */
  70541. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70542. /**
  70543. * Enables physics to the current scene
  70544. * @param gravity defines the scene's gravity for the physics engine
  70545. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70546. * @return a boolean indicating if the physics engine was initialized
  70547. */
  70548. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70549. /**
  70550. * Disables and disposes the physics engine associated with the scene
  70551. */
  70552. disablePhysicsEngine(): void;
  70553. /**
  70554. * Gets a boolean indicating if there is an active physics engine
  70555. * @returns a boolean indicating if there is an active physics engine
  70556. */
  70557. isPhysicsEnabled(): boolean;
  70558. /**
  70559. * Deletes a physics compound impostor
  70560. * @param compound defines the compound to delete
  70561. */
  70562. deleteCompoundImpostor(compound: any): void;
  70563. /**
  70564. * An event triggered when physic simulation is about to be run
  70565. */
  70566. onBeforePhysicsObservable: Observable<Scene>;
  70567. /**
  70568. * An event triggered when physic simulation has been done
  70569. */
  70570. onAfterPhysicsObservable: Observable<Scene>;
  70571. }
  70572. }
  70573. module "babylonjs/Meshes/abstractMesh" {
  70574. interface AbstractMesh {
  70575. /** @hidden */
  70576. _physicsImpostor: Nullable<PhysicsImpostor>;
  70577. /**
  70578. * Gets or sets impostor used for physic simulation
  70579. * @see http://doc.babylonjs.com/features/physics_engine
  70580. */
  70581. physicsImpostor: Nullable<PhysicsImpostor>;
  70582. /**
  70583. * Gets the current physics impostor
  70584. * @see http://doc.babylonjs.com/features/physics_engine
  70585. * @returns a physics impostor or null
  70586. */
  70587. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70588. /** Apply a physic impulse to the mesh
  70589. * @param force defines the force to apply
  70590. * @param contactPoint defines where to apply the force
  70591. * @returns the current mesh
  70592. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70593. */
  70594. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70595. /**
  70596. * Creates a physic joint between two meshes
  70597. * @param otherMesh defines the other mesh to use
  70598. * @param pivot1 defines the pivot to use on this mesh
  70599. * @param pivot2 defines the pivot to use on the other mesh
  70600. * @param options defines additional options (can be plugin dependent)
  70601. * @returns the current mesh
  70602. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70603. */
  70604. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70605. /** @hidden */
  70606. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70607. }
  70608. }
  70609. /**
  70610. * Defines the physics engine scene component responsible to manage a physics engine
  70611. */
  70612. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70613. /**
  70614. * The component name helpful to identify the component in the list of scene components.
  70615. */
  70616. readonly name: string;
  70617. /**
  70618. * The scene the component belongs to.
  70619. */
  70620. scene: Scene;
  70621. /**
  70622. * Creates a new instance of the component for the given scene
  70623. * @param scene Defines the scene to register the component in
  70624. */
  70625. constructor(scene: Scene);
  70626. /**
  70627. * Registers the component in a given scene
  70628. */
  70629. register(): void;
  70630. /**
  70631. * Rebuilds the elements related to this component in case of
  70632. * context lost for instance.
  70633. */
  70634. rebuild(): void;
  70635. /**
  70636. * Disposes the component and the associated ressources
  70637. */
  70638. dispose(): void;
  70639. }
  70640. }
  70641. declare module "babylonjs/Physics/physicsHelper" {
  70642. import { Nullable } from "babylonjs/types";
  70643. import { Vector3 } from "babylonjs/Maths/math.vector";
  70644. import { Mesh } from "babylonjs/Meshes/mesh";
  70645. import { Scene } from "babylonjs/scene";
  70646. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70647. /**
  70648. * A helper for physics simulations
  70649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70650. */
  70651. export class PhysicsHelper {
  70652. private _scene;
  70653. private _physicsEngine;
  70654. /**
  70655. * Initializes the Physics helper
  70656. * @param scene Babylon.js scene
  70657. */
  70658. constructor(scene: Scene);
  70659. /**
  70660. * Applies a radial explosion impulse
  70661. * @param origin the origin of the explosion
  70662. * @param radiusOrEventOptions the radius or the options of radial explosion
  70663. * @param strength the explosion strength
  70664. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70665. * @returns A physics radial explosion event, or null
  70666. */
  70667. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70668. /**
  70669. * Applies a radial explosion force
  70670. * @param origin the origin of the explosion
  70671. * @param radiusOrEventOptions the radius or the options of radial explosion
  70672. * @param strength the explosion strength
  70673. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70674. * @returns A physics radial explosion event, or null
  70675. */
  70676. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70677. /**
  70678. * Creates a gravitational field
  70679. * @param origin the origin of the explosion
  70680. * @param radiusOrEventOptions the radius or the options of radial explosion
  70681. * @param strength the explosion strength
  70682. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70683. * @returns A physics gravitational field event, or null
  70684. */
  70685. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70686. /**
  70687. * Creates a physics updraft event
  70688. * @param origin the origin of the updraft
  70689. * @param radiusOrEventOptions the radius or the options of the updraft
  70690. * @param strength the strength of the updraft
  70691. * @param height the height of the updraft
  70692. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70693. * @returns A physics updraft event, or null
  70694. */
  70695. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70696. /**
  70697. * Creates a physics vortex event
  70698. * @param origin the of the vortex
  70699. * @param radiusOrEventOptions the radius or the options of the vortex
  70700. * @param strength the strength of the vortex
  70701. * @param height the height of the vortex
  70702. * @returns a Physics vortex event, or null
  70703. * A physics vortex event or null
  70704. */
  70705. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70706. }
  70707. /**
  70708. * Represents a physics radial explosion event
  70709. */
  70710. class PhysicsRadialExplosionEvent {
  70711. private _scene;
  70712. private _options;
  70713. private _sphere;
  70714. private _dataFetched;
  70715. /**
  70716. * Initializes a radial explosioin event
  70717. * @param _scene BabylonJS scene
  70718. * @param _options The options for the vortex event
  70719. */
  70720. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70721. /**
  70722. * Returns the data related to the radial explosion event (sphere).
  70723. * @returns The radial explosion event data
  70724. */
  70725. getData(): PhysicsRadialExplosionEventData;
  70726. /**
  70727. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70728. * @param impostor A physics imposter
  70729. * @param origin the origin of the explosion
  70730. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70731. */
  70732. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70733. /**
  70734. * Triggers affecterd impostors callbacks
  70735. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70736. */
  70737. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70738. /**
  70739. * Disposes the sphere.
  70740. * @param force Specifies if the sphere should be disposed by force
  70741. */
  70742. dispose(force?: boolean): void;
  70743. /*** Helpers ***/
  70744. private _prepareSphere;
  70745. private _intersectsWithSphere;
  70746. }
  70747. /**
  70748. * Represents a gravitational field event
  70749. */
  70750. class PhysicsGravitationalFieldEvent {
  70751. private _physicsHelper;
  70752. private _scene;
  70753. private _origin;
  70754. private _options;
  70755. private _tickCallback;
  70756. private _sphere;
  70757. private _dataFetched;
  70758. /**
  70759. * Initializes the physics gravitational field event
  70760. * @param _physicsHelper A physics helper
  70761. * @param _scene BabylonJS scene
  70762. * @param _origin The origin position of the gravitational field event
  70763. * @param _options The options for the vortex event
  70764. */
  70765. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70766. /**
  70767. * Returns the data related to the gravitational field event (sphere).
  70768. * @returns A gravitational field event
  70769. */
  70770. getData(): PhysicsGravitationalFieldEventData;
  70771. /**
  70772. * Enables the gravitational field.
  70773. */
  70774. enable(): void;
  70775. /**
  70776. * Disables the gravitational field.
  70777. */
  70778. disable(): void;
  70779. /**
  70780. * Disposes the sphere.
  70781. * @param force The force to dispose from the gravitational field event
  70782. */
  70783. dispose(force?: boolean): void;
  70784. private _tick;
  70785. }
  70786. /**
  70787. * Represents a physics updraft event
  70788. */
  70789. class PhysicsUpdraftEvent {
  70790. private _scene;
  70791. private _origin;
  70792. private _options;
  70793. private _physicsEngine;
  70794. private _originTop;
  70795. private _originDirection;
  70796. private _tickCallback;
  70797. private _cylinder;
  70798. private _cylinderPosition;
  70799. private _dataFetched;
  70800. /**
  70801. * Initializes the physics updraft event
  70802. * @param _scene BabylonJS scene
  70803. * @param _origin The origin position of the updraft
  70804. * @param _options The options for the updraft event
  70805. */
  70806. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70807. /**
  70808. * Returns the data related to the updraft event (cylinder).
  70809. * @returns A physics updraft event
  70810. */
  70811. getData(): PhysicsUpdraftEventData;
  70812. /**
  70813. * Enables the updraft.
  70814. */
  70815. enable(): void;
  70816. /**
  70817. * Disables the updraft.
  70818. */
  70819. disable(): void;
  70820. /**
  70821. * Disposes the cylinder.
  70822. * @param force Specifies if the updraft should be disposed by force
  70823. */
  70824. dispose(force?: boolean): void;
  70825. private getImpostorHitData;
  70826. private _tick;
  70827. /*** Helpers ***/
  70828. private _prepareCylinder;
  70829. private _intersectsWithCylinder;
  70830. }
  70831. /**
  70832. * Represents a physics vortex event
  70833. */
  70834. class PhysicsVortexEvent {
  70835. private _scene;
  70836. private _origin;
  70837. private _options;
  70838. private _physicsEngine;
  70839. private _originTop;
  70840. private _tickCallback;
  70841. private _cylinder;
  70842. private _cylinderPosition;
  70843. private _dataFetched;
  70844. /**
  70845. * Initializes the physics vortex event
  70846. * @param _scene The BabylonJS scene
  70847. * @param _origin The origin position of the vortex
  70848. * @param _options The options for the vortex event
  70849. */
  70850. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70851. /**
  70852. * Returns the data related to the vortex event (cylinder).
  70853. * @returns The physics vortex event data
  70854. */
  70855. getData(): PhysicsVortexEventData;
  70856. /**
  70857. * Enables the vortex.
  70858. */
  70859. enable(): void;
  70860. /**
  70861. * Disables the cortex.
  70862. */
  70863. disable(): void;
  70864. /**
  70865. * Disposes the sphere.
  70866. * @param force
  70867. */
  70868. dispose(force?: boolean): void;
  70869. private getImpostorHitData;
  70870. private _tick;
  70871. /*** Helpers ***/
  70872. private _prepareCylinder;
  70873. private _intersectsWithCylinder;
  70874. }
  70875. /**
  70876. * Options fot the radial explosion event
  70877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70878. */
  70879. export class PhysicsRadialExplosionEventOptions {
  70880. /**
  70881. * The radius of the sphere for the radial explosion.
  70882. */
  70883. radius: number;
  70884. /**
  70885. * The strenth of the explosion.
  70886. */
  70887. strength: number;
  70888. /**
  70889. * The strenght of the force in correspondence to the distance of the affected object
  70890. */
  70891. falloff: PhysicsRadialImpulseFalloff;
  70892. /**
  70893. * Sphere options for the radial explosion.
  70894. */
  70895. sphere: {
  70896. segments: number;
  70897. diameter: number;
  70898. };
  70899. /**
  70900. * Sphere options for the radial explosion.
  70901. */
  70902. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70903. }
  70904. /**
  70905. * Options fot the updraft event
  70906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70907. */
  70908. export class PhysicsUpdraftEventOptions {
  70909. /**
  70910. * The radius of the cylinder for the vortex
  70911. */
  70912. radius: number;
  70913. /**
  70914. * The strenth of the updraft.
  70915. */
  70916. strength: number;
  70917. /**
  70918. * The height of the cylinder for the updraft.
  70919. */
  70920. height: number;
  70921. /**
  70922. * The mode for the the updraft.
  70923. */
  70924. updraftMode: PhysicsUpdraftMode;
  70925. }
  70926. /**
  70927. * Options fot the vortex event
  70928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70929. */
  70930. export class PhysicsVortexEventOptions {
  70931. /**
  70932. * The radius of the cylinder for the vortex
  70933. */
  70934. radius: number;
  70935. /**
  70936. * The strenth of the vortex.
  70937. */
  70938. strength: number;
  70939. /**
  70940. * The height of the cylinder for the vortex.
  70941. */
  70942. height: number;
  70943. /**
  70944. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70945. */
  70946. centripetalForceThreshold: number;
  70947. /**
  70948. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70949. */
  70950. centripetalForceMultiplier: number;
  70951. /**
  70952. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70953. */
  70954. centrifugalForceMultiplier: number;
  70955. /**
  70956. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70957. */
  70958. updraftForceMultiplier: number;
  70959. }
  70960. /**
  70961. * The strenght of the force in correspondence to the distance of the affected object
  70962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70963. */
  70964. export enum PhysicsRadialImpulseFalloff {
  70965. /** Defines that impulse is constant in strength across it's whole radius */
  70966. Constant = 0,
  70967. /** Defines that impulse gets weaker if it's further from the origin */
  70968. Linear = 1
  70969. }
  70970. /**
  70971. * The strength of the force in correspondence to the distance of the affected object
  70972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70973. */
  70974. export enum PhysicsUpdraftMode {
  70975. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70976. Center = 0,
  70977. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70978. Perpendicular = 1
  70979. }
  70980. /**
  70981. * Interface for a physics hit data
  70982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70983. */
  70984. export interface PhysicsHitData {
  70985. /**
  70986. * The force applied at the contact point
  70987. */
  70988. force: Vector3;
  70989. /**
  70990. * The contact point
  70991. */
  70992. contactPoint: Vector3;
  70993. /**
  70994. * The distance from the origin to the contact point
  70995. */
  70996. distanceFromOrigin: number;
  70997. }
  70998. /**
  70999. * Interface for radial explosion event data
  71000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71001. */
  71002. export interface PhysicsRadialExplosionEventData {
  71003. /**
  71004. * A sphere used for the radial explosion event
  71005. */
  71006. sphere: Mesh;
  71007. }
  71008. /**
  71009. * Interface for gravitational field event data
  71010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71011. */
  71012. export interface PhysicsGravitationalFieldEventData {
  71013. /**
  71014. * A sphere mesh used for the gravitational field event
  71015. */
  71016. sphere: Mesh;
  71017. }
  71018. /**
  71019. * Interface for updraft event data
  71020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71021. */
  71022. export interface PhysicsUpdraftEventData {
  71023. /**
  71024. * A cylinder used for the updraft event
  71025. */
  71026. cylinder: Mesh;
  71027. }
  71028. /**
  71029. * Interface for vortex event data
  71030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71031. */
  71032. export interface PhysicsVortexEventData {
  71033. /**
  71034. * A cylinder used for the vortex event
  71035. */
  71036. cylinder: Mesh;
  71037. }
  71038. /**
  71039. * Interface for an affected physics impostor
  71040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71041. */
  71042. export interface PhysicsAffectedImpostorWithData {
  71043. /**
  71044. * The impostor affected by the effect
  71045. */
  71046. impostor: PhysicsImpostor;
  71047. /**
  71048. * The data about the hit/horce from the explosion
  71049. */
  71050. hitData: PhysicsHitData;
  71051. }
  71052. }
  71053. declare module "babylonjs/Physics/Plugins/index" {
  71054. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71055. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71056. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71057. }
  71058. declare module "babylonjs/Physics/index" {
  71059. export * from "babylonjs/Physics/IPhysicsEngine";
  71060. export * from "babylonjs/Physics/physicsEngine";
  71061. export * from "babylonjs/Physics/physicsEngineComponent";
  71062. export * from "babylonjs/Physics/physicsHelper";
  71063. export * from "babylonjs/Physics/physicsImpostor";
  71064. export * from "babylonjs/Physics/physicsJoint";
  71065. export * from "babylonjs/Physics/Plugins/index";
  71066. }
  71067. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71068. /** @hidden */
  71069. export var blackAndWhitePixelShader: {
  71070. name: string;
  71071. shader: string;
  71072. };
  71073. }
  71074. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71075. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71076. import { Camera } from "babylonjs/Cameras/camera";
  71077. import { Engine } from "babylonjs/Engines/engine";
  71078. import "babylonjs/Shaders/blackAndWhite.fragment";
  71079. /**
  71080. * Post process used to render in black and white
  71081. */
  71082. export class BlackAndWhitePostProcess extends PostProcess {
  71083. /**
  71084. * Linear about to convert he result to black and white (default: 1)
  71085. */
  71086. degree: number;
  71087. /**
  71088. * Creates a black and white post process
  71089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71090. * @param name The name of the effect.
  71091. * @param options The required width/height ratio to downsize to before computing the render pass.
  71092. * @param camera The camera to apply the render pass to.
  71093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71094. * @param engine The engine which the post process will be applied. (default: current engine)
  71095. * @param reusable If the post process can be reused on the same frame. (default: false)
  71096. */
  71097. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71098. }
  71099. }
  71100. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71101. import { Nullable } from "babylonjs/types";
  71102. import { Camera } from "babylonjs/Cameras/camera";
  71103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71104. import { Engine } from "babylonjs/Engines/engine";
  71105. /**
  71106. * This represents a set of one or more post processes in Babylon.
  71107. * A post process can be used to apply a shader to a texture after it is rendered.
  71108. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71109. */
  71110. export class PostProcessRenderEffect {
  71111. private _postProcesses;
  71112. private _getPostProcesses;
  71113. private _singleInstance;
  71114. private _cameras;
  71115. private _indicesForCamera;
  71116. /**
  71117. * Name of the effect
  71118. * @hidden
  71119. */
  71120. _name: string;
  71121. /**
  71122. * Instantiates a post process render effect.
  71123. * A post process can be used to apply a shader to a texture after it is rendered.
  71124. * @param engine The engine the effect is tied to
  71125. * @param name The name of the effect
  71126. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71127. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71128. */
  71129. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71130. /**
  71131. * Checks if all the post processes in the effect are supported.
  71132. */
  71133. get isSupported(): boolean;
  71134. /**
  71135. * Updates the current state of the effect
  71136. * @hidden
  71137. */
  71138. _update(): void;
  71139. /**
  71140. * Attaches the effect on cameras
  71141. * @param cameras The camera to attach to.
  71142. * @hidden
  71143. */
  71144. _attachCameras(cameras: Camera): void;
  71145. /**
  71146. * Attaches the effect on cameras
  71147. * @param cameras The camera to attach to.
  71148. * @hidden
  71149. */
  71150. _attachCameras(cameras: Camera[]): void;
  71151. /**
  71152. * Detaches the effect on cameras
  71153. * @param cameras The camera to detatch from.
  71154. * @hidden
  71155. */
  71156. _detachCameras(cameras: Camera): void;
  71157. /**
  71158. * Detatches the effect on cameras
  71159. * @param cameras The camera to detatch from.
  71160. * @hidden
  71161. */
  71162. _detachCameras(cameras: Camera[]): void;
  71163. /**
  71164. * Enables the effect on given cameras
  71165. * @param cameras The camera to enable.
  71166. * @hidden
  71167. */
  71168. _enable(cameras: Camera): void;
  71169. /**
  71170. * Enables the effect on given cameras
  71171. * @param cameras The camera to enable.
  71172. * @hidden
  71173. */
  71174. _enable(cameras: Nullable<Camera[]>): void;
  71175. /**
  71176. * Disables the effect on the given cameras
  71177. * @param cameras The camera to disable.
  71178. * @hidden
  71179. */
  71180. _disable(cameras: Camera): void;
  71181. /**
  71182. * Disables the effect on the given cameras
  71183. * @param cameras The camera to disable.
  71184. * @hidden
  71185. */
  71186. _disable(cameras: Nullable<Camera[]>): void;
  71187. /**
  71188. * Gets a list of the post processes contained in the effect.
  71189. * @param camera The camera to get the post processes on.
  71190. * @returns The list of the post processes in the effect.
  71191. */
  71192. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71193. }
  71194. }
  71195. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71196. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71197. /** @hidden */
  71198. export var extractHighlightsPixelShader: {
  71199. name: string;
  71200. shader: string;
  71201. };
  71202. }
  71203. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71204. import { Nullable } from "babylonjs/types";
  71205. import { Camera } from "babylonjs/Cameras/camera";
  71206. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71207. import { Engine } from "babylonjs/Engines/engine";
  71208. import "babylonjs/Shaders/extractHighlights.fragment";
  71209. /**
  71210. * 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.
  71211. */
  71212. export class ExtractHighlightsPostProcess extends PostProcess {
  71213. /**
  71214. * The luminance threshold, pixels below this value will be set to black.
  71215. */
  71216. threshold: number;
  71217. /** @hidden */
  71218. _exposure: number;
  71219. /**
  71220. * Post process which has the input texture to be used when performing highlight extraction
  71221. * @hidden
  71222. */
  71223. _inputPostProcess: Nullable<PostProcess>;
  71224. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71225. }
  71226. }
  71227. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71228. /** @hidden */
  71229. export var bloomMergePixelShader: {
  71230. name: string;
  71231. shader: string;
  71232. };
  71233. }
  71234. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71236. import { Nullable } from "babylonjs/types";
  71237. import { Engine } from "babylonjs/Engines/engine";
  71238. import { Camera } from "babylonjs/Cameras/camera";
  71239. import "babylonjs/Shaders/bloomMerge.fragment";
  71240. /**
  71241. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71242. */
  71243. export class BloomMergePostProcess extends PostProcess {
  71244. /** Weight of the bloom to be added to the original input. */
  71245. weight: number;
  71246. /**
  71247. * Creates a new instance of @see BloomMergePostProcess
  71248. * @param name The name of the effect.
  71249. * @param originalFromInput Post process which's input will be used for the merge.
  71250. * @param blurred Blurred highlights post process which's output will be used.
  71251. * @param weight Weight of the bloom to be added to the original input.
  71252. * @param options The required width/height ratio to downsize to before computing the render pass.
  71253. * @param camera The camera to apply the render pass to.
  71254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71255. * @param engine The engine which the post process will be applied. (default: current engine)
  71256. * @param reusable If the post process can be reused on the same frame. (default: false)
  71257. * @param textureType Type of textures used when performing the post process. (default: 0)
  71258. * @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)
  71259. */
  71260. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71261. /** Weight of the bloom to be added to the original input. */
  71262. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71263. }
  71264. }
  71265. declare module "babylonjs/PostProcesses/bloomEffect" {
  71266. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71268. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71269. import { Camera } from "babylonjs/Cameras/camera";
  71270. import { Scene } from "babylonjs/scene";
  71271. /**
  71272. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71273. */
  71274. export class BloomEffect extends PostProcessRenderEffect {
  71275. private bloomScale;
  71276. /**
  71277. * @hidden Internal
  71278. */
  71279. _effects: Array<PostProcess>;
  71280. /**
  71281. * @hidden Internal
  71282. */
  71283. _downscale: ExtractHighlightsPostProcess;
  71284. private _blurX;
  71285. private _blurY;
  71286. private _merge;
  71287. /**
  71288. * The luminance threshold to find bright areas of the image to bloom.
  71289. */
  71290. get threshold(): number;
  71291. set threshold(value: number);
  71292. /**
  71293. * The strength of the bloom.
  71294. */
  71295. get weight(): number;
  71296. set weight(value: number);
  71297. /**
  71298. * Specifies the size of the bloom blur kernel, relative to the final output size
  71299. */
  71300. get kernel(): number;
  71301. set kernel(value: number);
  71302. /**
  71303. * Creates a new instance of @see BloomEffect
  71304. * @param scene The scene the effect belongs to.
  71305. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71306. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71307. * @param bloomWeight The the strength of bloom.
  71308. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71309. * @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)
  71310. */
  71311. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71312. /**
  71313. * Disposes each of the internal effects for a given camera.
  71314. * @param camera The camera to dispose the effect on.
  71315. */
  71316. disposeEffects(camera: Camera): void;
  71317. /**
  71318. * @hidden Internal
  71319. */
  71320. _updateEffects(): void;
  71321. /**
  71322. * Internal
  71323. * @returns if all the contained post processes are ready.
  71324. * @hidden
  71325. */
  71326. _isReady(): boolean;
  71327. }
  71328. }
  71329. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71330. /** @hidden */
  71331. export var chromaticAberrationPixelShader: {
  71332. name: string;
  71333. shader: string;
  71334. };
  71335. }
  71336. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71337. import { Vector2 } from "babylonjs/Maths/math.vector";
  71338. import { Nullable } from "babylonjs/types";
  71339. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71340. import { Camera } from "babylonjs/Cameras/camera";
  71341. import { Engine } from "babylonjs/Engines/engine";
  71342. import "babylonjs/Shaders/chromaticAberration.fragment";
  71343. /**
  71344. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71345. */
  71346. export class ChromaticAberrationPostProcess extends PostProcess {
  71347. /**
  71348. * The amount of seperation of rgb channels (default: 30)
  71349. */
  71350. aberrationAmount: number;
  71351. /**
  71352. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71353. */
  71354. radialIntensity: number;
  71355. /**
  71356. * 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))
  71357. */
  71358. direction: Vector2;
  71359. /**
  71360. * 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))
  71361. */
  71362. centerPosition: Vector2;
  71363. /**
  71364. * Creates a new instance ChromaticAberrationPostProcess
  71365. * @param name The name of the effect.
  71366. * @param screenWidth The width of the screen to apply the effect on.
  71367. * @param screenHeight The height of the screen to apply the effect on.
  71368. * @param options The required width/height ratio to downsize to before computing the render pass.
  71369. * @param camera The camera to apply the render pass to.
  71370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71371. * @param engine The engine which the post process will be applied. (default: current engine)
  71372. * @param reusable If the post process can be reused on the same frame. (default: false)
  71373. * @param textureType Type of textures used when performing the post process. (default: 0)
  71374. * @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)
  71375. */
  71376. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71377. }
  71378. }
  71379. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71380. /** @hidden */
  71381. export var circleOfConfusionPixelShader: {
  71382. name: string;
  71383. shader: string;
  71384. };
  71385. }
  71386. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71387. import { Nullable } from "babylonjs/types";
  71388. import { Engine } from "babylonjs/Engines/engine";
  71389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71391. import { Camera } from "babylonjs/Cameras/camera";
  71392. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71393. /**
  71394. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71395. */
  71396. export class CircleOfConfusionPostProcess extends PostProcess {
  71397. /**
  71398. * 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.
  71399. */
  71400. lensSize: number;
  71401. /**
  71402. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71403. */
  71404. fStop: number;
  71405. /**
  71406. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71407. */
  71408. focusDistance: number;
  71409. /**
  71410. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71411. */
  71412. focalLength: number;
  71413. private _depthTexture;
  71414. /**
  71415. * Creates a new instance CircleOfConfusionPostProcess
  71416. * @param name The name of the effect.
  71417. * @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.
  71418. * @param options The required width/height ratio to downsize to before computing the render pass.
  71419. * @param camera The camera to apply the render pass to.
  71420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71421. * @param engine The engine which the post process will be applied. (default: current engine)
  71422. * @param reusable If the post process can be reused on the same frame. (default: false)
  71423. * @param textureType Type of textures used when performing the post process. (default: 0)
  71424. * @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)
  71425. */
  71426. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71427. /**
  71428. * 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.
  71429. */
  71430. set depthTexture(value: RenderTargetTexture);
  71431. }
  71432. }
  71433. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71434. /** @hidden */
  71435. export var colorCorrectionPixelShader: {
  71436. name: string;
  71437. shader: string;
  71438. };
  71439. }
  71440. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71441. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71442. import { Engine } from "babylonjs/Engines/engine";
  71443. import { Camera } from "babylonjs/Cameras/camera";
  71444. import "babylonjs/Shaders/colorCorrection.fragment";
  71445. /**
  71446. *
  71447. * This post-process allows the modification of rendered colors by using
  71448. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71449. *
  71450. * The object needs to be provided an url to a texture containing the color
  71451. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71452. * Use an image editing software to tweak the LUT to match your needs.
  71453. *
  71454. * For an example of a color LUT, see here:
  71455. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71456. * For explanations on color grading, see here:
  71457. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71458. *
  71459. */
  71460. export class ColorCorrectionPostProcess extends PostProcess {
  71461. private _colorTableTexture;
  71462. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71463. }
  71464. }
  71465. declare module "babylonjs/Shaders/convolution.fragment" {
  71466. /** @hidden */
  71467. export var convolutionPixelShader: {
  71468. name: string;
  71469. shader: string;
  71470. };
  71471. }
  71472. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71474. import { Nullable } from "babylonjs/types";
  71475. import { Camera } from "babylonjs/Cameras/camera";
  71476. import { Engine } from "babylonjs/Engines/engine";
  71477. import "babylonjs/Shaders/convolution.fragment";
  71478. /**
  71479. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71480. * input texture to perform effects such as edge detection or sharpening
  71481. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71482. */
  71483. export class ConvolutionPostProcess extends PostProcess {
  71484. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71485. kernel: number[];
  71486. /**
  71487. * Creates a new instance ConvolutionPostProcess
  71488. * @param name The name of the effect.
  71489. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71490. * @param options The required width/height ratio to downsize to before computing the render pass.
  71491. * @param camera The camera to apply the render pass to.
  71492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71493. * @param engine The engine which the post process will be applied. (default: current engine)
  71494. * @param reusable If the post process can be reused on the same frame. (default: false)
  71495. * @param textureType Type of textures used when performing the post process. (default: 0)
  71496. */
  71497. constructor(name: string,
  71498. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71499. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71500. /**
  71501. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71502. */
  71503. static EdgeDetect0Kernel: number[];
  71504. /**
  71505. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71506. */
  71507. static EdgeDetect1Kernel: number[];
  71508. /**
  71509. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71510. */
  71511. static EdgeDetect2Kernel: number[];
  71512. /**
  71513. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71514. */
  71515. static SharpenKernel: number[];
  71516. /**
  71517. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71518. */
  71519. static EmbossKernel: number[];
  71520. /**
  71521. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71522. */
  71523. static GaussianKernel: number[];
  71524. }
  71525. }
  71526. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71527. import { Nullable } from "babylonjs/types";
  71528. import { Vector2 } from "babylonjs/Maths/math.vector";
  71529. import { Camera } from "babylonjs/Cameras/camera";
  71530. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71531. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71532. import { Engine } from "babylonjs/Engines/engine";
  71533. import { Scene } from "babylonjs/scene";
  71534. /**
  71535. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71536. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71537. * based on samples that have a large difference in distance than the center pixel.
  71538. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71539. */
  71540. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71541. direction: Vector2;
  71542. /**
  71543. * Creates a new instance CircleOfConfusionPostProcess
  71544. * @param name The name of the effect.
  71545. * @param scene The scene the effect belongs to.
  71546. * @param direction The direction the blur should be applied.
  71547. * @param kernel The size of the kernel used to blur.
  71548. * @param options The required width/height ratio to downsize to before computing the render pass.
  71549. * @param camera The camera to apply the render pass to.
  71550. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71551. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71553. * @param engine The engine which the post process will be applied. (default: current engine)
  71554. * @param reusable If the post process can be reused on the same frame. (default: false)
  71555. * @param textureType Type of textures used when performing the post process. (default: 0)
  71556. * @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)
  71557. */
  71558. 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);
  71559. }
  71560. }
  71561. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71562. /** @hidden */
  71563. export var depthOfFieldMergePixelShader: {
  71564. name: string;
  71565. shader: string;
  71566. };
  71567. }
  71568. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71569. import { Nullable } from "babylonjs/types";
  71570. import { Camera } from "babylonjs/Cameras/camera";
  71571. import { Effect } from "babylonjs/Materials/effect";
  71572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71573. import { Engine } from "babylonjs/Engines/engine";
  71574. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71575. /**
  71576. * Options to be set when merging outputs from the default pipeline.
  71577. */
  71578. export class DepthOfFieldMergePostProcessOptions {
  71579. /**
  71580. * The original image to merge on top of
  71581. */
  71582. originalFromInput: PostProcess;
  71583. /**
  71584. * Parameters to perform the merge of the depth of field effect
  71585. */
  71586. depthOfField?: {
  71587. circleOfConfusion: PostProcess;
  71588. blurSteps: Array<PostProcess>;
  71589. };
  71590. /**
  71591. * Parameters to perform the merge of bloom effect
  71592. */
  71593. bloom?: {
  71594. blurred: PostProcess;
  71595. weight: number;
  71596. };
  71597. }
  71598. /**
  71599. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71600. */
  71601. export class DepthOfFieldMergePostProcess extends PostProcess {
  71602. private blurSteps;
  71603. /**
  71604. * Creates a new instance of DepthOfFieldMergePostProcess
  71605. * @param name The name of the effect.
  71606. * @param originalFromInput Post process which's input will be used for the merge.
  71607. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71608. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71609. * @param options The required width/height ratio to downsize to before computing the render pass.
  71610. * @param camera The camera to apply the render pass to.
  71611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71612. * @param engine The engine which the post process will be applied. (default: current engine)
  71613. * @param reusable If the post process can be reused on the same frame. (default: false)
  71614. * @param textureType Type of textures used when performing the post process. (default: 0)
  71615. * @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)
  71616. */
  71617. 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);
  71618. /**
  71619. * Updates the effect with the current post process compile time values and recompiles the shader.
  71620. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71621. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71622. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71623. * @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
  71624. * @param onCompiled Called when the shader has been compiled.
  71625. * @param onError Called if there is an error when compiling a shader.
  71626. */
  71627. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71628. }
  71629. }
  71630. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71631. import { Nullable } from "babylonjs/types";
  71632. import { Camera } from "babylonjs/Cameras/camera";
  71633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71634. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71635. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71636. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71637. import { Scene } from "babylonjs/scene";
  71638. /**
  71639. * Specifies the level of max blur that should be applied when using the depth of field effect
  71640. */
  71641. export enum DepthOfFieldEffectBlurLevel {
  71642. /**
  71643. * Subtle blur
  71644. */
  71645. Low = 0,
  71646. /**
  71647. * Medium blur
  71648. */
  71649. Medium = 1,
  71650. /**
  71651. * Large blur
  71652. */
  71653. High = 2
  71654. }
  71655. /**
  71656. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71657. */
  71658. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71659. private _circleOfConfusion;
  71660. /**
  71661. * @hidden Internal, blurs from high to low
  71662. */
  71663. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71664. private _depthOfFieldBlurY;
  71665. private _dofMerge;
  71666. /**
  71667. * @hidden Internal post processes in depth of field effect
  71668. */
  71669. _effects: Array<PostProcess>;
  71670. /**
  71671. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71672. */
  71673. set focalLength(value: number);
  71674. get focalLength(): number;
  71675. /**
  71676. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71677. */
  71678. set fStop(value: number);
  71679. get fStop(): number;
  71680. /**
  71681. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71682. */
  71683. set focusDistance(value: number);
  71684. get focusDistance(): number;
  71685. /**
  71686. * 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.
  71687. */
  71688. set lensSize(value: number);
  71689. get lensSize(): number;
  71690. /**
  71691. * Creates a new instance DepthOfFieldEffect
  71692. * @param scene The scene the effect belongs to.
  71693. * @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.
  71694. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71695. * @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)
  71696. */
  71697. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71698. /**
  71699. * Get the current class name of the current effet
  71700. * @returns "DepthOfFieldEffect"
  71701. */
  71702. getClassName(): string;
  71703. /**
  71704. * 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.
  71705. */
  71706. set depthTexture(value: RenderTargetTexture);
  71707. /**
  71708. * Disposes each of the internal effects for a given camera.
  71709. * @param camera The camera to dispose the effect on.
  71710. */
  71711. disposeEffects(camera: Camera): void;
  71712. /**
  71713. * @hidden Internal
  71714. */
  71715. _updateEffects(): void;
  71716. /**
  71717. * Internal
  71718. * @returns if all the contained post processes are ready.
  71719. * @hidden
  71720. */
  71721. _isReady(): boolean;
  71722. }
  71723. }
  71724. declare module "babylonjs/Shaders/displayPass.fragment" {
  71725. /** @hidden */
  71726. export var displayPassPixelShader: {
  71727. name: string;
  71728. shader: string;
  71729. };
  71730. }
  71731. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71732. import { Nullable } from "babylonjs/types";
  71733. import { Camera } from "babylonjs/Cameras/camera";
  71734. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71735. import { Engine } from "babylonjs/Engines/engine";
  71736. import "babylonjs/Shaders/displayPass.fragment";
  71737. /**
  71738. * DisplayPassPostProcess which produces an output the same as it's input
  71739. */
  71740. export class DisplayPassPostProcess extends PostProcess {
  71741. /**
  71742. * Creates the DisplayPassPostProcess
  71743. * @param name The name of the effect.
  71744. * @param options The required width/height ratio to downsize to before computing the render pass.
  71745. * @param camera The camera to apply the render pass to.
  71746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71747. * @param engine The engine which the post process will be applied. (default: current engine)
  71748. * @param reusable If the post process can be reused on the same frame. (default: false)
  71749. */
  71750. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71751. }
  71752. }
  71753. declare module "babylonjs/Shaders/filter.fragment" {
  71754. /** @hidden */
  71755. export var filterPixelShader: {
  71756. name: string;
  71757. shader: string;
  71758. };
  71759. }
  71760. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71761. import { Nullable } from "babylonjs/types";
  71762. import { Matrix } from "babylonjs/Maths/math.vector";
  71763. import { Camera } from "babylonjs/Cameras/camera";
  71764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71765. import { Engine } from "babylonjs/Engines/engine";
  71766. import "babylonjs/Shaders/filter.fragment";
  71767. /**
  71768. * Applies a kernel filter to the image
  71769. */
  71770. export class FilterPostProcess extends PostProcess {
  71771. /** The matrix to be applied to the image */
  71772. kernelMatrix: Matrix;
  71773. /**
  71774. *
  71775. * @param name The name of the effect.
  71776. * @param kernelMatrix The matrix to be applied to the image
  71777. * @param options The required width/height ratio to downsize to before computing the render pass.
  71778. * @param camera The camera to apply the render pass to.
  71779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71780. * @param engine The engine which the post process will be applied. (default: current engine)
  71781. * @param reusable If the post process can be reused on the same frame. (default: false)
  71782. */
  71783. constructor(name: string,
  71784. /** The matrix to be applied to the image */
  71785. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71786. }
  71787. }
  71788. declare module "babylonjs/Shaders/fxaa.fragment" {
  71789. /** @hidden */
  71790. export var fxaaPixelShader: {
  71791. name: string;
  71792. shader: string;
  71793. };
  71794. }
  71795. declare module "babylonjs/Shaders/fxaa.vertex" {
  71796. /** @hidden */
  71797. export var fxaaVertexShader: {
  71798. name: string;
  71799. shader: string;
  71800. };
  71801. }
  71802. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71803. import { Nullable } from "babylonjs/types";
  71804. import { Camera } from "babylonjs/Cameras/camera";
  71805. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71806. import { Engine } from "babylonjs/Engines/engine";
  71807. import "babylonjs/Shaders/fxaa.fragment";
  71808. import "babylonjs/Shaders/fxaa.vertex";
  71809. /**
  71810. * Fxaa post process
  71811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71812. */
  71813. export class FxaaPostProcess extends PostProcess {
  71814. /** @hidden */
  71815. texelWidth: number;
  71816. /** @hidden */
  71817. texelHeight: number;
  71818. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71819. private _getDefines;
  71820. }
  71821. }
  71822. declare module "babylonjs/Shaders/grain.fragment" {
  71823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71824. /** @hidden */
  71825. export var grainPixelShader: {
  71826. name: string;
  71827. shader: string;
  71828. };
  71829. }
  71830. declare module "babylonjs/PostProcesses/grainPostProcess" {
  71831. import { Nullable } from "babylonjs/types";
  71832. import { Camera } from "babylonjs/Cameras/camera";
  71833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71834. import { Engine } from "babylonjs/Engines/engine";
  71835. import "babylonjs/Shaders/grain.fragment";
  71836. /**
  71837. * The GrainPostProcess adds noise to the image at mid luminance levels
  71838. */
  71839. export class GrainPostProcess extends PostProcess {
  71840. /**
  71841. * The intensity of the grain added (default: 30)
  71842. */
  71843. intensity: number;
  71844. /**
  71845. * If the grain should be randomized on every frame
  71846. */
  71847. animated: boolean;
  71848. /**
  71849. * Creates a new instance of @see GrainPostProcess
  71850. * @param name The name of the effect.
  71851. * @param options The required width/height ratio to downsize to before computing the render pass.
  71852. * @param camera The camera to apply the render pass to.
  71853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71854. * @param engine The engine which the post process will be applied. (default: current engine)
  71855. * @param reusable If the post process can be reused on the same frame. (default: false)
  71856. * @param textureType Type of textures used when performing the post process. (default: 0)
  71857. * @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)
  71858. */
  71859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71860. }
  71861. }
  71862. declare module "babylonjs/Shaders/highlights.fragment" {
  71863. /** @hidden */
  71864. export var highlightsPixelShader: {
  71865. name: string;
  71866. shader: string;
  71867. };
  71868. }
  71869. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  71870. import { Nullable } from "babylonjs/types";
  71871. import { Camera } from "babylonjs/Cameras/camera";
  71872. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71873. import { Engine } from "babylonjs/Engines/engine";
  71874. import "babylonjs/Shaders/highlights.fragment";
  71875. /**
  71876. * Extracts highlights from the image
  71877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71878. */
  71879. export class HighlightsPostProcess extends PostProcess {
  71880. /**
  71881. * Extracts highlights from the image
  71882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71883. * @param name The name of the effect.
  71884. * @param options The required width/height ratio to downsize to before computing the render pass.
  71885. * @param camera The camera to apply the render pass to.
  71886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71887. * @param engine The engine which the post process will be applied. (default: current engine)
  71888. * @param reusable If the post process can be reused on the same frame. (default: false)
  71889. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71890. */
  71891. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71892. }
  71893. }
  71894. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  71895. /** @hidden */
  71896. export var mrtFragmentDeclaration: {
  71897. name: string;
  71898. shader: string;
  71899. };
  71900. }
  71901. declare module "babylonjs/Shaders/geometry.fragment" {
  71902. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  71903. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  71904. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  71905. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  71906. /** @hidden */
  71907. export var geometryPixelShader: {
  71908. name: string;
  71909. shader: string;
  71910. };
  71911. }
  71912. declare module "babylonjs/Shaders/geometry.vertex" {
  71913. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71914. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71916. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71918. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71919. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71920. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  71921. /** @hidden */
  71922. export var geometryVertexShader: {
  71923. name: string;
  71924. shader: string;
  71925. };
  71926. }
  71927. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  71928. import { Matrix } from "babylonjs/Maths/math.vector";
  71929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71930. import { Mesh } from "babylonjs/Meshes/mesh";
  71931. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  71932. import { Effect } from "babylonjs/Materials/effect";
  71933. import { Scene } from "babylonjs/scene";
  71934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71935. import "babylonjs/Shaders/geometry.fragment";
  71936. import "babylonjs/Shaders/geometry.vertex";
  71937. /** @hidden */
  71938. interface ISavedTransformationMatrix {
  71939. world: Matrix;
  71940. viewProjection: Matrix;
  71941. }
  71942. /**
  71943. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  71944. */
  71945. export class GeometryBufferRenderer {
  71946. /**
  71947. * Constant used to retrieve the position texture index in the G-Buffer textures array
  71948. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  71949. */
  71950. static readonly POSITION_TEXTURE_TYPE: number;
  71951. /**
  71952. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  71953. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  71954. */
  71955. static readonly VELOCITY_TEXTURE_TYPE: number;
  71956. /**
  71957. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  71958. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  71959. */
  71960. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  71961. /**
  71962. * Dictionary used to store the previous transformation matrices of each rendered mesh
  71963. * in order to compute objects velocities when enableVelocity is set to "true"
  71964. * @hidden
  71965. */
  71966. _previousTransformationMatrices: {
  71967. [index: number]: ISavedTransformationMatrix;
  71968. };
  71969. /**
  71970. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  71971. * in order to compute objects velocities when enableVelocity is set to "true"
  71972. * @hidden
  71973. */
  71974. _previousBonesTransformationMatrices: {
  71975. [index: number]: Float32Array;
  71976. };
  71977. /**
  71978. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  71979. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  71980. */
  71981. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  71982. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  71983. renderTransparentMeshes: boolean;
  71984. private _scene;
  71985. private _multiRenderTarget;
  71986. private _ratio;
  71987. private _enablePosition;
  71988. private _enableVelocity;
  71989. private _enableReflectivity;
  71990. private _positionIndex;
  71991. private _velocityIndex;
  71992. private _reflectivityIndex;
  71993. protected _effect: Effect;
  71994. protected _cachedDefines: string;
  71995. /**
  71996. * Set the render list (meshes to be rendered) used in the G buffer.
  71997. */
  71998. set renderList(meshes: Mesh[]);
  71999. /**
  72000. * Gets wether or not G buffer are supported by the running hardware.
  72001. * This requires draw buffer supports
  72002. */
  72003. get isSupported(): boolean;
  72004. /**
  72005. * Returns the index of the given texture type in the G-Buffer textures array
  72006. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72007. * @returns the index of the given texture type in the G-Buffer textures array
  72008. */
  72009. getTextureIndex(textureType: number): number;
  72010. /**
  72011. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72012. */
  72013. get enablePosition(): boolean;
  72014. /**
  72015. * Sets whether or not objects positions are enabled for the G buffer.
  72016. */
  72017. set enablePosition(enable: boolean);
  72018. /**
  72019. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72020. */
  72021. get enableVelocity(): boolean;
  72022. /**
  72023. * Sets wether or not objects velocities are enabled for the G buffer.
  72024. */
  72025. set enableVelocity(enable: boolean);
  72026. /**
  72027. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72028. */
  72029. get enableReflectivity(): boolean;
  72030. /**
  72031. * Sets wether or not objects roughness are enabled for the G buffer.
  72032. */
  72033. set enableReflectivity(enable: boolean);
  72034. /**
  72035. * Gets the scene associated with the buffer.
  72036. */
  72037. get scene(): Scene;
  72038. /**
  72039. * Gets the ratio used by the buffer during its creation.
  72040. * How big is the buffer related to the main canvas.
  72041. */
  72042. get ratio(): number;
  72043. /** @hidden */
  72044. static _SceneComponentInitialization: (scene: Scene) => void;
  72045. /**
  72046. * Creates a new G Buffer for the scene
  72047. * @param scene The scene the buffer belongs to
  72048. * @param ratio How big is the buffer related to the main canvas.
  72049. */
  72050. constructor(scene: Scene, ratio?: number);
  72051. /**
  72052. * Checks wether everything is ready to render a submesh to the G buffer.
  72053. * @param subMesh the submesh to check readiness for
  72054. * @param useInstances is the mesh drawn using instance or not
  72055. * @returns true if ready otherwise false
  72056. */
  72057. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72058. /**
  72059. * Gets the current underlying G Buffer.
  72060. * @returns the buffer
  72061. */
  72062. getGBuffer(): MultiRenderTarget;
  72063. /**
  72064. * Gets the number of samples used to render the buffer (anti aliasing).
  72065. */
  72066. get samples(): number;
  72067. /**
  72068. * Sets the number of samples used to render the buffer (anti aliasing).
  72069. */
  72070. set samples(value: number);
  72071. /**
  72072. * Disposes the renderer and frees up associated resources.
  72073. */
  72074. dispose(): void;
  72075. protected _createRenderTargets(): void;
  72076. private _copyBonesTransformationMatrices;
  72077. }
  72078. }
  72079. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72080. import { Nullable } from "babylonjs/types";
  72081. import { Scene } from "babylonjs/scene";
  72082. import { ISceneComponent } from "babylonjs/sceneComponent";
  72083. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72084. module "babylonjs/scene" {
  72085. interface Scene {
  72086. /** @hidden (Backing field) */
  72087. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72088. /**
  72089. * Gets or Sets the current geometry buffer associated to the scene.
  72090. */
  72091. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72092. /**
  72093. * Enables a GeometryBufferRender and associates it with the scene
  72094. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72095. * @returns the GeometryBufferRenderer
  72096. */
  72097. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72098. /**
  72099. * Disables the GeometryBufferRender associated with the scene
  72100. */
  72101. disableGeometryBufferRenderer(): void;
  72102. }
  72103. }
  72104. /**
  72105. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72106. * in several rendering techniques.
  72107. */
  72108. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72109. /**
  72110. * The component name helpful to identify the component in the list of scene components.
  72111. */
  72112. readonly name: string;
  72113. /**
  72114. * The scene the component belongs to.
  72115. */
  72116. scene: Scene;
  72117. /**
  72118. * Creates a new instance of the component for the given scene
  72119. * @param scene Defines the scene to register the component in
  72120. */
  72121. constructor(scene: Scene);
  72122. /**
  72123. * Registers the component in a given scene
  72124. */
  72125. register(): void;
  72126. /**
  72127. * Rebuilds the elements related to this component in case of
  72128. * context lost for instance.
  72129. */
  72130. rebuild(): void;
  72131. /**
  72132. * Disposes the component and the associated ressources
  72133. */
  72134. dispose(): void;
  72135. private _gatherRenderTargets;
  72136. }
  72137. }
  72138. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72139. /** @hidden */
  72140. export var motionBlurPixelShader: {
  72141. name: string;
  72142. shader: string;
  72143. };
  72144. }
  72145. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72146. import { Nullable } from "babylonjs/types";
  72147. import { Camera } from "babylonjs/Cameras/camera";
  72148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72149. import { Scene } from "babylonjs/scene";
  72150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72151. import "babylonjs/Animations/animatable";
  72152. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72153. import "babylonjs/Shaders/motionBlur.fragment";
  72154. import { Engine } from "babylonjs/Engines/engine";
  72155. /**
  72156. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72157. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72158. * As an example, all you have to do is to create the post-process:
  72159. * var mb = new BABYLON.MotionBlurPostProcess(
  72160. * 'mb', // The name of the effect.
  72161. * scene, // The scene containing the objects to blur according to their velocity.
  72162. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72163. * camera // The camera to apply the render pass to.
  72164. * );
  72165. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72166. */
  72167. export class MotionBlurPostProcess extends PostProcess {
  72168. /**
  72169. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72170. */
  72171. motionStrength: number;
  72172. /**
  72173. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72174. */
  72175. get motionBlurSamples(): number;
  72176. /**
  72177. * Sets the number of iterations to be used for motion blur quality
  72178. */
  72179. set motionBlurSamples(samples: number);
  72180. private _motionBlurSamples;
  72181. private _geometryBufferRenderer;
  72182. /**
  72183. * Creates a new instance MotionBlurPostProcess
  72184. * @param name The name of the effect.
  72185. * @param scene The scene containing the objects to blur according to their velocity.
  72186. * @param options The required width/height ratio to downsize to before computing the render pass.
  72187. * @param camera The camera to apply the render pass to.
  72188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72189. * @param engine The engine which the post process will be applied. (default: current engine)
  72190. * @param reusable If the post process can be reused on the same frame. (default: false)
  72191. * @param textureType Type of textures used when performing the post process. (default: 0)
  72192. * @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)
  72193. */
  72194. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72195. /**
  72196. * Excludes the given skinned mesh from computing bones velocities.
  72197. * 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.
  72198. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72199. */
  72200. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72201. /**
  72202. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72203. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72204. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72205. */
  72206. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72207. /**
  72208. * Disposes the post process.
  72209. * @param camera The camera to dispose the post process on.
  72210. */
  72211. dispose(camera?: Camera): void;
  72212. }
  72213. }
  72214. declare module "babylonjs/Shaders/refraction.fragment" {
  72215. /** @hidden */
  72216. export var refractionPixelShader: {
  72217. name: string;
  72218. shader: string;
  72219. };
  72220. }
  72221. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72222. import { Color3 } from "babylonjs/Maths/math.color";
  72223. import { Camera } from "babylonjs/Cameras/camera";
  72224. import { Texture } from "babylonjs/Materials/Textures/texture";
  72225. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72226. import { Engine } from "babylonjs/Engines/engine";
  72227. import "babylonjs/Shaders/refraction.fragment";
  72228. /**
  72229. * Post process which applies a refractin texture
  72230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72231. */
  72232. export class RefractionPostProcess extends PostProcess {
  72233. /** the base color of the refraction (used to taint the rendering) */
  72234. color: Color3;
  72235. /** simulated refraction depth */
  72236. depth: number;
  72237. /** the coefficient of the base color (0 to remove base color tainting) */
  72238. colorLevel: number;
  72239. private _refTexture;
  72240. private _ownRefractionTexture;
  72241. /**
  72242. * Gets or sets the refraction texture
  72243. * Please note that you are responsible for disposing the texture if you set it manually
  72244. */
  72245. get refractionTexture(): Texture;
  72246. set refractionTexture(value: Texture);
  72247. /**
  72248. * Initializes the RefractionPostProcess
  72249. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72250. * @param name The name of the effect.
  72251. * @param refractionTextureUrl Url of the refraction texture to use
  72252. * @param color the base color of the refraction (used to taint the rendering)
  72253. * @param depth simulated refraction depth
  72254. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72255. * @param camera The camera to apply the render pass to.
  72256. * @param options The required width/height ratio to downsize to before computing the render pass.
  72257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72258. * @param engine The engine which the post process will be applied. (default: current engine)
  72259. * @param reusable If the post process can be reused on the same frame. (default: false)
  72260. */
  72261. constructor(name: string, refractionTextureUrl: string,
  72262. /** the base color of the refraction (used to taint the rendering) */
  72263. color: Color3,
  72264. /** simulated refraction depth */
  72265. depth: number,
  72266. /** the coefficient of the base color (0 to remove base color tainting) */
  72267. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72268. /**
  72269. * Disposes of the post process
  72270. * @param camera Camera to dispose post process on
  72271. */
  72272. dispose(camera: Camera): void;
  72273. }
  72274. }
  72275. declare module "babylonjs/Shaders/sharpen.fragment" {
  72276. /** @hidden */
  72277. export var sharpenPixelShader: {
  72278. name: string;
  72279. shader: string;
  72280. };
  72281. }
  72282. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72283. import { Nullable } from "babylonjs/types";
  72284. import { Camera } from "babylonjs/Cameras/camera";
  72285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72286. import "babylonjs/Shaders/sharpen.fragment";
  72287. import { Engine } from "babylonjs/Engines/engine";
  72288. /**
  72289. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72290. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72291. */
  72292. export class SharpenPostProcess extends PostProcess {
  72293. /**
  72294. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72295. */
  72296. colorAmount: number;
  72297. /**
  72298. * How much sharpness should be applied (default: 0.3)
  72299. */
  72300. edgeAmount: number;
  72301. /**
  72302. * Creates a new instance ConvolutionPostProcess
  72303. * @param name The name of the effect.
  72304. * @param options The required width/height ratio to downsize to before computing the render pass.
  72305. * @param camera The camera to apply the render pass to.
  72306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72307. * @param engine The engine which the post process will be applied. (default: current engine)
  72308. * @param reusable If the post process can be reused on the same frame. (default: false)
  72309. * @param textureType Type of textures used when performing the post process. (default: 0)
  72310. * @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)
  72311. */
  72312. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72313. }
  72314. }
  72315. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72316. import { Nullable } from "babylonjs/types";
  72317. import { Camera } from "babylonjs/Cameras/camera";
  72318. import { Engine } from "babylonjs/Engines/engine";
  72319. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72320. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72321. /**
  72322. * PostProcessRenderPipeline
  72323. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72324. */
  72325. export class PostProcessRenderPipeline {
  72326. private engine;
  72327. private _renderEffects;
  72328. private _renderEffectsForIsolatedPass;
  72329. /**
  72330. * List of inspectable custom properties (used by the Inspector)
  72331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72332. */
  72333. inspectableCustomProperties: IInspectable[];
  72334. /**
  72335. * @hidden
  72336. */
  72337. protected _cameras: Camera[];
  72338. /** @hidden */
  72339. _name: string;
  72340. /**
  72341. * Gets pipeline name
  72342. */
  72343. get name(): string;
  72344. /** Gets the list of attached cameras */
  72345. get cameras(): Camera[];
  72346. /**
  72347. * Initializes a PostProcessRenderPipeline
  72348. * @param engine engine to add the pipeline to
  72349. * @param name name of the pipeline
  72350. */
  72351. constructor(engine: Engine, name: string);
  72352. /**
  72353. * Gets the class name
  72354. * @returns "PostProcessRenderPipeline"
  72355. */
  72356. getClassName(): string;
  72357. /**
  72358. * If all the render effects in the pipeline are supported
  72359. */
  72360. get isSupported(): boolean;
  72361. /**
  72362. * Adds an effect to the pipeline
  72363. * @param renderEffect the effect to add
  72364. */
  72365. addEffect(renderEffect: PostProcessRenderEffect): void;
  72366. /** @hidden */
  72367. _rebuild(): void;
  72368. /** @hidden */
  72369. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72370. /** @hidden */
  72371. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72372. /** @hidden */
  72373. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72374. /** @hidden */
  72375. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72376. /** @hidden */
  72377. _attachCameras(cameras: Camera, unique: boolean): void;
  72378. /** @hidden */
  72379. _attachCameras(cameras: Camera[], unique: boolean): void;
  72380. /** @hidden */
  72381. _detachCameras(cameras: Camera): void;
  72382. /** @hidden */
  72383. _detachCameras(cameras: Nullable<Camera[]>): void;
  72384. /** @hidden */
  72385. _update(): void;
  72386. /** @hidden */
  72387. _reset(): void;
  72388. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72389. /**
  72390. * Disposes of the pipeline
  72391. */
  72392. dispose(): void;
  72393. }
  72394. }
  72395. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72396. import { Camera } from "babylonjs/Cameras/camera";
  72397. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72398. /**
  72399. * PostProcessRenderPipelineManager class
  72400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72401. */
  72402. export class PostProcessRenderPipelineManager {
  72403. private _renderPipelines;
  72404. /**
  72405. * Initializes a PostProcessRenderPipelineManager
  72406. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72407. */
  72408. constructor();
  72409. /**
  72410. * Gets the list of supported render pipelines
  72411. */
  72412. get supportedPipelines(): PostProcessRenderPipeline[];
  72413. /**
  72414. * Adds a pipeline to the manager
  72415. * @param renderPipeline The pipeline to add
  72416. */
  72417. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72418. /**
  72419. * Attaches a camera to the pipeline
  72420. * @param renderPipelineName The name of the pipeline to attach to
  72421. * @param cameras the camera to attach
  72422. * @param unique if the camera can be attached multiple times to the pipeline
  72423. */
  72424. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72425. /**
  72426. * Detaches a camera from the pipeline
  72427. * @param renderPipelineName The name of the pipeline to detach from
  72428. * @param cameras the camera to detach
  72429. */
  72430. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72431. /**
  72432. * Enables an effect by name on a pipeline
  72433. * @param renderPipelineName the name of the pipeline to enable the effect in
  72434. * @param renderEffectName the name of the effect to enable
  72435. * @param cameras the cameras that the effect should be enabled on
  72436. */
  72437. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72438. /**
  72439. * Disables an effect by name on a pipeline
  72440. * @param renderPipelineName the name of the pipeline to disable the effect in
  72441. * @param renderEffectName the name of the effect to disable
  72442. * @param cameras the cameras that the effect should be disabled on
  72443. */
  72444. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72445. /**
  72446. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72447. */
  72448. update(): void;
  72449. /** @hidden */
  72450. _rebuild(): void;
  72451. /**
  72452. * Disposes of the manager and pipelines
  72453. */
  72454. dispose(): void;
  72455. }
  72456. }
  72457. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72458. import { ISceneComponent } from "babylonjs/sceneComponent";
  72459. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72460. import { Scene } from "babylonjs/scene";
  72461. module "babylonjs/scene" {
  72462. interface Scene {
  72463. /** @hidden (Backing field) */
  72464. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72465. /**
  72466. * Gets the postprocess render pipeline manager
  72467. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72468. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72469. */
  72470. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72471. }
  72472. }
  72473. /**
  72474. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72475. */
  72476. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72477. /**
  72478. * The component name helpfull to identify the component in the list of scene components.
  72479. */
  72480. readonly name: string;
  72481. /**
  72482. * The scene the component belongs to.
  72483. */
  72484. scene: Scene;
  72485. /**
  72486. * Creates a new instance of the component for the given scene
  72487. * @param scene Defines the scene to register the component in
  72488. */
  72489. constructor(scene: Scene);
  72490. /**
  72491. * Registers the component in a given scene
  72492. */
  72493. register(): void;
  72494. /**
  72495. * Rebuilds the elements related to this component in case of
  72496. * context lost for instance.
  72497. */
  72498. rebuild(): void;
  72499. /**
  72500. * Disposes the component and the associated ressources
  72501. */
  72502. dispose(): void;
  72503. private _gatherRenderTargets;
  72504. }
  72505. }
  72506. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72507. import { Nullable } from "babylonjs/types";
  72508. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72509. import { Camera } from "babylonjs/Cameras/camera";
  72510. import { IDisposable } from "babylonjs/scene";
  72511. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72512. import { Scene } from "babylonjs/scene";
  72513. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72514. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72515. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72516. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72517. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72518. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72519. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72520. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72521. import { Animation } from "babylonjs/Animations/animation";
  72522. /**
  72523. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72524. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72525. */
  72526. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72527. private _scene;
  72528. private _camerasToBeAttached;
  72529. /**
  72530. * ID of the sharpen post process,
  72531. */
  72532. private readonly SharpenPostProcessId;
  72533. /**
  72534. * @ignore
  72535. * ID of the image processing post process;
  72536. */
  72537. readonly ImageProcessingPostProcessId: string;
  72538. /**
  72539. * @ignore
  72540. * ID of the Fast Approximate Anti-Aliasing post process;
  72541. */
  72542. readonly FxaaPostProcessId: string;
  72543. /**
  72544. * ID of the chromatic aberration post process,
  72545. */
  72546. private readonly ChromaticAberrationPostProcessId;
  72547. /**
  72548. * ID of the grain post process
  72549. */
  72550. private readonly GrainPostProcessId;
  72551. /**
  72552. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72553. */
  72554. sharpen: SharpenPostProcess;
  72555. private _sharpenEffect;
  72556. private bloom;
  72557. /**
  72558. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72559. */
  72560. depthOfField: DepthOfFieldEffect;
  72561. /**
  72562. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72563. */
  72564. fxaa: FxaaPostProcess;
  72565. /**
  72566. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72567. */
  72568. imageProcessing: ImageProcessingPostProcess;
  72569. /**
  72570. * Chromatic aberration post process which will shift rgb colors in the image
  72571. */
  72572. chromaticAberration: ChromaticAberrationPostProcess;
  72573. private _chromaticAberrationEffect;
  72574. /**
  72575. * Grain post process which add noise to the image
  72576. */
  72577. grain: GrainPostProcess;
  72578. private _grainEffect;
  72579. /**
  72580. * Glow post process which adds a glow to emissive areas of the image
  72581. */
  72582. private _glowLayer;
  72583. /**
  72584. * Animations which can be used to tweak settings over a period of time
  72585. */
  72586. animations: Animation[];
  72587. private _imageProcessingConfigurationObserver;
  72588. private _sharpenEnabled;
  72589. private _bloomEnabled;
  72590. private _depthOfFieldEnabled;
  72591. private _depthOfFieldBlurLevel;
  72592. private _fxaaEnabled;
  72593. private _imageProcessingEnabled;
  72594. private _defaultPipelineTextureType;
  72595. private _bloomScale;
  72596. private _chromaticAberrationEnabled;
  72597. private _grainEnabled;
  72598. private _buildAllowed;
  72599. /**
  72600. * Gets active scene
  72601. */
  72602. get scene(): Scene;
  72603. /**
  72604. * Enable or disable the sharpen process from the pipeline
  72605. */
  72606. set sharpenEnabled(enabled: boolean);
  72607. get sharpenEnabled(): boolean;
  72608. private _resizeObserver;
  72609. private _hardwareScaleLevel;
  72610. private _bloomKernel;
  72611. /**
  72612. * Specifies the size of the bloom blur kernel, relative to the final output size
  72613. */
  72614. get bloomKernel(): number;
  72615. set bloomKernel(value: number);
  72616. /**
  72617. * Specifies the weight of the bloom in the final rendering
  72618. */
  72619. private _bloomWeight;
  72620. /**
  72621. * Specifies the luma threshold for the area that will be blurred by the bloom
  72622. */
  72623. private _bloomThreshold;
  72624. private _hdr;
  72625. /**
  72626. * The strength of the bloom.
  72627. */
  72628. set bloomWeight(value: number);
  72629. get bloomWeight(): number;
  72630. /**
  72631. * The strength of the bloom.
  72632. */
  72633. set bloomThreshold(value: number);
  72634. get bloomThreshold(): number;
  72635. /**
  72636. * The scale of the bloom, lower value will provide better performance.
  72637. */
  72638. set bloomScale(value: number);
  72639. get bloomScale(): number;
  72640. /**
  72641. * Enable or disable the bloom from the pipeline
  72642. */
  72643. set bloomEnabled(enabled: boolean);
  72644. get bloomEnabled(): boolean;
  72645. private _rebuildBloom;
  72646. /**
  72647. * If the depth of field is enabled.
  72648. */
  72649. get depthOfFieldEnabled(): boolean;
  72650. set depthOfFieldEnabled(enabled: boolean);
  72651. /**
  72652. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72653. */
  72654. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72655. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72656. /**
  72657. * If the anti aliasing is enabled.
  72658. */
  72659. set fxaaEnabled(enabled: boolean);
  72660. get fxaaEnabled(): boolean;
  72661. private _samples;
  72662. /**
  72663. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72664. */
  72665. set samples(sampleCount: number);
  72666. get samples(): number;
  72667. /**
  72668. * If image processing is enabled.
  72669. */
  72670. set imageProcessingEnabled(enabled: boolean);
  72671. get imageProcessingEnabled(): boolean;
  72672. /**
  72673. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72674. */
  72675. set glowLayerEnabled(enabled: boolean);
  72676. get glowLayerEnabled(): boolean;
  72677. /**
  72678. * Gets the glow layer (or null if not defined)
  72679. */
  72680. get glowLayer(): Nullable<GlowLayer>;
  72681. /**
  72682. * Enable or disable the chromaticAberration process from the pipeline
  72683. */
  72684. set chromaticAberrationEnabled(enabled: boolean);
  72685. get chromaticAberrationEnabled(): boolean;
  72686. /**
  72687. * Enable or disable the grain process from the pipeline
  72688. */
  72689. set grainEnabled(enabled: boolean);
  72690. get grainEnabled(): boolean;
  72691. /**
  72692. * @constructor
  72693. * @param name - The rendering pipeline name (default: "")
  72694. * @param hdr - If high dynamic range textures should be used (default: true)
  72695. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72696. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72697. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72698. */
  72699. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72700. /**
  72701. * Get the class name
  72702. * @returns "DefaultRenderingPipeline"
  72703. */
  72704. getClassName(): string;
  72705. /**
  72706. * Force the compilation of the entire pipeline.
  72707. */
  72708. prepare(): void;
  72709. private _hasCleared;
  72710. private _prevPostProcess;
  72711. private _prevPrevPostProcess;
  72712. private _setAutoClearAndTextureSharing;
  72713. private _depthOfFieldSceneObserver;
  72714. private _buildPipeline;
  72715. private _disposePostProcesses;
  72716. /**
  72717. * Adds a camera to the pipeline
  72718. * @param camera the camera to be added
  72719. */
  72720. addCamera(camera: Camera): void;
  72721. /**
  72722. * Removes a camera from the pipeline
  72723. * @param camera the camera to remove
  72724. */
  72725. removeCamera(camera: Camera): void;
  72726. /**
  72727. * Dispose of the pipeline and stop all post processes
  72728. */
  72729. dispose(): void;
  72730. /**
  72731. * Serialize the rendering pipeline (Used when exporting)
  72732. * @returns the serialized object
  72733. */
  72734. serialize(): any;
  72735. /**
  72736. * Parse the serialized pipeline
  72737. * @param source Source pipeline.
  72738. * @param scene The scene to load the pipeline to.
  72739. * @param rootUrl The URL of the serialized pipeline.
  72740. * @returns An instantiated pipeline from the serialized object.
  72741. */
  72742. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72743. }
  72744. }
  72745. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72746. /** @hidden */
  72747. export var lensHighlightsPixelShader: {
  72748. name: string;
  72749. shader: string;
  72750. };
  72751. }
  72752. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72753. /** @hidden */
  72754. export var depthOfFieldPixelShader: {
  72755. name: string;
  72756. shader: string;
  72757. };
  72758. }
  72759. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72760. import { Camera } from "babylonjs/Cameras/camera";
  72761. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72762. import { Scene } from "babylonjs/scene";
  72763. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72764. import "babylonjs/Shaders/chromaticAberration.fragment";
  72765. import "babylonjs/Shaders/lensHighlights.fragment";
  72766. import "babylonjs/Shaders/depthOfField.fragment";
  72767. /**
  72768. * BABYLON.JS Chromatic Aberration GLSL Shader
  72769. * Author: Olivier Guyot
  72770. * Separates very slightly R, G and B colors on the edges of the screen
  72771. * Inspired by Francois Tarlier & Martins Upitis
  72772. */
  72773. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72774. /**
  72775. * @ignore
  72776. * The chromatic aberration PostProcess id in the pipeline
  72777. */
  72778. LensChromaticAberrationEffect: string;
  72779. /**
  72780. * @ignore
  72781. * The highlights enhancing PostProcess id in the pipeline
  72782. */
  72783. HighlightsEnhancingEffect: string;
  72784. /**
  72785. * @ignore
  72786. * The depth-of-field PostProcess id in the pipeline
  72787. */
  72788. LensDepthOfFieldEffect: string;
  72789. private _scene;
  72790. private _depthTexture;
  72791. private _grainTexture;
  72792. private _chromaticAberrationPostProcess;
  72793. private _highlightsPostProcess;
  72794. private _depthOfFieldPostProcess;
  72795. private _edgeBlur;
  72796. private _grainAmount;
  72797. private _chromaticAberration;
  72798. private _distortion;
  72799. private _highlightsGain;
  72800. private _highlightsThreshold;
  72801. private _dofDistance;
  72802. private _dofAperture;
  72803. private _dofDarken;
  72804. private _dofPentagon;
  72805. private _blurNoise;
  72806. /**
  72807. * @constructor
  72808. *
  72809. * Effect parameters are as follow:
  72810. * {
  72811. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72812. * edge_blur: number; // from 0 to x (1 for realism)
  72813. * distortion: number; // from 0 to x (1 for realism)
  72814. * grain_amount: number; // from 0 to 1
  72815. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72816. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72817. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72818. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72819. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72820. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72821. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72822. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72823. * }
  72824. * Note: if an effect parameter is unset, effect is disabled
  72825. *
  72826. * @param name The rendering pipeline name
  72827. * @param parameters - An object containing all parameters (see above)
  72828. * @param scene The scene linked to this pipeline
  72829. * @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)
  72830. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72831. */
  72832. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72833. /**
  72834. * Get the class name
  72835. * @returns "LensRenderingPipeline"
  72836. */
  72837. getClassName(): string;
  72838. /**
  72839. * Gets associated scene
  72840. */
  72841. get scene(): Scene;
  72842. /**
  72843. * Gets or sets the edge blur
  72844. */
  72845. get edgeBlur(): number;
  72846. set edgeBlur(value: number);
  72847. /**
  72848. * Gets or sets the grain amount
  72849. */
  72850. get grainAmount(): number;
  72851. set grainAmount(value: number);
  72852. /**
  72853. * Gets or sets the chromatic aberration amount
  72854. */
  72855. get chromaticAberration(): number;
  72856. set chromaticAberration(value: number);
  72857. /**
  72858. * Gets or sets the depth of field aperture
  72859. */
  72860. get dofAperture(): number;
  72861. set dofAperture(value: number);
  72862. /**
  72863. * Gets or sets the edge distortion
  72864. */
  72865. get edgeDistortion(): number;
  72866. set edgeDistortion(value: number);
  72867. /**
  72868. * Gets or sets the depth of field distortion
  72869. */
  72870. get dofDistortion(): number;
  72871. set dofDistortion(value: number);
  72872. /**
  72873. * Gets or sets the darken out of focus amount
  72874. */
  72875. get darkenOutOfFocus(): number;
  72876. set darkenOutOfFocus(value: number);
  72877. /**
  72878. * Gets or sets a boolean indicating if blur noise is enabled
  72879. */
  72880. get blurNoise(): boolean;
  72881. set blurNoise(value: boolean);
  72882. /**
  72883. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72884. */
  72885. get pentagonBokeh(): boolean;
  72886. set pentagonBokeh(value: boolean);
  72887. /**
  72888. * Gets or sets the highlight grain amount
  72889. */
  72890. get highlightsGain(): number;
  72891. set highlightsGain(value: number);
  72892. /**
  72893. * Gets or sets the highlight threshold
  72894. */
  72895. get highlightsThreshold(): number;
  72896. set highlightsThreshold(value: number);
  72897. /**
  72898. * Sets the amount of blur at the edges
  72899. * @param amount blur amount
  72900. */
  72901. setEdgeBlur(amount: number): void;
  72902. /**
  72903. * Sets edge blur to 0
  72904. */
  72905. disableEdgeBlur(): void;
  72906. /**
  72907. * Sets the amout of grain
  72908. * @param amount Amount of grain
  72909. */
  72910. setGrainAmount(amount: number): void;
  72911. /**
  72912. * Set grain amount to 0
  72913. */
  72914. disableGrain(): void;
  72915. /**
  72916. * Sets the chromatic aberration amount
  72917. * @param amount amount of chromatic aberration
  72918. */
  72919. setChromaticAberration(amount: number): void;
  72920. /**
  72921. * Sets chromatic aberration amount to 0
  72922. */
  72923. disableChromaticAberration(): void;
  72924. /**
  72925. * Sets the EdgeDistortion amount
  72926. * @param amount amount of EdgeDistortion
  72927. */
  72928. setEdgeDistortion(amount: number): void;
  72929. /**
  72930. * Sets edge distortion to 0
  72931. */
  72932. disableEdgeDistortion(): void;
  72933. /**
  72934. * Sets the FocusDistance amount
  72935. * @param amount amount of FocusDistance
  72936. */
  72937. setFocusDistance(amount: number): void;
  72938. /**
  72939. * Disables depth of field
  72940. */
  72941. disableDepthOfField(): void;
  72942. /**
  72943. * Sets the Aperture amount
  72944. * @param amount amount of Aperture
  72945. */
  72946. setAperture(amount: number): void;
  72947. /**
  72948. * Sets the DarkenOutOfFocus amount
  72949. * @param amount amount of DarkenOutOfFocus
  72950. */
  72951. setDarkenOutOfFocus(amount: number): void;
  72952. private _pentagonBokehIsEnabled;
  72953. /**
  72954. * Creates a pentagon bokeh effect
  72955. */
  72956. enablePentagonBokeh(): void;
  72957. /**
  72958. * Disables the pentagon bokeh effect
  72959. */
  72960. disablePentagonBokeh(): void;
  72961. /**
  72962. * Enables noise blur
  72963. */
  72964. enableNoiseBlur(): void;
  72965. /**
  72966. * Disables noise blur
  72967. */
  72968. disableNoiseBlur(): void;
  72969. /**
  72970. * Sets the HighlightsGain amount
  72971. * @param amount amount of HighlightsGain
  72972. */
  72973. setHighlightsGain(amount: number): void;
  72974. /**
  72975. * Sets the HighlightsThreshold amount
  72976. * @param amount amount of HighlightsThreshold
  72977. */
  72978. setHighlightsThreshold(amount: number): void;
  72979. /**
  72980. * Disables highlights
  72981. */
  72982. disableHighlights(): void;
  72983. /**
  72984. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72985. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72986. */
  72987. dispose(disableDepthRender?: boolean): void;
  72988. private _createChromaticAberrationPostProcess;
  72989. private _createHighlightsPostProcess;
  72990. private _createDepthOfFieldPostProcess;
  72991. private _createGrainTexture;
  72992. }
  72993. }
  72994. declare module "babylonjs/Shaders/ssao2.fragment" {
  72995. /** @hidden */
  72996. export var ssao2PixelShader: {
  72997. name: string;
  72998. shader: string;
  72999. };
  73000. }
  73001. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73002. /** @hidden */
  73003. export var ssaoCombinePixelShader: {
  73004. name: string;
  73005. shader: string;
  73006. };
  73007. }
  73008. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73009. import { Camera } from "babylonjs/Cameras/camera";
  73010. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73011. import { Scene } from "babylonjs/scene";
  73012. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73013. import "babylonjs/Shaders/ssao2.fragment";
  73014. import "babylonjs/Shaders/ssaoCombine.fragment";
  73015. /**
  73016. * Render pipeline to produce ssao effect
  73017. */
  73018. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73019. /**
  73020. * @ignore
  73021. * The PassPostProcess id in the pipeline that contains the original scene color
  73022. */
  73023. SSAOOriginalSceneColorEffect: string;
  73024. /**
  73025. * @ignore
  73026. * The SSAO PostProcess id in the pipeline
  73027. */
  73028. SSAORenderEffect: string;
  73029. /**
  73030. * @ignore
  73031. * The horizontal blur PostProcess id in the pipeline
  73032. */
  73033. SSAOBlurHRenderEffect: string;
  73034. /**
  73035. * @ignore
  73036. * The vertical blur PostProcess id in the pipeline
  73037. */
  73038. SSAOBlurVRenderEffect: string;
  73039. /**
  73040. * @ignore
  73041. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73042. */
  73043. SSAOCombineRenderEffect: string;
  73044. /**
  73045. * The output strength of the SSAO post-process. Default value is 1.0.
  73046. */
  73047. totalStrength: number;
  73048. /**
  73049. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73050. */
  73051. maxZ: number;
  73052. /**
  73053. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73054. */
  73055. minZAspect: number;
  73056. private _samples;
  73057. /**
  73058. * Number of samples used for the SSAO calculations. Default value is 8
  73059. */
  73060. set samples(n: number);
  73061. get samples(): number;
  73062. private _textureSamples;
  73063. /**
  73064. * Number of samples to use for antialiasing
  73065. */
  73066. set textureSamples(n: number);
  73067. get textureSamples(): number;
  73068. /**
  73069. * Ratio object used for SSAO ratio and blur ratio
  73070. */
  73071. private _ratio;
  73072. /**
  73073. * Dynamically generated sphere sampler.
  73074. */
  73075. private _sampleSphere;
  73076. /**
  73077. * Blur filter offsets
  73078. */
  73079. private _samplerOffsets;
  73080. private _expensiveBlur;
  73081. /**
  73082. * If bilateral blur should be used
  73083. */
  73084. set expensiveBlur(b: boolean);
  73085. get expensiveBlur(): boolean;
  73086. /**
  73087. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73088. */
  73089. radius: number;
  73090. /**
  73091. * The base color of the SSAO post-process
  73092. * The final result is "base + ssao" between [0, 1]
  73093. */
  73094. base: number;
  73095. /**
  73096. * Support test.
  73097. */
  73098. static get IsSupported(): boolean;
  73099. private _scene;
  73100. private _depthTexture;
  73101. private _normalTexture;
  73102. private _randomTexture;
  73103. private _originalColorPostProcess;
  73104. private _ssaoPostProcess;
  73105. private _blurHPostProcess;
  73106. private _blurVPostProcess;
  73107. private _ssaoCombinePostProcess;
  73108. /**
  73109. * Gets active scene
  73110. */
  73111. get scene(): Scene;
  73112. /**
  73113. * @constructor
  73114. * @param name The rendering pipeline name
  73115. * @param scene The scene linked to this pipeline
  73116. * @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 }
  73117. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73118. */
  73119. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73120. /**
  73121. * Get the class name
  73122. * @returns "SSAO2RenderingPipeline"
  73123. */
  73124. getClassName(): string;
  73125. /**
  73126. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73127. */
  73128. dispose(disableGeometryBufferRenderer?: boolean): void;
  73129. private _createBlurPostProcess;
  73130. /** @hidden */
  73131. _rebuild(): void;
  73132. private _bits;
  73133. private _radicalInverse_VdC;
  73134. private _hammersley;
  73135. private _hemisphereSample_uniform;
  73136. private _generateHemisphere;
  73137. private _createSSAOPostProcess;
  73138. private _createSSAOCombinePostProcess;
  73139. private _createRandomTexture;
  73140. /**
  73141. * Serialize the rendering pipeline (Used when exporting)
  73142. * @returns the serialized object
  73143. */
  73144. serialize(): any;
  73145. /**
  73146. * Parse the serialized pipeline
  73147. * @param source Source pipeline.
  73148. * @param scene The scene to load the pipeline to.
  73149. * @param rootUrl The URL of the serialized pipeline.
  73150. * @returns An instantiated pipeline from the serialized object.
  73151. */
  73152. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73153. }
  73154. }
  73155. declare module "babylonjs/Shaders/ssao.fragment" {
  73156. /** @hidden */
  73157. export var ssaoPixelShader: {
  73158. name: string;
  73159. shader: string;
  73160. };
  73161. }
  73162. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73163. import { Camera } from "babylonjs/Cameras/camera";
  73164. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73165. import { Scene } from "babylonjs/scene";
  73166. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73167. import "babylonjs/Shaders/ssao.fragment";
  73168. import "babylonjs/Shaders/ssaoCombine.fragment";
  73169. /**
  73170. * Render pipeline to produce ssao effect
  73171. */
  73172. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73173. /**
  73174. * @ignore
  73175. * The PassPostProcess id in the pipeline that contains the original scene color
  73176. */
  73177. SSAOOriginalSceneColorEffect: string;
  73178. /**
  73179. * @ignore
  73180. * The SSAO PostProcess id in the pipeline
  73181. */
  73182. SSAORenderEffect: string;
  73183. /**
  73184. * @ignore
  73185. * The horizontal blur PostProcess id in the pipeline
  73186. */
  73187. SSAOBlurHRenderEffect: string;
  73188. /**
  73189. * @ignore
  73190. * The vertical blur PostProcess id in the pipeline
  73191. */
  73192. SSAOBlurVRenderEffect: string;
  73193. /**
  73194. * @ignore
  73195. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73196. */
  73197. SSAOCombineRenderEffect: string;
  73198. /**
  73199. * The output strength of the SSAO post-process. Default value is 1.0.
  73200. */
  73201. totalStrength: number;
  73202. /**
  73203. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73204. */
  73205. radius: number;
  73206. /**
  73207. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73208. * Must not be equal to fallOff and superior to fallOff.
  73209. * Default value is 0.0075
  73210. */
  73211. area: number;
  73212. /**
  73213. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73214. * Must not be equal to area and inferior to area.
  73215. * Default value is 0.000001
  73216. */
  73217. fallOff: number;
  73218. /**
  73219. * The base color of the SSAO post-process
  73220. * The final result is "base + ssao" between [0, 1]
  73221. */
  73222. base: number;
  73223. private _scene;
  73224. private _depthTexture;
  73225. private _randomTexture;
  73226. private _originalColorPostProcess;
  73227. private _ssaoPostProcess;
  73228. private _blurHPostProcess;
  73229. private _blurVPostProcess;
  73230. private _ssaoCombinePostProcess;
  73231. private _firstUpdate;
  73232. /**
  73233. * Gets active scene
  73234. */
  73235. get scene(): Scene;
  73236. /**
  73237. * @constructor
  73238. * @param name - The rendering pipeline name
  73239. * @param scene - The scene linked to this pipeline
  73240. * @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 }
  73241. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73242. */
  73243. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73244. /**
  73245. * Get the class name
  73246. * @returns "SSAORenderingPipeline"
  73247. */
  73248. getClassName(): string;
  73249. /**
  73250. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73251. */
  73252. dispose(disableDepthRender?: boolean): void;
  73253. private _createBlurPostProcess;
  73254. /** @hidden */
  73255. _rebuild(): void;
  73256. private _createSSAOPostProcess;
  73257. private _createSSAOCombinePostProcess;
  73258. private _createRandomTexture;
  73259. }
  73260. }
  73261. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73262. /** @hidden */
  73263. export var screenSpaceReflectionPixelShader: {
  73264. name: string;
  73265. shader: string;
  73266. };
  73267. }
  73268. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73269. import { Nullable } from "babylonjs/types";
  73270. import { Camera } from "babylonjs/Cameras/camera";
  73271. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73272. import { Scene } from "babylonjs/scene";
  73273. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73274. import { Engine } from "babylonjs/Engines/engine";
  73275. /**
  73276. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73277. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73278. */
  73279. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73280. /**
  73281. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73282. */
  73283. threshold: number;
  73284. /**
  73285. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73286. */
  73287. strength: number;
  73288. /**
  73289. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73290. */
  73291. reflectionSpecularFalloffExponent: number;
  73292. /**
  73293. * 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]
  73294. */
  73295. step: number;
  73296. /**
  73297. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73298. */
  73299. roughnessFactor: number;
  73300. private _geometryBufferRenderer;
  73301. private _enableSmoothReflections;
  73302. private _reflectionSamples;
  73303. private _smoothSteps;
  73304. /**
  73305. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73306. * @param name The name of the effect.
  73307. * @param scene The scene containing the objects to calculate reflections.
  73308. * @param options The required width/height ratio to downsize to before computing the render pass.
  73309. * @param camera The camera to apply the render pass to.
  73310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73311. * @param engine The engine which the post process will be applied. (default: current engine)
  73312. * @param reusable If the post process can be reused on the same frame. (default: false)
  73313. * @param textureType Type of textures used when performing the post process. (default: 0)
  73314. * @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)
  73315. */
  73316. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73317. /**
  73318. * Gets wether or not smoothing reflections is enabled.
  73319. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73320. */
  73321. get enableSmoothReflections(): boolean;
  73322. /**
  73323. * Sets wether or not smoothing reflections is enabled.
  73324. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73325. */
  73326. set enableSmoothReflections(enabled: boolean);
  73327. /**
  73328. * Gets the number of samples taken while computing reflections. More samples count is high,
  73329. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73330. */
  73331. get reflectionSamples(): number;
  73332. /**
  73333. * Sets the number of samples taken while computing reflections. More samples count is high,
  73334. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73335. */
  73336. set reflectionSamples(samples: number);
  73337. /**
  73338. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73339. * more the post-process will require GPU power and can generate a drop in FPS.
  73340. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73341. */
  73342. get smoothSteps(): number;
  73343. set smoothSteps(steps: number);
  73344. private _updateEffectDefines;
  73345. }
  73346. }
  73347. declare module "babylonjs/Shaders/standard.fragment" {
  73348. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73349. /** @hidden */
  73350. export var standardPixelShader: {
  73351. name: string;
  73352. shader: string;
  73353. };
  73354. }
  73355. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73356. import { Nullable } from "babylonjs/types";
  73357. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73358. import { Camera } from "babylonjs/Cameras/camera";
  73359. import { Texture } from "babylonjs/Materials/Textures/texture";
  73360. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73361. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73362. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73363. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73364. import { IDisposable } from "babylonjs/scene";
  73365. import { SpotLight } from "babylonjs/Lights/spotLight";
  73366. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73367. import { Scene } from "babylonjs/scene";
  73368. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73369. import { Animation } from "babylonjs/Animations/animation";
  73370. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73371. import "babylonjs/Shaders/standard.fragment";
  73372. /**
  73373. * Standard rendering pipeline
  73374. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73375. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73376. */
  73377. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73378. /**
  73379. * Public members
  73380. */
  73381. /**
  73382. * Post-process which contains the original scene color before the pipeline applies all the effects
  73383. */
  73384. originalPostProcess: Nullable<PostProcess>;
  73385. /**
  73386. * Post-process used to down scale an image x4
  73387. */
  73388. downSampleX4PostProcess: Nullable<PostProcess>;
  73389. /**
  73390. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73391. */
  73392. brightPassPostProcess: Nullable<PostProcess>;
  73393. /**
  73394. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73395. */
  73396. blurHPostProcesses: PostProcess[];
  73397. /**
  73398. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73399. */
  73400. blurVPostProcesses: PostProcess[];
  73401. /**
  73402. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73403. */
  73404. textureAdderPostProcess: Nullable<PostProcess>;
  73405. /**
  73406. * Post-process used to create volumetric lighting effect
  73407. */
  73408. volumetricLightPostProcess: Nullable<PostProcess>;
  73409. /**
  73410. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73411. */
  73412. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73413. /**
  73414. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73415. */
  73416. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73417. /**
  73418. * Post-process used to merge the volumetric light effect and the real scene color
  73419. */
  73420. volumetricLightMergePostProces: Nullable<PostProcess>;
  73421. /**
  73422. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73423. */
  73424. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73425. /**
  73426. * Base post-process used to calculate the average luminance of the final image for HDR
  73427. */
  73428. luminancePostProcess: Nullable<PostProcess>;
  73429. /**
  73430. * Post-processes used to create down sample post-processes in order to get
  73431. * the average luminance of the final image for HDR
  73432. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73433. */
  73434. luminanceDownSamplePostProcesses: PostProcess[];
  73435. /**
  73436. * Post-process used to create a HDR effect (light adaptation)
  73437. */
  73438. hdrPostProcess: Nullable<PostProcess>;
  73439. /**
  73440. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73441. */
  73442. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73443. /**
  73444. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73445. */
  73446. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73447. /**
  73448. * Post-process used to merge the final HDR post-process and the real scene color
  73449. */
  73450. hdrFinalPostProcess: Nullable<PostProcess>;
  73451. /**
  73452. * Post-process used to create a lens flare effect
  73453. */
  73454. lensFlarePostProcess: Nullable<PostProcess>;
  73455. /**
  73456. * Post-process that merges the result of the lens flare post-process and the real scene color
  73457. */
  73458. lensFlareComposePostProcess: Nullable<PostProcess>;
  73459. /**
  73460. * Post-process used to create a motion blur effect
  73461. */
  73462. motionBlurPostProcess: Nullable<PostProcess>;
  73463. /**
  73464. * Post-process used to create a depth of field effect
  73465. */
  73466. depthOfFieldPostProcess: Nullable<PostProcess>;
  73467. /**
  73468. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73469. */
  73470. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73471. /**
  73472. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73473. */
  73474. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73475. /**
  73476. * Represents the brightness threshold in order to configure the illuminated surfaces
  73477. */
  73478. brightThreshold: number;
  73479. /**
  73480. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73481. */
  73482. blurWidth: number;
  73483. /**
  73484. * Sets if the blur for highlighted surfaces must be only horizontal
  73485. */
  73486. horizontalBlur: boolean;
  73487. /**
  73488. * Gets the overall exposure used by the pipeline
  73489. */
  73490. get exposure(): number;
  73491. /**
  73492. * Sets the overall exposure used by the pipeline
  73493. */
  73494. set exposure(value: number);
  73495. /**
  73496. * Texture used typically to simulate "dirty" on camera lens
  73497. */
  73498. lensTexture: Nullable<Texture>;
  73499. /**
  73500. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73501. */
  73502. volumetricLightCoefficient: number;
  73503. /**
  73504. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73505. */
  73506. volumetricLightPower: number;
  73507. /**
  73508. * Used the set the blur intensity to smooth the volumetric lights
  73509. */
  73510. volumetricLightBlurScale: number;
  73511. /**
  73512. * Light (spot or directional) used to generate the volumetric lights rays
  73513. * The source light must have a shadow generate so the pipeline can get its
  73514. * depth map
  73515. */
  73516. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73517. /**
  73518. * For eye adaptation, represents the minimum luminance the eye can see
  73519. */
  73520. hdrMinimumLuminance: number;
  73521. /**
  73522. * For eye adaptation, represents the decrease luminance speed
  73523. */
  73524. hdrDecreaseRate: number;
  73525. /**
  73526. * For eye adaptation, represents the increase luminance speed
  73527. */
  73528. hdrIncreaseRate: number;
  73529. /**
  73530. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73531. */
  73532. get hdrAutoExposure(): boolean;
  73533. /**
  73534. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73535. */
  73536. set hdrAutoExposure(value: boolean);
  73537. /**
  73538. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73539. */
  73540. lensColorTexture: Nullable<Texture>;
  73541. /**
  73542. * The overall strengh for the lens flare effect
  73543. */
  73544. lensFlareStrength: number;
  73545. /**
  73546. * Dispersion coefficient for lens flare ghosts
  73547. */
  73548. lensFlareGhostDispersal: number;
  73549. /**
  73550. * Main lens flare halo width
  73551. */
  73552. lensFlareHaloWidth: number;
  73553. /**
  73554. * Based on the lens distortion effect, defines how much the lens flare result
  73555. * is distorted
  73556. */
  73557. lensFlareDistortionStrength: number;
  73558. /**
  73559. * Configures the blur intensity used for for lens flare (halo)
  73560. */
  73561. lensFlareBlurWidth: number;
  73562. /**
  73563. * Lens star texture must be used to simulate rays on the flares and is available
  73564. * in the documentation
  73565. */
  73566. lensStarTexture: Nullable<Texture>;
  73567. /**
  73568. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73569. * flare effect by taking account of the dirt texture
  73570. */
  73571. lensFlareDirtTexture: Nullable<Texture>;
  73572. /**
  73573. * Represents the focal length for the depth of field effect
  73574. */
  73575. depthOfFieldDistance: number;
  73576. /**
  73577. * Represents the blur intensity for the blurred part of the depth of field effect
  73578. */
  73579. depthOfFieldBlurWidth: number;
  73580. /**
  73581. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73582. */
  73583. get motionStrength(): number;
  73584. /**
  73585. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73586. */
  73587. set motionStrength(strength: number);
  73588. /**
  73589. * Gets wether or not the motion blur post-process is object based or screen based.
  73590. */
  73591. get objectBasedMotionBlur(): boolean;
  73592. /**
  73593. * Sets wether or not the motion blur post-process should be object based or screen based
  73594. */
  73595. set objectBasedMotionBlur(value: boolean);
  73596. /**
  73597. * List of animations for the pipeline (IAnimatable implementation)
  73598. */
  73599. animations: Animation[];
  73600. /**
  73601. * Private members
  73602. */
  73603. private _scene;
  73604. private _currentDepthOfFieldSource;
  73605. private _basePostProcess;
  73606. private _fixedExposure;
  73607. private _currentExposure;
  73608. private _hdrAutoExposure;
  73609. private _hdrCurrentLuminance;
  73610. private _motionStrength;
  73611. private _isObjectBasedMotionBlur;
  73612. private _floatTextureType;
  73613. private _camerasToBeAttached;
  73614. private _ratio;
  73615. private _bloomEnabled;
  73616. private _depthOfFieldEnabled;
  73617. private _vlsEnabled;
  73618. private _lensFlareEnabled;
  73619. private _hdrEnabled;
  73620. private _motionBlurEnabled;
  73621. private _fxaaEnabled;
  73622. private _screenSpaceReflectionsEnabled;
  73623. private _motionBlurSamples;
  73624. private _volumetricLightStepsCount;
  73625. private _samples;
  73626. /**
  73627. * @ignore
  73628. * Specifies if the bloom pipeline is enabled
  73629. */
  73630. get BloomEnabled(): boolean;
  73631. set BloomEnabled(enabled: boolean);
  73632. /**
  73633. * @ignore
  73634. * Specifies if the depth of field pipeline is enabed
  73635. */
  73636. get DepthOfFieldEnabled(): boolean;
  73637. set DepthOfFieldEnabled(enabled: boolean);
  73638. /**
  73639. * @ignore
  73640. * Specifies if the lens flare pipeline is enabed
  73641. */
  73642. get LensFlareEnabled(): boolean;
  73643. set LensFlareEnabled(enabled: boolean);
  73644. /**
  73645. * @ignore
  73646. * Specifies if the HDR pipeline is enabled
  73647. */
  73648. get HDREnabled(): boolean;
  73649. set HDREnabled(enabled: boolean);
  73650. /**
  73651. * @ignore
  73652. * Specifies if the volumetric lights scattering effect is enabled
  73653. */
  73654. get VLSEnabled(): boolean;
  73655. set VLSEnabled(enabled: boolean);
  73656. /**
  73657. * @ignore
  73658. * Specifies if the motion blur effect is enabled
  73659. */
  73660. get MotionBlurEnabled(): boolean;
  73661. set MotionBlurEnabled(enabled: boolean);
  73662. /**
  73663. * Specifies if anti-aliasing is enabled
  73664. */
  73665. get fxaaEnabled(): boolean;
  73666. set fxaaEnabled(enabled: boolean);
  73667. /**
  73668. * Specifies if screen space reflections are enabled.
  73669. */
  73670. get screenSpaceReflectionsEnabled(): boolean;
  73671. set screenSpaceReflectionsEnabled(enabled: boolean);
  73672. /**
  73673. * Specifies the number of steps used to calculate the volumetric lights
  73674. * Typically in interval [50, 200]
  73675. */
  73676. get volumetricLightStepsCount(): number;
  73677. set volumetricLightStepsCount(count: number);
  73678. /**
  73679. * Specifies the number of samples used for the motion blur effect
  73680. * Typically in interval [16, 64]
  73681. */
  73682. get motionBlurSamples(): number;
  73683. set motionBlurSamples(samples: number);
  73684. /**
  73685. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73686. */
  73687. get samples(): number;
  73688. set samples(sampleCount: number);
  73689. /**
  73690. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73691. * @constructor
  73692. * @param name The rendering pipeline name
  73693. * @param scene The scene linked to this pipeline
  73694. * @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)
  73695. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73696. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73697. */
  73698. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73699. private _buildPipeline;
  73700. private _createDownSampleX4PostProcess;
  73701. private _createBrightPassPostProcess;
  73702. private _createBlurPostProcesses;
  73703. private _createTextureAdderPostProcess;
  73704. private _createVolumetricLightPostProcess;
  73705. private _createLuminancePostProcesses;
  73706. private _createHdrPostProcess;
  73707. private _createLensFlarePostProcess;
  73708. private _createDepthOfFieldPostProcess;
  73709. private _createMotionBlurPostProcess;
  73710. private _getDepthTexture;
  73711. private _disposePostProcesses;
  73712. /**
  73713. * Dispose of the pipeline and stop all post processes
  73714. */
  73715. dispose(): void;
  73716. /**
  73717. * Serialize the rendering pipeline (Used when exporting)
  73718. * @returns the serialized object
  73719. */
  73720. serialize(): any;
  73721. /**
  73722. * Parse the serialized pipeline
  73723. * @param source Source pipeline.
  73724. * @param scene The scene to load the pipeline to.
  73725. * @param rootUrl The URL of the serialized pipeline.
  73726. * @returns An instantiated pipeline from the serialized object.
  73727. */
  73728. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73729. /**
  73730. * Luminance steps
  73731. */
  73732. static LuminanceSteps: number;
  73733. }
  73734. }
  73735. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73736. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73737. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73738. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73739. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73740. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73741. }
  73742. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73743. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73744. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73745. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73746. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73747. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73748. }
  73749. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73750. /** @hidden */
  73751. export var stereoscopicInterlacePixelShader: {
  73752. name: string;
  73753. shader: string;
  73754. };
  73755. }
  73756. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73757. import { Camera } from "babylonjs/Cameras/camera";
  73758. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73759. import { Engine } from "babylonjs/Engines/engine";
  73760. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73761. /**
  73762. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73763. */
  73764. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73765. private _stepSize;
  73766. private _passedProcess;
  73767. /**
  73768. * Initializes a StereoscopicInterlacePostProcessI
  73769. * @param name The name of the effect.
  73770. * @param rigCameras The rig cameras to be appled to the post process
  73771. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73772. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73774. * @param engine The engine which the post process will be applied. (default: current engine)
  73775. * @param reusable If the post process can be reused on the same frame. (default: false)
  73776. */
  73777. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73778. }
  73779. /**
  73780. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73781. */
  73782. export class StereoscopicInterlacePostProcess extends PostProcess {
  73783. private _stepSize;
  73784. private _passedProcess;
  73785. /**
  73786. * Initializes a StereoscopicInterlacePostProcess
  73787. * @param name The name of the effect.
  73788. * @param rigCameras The rig cameras to be appled to the post process
  73789. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73791. * @param engine The engine which the post process will be applied. (default: current engine)
  73792. * @param reusable If the post process can be reused on the same frame. (default: false)
  73793. */
  73794. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73795. }
  73796. }
  73797. declare module "babylonjs/Shaders/tonemap.fragment" {
  73798. /** @hidden */
  73799. export var tonemapPixelShader: {
  73800. name: string;
  73801. shader: string;
  73802. };
  73803. }
  73804. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73805. import { Camera } from "babylonjs/Cameras/camera";
  73806. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73807. import "babylonjs/Shaders/tonemap.fragment";
  73808. import { Engine } from "babylonjs/Engines/engine";
  73809. /** Defines operator used for tonemapping */
  73810. export enum TonemappingOperator {
  73811. /** Hable */
  73812. Hable = 0,
  73813. /** Reinhard */
  73814. Reinhard = 1,
  73815. /** HejiDawson */
  73816. HejiDawson = 2,
  73817. /** Photographic */
  73818. Photographic = 3
  73819. }
  73820. /**
  73821. * Defines a post process to apply tone mapping
  73822. */
  73823. export class TonemapPostProcess extends PostProcess {
  73824. private _operator;
  73825. /** Defines the required exposure adjustement */
  73826. exposureAdjustment: number;
  73827. /**
  73828. * Creates a new TonemapPostProcess
  73829. * @param name defines the name of the postprocess
  73830. * @param _operator defines the operator to use
  73831. * @param exposureAdjustment defines the required exposure adjustement
  73832. * @param camera defines the camera to use (can be null)
  73833. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73834. * @param engine defines the hosting engine (can be ignore if camera is set)
  73835. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73836. */
  73837. constructor(name: string, _operator: TonemappingOperator,
  73838. /** Defines the required exposure adjustement */
  73839. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73840. }
  73841. }
  73842. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  73843. /** @hidden */
  73844. export var volumetricLightScatteringPixelShader: {
  73845. name: string;
  73846. shader: string;
  73847. };
  73848. }
  73849. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  73850. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73851. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73853. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73854. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73855. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73856. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73857. /** @hidden */
  73858. export var volumetricLightScatteringPassVertexShader: {
  73859. name: string;
  73860. shader: string;
  73861. };
  73862. }
  73863. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  73864. /** @hidden */
  73865. export var volumetricLightScatteringPassPixelShader: {
  73866. name: string;
  73867. shader: string;
  73868. };
  73869. }
  73870. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  73871. import { Vector3 } from "babylonjs/Maths/math.vector";
  73872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73873. import { Mesh } from "babylonjs/Meshes/mesh";
  73874. import { Camera } from "babylonjs/Cameras/camera";
  73875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73876. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73877. import { Scene } from "babylonjs/scene";
  73878. import "babylonjs/Meshes/Builders/planeBuilder";
  73879. import "babylonjs/Shaders/depth.vertex";
  73880. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  73881. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  73882. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  73883. import { Engine } from "babylonjs/Engines/engine";
  73884. /**
  73885. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73886. */
  73887. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73888. private _volumetricLightScatteringPass;
  73889. private _volumetricLightScatteringRTT;
  73890. private _viewPort;
  73891. private _screenCoordinates;
  73892. private _cachedDefines;
  73893. /**
  73894. * If not undefined, the mesh position is computed from the attached node position
  73895. */
  73896. attachedNode: {
  73897. position: Vector3;
  73898. };
  73899. /**
  73900. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73901. */
  73902. customMeshPosition: Vector3;
  73903. /**
  73904. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73905. */
  73906. useCustomMeshPosition: boolean;
  73907. /**
  73908. * If the post-process should inverse the light scattering direction
  73909. */
  73910. invert: boolean;
  73911. /**
  73912. * The internal mesh used by the post-process
  73913. */
  73914. mesh: Mesh;
  73915. /**
  73916. * @hidden
  73917. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73918. */
  73919. get useDiffuseColor(): boolean;
  73920. set useDiffuseColor(useDiffuseColor: boolean);
  73921. /**
  73922. * Array containing the excluded meshes not rendered in the internal pass
  73923. */
  73924. excludedMeshes: AbstractMesh[];
  73925. /**
  73926. * Controls the overall intensity of the post-process
  73927. */
  73928. exposure: number;
  73929. /**
  73930. * Dissipates each sample's contribution in range [0, 1]
  73931. */
  73932. decay: number;
  73933. /**
  73934. * Controls the overall intensity of each sample
  73935. */
  73936. weight: number;
  73937. /**
  73938. * Controls the density of each sample
  73939. */
  73940. density: number;
  73941. /**
  73942. * @constructor
  73943. * @param name The post-process name
  73944. * @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)
  73945. * @param camera The camera that the post-process will be attached to
  73946. * @param mesh The mesh used to create the light scattering
  73947. * @param samples The post-process quality, default 100
  73948. * @param samplingModeThe post-process filtering mode
  73949. * @param engine The babylon engine
  73950. * @param reusable If the post-process is reusable
  73951. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73952. */
  73953. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73954. /**
  73955. * Returns the string "VolumetricLightScatteringPostProcess"
  73956. * @returns "VolumetricLightScatteringPostProcess"
  73957. */
  73958. getClassName(): string;
  73959. private _isReady;
  73960. /**
  73961. * Sets the new light position for light scattering effect
  73962. * @param position The new custom light position
  73963. */
  73964. setCustomMeshPosition(position: Vector3): void;
  73965. /**
  73966. * Returns the light position for light scattering effect
  73967. * @return Vector3 The custom light position
  73968. */
  73969. getCustomMeshPosition(): Vector3;
  73970. /**
  73971. * Disposes the internal assets and detaches the post-process from the camera
  73972. */
  73973. dispose(camera: Camera): void;
  73974. /**
  73975. * Returns the render target texture used by the post-process
  73976. * @return the render target texture used by the post-process
  73977. */
  73978. getPass(): RenderTargetTexture;
  73979. private _meshExcluded;
  73980. private _createPass;
  73981. private _updateMeshScreenCoordinates;
  73982. /**
  73983. * Creates a default mesh for the Volumeric Light Scattering post-process
  73984. * @param name The mesh name
  73985. * @param scene The scene where to create the mesh
  73986. * @return the default mesh
  73987. */
  73988. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73989. }
  73990. }
  73991. declare module "babylonjs/PostProcesses/index" {
  73992. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  73993. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  73994. export * from "babylonjs/PostProcesses/bloomEffect";
  73995. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  73996. export * from "babylonjs/PostProcesses/blurPostProcess";
  73997. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73998. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  73999. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74000. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74001. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74002. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74003. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74004. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74005. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74006. export * from "babylonjs/PostProcesses/filterPostProcess";
  74007. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74008. export * from "babylonjs/PostProcesses/grainPostProcess";
  74009. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74010. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74011. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74012. export * from "babylonjs/PostProcesses/passPostProcess";
  74013. export * from "babylonjs/PostProcesses/postProcess";
  74014. export * from "babylonjs/PostProcesses/postProcessManager";
  74015. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74016. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74017. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74018. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74019. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74020. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74021. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74022. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74023. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74024. }
  74025. declare module "babylonjs/Probes/index" {
  74026. export * from "babylonjs/Probes/reflectionProbe";
  74027. }
  74028. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74029. import { Scene } from "babylonjs/scene";
  74030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74031. import { SmartArray } from "babylonjs/Misc/smartArray";
  74032. import { ISceneComponent } from "babylonjs/sceneComponent";
  74033. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74034. import "babylonjs/Meshes/Builders/boxBuilder";
  74035. import "babylonjs/Shaders/color.fragment";
  74036. import "babylonjs/Shaders/color.vertex";
  74037. import { Color3 } from "babylonjs/Maths/math.color";
  74038. import { Observable } from "babylonjs/Misc/observable";
  74039. module "babylonjs/scene" {
  74040. interface Scene {
  74041. /** @hidden (Backing field) */
  74042. _boundingBoxRenderer: BoundingBoxRenderer;
  74043. /** @hidden (Backing field) */
  74044. _forceShowBoundingBoxes: boolean;
  74045. /**
  74046. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74047. */
  74048. forceShowBoundingBoxes: boolean;
  74049. /**
  74050. * Gets the bounding box renderer associated with the scene
  74051. * @returns a BoundingBoxRenderer
  74052. */
  74053. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74054. }
  74055. }
  74056. module "babylonjs/Meshes/abstractMesh" {
  74057. interface AbstractMesh {
  74058. /** @hidden (Backing field) */
  74059. _showBoundingBox: boolean;
  74060. /**
  74061. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74062. */
  74063. showBoundingBox: boolean;
  74064. }
  74065. }
  74066. /**
  74067. * Component responsible of rendering the bounding box of the meshes in a scene.
  74068. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74069. */
  74070. export class BoundingBoxRenderer implements ISceneComponent {
  74071. /**
  74072. * The component name helpfull to identify the component in the list of scene components.
  74073. */
  74074. readonly name: string;
  74075. /**
  74076. * The scene the component belongs to.
  74077. */
  74078. scene: Scene;
  74079. /**
  74080. * Color of the bounding box lines placed in front of an object
  74081. */
  74082. frontColor: Color3;
  74083. /**
  74084. * Color of the bounding box lines placed behind an object
  74085. */
  74086. backColor: Color3;
  74087. /**
  74088. * Defines if the renderer should show the back lines or not
  74089. */
  74090. showBackLines: boolean;
  74091. /**
  74092. * Observable raised before rendering a bounding box
  74093. */
  74094. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74095. /**
  74096. * Observable raised after rendering a bounding box
  74097. */
  74098. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74099. /**
  74100. * @hidden
  74101. */
  74102. renderList: SmartArray<BoundingBox>;
  74103. private _colorShader;
  74104. private _vertexBuffers;
  74105. private _indexBuffer;
  74106. private _fillIndexBuffer;
  74107. private _fillIndexData;
  74108. /**
  74109. * Instantiates a new bounding box renderer in a scene.
  74110. * @param scene the scene the renderer renders in
  74111. */
  74112. constructor(scene: Scene);
  74113. /**
  74114. * Registers the component in a given scene
  74115. */
  74116. register(): void;
  74117. private _evaluateSubMesh;
  74118. private _activeMesh;
  74119. private _prepareRessources;
  74120. private _createIndexBuffer;
  74121. /**
  74122. * Rebuilds the elements related to this component in case of
  74123. * context lost for instance.
  74124. */
  74125. rebuild(): void;
  74126. /**
  74127. * @hidden
  74128. */
  74129. reset(): void;
  74130. /**
  74131. * Render the bounding boxes of a specific rendering group
  74132. * @param renderingGroupId defines the rendering group to render
  74133. */
  74134. render(renderingGroupId: number): void;
  74135. /**
  74136. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74137. * @param mesh Define the mesh to render the occlusion bounding box for
  74138. */
  74139. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74140. /**
  74141. * Dispose and release the resources attached to this renderer.
  74142. */
  74143. dispose(): void;
  74144. }
  74145. }
  74146. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74147. import { Nullable } from "babylonjs/types";
  74148. import { Scene } from "babylonjs/scene";
  74149. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74150. import { Camera } from "babylonjs/Cameras/camera";
  74151. import { ISceneComponent } from "babylonjs/sceneComponent";
  74152. module "babylonjs/scene" {
  74153. interface Scene {
  74154. /** @hidden (Backing field) */
  74155. _depthRenderer: {
  74156. [id: string]: DepthRenderer;
  74157. };
  74158. /**
  74159. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74160. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74161. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74162. * @returns the created depth renderer
  74163. */
  74164. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74165. /**
  74166. * Disables a depth renderer for a given camera
  74167. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74168. */
  74169. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74170. }
  74171. }
  74172. /**
  74173. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74174. * in several rendering techniques.
  74175. */
  74176. export class DepthRendererSceneComponent implements ISceneComponent {
  74177. /**
  74178. * The component name helpfull to identify the component in the list of scene components.
  74179. */
  74180. readonly name: string;
  74181. /**
  74182. * The scene the component belongs to.
  74183. */
  74184. scene: Scene;
  74185. /**
  74186. * Creates a new instance of the component for the given scene
  74187. * @param scene Defines the scene to register the component in
  74188. */
  74189. constructor(scene: Scene);
  74190. /**
  74191. * Registers the component in a given scene
  74192. */
  74193. register(): void;
  74194. /**
  74195. * Rebuilds the elements related to this component in case of
  74196. * context lost for instance.
  74197. */
  74198. rebuild(): void;
  74199. /**
  74200. * Disposes the component and the associated ressources
  74201. */
  74202. dispose(): void;
  74203. private _gatherRenderTargets;
  74204. private _gatherActiveCameraRenderTargets;
  74205. }
  74206. }
  74207. declare module "babylonjs/Shaders/outline.fragment" {
  74208. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74209. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74210. /** @hidden */
  74211. export var outlinePixelShader: {
  74212. name: string;
  74213. shader: string;
  74214. };
  74215. }
  74216. declare module "babylonjs/Shaders/outline.vertex" {
  74217. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74221. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74225. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74226. /** @hidden */
  74227. export var outlineVertexShader: {
  74228. name: string;
  74229. shader: string;
  74230. };
  74231. }
  74232. declare module "babylonjs/Rendering/outlineRenderer" {
  74233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74234. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74235. import { Scene } from "babylonjs/scene";
  74236. import { ISceneComponent } from "babylonjs/sceneComponent";
  74237. import "babylonjs/Shaders/outline.fragment";
  74238. import "babylonjs/Shaders/outline.vertex";
  74239. module "babylonjs/scene" {
  74240. interface Scene {
  74241. /** @hidden */
  74242. _outlineRenderer: OutlineRenderer;
  74243. /**
  74244. * Gets the outline renderer associated with the scene
  74245. * @returns a OutlineRenderer
  74246. */
  74247. getOutlineRenderer(): OutlineRenderer;
  74248. }
  74249. }
  74250. module "babylonjs/Meshes/abstractMesh" {
  74251. interface AbstractMesh {
  74252. /** @hidden (Backing field) */
  74253. _renderOutline: boolean;
  74254. /**
  74255. * Gets or sets a boolean indicating if the outline must be rendered as well
  74256. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74257. */
  74258. renderOutline: boolean;
  74259. /** @hidden (Backing field) */
  74260. _renderOverlay: boolean;
  74261. /**
  74262. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74263. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74264. */
  74265. renderOverlay: boolean;
  74266. }
  74267. }
  74268. /**
  74269. * This class is responsible to draw bothe outline/overlay of meshes.
  74270. * It should not be used directly but through the available method on mesh.
  74271. */
  74272. export class OutlineRenderer implements ISceneComponent {
  74273. /**
  74274. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74275. */
  74276. private static _StencilReference;
  74277. /**
  74278. * The name of the component. Each component must have a unique name.
  74279. */
  74280. name: string;
  74281. /**
  74282. * The scene the component belongs to.
  74283. */
  74284. scene: Scene;
  74285. /**
  74286. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74287. */
  74288. zOffset: number;
  74289. private _engine;
  74290. private _effect;
  74291. private _cachedDefines;
  74292. private _savedDepthWrite;
  74293. /**
  74294. * Instantiates a new outline renderer. (There could be only one per scene).
  74295. * @param scene Defines the scene it belongs to
  74296. */
  74297. constructor(scene: Scene);
  74298. /**
  74299. * Register the component to one instance of a scene.
  74300. */
  74301. register(): void;
  74302. /**
  74303. * Rebuilds the elements related to this component in case of
  74304. * context lost for instance.
  74305. */
  74306. rebuild(): void;
  74307. /**
  74308. * Disposes the component and the associated ressources.
  74309. */
  74310. dispose(): void;
  74311. /**
  74312. * Renders the outline in the canvas.
  74313. * @param subMesh Defines the sumesh to render
  74314. * @param batch Defines the batch of meshes in case of instances
  74315. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74316. */
  74317. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74318. /**
  74319. * Returns whether or not the outline renderer is ready for a given submesh.
  74320. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74321. * @param subMesh Defines the submesh to check readyness for
  74322. * @param useInstances Defines wheter wee are trying to render instances or not
  74323. * @returns true if ready otherwise false
  74324. */
  74325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74326. private _beforeRenderingMesh;
  74327. private _afterRenderingMesh;
  74328. }
  74329. }
  74330. declare module "babylonjs/Rendering/index" {
  74331. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74332. export * from "babylonjs/Rendering/depthRenderer";
  74333. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74334. export * from "babylonjs/Rendering/edgesRenderer";
  74335. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74336. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74337. export * from "babylonjs/Rendering/outlineRenderer";
  74338. export * from "babylonjs/Rendering/renderingGroup";
  74339. export * from "babylonjs/Rendering/renderingManager";
  74340. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74341. }
  74342. declare module "babylonjs/Sprites/ISprites" {
  74343. /**
  74344. * Defines the basic options interface of a Sprite Frame Source Size.
  74345. */
  74346. export interface ISpriteJSONSpriteSourceSize {
  74347. /**
  74348. * number of the original width of the Frame
  74349. */
  74350. w: number;
  74351. /**
  74352. * number of the original height of the Frame
  74353. */
  74354. h: number;
  74355. }
  74356. /**
  74357. * Defines the basic options interface of a Sprite Frame Data.
  74358. */
  74359. export interface ISpriteJSONSpriteFrameData {
  74360. /**
  74361. * number of the x offset of the Frame
  74362. */
  74363. x: number;
  74364. /**
  74365. * number of the y offset of the Frame
  74366. */
  74367. y: number;
  74368. /**
  74369. * number of the width of the Frame
  74370. */
  74371. w: number;
  74372. /**
  74373. * number of the height of the Frame
  74374. */
  74375. h: number;
  74376. }
  74377. /**
  74378. * Defines the basic options interface of a JSON Sprite.
  74379. */
  74380. export interface ISpriteJSONSprite {
  74381. /**
  74382. * string name of the Frame
  74383. */
  74384. filename: string;
  74385. /**
  74386. * ISpriteJSONSpriteFrame basic object of the frame data
  74387. */
  74388. frame: ISpriteJSONSpriteFrameData;
  74389. /**
  74390. * boolean to flag is the frame was rotated.
  74391. */
  74392. rotated: boolean;
  74393. /**
  74394. * boolean to flag is the frame was trimmed.
  74395. */
  74396. trimmed: boolean;
  74397. /**
  74398. * ISpriteJSONSpriteFrame basic object of the source data
  74399. */
  74400. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74401. /**
  74402. * ISpriteJSONSpriteFrame basic object of the source data
  74403. */
  74404. sourceSize: ISpriteJSONSpriteSourceSize;
  74405. }
  74406. /**
  74407. * Defines the basic options interface of a JSON atlas.
  74408. */
  74409. export interface ISpriteJSONAtlas {
  74410. /**
  74411. * Array of objects that contain the frame data.
  74412. */
  74413. frames: Array<ISpriteJSONSprite>;
  74414. /**
  74415. * object basic object containing the sprite meta data.
  74416. */
  74417. meta?: object;
  74418. }
  74419. }
  74420. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74421. /** @hidden */
  74422. export var spriteMapPixelShader: {
  74423. name: string;
  74424. shader: string;
  74425. };
  74426. }
  74427. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74428. /** @hidden */
  74429. export var spriteMapVertexShader: {
  74430. name: string;
  74431. shader: string;
  74432. };
  74433. }
  74434. declare module "babylonjs/Sprites/spriteMap" {
  74435. import { IDisposable, Scene } from "babylonjs/scene";
  74436. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74437. import { Texture } from "babylonjs/Materials/Textures/texture";
  74438. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74439. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74440. import "babylonjs/Meshes/Builders/planeBuilder";
  74441. import "babylonjs/Shaders/spriteMap.fragment";
  74442. import "babylonjs/Shaders/spriteMap.vertex";
  74443. /**
  74444. * Defines the basic options interface of a SpriteMap
  74445. */
  74446. export interface ISpriteMapOptions {
  74447. /**
  74448. * Vector2 of the number of cells in the grid.
  74449. */
  74450. stageSize?: Vector2;
  74451. /**
  74452. * Vector2 of the size of the output plane in World Units.
  74453. */
  74454. outputSize?: Vector2;
  74455. /**
  74456. * Vector3 of the position of the output plane in World Units.
  74457. */
  74458. outputPosition?: Vector3;
  74459. /**
  74460. * Vector3 of the rotation of the output plane.
  74461. */
  74462. outputRotation?: Vector3;
  74463. /**
  74464. * number of layers that the system will reserve in resources.
  74465. */
  74466. layerCount?: number;
  74467. /**
  74468. * number of max animation frames a single cell will reserve in resources.
  74469. */
  74470. maxAnimationFrames?: number;
  74471. /**
  74472. * number cell index of the base tile when the system compiles.
  74473. */
  74474. baseTile?: number;
  74475. /**
  74476. * boolean flip the sprite after its been repositioned by the framing data.
  74477. */
  74478. flipU?: boolean;
  74479. /**
  74480. * Vector3 scalar of the global RGB values of the SpriteMap.
  74481. */
  74482. colorMultiply?: Vector3;
  74483. }
  74484. /**
  74485. * Defines the IDisposable interface in order to be cleanable from resources.
  74486. */
  74487. export interface ISpriteMap extends IDisposable {
  74488. /**
  74489. * String name of the SpriteMap.
  74490. */
  74491. name: string;
  74492. /**
  74493. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74494. */
  74495. atlasJSON: ISpriteJSONAtlas;
  74496. /**
  74497. * Texture of the SpriteMap.
  74498. */
  74499. spriteSheet: Texture;
  74500. /**
  74501. * The parameters to initialize the SpriteMap with.
  74502. */
  74503. options: ISpriteMapOptions;
  74504. }
  74505. /**
  74506. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74507. */
  74508. export class SpriteMap implements ISpriteMap {
  74509. /** The Name of the spriteMap */
  74510. name: string;
  74511. /** The JSON file with the frame and meta data */
  74512. atlasJSON: ISpriteJSONAtlas;
  74513. /** The systems Sprite Sheet Texture */
  74514. spriteSheet: Texture;
  74515. /** Arguments passed with the Constructor */
  74516. options: ISpriteMapOptions;
  74517. /** Public Sprite Storage array, parsed from atlasJSON */
  74518. sprites: Array<ISpriteJSONSprite>;
  74519. /** Returns the Number of Sprites in the System */
  74520. get spriteCount(): number;
  74521. /** Returns the Position of Output Plane*/
  74522. get position(): Vector3;
  74523. /** Returns the Position of Output Plane*/
  74524. set position(v: Vector3);
  74525. /** Returns the Rotation of Output Plane*/
  74526. get rotation(): Vector3;
  74527. /** Returns the Rotation of Output Plane*/
  74528. set rotation(v: Vector3);
  74529. /** Sets the AnimationMap*/
  74530. get animationMap(): RawTexture;
  74531. /** Sets the AnimationMap*/
  74532. set animationMap(v: RawTexture);
  74533. /** Scene that the SpriteMap was created in */
  74534. private _scene;
  74535. /** Texture Buffer of Float32 that holds tile frame data*/
  74536. private _frameMap;
  74537. /** Texture Buffers of Float32 that holds tileMap data*/
  74538. private _tileMaps;
  74539. /** Texture Buffer of Float32 that holds Animation Data*/
  74540. private _animationMap;
  74541. /** Custom ShaderMaterial Central to the System*/
  74542. private _material;
  74543. /** Custom ShaderMaterial Central to the System*/
  74544. private _output;
  74545. /** Systems Time Ticker*/
  74546. private _time;
  74547. /**
  74548. * Creates a new SpriteMap
  74549. * @param name defines the SpriteMaps Name
  74550. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74551. * @param spriteSheet is the Texture that the Sprites are on.
  74552. * @param options a basic deployment configuration
  74553. * @param scene The Scene that the map is deployed on
  74554. */
  74555. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74556. /**
  74557. * Returns tileID location
  74558. * @returns Vector2 the cell position ID
  74559. */
  74560. getTileID(): Vector2;
  74561. /**
  74562. * Gets the UV location of the mouse over the SpriteMap.
  74563. * @returns Vector2 the UV position of the mouse interaction
  74564. */
  74565. getMousePosition(): Vector2;
  74566. /**
  74567. * Creates the "frame" texture Buffer
  74568. * -------------------------------------
  74569. * Structure of frames
  74570. * "filename": "Falling-Water-2.png",
  74571. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74572. * "rotated": true,
  74573. * "trimmed": true,
  74574. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74575. * "sourceSize": {"w":32,"h":32}
  74576. * @returns RawTexture of the frameMap
  74577. */
  74578. private _createFrameBuffer;
  74579. /**
  74580. * Creates the tileMap texture Buffer
  74581. * @param buffer normally and array of numbers, or a false to generate from scratch
  74582. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74583. * @returns RawTexture of the tileMap
  74584. */
  74585. private _createTileBuffer;
  74586. /**
  74587. * Modifies the data of the tileMaps
  74588. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74589. * @param pos is the iVector2 Coordinates of the Tile
  74590. * @param tile The SpriteIndex of the new Tile
  74591. */
  74592. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74593. /**
  74594. * Creates the animationMap texture Buffer
  74595. * @param buffer normally and array of numbers, or a false to generate from scratch
  74596. * @returns RawTexture of the animationMap
  74597. */
  74598. private _createTileAnimationBuffer;
  74599. /**
  74600. * Modifies the data of the animationMap
  74601. * @param cellID is the Index of the Sprite
  74602. * @param _frame is the target Animation frame
  74603. * @param toCell is the Target Index of the next frame of the animation
  74604. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74605. * @param speed is a global scalar of the time variable on the map.
  74606. */
  74607. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74608. /**
  74609. * Exports the .tilemaps file
  74610. */
  74611. saveTileMaps(): void;
  74612. /**
  74613. * Imports the .tilemaps file
  74614. * @param url of the .tilemaps file
  74615. */
  74616. loadTileMaps(url: string): void;
  74617. /**
  74618. * Release associated resources
  74619. */
  74620. dispose(): void;
  74621. }
  74622. }
  74623. declare module "babylonjs/Sprites/spritePackedManager" {
  74624. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74625. import { Scene } from "babylonjs/scene";
  74626. /**
  74627. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74628. * @see http://doc.babylonjs.com/babylon101/sprites
  74629. */
  74630. export class SpritePackedManager extends SpriteManager {
  74631. /** defines the packed manager's name */
  74632. name: string;
  74633. /**
  74634. * Creates a new sprite manager from a packed sprite sheet
  74635. * @param name defines the manager's name
  74636. * @param imgUrl defines the sprite sheet url
  74637. * @param capacity defines the maximum allowed number of sprites
  74638. * @param scene defines the hosting scene
  74639. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74640. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74641. * @param samplingMode defines the smapling mode to use with spritesheet
  74642. * @param fromPacked set to true; do not alter
  74643. */
  74644. constructor(
  74645. /** defines the packed manager's name */
  74646. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74647. }
  74648. }
  74649. declare module "babylonjs/Sprites/index" {
  74650. export * from "babylonjs/Sprites/sprite";
  74651. export * from "babylonjs/Sprites/ISprites";
  74652. export * from "babylonjs/Sprites/spriteManager";
  74653. export * from "babylonjs/Sprites/spriteMap";
  74654. export * from "babylonjs/Sprites/spritePackedManager";
  74655. export * from "babylonjs/Sprites/spriteSceneComponent";
  74656. }
  74657. declare module "babylonjs/States/index" {
  74658. export * from "babylonjs/States/alphaCullingState";
  74659. export * from "babylonjs/States/depthCullingState";
  74660. export * from "babylonjs/States/stencilState";
  74661. }
  74662. declare module "babylonjs/Misc/assetsManager" {
  74663. import { Scene } from "babylonjs/scene";
  74664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74665. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74666. import { Skeleton } from "babylonjs/Bones/skeleton";
  74667. import { Observable } from "babylonjs/Misc/observable";
  74668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74669. import { Texture } from "babylonjs/Materials/Textures/texture";
  74670. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74671. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74672. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74673. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74674. /**
  74675. * Defines the list of states available for a task inside a AssetsManager
  74676. */
  74677. export enum AssetTaskState {
  74678. /**
  74679. * Initialization
  74680. */
  74681. INIT = 0,
  74682. /**
  74683. * Running
  74684. */
  74685. RUNNING = 1,
  74686. /**
  74687. * Done
  74688. */
  74689. DONE = 2,
  74690. /**
  74691. * Error
  74692. */
  74693. ERROR = 3
  74694. }
  74695. /**
  74696. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74697. */
  74698. export abstract class AbstractAssetTask {
  74699. /**
  74700. * Task name
  74701. */ name: string;
  74702. /**
  74703. * Callback called when the task is successful
  74704. */
  74705. onSuccess: (task: any) => void;
  74706. /**
  74707. * Callback called when the task is not successful
  74708. */
  74709. onError: (task: any, message?: string, exception?: any) => void;
  74710. /**
  74711. * Creates a new AssetsManager
  74712. * @param name defines the name of the task
  74713. */
  74714. constructor(
  74715. /**
  74716. * Task name
  74717. */ name: string);
  74718. private _isCompleted;
  74719. private _taskState;
  74720. private _errorObject;
  74721. /**
  74722. * Get if the task is completed
  74723. */
  74724. get isCompleted(): boolean;
  74725. /**
  74726. * Gets the current state of the task
  74727. */
  74728. get taskState(): AssetTaskState;
  74729. /**
  74730. * Gets the current error object (if task is in error)
  74731. */
  74732. get errorObject(): {
  74733. message?: string;
  74734. exception?: any;
  74735. };
  74736. /**
  74737. * Internal only
  74738. * @hidden
  74739. */
  74740. _setErrorObject(message?: string, exception?: any): void;
  74741. /**
  74742. * Execute the current task
  74743. * @param scene defines the scene where you want your assets to be loaded
  74744. * @param onSuccess is a callback called when the task is successfully executed
  74745. * @param onError is a callback called if an error occurs
  74746. */
  74747. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74748. /**
  74749. * Execute the current task
  74750. * @param scene defines the scene where you want your assets to be loaded
  74751. * @param onSuccess is a callback called when the task is successfully executed
  74752. * @param onError is a callback called if an error occurs
  74753. */
  74754. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74755. /**
  74756. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74757. * This can be used with failed tasks that have the reason for failure fixed.
  74758. */
  74759. reset(): void;
  74760. private onErrorCallback;
  74761. private onDoneCallback;
  74762. }
  74763. /**
  74764. * Define the interface used by progress events raised during assets loading
  74765. */
  74766. export interface IAssetsProgressEvent {
  74767. /**
  74768. * Defines the number of remaining tasks to process
  74769. */
  74770. remainingCount: number;
  74771. /**
  74772. * Defines the total number of tasks
  74773. */
  74774. totalCount: number;
  74775. /**
  74776. * Defines the task that was just processed
  74777. */
  74778. task: AbstractAssetTask;
  74779. }
  74780. /**
  74781. * Class used to share progress information about assets loading
  74782. */
  74783. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74784. /**
  74785. * Defines the number of remaining tasks to process
  74786. */
  74787. remainingCount: number;
  74788. /**
  74789. * Defines the total number of tasks
  74790. */
  74791. totalCount: number;
  74792. /**
  74793. * Defines the task that was just processed
  74794. */
  74795. task: AbstractAssetTask;
  74796. /**
  74797. * Creates a AssetsProgressEvent
  74798. * @param remainingCount defines the number of remaining tasks to process
  74799. * @param totalCount defines the total number of tasks
  74800. * @param task defines the task that was just processed
  74801. */
  74802. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74803. }
  74804. /**
  74805. * Define a task used by AssetsManager to load meshes
  74806. */
  74807. export class MeshAssetTask extends AbstractAssetTask {
  74808. /**
  74809. * Defines the name of the task
  74810. */
  74811. name: string;
  74812. /**
  74813. * Defines the list of mesh's names you want to load
  74814. */
  74815. meshesNames: any;
  74816. /**
  74817. * Defines the root url to use as a base to load your meshes and associated resources
  74818. */
  74819. rootUrl: string;
  74820. /**
  74821. * Defines the filename or File of the scene to load from
  74822. */
  74823. sceneFilename: string | File;
  74824. /**
  74825. * Gets the list of loaded meshes
  74826. */
  74827. loadedMeshes: Array<AbstractMesh>;
  74828. /**
  74829. * Gets the list of loaded particle systems
  74830. */
  74831. loadedParticleSystems: Array<IParticleSystem>;
  74832. /**
  74833. * Gets the list of loaded skeletons
  74834. */
  74835. loadedSkeletons: Array<Skeleton>;
  74836. /**
  74837. * Gets the list of loaded animation groups
  74838. */
  74839. loadedAnimationGroups: Array<AnimationGroup>;
  74840. /**
  74841. * Callback called when the task is successful
  74842. */
  74843. onSuccess: (task: MeshAssetTask) => void;
  74844. /**
  74845. * Callback called when the task is successful
  74846. */
  74847. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74848. /**
  74849. * Creates a new MeshAssetTask
  74850. * @param name defines the name of the task
  74851. * @param meshesNames defines the list of mesh's names you want to load
  74852. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74853. * @param sceneFilename defines the filename or File of the scene to load from
  74854. */
  74855. constructor(
  74856. /**
  74857. * Defines the name of the task
  74858. */
  74859. name: string,
  74860. /**
  74861. * Defines the list of mesh's names you want to load
  74862. */
  74863. meshesNames: any,
  74864. /**
  74865. * Defines the root url to use as a base to load your meshes and associated resources
  74866. */
  74867. rootUrl: string,
  74868. /**
  74869. * Defines the filename or File of the scene to load from
  74870. */
  74871. sceneFilename: string | File);
  74872. /**
  74873. * Execute the current task
  74874. * @param scene defines the scene where you want your assets to be loaded
  74875. * @param onSuccess is a callback called when the task is successfully executed
  74876. * @param onError is a callback called if an error occurs
  74877. */
  74878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74879. }
  74880. /**
  74881. * Define a task used by AssetsManager to load text content
  74882. */
  74883. export class TextFileAssetTask extends AbstractAssetTask {
  74884. /**
  74885. * Defines the name of the task
  74886. */
  74887. name: string;
  74888. /**
  74889. * Defines the location of the file to load
  74890. */
  74891. url: string;
  74892. /**
  74893. * Gets the loaded text string
  74894. */
  74895. text: string;
  74896. /**
  74897. * Callback called when the task is successful
  74898. */
  74899. onSuccess: (task: TextFileAssetTask) => void;
  74900. /**
  74901. * Callback called when the task is successful
  74902. */
  74903. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74904. /**
  74905. * Creates a new TextFileAssetTask object
  74906. * @param name defines the name of the task
  74907. * @param url defines the location of the file to load
  74908. */
  74909. constructor(
  74910. /**
  74911. * Defines the name of the task
  74912. */
  74913. name: string,
  74914. /**
  74915. * Defines the location of the file to load
  74916. */
  74917. url: string);
  74918. /**
  74919. * Execute the current task
  74920. * @param scene defines the scene where you want your assets to be loaded
  74921. * @param onSuccess is a callback called when the task is successfully executed
  74922. * @param onError is a callback called if an error occurs
  74923. */
  74924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74925. }
  74926. /**
  74927. * Define a task used by AssetsManager to load binary data
  74928. */
  74929. export class BinaryFileAssetTask extends AbstractAssetTask {
  74930. /**
  74931. * Defines the name of the task
  74932. */
  74933. name: string;
  74934. /**
  74935. * Defines the location of the file to load
  74936. */
  74937. url: string;
  74938. /**
  74939. * Gets the lodaded data (as an array buffer)
  74940. */
  74941. data: ArrayBuffer;
  74942. /**
  74943. * Callback called when the task is successful
  74944. */
  74945. onSuccess: (task: BinaryFileAssetTask) => void;
  74946. /**
  74947. * Callback called when the task is successful
  74948. */
  74949. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74950. /**
  74951. * Creates a new BinaryFileAssetTask object
  74952. * @param name defines the name of the new task
  74953. * @param url defines the location of the file to load
  74954. */
  74955. constructor(
  74956. /**
  74957. * Defines the name of the task
  74958. */
  74959. name: string,
  74960. /**
  74961. * Defines the location of the file to load
  74962. */
  74963. url: string);
  74964. /**
  74965. * Execute the current task
  74966. * @param scene defines the scene where you want your assets to be loaded
  74967. * @param onSuccess is a callback called when the task is successfully executed
  74968. * @param onError is a callback called if an error occurs
  74969. */
  74970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74971. }
  74972. /**
  74973. * Define a task used by AssetsManager to load images
  74974. */
  74975. export class ImageAssetTask extends AbstractAssetTask {
  74976. /**
  74977. * Defines the name of the task
  74978. */
  74979. name: string;
  74980. /**
  74981. * Defines the location of the image to load
  74982. */
  74983. url: string;
  74984. /**
  74985. * Gets the loaded images
  74986. */
  74987. image: HTMLImageElement;
  74988. /**
  74989. * Callback called when the task is successful
  74990. */
  74991. onSuccess: (task: ImageAssetTask) => void;
  74992. /**
  74993. * Callback called when the task is successful
  74994. */
  74995. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74996. /**
  74997. * Creates a new ImageAssetTask
  74998. * @param name defines the name of the task
  74999. * @param url defines the location of the image to load
  75000. */
  75001. constructor(
  75002. /**
  75003. * Defines the name of the task
  75004. */
  75005. name: string,
  75006. /**
  75007. * Defines the location of the image to load
  75008. */
  75009. url: string);
  75010. /**
  75011. * Execute the current task
  75012. * @param scene defines the scene where you want your assets to be loaded
  75013. * @param onSuccess is a callback called when the task is successfully executed
  75014. * @param onError is a callback called if an error occurs
  75015. */
  75016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75017. }
  75018. /**
  75019. * Defines the interface used by texture loading tasks
  75020. */
  75021. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75022. /**
  75023. * Gets the loaded texture
  75024. */
  75025. texture: TEX;
  75026. }
  75027. /**
  75028. * Define a task used by AssetsManager to load 2D textures
  75029. */
  75030. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75031. /**
  75032. * Defines the name of the task
  75033. */
  75034. name: string;
  75035. /**
  75036. * Defines the location of the file to load
  75037. */
  75038. url: string;
  75039. /**
  75040. * Defines if mipmap should not be generated (default is false)
  75041. */
  75042. noMipmap?: boolean | undefined;
  75043. /**
  75044. * Defines if texture must be inverted on Y axis (default is true)
  75045. */
  75046. invertY: boolean;
  75047. /**
  75048. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75049. */
  75050. samplingMode: number;
  75051. /**
  75052. * Gets the loaded texture
  75053. */
  75054. texture: Texture;
  75055. /**
  75056. * Callback called when the task is successful
  75057. */
  75058. onSuccess: (task: TextureAssetTask) => void;
  75059. /**
  75060. * Callback called when the task is successful
  75061. */
  75062. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75063. /**
  75064. * Creates a new TextureAssetTask object
  75065. * @param name defines the name of the task
  75066. * @param url defines the location of the file to load
  75067. * @param noMipmap defines if mipmap should not be generated (default is false)
  75068. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75069. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75070. */
  75071. constructor(
  75072. /**
  75073. * Defines the name of the task
  75074. */
  75075. name: string,
  75076. /**
  75077. * Defines the location of the file to load
  75078. */
  75079. url: string,
  75080. /**
  75081. * Defines if mipmap should not be generated (default is false)
  75082. */
  75083. noMipmap?: boolean | undefined,
  75084. /**
  75085. * Defines if texture must be inverted on Y axis (default is true)
  75086. */
  75087. invertY?: boolean,
  75088. /**
  75089. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75090. */
  75091. samplingMode?: number);
  75092. /**
  75093. * Execute the current task
  75094. * @param scene defines the scene where you want your assets to be loaded
  75095. * @param onSuccess is a callback called when the task is successfully executed
  75096. * @param onError is a callback called if an error occurs
  75097. */
  75098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75099. }
  75100. /**
  75101. * Define a task used by AssetsManager to load cube textures
  75102. */
  75103. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75104. /**
  75105. * Defines the name of the task
  75106. */
  75107. name: string;
  75108. /**
  75109. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75110. */
  75111. url: string;
  75112. /**
  75113. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75114. */
  75115. extensions?: string[] | undefined;
  75116. /**
  75117. * Defines if mipmaps should not be generated (default is false)
  75118. */
  75119. noMipmap?: boolean | undefined;
  75120. /**
  75121. * Defines the explicit list of files (undefined by default)
  75122. */
  75123. files?: string[] | undefined;
  75124. /**
  75125. * Gets the loaded texture
  75126. */
  75127. texture: CubeTexture;
  75128. /**
  75129. * Callback called when the task is successful
  75130. */
  75131. onSuccess: (task: CubeTextureAssetTask) => void;
  75132. /**
  75133. * Callback called when the task is successful
  75134. */
  75135. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75136. /**
  75137. * Creates a new CubeTextureAssetTask
  75138. * @param name defines the name of the task
  75139. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75140. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75141. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75142. * @param files defines the explicit list of files (undefined by default)
  75143. */
  75144. constructor(
  75145. /**
  75146. * Defines the name of the task
  75147. */
  75148. name: string,
  75149. /**
  75150. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75151. */
  75152. url: string,
  75153. /**
  75154. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75155. */
  75156. extensions?: string[] | undefined,
  75157. /**
  75158. * Defines if mipmaps should not be generated (default is false)
  75159. */
  75160. noMipmap?: boolean | undefined,
  75161. /**
  75162. * Defines the explicit list of files (undefined by default)
  75163. */
  75164. files?: string[] | undefined);
  75165. /**
  75166. * Execute the current task
  75167. * @param scene defines the scene where you want your assets to be loaded
  75168. * @param onSuccess is a callback called when the task is successfully executed
  75169. * @param onError is a callback called if an error occurs
  75170. */
  75171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75172. }
  75173. /**
  75174. * Define a task used by AssetsManager to load HDR cube textures
  75175. */
  75176. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75177. /**
  75178. * Defines the name of the task
  75179. */
  75180. name: string;
  75181. /**
  75182. * Defines the location of the file to load
  75183. */
  75184. url: string;
  75185. /**
  75186. * Defines the desired size (the more it increases the longer the generation will be)
  75187. */
  75188. size: number;
  75189. /**
  75190. * Defines if mipmaps should not be generated (default is false)
  75191. */
  75192. noMipmap: boolean;
  75193. /**
  75194. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75195. */
  75196. generateHarmonics: boolean;
  75197. /**
  75198. * 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)
  75199. */
  75200. gammaSpace: boolean;
  75201. /**
  75202. * Internal Use Only
  75203. */
  75204. reserved: boolean;
  75205. /**
  75206. * Gets the loaded texture
  75207. */
  75208. texture: HDRCubeTexture;
  75209. /**
  75210. * Callback called when the task is successful
  75211. */
  75212. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75213. /**
  75214. * Callback called when the task is successful
  75215. */
  75216. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75217. /**
  75218. * Creates a new HDRCubeTextureAssetTask object
  75219. * @param name defines the name of the task
  75220. * @param url defines the location of the file to load
  75221. * @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.
  75222. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75223. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75224. * @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)
  75225. * @param reserved Internal use only
  75226. */
  75227. constructor(
  75228. /**
  75229. * Defines the name of the task
  75230. */
  75231. name: string,
  75232. /**
  75233. * Defines the location of the file to load
  75234. */
  75235. url: string,
  75236. /**
  75237. * Defines the desired size (the more it increases the longer the generation will be)
  75238. */
  75239. size: number,
  75240. /**
  75241. * Defines if mipmaps should not be generated (default is false)
  75242. */
  75243. noMipmap?: boolean,
  75244. /**
  75245. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75246. */
  75247. generateHarmonics?: boolean,
  75248. /**
  75249. * 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)
  75250. */
  75251. gammaSpace?: boolean,
  75252. /**
  75253. * Internal Use Only
  75254. */
  75255. reserved?: boolean);
  75256. /**
  75257. * Execute the current task
  75258. * @param scene defines the scene where you want your assets to be loaded
  75259. * @param onSuccess is a callback called when the task is successfully executed
  75260. * @param onError is a callback called if an error occurs
  75261. */
  75262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75263. }
  75264. /**
  75265. * Define a task used by AssetsManager to load Equirectangular cube textures
  75266. */
  75267. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75268. /**
  75269. * Defines the name of the task
  75270. */
  75271. name: string;
  75272. /**
  75273. * Defines the location of the file to load
  75274. */
  75275. url: string;
  75276. /**
  75277. * Defines the desired size (the more it increases the longer the generation will be)
  75278. */
  75279. size: number;
  75280. /**
  75281. * Defines if mipmaps should not be generated (default is false)
  75282. */
  75283. noMipmap: boolean;
  75284. /**
  75285. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75286. * but the standard material would require them in Gamma space) (default is true)
  75287. */
  75288. gammaSpace: boolean;
  75289. /**
  75290. * Gets the loaded texture
  75291. */
  75292. texture: EquiRectangularCubeTexture;
  75293. /**
  75294. * Callback called when the task is successful
  75295. */
  75296. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75297. /**
  75298. * Callback called when the task is successful
  75299. */
  75300. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75301. /**
  75302. * Creates a new EquiRectangularCubeTextureAssetTask object
  75303. * @param name defines the name of the task
  75304. * @param url defines the location of the file to load
  75305. * @param size defines the desired size (the more it increases the longer the generation will be)
  75306. * If the size is omitted this implies you are using a preprocessed cubemap.
  75307. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75308. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75309. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75310. * (default is true)
  75311. */
  75312. constructor(
  75313. /**
  75314. * Defines the name of the task
  75315. */
  75316. name: string,
  75317. /**
  75318. * Defines the location of the file to load
  75319. */
  75320. url: string,
  75321. /**
  75322. * Defines the desired size (the more it increases the longer the generation will be)
  75323. */
  75324. size: number,
  75325. /**
  75326. * Defines if mipmaps should not be generated (default is false)
  75327. */
  75328. noMipmap?: boolean,
  75329. /**
  75330. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75331. * but the standard material would require them in Gamma space) (default is true)
  75332. */
  75333. gammaSpace?: boolean);
  75334. /**
  75335. * Execute the current task
  75336. * @param scene defines the scene where you want your assets to be loaded
  75337. * @param onSuccess is a callback called when the task is successfully executed
  75338. * @param onError is a callback called if an error occurs
  75339. */
  75340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75341. }
  75342. /**
  75343. * This class can be used to easily import assets into a scene
  75344. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75345. */
  75346. export class AssetsManager {
  75347. private _scene;
  75348. private _isLoading;
  75349. protected _tasks: AbstractAssetTask[];
  75350. protected _waitingTasksCount: number;
  75351. protected _totalTasksCount: number;
  75352. /**
  75353. * Callback called when all tasks are processed
  75354. */
  75355. onFinish: (tasks: AbstractAssetTask[]) => void;
  75356. /**
  75357. * Callback called when a task is successful
  75358. */
  75359. onTaskSuccess: (task: AbstractAssetTask) => void;
  75360. /**
  75361. * Callback called when a task had an error
  75362. */
  75363. onTaskError: (task: AbstractAssetTask) => void;
  75364. /**
  75365. * Callback called when a task is done (whatever the result is)
  75366. */
  75367. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75368. /**
  75369. * Observable called when all tasks are processed
  75370. */
  75371. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75372. /**
  75373. * Observable called when a task had an error
  75374. */
  75375. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75376. /**
  75377. * Observable called when all tasks were executed
  75378. */
  75379. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75380. /**
  75381. * Observable called when a task is done (whatever the result is)
  75382. */
  75383. onProgressObservable: Observable<IAssetsProgressEvent>;
  75384. /**
  75385. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75387. */
  75388. useDefaultLoadingScreen: boolean;
  75389. /**
  75390. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75391. * when all assets have been downloaded.
  75392. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75393. */
  75394. autoHideLoadingUI: boolean;
  75395. /**
  75396. * Creates a new AssetsManager
  75397. * @param scene defines the scene to work on
  75398. */
  75399. constructor(scene: Scene);
  75400. /**
  75401. * Add a MeshAssetTask to the list of active tasks
  75402. * @param taskName defines the name of the new task
  75403. * @param meshesNames defines the name of meshes to load
  75404. * @param rootUrl defines the root url to use to locate files
  75405. * @param sceneFilename defines the filename of the scene file
  75406. * @returns a new MeshAssetTask object
  75407. */
  75408. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75409. /**
  75410. * Add a TextFileAssetTask to the list of active tasks
  75411. * @param taskName defines the name of the new task
  75412. * @param url defines the url of the file to load
  75413. * @returns a new TextFileAssetTask object
  75414. */
  75415. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75416. /**
  75417. * Add a BinaryFileAssetTask to the list of active tasks
  75418. * @param taskName defines the name of the new task
  75419. * @param url defines the url of the file to load
  75420. * @returns a new BinaryFileAssetTask object
  75421. */
  75422. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75423. /**
  75424. * Add a ImageAssetTask to the list of active tasks
  75425. * @param taskName defines the name of the new task
  75426. * @param url defines the url of the file to load
  75427. * @returns a new ImageAssetTask object
  75428. */
  75429. addImageTask(taskName: string, url: string): ImageAssetTask;
  75430. /**
  75431. * Add a TextureAssetTask to the list of active tasks
  75432. * @param taskName defines the name of the new task
  75433. * @param url defines the url of the file to load
  75434. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75435. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75436. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75437. * @returns a new TextureAssetTask object
  75438. */
  75439. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75440. /**
  75441. * Add a CubeTextureAssetTask to the list of active tasks
  75442. * @param taskName defines the name of the new task
  75443. * @param url defines the url of the file to load
  75444. * @param extensions defines the extension to use to load the cube map (can be null)
  75445. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75446. * @param files defines the list of files to load (can be null)
  75447. * @returns a new CubeTextureAssetTask object
  75448. */
  75449. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75450. /**
  75451. *
  75452. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75453. * @param taskName defines the name of the new task
  75454. * @param url defines the url of the file to load
  75455. * @param size defines the size you want for the cubemap (can be null)
  75456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75457. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75458. * @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)
  75459. * @param reserved Internal use only
  75460. * @returns a new HDRCubeTextureAssetTask object
  75461. */
  75462. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75463. /**
  75464. *
  75465. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75466. * @param taskName defines the name of the new task
  75467. * @param url defines the url of the file to load
  75468. * @param size defines the size you want for the cubemap (can be null)
  75469. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75470. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75471. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75472. * @returns a new EquiRectangularCubeTextureAssetTask object
  75473. */
  75474. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75475. /**
  75476. * Remove a task from the assets manager.
  75477. * @param task the task to remove
  75478. */
  75479. removeTask(task: AbstractAssetTask): void;
  75480. private _decreaseWaitingTasksCount;
  75481. private _runTask;
  75482. /**
  75483. * Reset the AssetsManager and remove all tasks
  75484. * @return the current instance of the AssetsManager
  75485. */
  75486. reset(): AssetsManager;
  75487. /**
  75488. * Start the loading process
  75489. * @return the current instance of the AssetsManager
  75490. */
  75491. load(): AssetsManager;
  75492. /**
  75493. * Start the loading process as an async operation
  75494. * @return a promise returning the list of failed tasks
  75495. */
  75496. loadAsync(): Promise<void>;
  75497. }
  75498. }
  75499. declare module "babylonjs/Misc/deferred" {
  75500. /**
  75501. * Wrapper class for promise with external resolve and reject.
  75502. */
  75503. export class Deferred<T> {
  75504. /**
  75505. * The promise associated with this deferred object.
  75506. */
  75507. readonly promise: Promise<T>;
  75508. private _resolve;
  75509. private _reject;
  75510. /**
  75511. * The resolve method of the promise associated with this deferred object.
  75512. */
  75513. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75514. /**
  75515. * The reject method of the promise associated with this deferred object.
  75516. */
  75517. get reject(): (reason?: any) => void;
  75518. /**
  75519. * Constructor for this deferred object.
  75520. */
  75521. constructor();
  75522. }
  75523. }
  75524. declare module "babylonjs/Misc/meshExploder" {
  75525. import { Mesh } from "babylonjs/Meshes/mesh";
  75526. /**
  75527. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75528. */
  75529. export class MeshExploder {
  75530. private _centerMesh;
  75531. private _meshes;
  75532. private _meshesOrigins;
  75533. private _toCenterVectors;
  75534. private _scaledDirection;
  75535. private _newPosition;
  75536. private _centerPosition;
  75537. /**
  75538. * Explodes meshes from a center mesh.
  75539. * @param meshes The meshes to explode.
  75540. * @param centerMesh The mesh to be center of explosion.
  75541. */
  75542. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75543. private _setCenterMesh;
  75544. /**
  75545. * Get class name
  75546. * @returns "MeshExploder"
  75547. */
  75548. getClassName(): string;
  75549. /**
  75550. * "Exploded meshes"
  75551. * @returns Array of meshes with the centerMesh at index 0.
  75552. */
  75553. getMeshes(): Array<Mesh>;
  75554. /**
  75555. * Explodes meshes giving a specific direction
  75556. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75557. */
  75558. explode(direction?: number): void;
  75559. }
  75560. }
  75561. declare module "babylonjs/Misc/filesInput" {
  75562. import { Engine } from "babylonjs/Engines/engine";
  75563. import { Scene } from "babylonjs/scene";
  75564. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75565. /**
  75566. * Class used to help managing file picking and drag'n'drop
  75567. */
  75568. export class FilesInput {
  75569. /**
  75570. * List of files ready to be loaded
  75571. */
  75572. static get FilesToLoad(): {
  75573. [key: string]: File;
  75574. };
  75575. /**
  75576. * Callback called when a file is processed
  75577. */
  75578. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75579. private _engine;
  75580. private _currentScene;
  75581. private _sceneLoadedCallback;
  75582. private _progressCallback;
  75583. private _additionalRenderLoopLogicCallback;
  75584. private _textureLoadingCallback;
  75585. private _startingProcessingFilesCallback;
  75586. private _onReloadCallback;
  75587. private _errorCallback;
  75588. private _elementToMonitor;
  75589. private _sceneFileToLoad;
  75590. private _filesToLoad;
  75591. /**
  75592. * Creates a new FilesInput
  75593. * @param engine defines the rendering engine
  75594. * @param scene defines the hosting scene
  75595. * @param sceneLoadedCallback callback called when scene is loaded
  75596. * @param progressCallback callback called to track progress
  75597. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75598. * @param textureLoadingCallback callback called when a texture is loading
  75599. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75600. * @param onReloadCallback callback called when a reload is requested
  75601. * @param errorCallback callback call if an error occurs
  75602. */
  75603. 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);
  75604. private _dragEnterHandler;
  75605. private _dragOverHandler;
  75606. private _dropHandler;
  75607. /**
  75608. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75609. * @param elementToMonitor defines the DOM element to track
  75610. */
  75611. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75612. /**
  75613. * Release all associated resources
  75614. */
  75615. dispose(): void;
  75616. private renderFunction;
  75617. private drag;
  75618. private drop;
  75619. private _traverseFolder;
  75620. private _processFiles;
  75621. /**
  75622. * Load files from a drop event
  75623. * @param event defines the drop event to use as source
  75624. */
  75625. loadFiles(event: any): void;
  75626. private _processReload;
  75627. /**
  75628. * Reload the current scene from the loaded files
  75629. */
  75630. reload(): void;
  75631. }
  75632. }
  75633. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75634. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75635. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75636. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75637. }
  75638. declare module "babylonjs/Misc/sceneOptimizer" {
  75639. import { Scene, IDisposable } from "babylonjs/scene";
  75640. import { Observable } from "babylonjs/Misc/observable";
  75641. /**
  75642. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75644. */
  75645. export class SceneOptimization {
  75646. /**
  75647. * Defines the priority of this optimization (0 by default which means first in the list)
  75648. */
  75649. priority: number;
  75650. /**
  75651. * Gets a string describing the action executed by the current optimization
  75652. * @returns description string
  75653. */
  75654. getDescription(): string;
  75655. /**
  75656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75657. * @param scene defines the current scene where to apply this optimization
  75658. * @param optimizer defines the current optimizer
  75659. * @returns true if everything that can be done was applied
  75660. */
  75661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75662. /**
  75663. * Creates the SceneOptimization object
  75664. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75665. * @param desc defines the description associated with the optimization
  75666. */
  75667. constructor(
  75668. /**
  75669. * Defines the priority of this optimization (0 by default which means first in the list)
  75670. */
  75671. priority?: number);
  75672. }
  75673. /**
  75674. * Defines an optimization used to reduce the size of render target textures
  75675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75676. */
  75677. export class TextureOptimization extends SceneOptimization {
  75678. /**
  75679. * Defines the priority of this optimization (0 by default which means first in the list)
  75680. */
  75681. priority: number;
  75682. /**
  75683. * 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
  75684. */
  75685. maximumSize: number;
  75686. /**
  75687. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75688. */
  75689. step: number;
  75690. /**
  75691. * Gets a string describing the action executed by the current optimization
  75692. * @returns description string
  75693. */
  75694. getDescription(): string;
  75695. /**
  75696. * Creates the TextureOptimization object
  75697. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75698. * @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
  75699. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75700. */
  75701. constructor(
  75702. /**
  75703. * Defines the priority of this optimization (0 by default which means first in the list)
  75704. */
  75705. priority?: number,
  75706. /**
  75707. * 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
  75708. */
  75709. maximumSize?: number,
  75710. /**
  75711. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75712. */
  75713. step?: number);
  75714. /**
  75715. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75716. * @param scene defines the current scene where to apply this optimization
  75717. * @param optimizer defines the current optimizer
  75718. * @returns true if everything that can be done was applied
  75719. */
  75720. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75721. }
  75722. /**
  75723. * Defines an optimization used to increase or decrease the rendering resolution
  75724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75725. */
  75726. export class HardwareScalingOptimization extends SceneOptimization {
  75727. /**
  75728. * Defines the priority of this optimization (0 by default which means first in the list)
  75729. */
  75730. priority: number;
  75731. /**
  75732. * Defines the maximum scale to use (2 by default)
  75733. */
  75734. maximumScale: number;
  75735. /**
  75736. * Defines the step to use between two passes (0.5 by default)
  75737. */
  75738. step: number;
  75739. private _currentScale;
  75740. private _directionOffset;
  75741. /**
  75742. * Gets a string describing the action executed by the current optimization
  75743. * @return description string
  75744. */
  75745. getDescription(): string;
  75746. /**
  75747. * Creates the HardwareScalingOptimization object
  75748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75749. * @param maximumScale defines the maximum scale to use (2 by default)
  75750. * @param step defines the step to use between two passes (0.5 by default)
  75751. */
  75752. constructor(
  75753. /**
  75754. * Defines the priority of this optimization (0 by default which means first in the list)
  75755. */
  75756. priority?: number,
  75757. /**
  75758. * Defines the maximum scale to use (2 by default)
  75759. */
  75760. maximumScale?: number,
  75761. /**
  75762. * Defines the step to use between two passes (0.5 by default)
  75763. */
  75764. step?: number);
  75765. /**
  75766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75767. * @param scene defines the current scene where to apply this optimization
  75768. * @param optimizer defines the current optimizer
  75769. * @returns true if everything that can be done was applied
  75770. */
  75771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75772. }
  75773. /**
  75774. * Defines an optimization used to remove shadows
  75775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75776. */
  75777. export class ShadowsOptimization extends SceneOptimization {
  75778. /**
  75779. * Gets a string describing the action executed by the current optimization
  75780. * @return description string
  75781. */
  75782. getDescription(): string;
  75783. /**
  75784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75785. * @param scene defines the current scene where to apply this optimization
  75786. * @param optimizer defines the current optimizer
  75787. * @returns true if everything that can be done was applied
  75788. */
  75789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75790. }
  75791. /**
  75792. * Defines an optimization used to turn post-processes off
  75793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75794. */
  75795. export class PostProcessesOptimization extends SceneOptimization {
  75796. /**
  75797. * Gets a string describing the action executed by the current optimization
  75798. * @return description string
  75799. */
  75800. getDescription(): string;
  75801. /**
  75802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75803. * @param scene defines the current scene where to apply this optimization
  75804. * @param optimizer defines the current optimizer
  75805. * @returns true if everything that can be done was applied
  75806. */
  75807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75808. }
  75809. /**
  75810. * Defines an optimization used to turn lens flares off
  75811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75812. */
  75813. export class LensFlaresOptimization extends SceneOptimization {
  75814. /**
  75815. * Gets a string describing the action executed by the current optimization
  75816. * @return description string
  75817. */
  75818. getDescription(): string;
  75819. /**
  75820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75821. * @param scene defines the current scene where to apply this optimization
  75822. * @param optimizer defines the current optimizer
  75823. * @returns true if everything that can be done was applied
  75824. */
  75825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75826. }
  75827. /**
  75828. * Defines an optimization based on user defined callback.
  75829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75830. */
  75831. export class CustomOptimization extends SceneOptimization {
  75832. /**
  75833. * Callback called to apply the custom optimization.
  75834. */
  75835. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75836. /**
  75837. * Callback called to get custom description
  75838. */
  75839. onGetDescription: () => string;
  75840. /**
  75841. * Gets a string describing the action executed by the current optimization
  75842. * @returns description string
  75843. */
  75844. getDescription(): string;
  75845. /**
  75846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75847. * @param scene defines the current scene where to apply this optimization
  75848. * @param optimizer defines the current optimizer
  75849. * @returns true if everything that can be done was applied
  75850. */
  75851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75852. }
  75853. /**
  75854. * Defines an optimization used to turn particles off
  75855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75856. */
  75857. export class ParticlesOptimization extends SceneOptimization {
  75858. /**
  75859. * Gets a string describing the action executed by the current optimization
  75860. * @return description string
  75861. */
  75862. getDescription(): string;
  75863. /**
  75864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75865. * @param scene defines the current scene where to apply this optimization
  75866. * @param optimizer defines the current optimizer
  75867. * @returns true if everything that can be done was applied
  75868. */
  75869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75870. }
  75871. /**
  75872. * Defines an optimization used to turn render targets off
  75873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75874. */
  75875. export class RenderTargetsOptimization extends SceneOptimization {
  75876. /**
  75877. * Gets a string describing the action executed by the current optimization
  75878. * @return description string
  75879. */
  75880. getDescription(): string;
  75881. /**
  75882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75883. * @param scene defines the current scene where to apply this optimization
  75884. * @param optimizer defines the current optimizer
  75885. * @returns true if everything that can be done was applied
  75886. */
  75887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75888. }
  75889. /**
  75890. * Defines an optimization used to merge meshes with compatible materials
  75891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75892. */
  75893. export class MergeMeshesOptimization extends SceneOptimization {
  75894. private static _UpdateSelectionTree;
  75895. /**
  75896. * Gets or sets a boolean which defines if optimization octree has to be updated
  75897. */
  75898. static get UpdateSelectionTree(): boolean;
  75899. /**
  75900. * Gets or sets a boolean which defines if optimization octree has to be updated
  75901. */
  75902. static set UpdateSelectionTree(value: boolean);
  75903. /**
  75904. * Gets a string describing the action executed by the current optimization
  75905. * @return description string
  75906. */
  75907. getDescription(): string;
  75908. private _canBeMerged;
  75909. /**
  75910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75911. * @param scene defines the current scene where to apply this optimization
  75912. * @param optimizer defines the current optimizer
  75913. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75914. * @returns true if everything that can be done was applied
  75915. */
  75916. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75917. }
  75918. /**
  75919. * Defines a list of options used by SceneOptimizer
  75920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75921. */
  75922. export class SceneOptimizerOptions {
  75923. /**
  75924. * Defines the target frame rate to reach (60 by default)
  75925. */
  75926. targetFrameRate: number;
  75927. /**
  75928. * Defines the interval between two checkes (2000ms by default)
  75929. */
  75930. trackerDuration: number;
  75931. /**
  75932. * Gets the list of optimizations to apply
  75933. */
  75934. optimizations: SceneOptimization[];
  75935. /**
  75936. * Creates a new list of options used by SceneOptimizer
  75937. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75938. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75939. */
  75940. constructor(
  75941. /**
  75942. * Defines the target frame rate to reach (60 by default)
  75943. */
  75944. targetFrameRate?: number,
  75945. /**
  75946. * Defines the interval between two checkes (2000ms by default)
  75947. */
  75948. trackerDuration?: number);
  75949. /**
  75950. * Add a new optimization
  75951. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75952. * @returns the current SceneOptimizerOptions
  75953. */
  75954. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75955. /**
  75956. * Add a new custom optimization
  75957. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75958. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75959. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75960. * @returns the current SceneOptimizerOptions
  75961. */
  75962. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75963. /**
  75964. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75965. * @param targetFrameRate defines the target frame rate (60 by default)
  75966. * @returns a SceneOptimizerOptions object
  75967. */
  75968. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75969. /**
  75970. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75971. * @param targetFrameRate defines the target frame rate (60 by default)
  75972. * @returns a SceneOptimizerOptions object
  75973. */
  75974. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75975. /**
  75976. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75977. * @param targetFrameRate defines the target frame rate (60 by default)
  75978. * @returns a SceneOptimizerOptions object
  75979. */
  75980. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75981. }
  75982. /**
  75983. * Class used to run optimizations in order to reach a target frame rate
  75984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75985. */
  75986. export class SceneOptimizer implements IDisposable {
  75987. private _isRunning;
  75988. private _options;
  75989. private _scene;
  75990. private _currentPriorityLevel;
  75991. private _targetFrameRate;
  75992. private _trackerDuration;
  75993. private _currentFrameRate;
  75994. private _sceneDisposeObserver;
  75995. private _improvementMode;
  75996. /**
  75997. * Defines an observable called when the optimizer reaches the target frame rate
  75998. */
  75999. onSuccessObservable: Observable<SceneOptimizer>;
  76000. /**
  76001. * Defines an observable called when the optimizer enables an optimization
  76002. */
  76003. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76004. /**
  76005. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76006. */
  76007. onFailureObservable: Observable<SceneOptimizer>;
  76008. /**
  76009. * Gets a boolean indicating if the optimizer is in improvement mode
  76010. */
  76011. get isInImprovementMode(): boolean;
  76012. /**
  76013. * Gets the current priority level (0 at start)
  76014. */
  76015. get currentPriorityLevel(): number;
  76016. /**
  76017. * Gets the current frame rate checked by the SceneOptimizer
  76018. */
  76019. get currentFrameRate(): number;
  76020. /**
  76021. * Gets or sets the current target frame rate (60 by default)
  76022. */
  76023. get targetFrameRate(): number;
  76024. /**
  76025. * Gets or sets the current target frame rate (60 by default)
  76026. */
  76027. set targetFrameRate(value: number);
  76028. /**
  76029. * Gets or sets the current interval between two checks (every 2000ms by default)
  76030. */
  76031. get trackerDuration(): number;
  76032. /**
  76033. * Gets or sets the current interval between two checks (every 2000ms by default)
  76034. */
  76035. set trackerDuration(value: number);
  76036. /**
  76037. * Gets the list of active optimizations
  76038. */
  76039. get optimizations(): SceneOptimization[];
  76040. /**
  76041. * Creates a new SceneOptimizer
  76042. * @param scene defines the scene to work on
  76043. * @param options defines the options to use with the SceneOptimizer
  76044. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76045. * @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)
  76046. */
  76047. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76048. /**
  76049. * Stops the current optimizer
  76050. */
  76051. stop(): void;
  76052. /**
  76053. * Reset the optimizer to initial step (current priority level = 0)
  76054. */
  76055. reset(): void;
  76056. /**
  76057. * Start the optimizer. By default it will try to reach a specific framerate
  76058. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76059. */
  76060. start(): void;
  76061. private _checkCurrentState;
  76062. /**
  76063. * Release all resources
  76064. */
  76065. dispose(): void;
  76066. /**
  76067. * Helper function to create a SceneOptimizer with one single line of code
  76068. * @param scene defines the scene to work on
  76069. * @param options defines the options to use with the SceneOptimizer
  76070. * @param onSuccess defines a callback to call on success
  76071. * @param onFailure defines a callback to call on failure
  76072. * @returns the new SceneOptimizer object
  76073. */
  76074. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76075. }
  76076. }
  76077. declare module "babylonjs/Misc/sceneSerializer" {
  76078. import { Scene } from "babylonjs/scene";
  76079. /**
  76080. * Class used to serialize a scene into a string
  76081. */
  76082. export class SceneSerializer {
  76083. /**
  76084. * Clear cache used by a previous serialization
  76085. */
  76086. static ClearCache(): void;
  76087. /**
  76088. * Serialize a scene into a JSON compatible object
  76089. * @param scene defines the scene to serialize
  76090. * @returns a JSON compatible object
  76091. */
  76092. static Serialize(scene: Scene): any;
  76093. /**
  76094. * Serialize a mesh into a JSON compatible object
  76095. * @param toSerialize defines the mesh to serialize
  76096. * @param withParents defines if parents must be serialized as well
  76097. * @param withChildren defines if children must be serialized as well
  76098. * @returns a JSON compatible object
  76099. */
  76100. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76101. }
  76102. }
  76103. declare module "babylonjs/Misc/textureTools" {
  76104. import { Texture } from "babylonjs/Materials/Textures/texture";
  76105. /**
  76106. * Class used to host texture specific utilities
  76107. */
  76108. export class TextureTools {
  76109. /**
  76110. * Uses the GPU to create a copy texture rescaled at a given size
  76111. * @param texture Texture to copy from
  76112. * @param width defines the desired width
  76113. * @param height defines the desired height
  76114. * @param useBilinearMode defines if bilinear mode has to be used
  76115. * @return the generated texture
  76116. */
  76117. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76118. }
  76119. }
  76120. declare module "babylonjs/Misc/videoRecorder" {
  76121. import { Nullable } from "babylonjs/types";
  76122. import { Engine } from "babylonjs/Engines/engine";
  76123. /**
  76124. * This represents the different options available for the video capture.
  76125. */
  76126. export interface VideoRecorderOptions {
  76127. /** Defines the mime type of the video. */
  76128. mimeType: string;
  76129. /** Defines the FPS the video should be recorded at. */
  76130. fps: number;
  76131. /** Defines the chunk size for the recording data. */
  76132. recordChunckSize: number;
  76133. /** The audio tracks to attach to the recording. */
  76134. audioTracks?: MediaStreamTrack[];
  76135. }
  76136. /**
  76137. * This can help with recording videos from BabylonJS.
  76138. * This is based on the available WebRTC functionalities of the browser.
  76139. *
  76140. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  76141. */
  76142. export class VideoRecorder {
  76143. private static readonly _defaultOptions;
  76144. /**
  76145. * Returns whether or not the VideoRecorder is available in your browser.
  76146. * @param engine Defines the Babylon Engine.
  76147. * @returns true if supported otherwise false.
  76148. */
  76149. static IsSupported(engine: Engine): boolean;
  76150. private readonly _options;
  76151. private _canvas;
  76152. private _mediaRecorder;
  76153. private _recordedChunks;
  76154. private _fileName;
  76155. private _resolve;
  76156. private _reject;
  76157. /**
  76158. * True when a recording is already in progress.
  76159. */
  76160. get isRecording(): boolean;
  76161. /**
  76162. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76163. * @param engine Defines the BabylonJS Engine you wish to record.
  76164. * @param options Defines options that can be used to customize the capture.
  76165. */
  76166. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76167. /**
  76168. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76169. */
  76170. stopRecording(): void;
  76171. /**
  76172. * Starts recording the canvas for a max duration specified in parameters.
  76173. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76174. * If null no automatic download will start and you can rely on the promise to get the data back.
  76175. * @param maxDuration Defines the maximum recording time in seconds.
  76176. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76177. * @return A promise callback at the end of the recording with the video data in Blob.
  76178. */
  76179. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76180. /**
  76181. * Releases internal resources used during the recording.
  76182. */
  76183. dispose(): void;
  76184. private _handleDataAvailable;
  76185. private _handleError;
  76186. private _handleStop;
  76187. }
  76188. }
  76189. declare module "babylonjs/Misc/screenshotTools" {
  76190. import { Camera } from "babylonjs/Cameras/camera";
  76191. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76192. import { Engine } from "babylonjs/Engines/engine";
  76193. /**
  76194. * Class containing a set of static utilities functions for screenshots
  76195. */
  76196. export class ScreenshotTools {
  76197. /**
  76198. * Captures a screenshot of the current rendering
  76199. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76200. * @param engine defines the rendering engine
  76201. * @param camera defines the source camera
  76202. * @param size This parameter can be set to a single number or to an object with the
  76203. * following (optional) properties: precision, width, height. If a single number is passed,
  76204. * it will be used for both width and height. If an object is passed, the screenshot size
  76205. * will be derived from the parameters. The precision property is a multiplier allowing
  76206. * rendering at a higher or lower resolution
  76207. * @param successCallback defines the callback receives a single parameter which contains the
  76208. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76209. * src parameter of an <img> to display it
  76210. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76211. * Check your browser for supported MIME types
  76212. */
  76213. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76214. /**
  76215. * Captures a screenshot of the current rendering
  76216. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76217. * @param engine defines the rendering engine
  76218. * @param camera defines the source camera
  76219. * @param size This parameter can be set to a single number or to an object with the
  76220. * following (optional) properties: precision, width, height. If a single number is passed,
  76221. * it will be used for both width and height. If an object is passed, the screenshot size
  76222. * will be derived from the parameters. The precision property is a multiplier allowing
  76223. * rendering at a higher or lower resolution
  76224. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76225. * Check your browser for supported MIME types
  76226. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76227. * to the src parameter of an <img> to display it
  76228. */
  76229. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76230. /**
  76231. * Generates an image screenshot from the specified camera.
  76232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76233. * @param engine The engine to use for rendering
  76234. * @param camera The camera to use for rendering
  76235. * @param size This parameter can be set to a single number or to an object with the
  76236. * following (optional) properties: precision, width, height. If a single number is passed,
  76237. * it will be used for both width and height. If an object is passed, the screenshot size
  76238. * will be derived from the parameters. The precision property is a multiplier allowing
  76239. * rendering at a higher or lower resolution
  76240. * @param successCallback The callback receives a single parameter which contains the
  76241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76242. * src parameter of an <img> to display it
  76243. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76244. * Check your browser for supported MIME types
  76245. * @param samples Texture samples (default: 1)
  76246. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76247. * @param fileName A name for for the downloaded file.
  76248. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76249. */
  76250. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76251. /**
  76252. * Generates an image screenshot from the specified camera.
  76253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76254. * @param engine The engine to use for rendering
  76255. * @param camera The camera to use for rendering
  76256. * @param size This parameter can be set to a single number or to an object with the
  76257. * following (optional) properties: precision, width, height. If a single number is passed,
  76258. * it will be used for both width and height. If an object is passed, the screenshot size
  76259. * will be derived from the parameters. The precision property is a multiplier allowing
  76260. * rendering at a higher or lower resolution
  76261. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76262. * Check your browser for supported MIME types
  76263. * @param samples Texture samples (default: 1)
  76264. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76265. * @param fileName A name for for the downloaded file.
  76266. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76267. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76268. * to the src parameter of an <img> to display it
  76269. */
  76270. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76271. /**
  76272. * Gets height and width for screenshot size
  76273. * @private
  76274. */
  76275. private static _getScreenshotSize;
  76276. }
  76277. }
  76278. declare module "babylonjs/Misc/dataReader" {
  76279. /**
  76280. * Interface for a data buffer
  76281. */
  76282. export interface IDataBuffer {
  76283. /**
  76284. * Reads bytes from the data buffer.
  76285. * @param byteOffset The byte offset to read
  76286. * @param byteLength The byte length to read
  76287. * @returns A promise that resolves when the bytes are read
  76288. */
  76289. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76290. /**
  76291. * The byte length of the buffer.
  76292. */
  76293. readonly byteLength: number;
  76294. }
  76295. /**
  76296. * Utility class for reading from a data buffer
  76297. */
  76298. export class DataReader {
  76299. /**
  76300. * The data buffer associated with this data reader.
  76301. */
  76302. readonly buffer: IDataBuffer;
  76303. /**
  76304. * The current byte offset from the beginning of the data buffer.
  76305. */
  76306. byteOffset: number;
  76307. private _dataView;
  76308. private _dataByteOffset;
  76309. /**
  76310. * Constructor
  76311. * @param buffer The buffer to read
  76312. */
  76313. constructor(buffer: IDataBuffer);
  76314. /**
  76315. * Loads the given byte length.
  76316. * @param byteLength The byte length to load
  76317. * @returns A promise that resolves when the load is complete
  76318. */
  76319. loadAsync(byteLength: number): Promise<void>;
  76320. /**
  76321. * Read a unsigned 32-bit integer from the currently loaded data range.
  76322. * @returns The 32-bit integer read
  76323. */
  76324. readUint32(): number;
  76325. /**
  76326. * Read a byte array from the currently loaded data range.
  76327. * @param byteLength The byte length to read
  76328. * @returns The byte array read
  76329. */
  76330. readUint8Array(byteLength: number): Uint8Array;
  76331. /**
  76332. * Read a string from the currently loaded data range.
  76333. * @param byteLength The byte length to read
  76334. * @returns The string read
  76335. */
  76336. readString(byteLength: number): string;
  76337. /**
  76338. * Skips the given byte length the currently loaded data range.
  76339. * @param byteLength The byte length to skip
  76340. */
  76341. skipBytes(byteLength: number): void;
  76342. }
  76343. }
  76344. declare module "babylonjs/Misc/dataStorage" {
  76345. /**
  76346. * Class for storing data to local storage if available or in-memory storage otherwise
  76347. */
  76348. export class DataStorage {
  76349. private static _Storage;
  76350. private static _GetStorage;
  76351. /**
  76352. * Reads a string from the data storage
  76353. * @param key The key to read
  76354. * @param defaultValue The value if the key doesn't exist
  76355. * @returns The string value
  76356. */
  76357. static ReadString(key: string, defaultValue: string): string;
  76358. /**
  76359. * Writes a string to the data storage
  76360. * @param key The key to write
  76361. * @param value The value to write
  76362. */
  76363. static WriteString(key: string, value: string): void;
  76364. /**
  76365. * Reads a boolean from the data storage
  76366. * @param key The key to read
  76367. * @param defaultValue The value if the key doesn't exist
  76368. * @returns The boolean value
  76369. */
  76370. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76371. /**
  76372. * Writes a boolean to the data storage
  76373. * @param key The key to write
  76374. * @param value The value to write
  76375. */
  76376. static WriteBoolean(key: string, value: boolean): void;
  76377. /**
  76378. * Reads a number from the data storage
  76379. * @param key The key to read
  76380. * @param defaultValue The value if the key doesn't exist
  76381. * @returns The number value
  76382. */
  76383. static ReadNumber(key: string, defaultValue: number): number;
  76384. /**
  76385. * Writes a number to the data storage
  76386. * @param key The key to write
  76387. * @param value The value to write
  76388. */
  76389. static WriteNumber(key: string, value: number): void;
  76390. }
  76391. }
  76392. declare module "babylonjs/Misc/index" {
  76393. export * from "babylonjs/Misc/andOrNotEvaluator";
  76394. export * from "babylonjs/Misc/assetsManager";
  76395. export * from "babylonjs/Misc/basis";
  76396. export * from "babylonjs/Misc/dds";
  76397. export * from "babylonjs/Misc/decorators";
  76398. export * from "babylonjs/Misc/deferred";
  76399. export * from "babylonjs/Misc/environmentTextureTools";
  76400. export * from "babylonjs/Misc/meshExploder";
  76401. export * from "babylonjs/Misc/filesInput";
  76402. export * from "babylonjs/Misc/HighDynamicRange/index";
  76403. export * from "babylonjs/Misc/khronosTextureContainer";
  76404. export * from "babylonjs/Misc/observable";
  76405. export * from "babylonjs/Misc/performanceMonitor";
  76406. export * from "babylonjs/Misc/promise";
  76407. export * from "babylonjs/Misc/sceneOptimizer";
  76408. export * from "babylonjs/Misc/sceneSerializer";
  76409. export * from "babylonjs/Misc/smartArray";
  76410. export * from "babylonjs/Misc/stringDictionary";
  76411. export * from "babylonjs/Misc/tags";
  76412. export * from "babylonjs/Misc/textureTools";
  76413. export * from "babylonjs/Misc/tga";
  76414. export * from "babylonjs/Misc/tools";
  76415. export * from "babylonjs/Misc/videoRecorder";
  76416. export * from "babylonjs/Misc/virtualJoystick";
  76417. export * from "babylonjs/Misc/workerPool";
  76418. export * from "babylonjs/Misc/logger";
  76419. export * from "babylonjs/Misc/typeStore";
  76420. export * from "babylonjs/Misc/filesInputStore";
  76421. export * from "babylonjs/Misc/deepCopier";
  76422. export * from "babylonjs/Misc/pivotTools";
  76423. export * from "babylonjs/Misc/precisionDate";
  76424. export * from "babylonjs/Misc/screenshotTools";
  76425. export * from "babylonjs/Misc/typeStore";
  76426. export * from "babylonjs/Misc/webRequest";
  76427. export * from "babylonjs/Misc/iInspectable";
  76428. export * from "babylonjs/Misc/brdfTextureTools";
  76429. export * from "babylonjs/Misc/rgbdTextureTools";
  76430. export * from "babylonjs/Misc/gradients";
  76431. export * from "babylonjs/Misc/perfCounter";
  76432. export * from "babylonjs/Misc/fileRequest";
  76433. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76434. export * from "babylonjs/Misc/retryStrategy";
  76435. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76436. export * from "babylonjs/Misc/canvasGenerator";
  76437. export * from "babylonjs/Misc/fileTools";
  76438. export * from "babylonjs/Misc/stringTools";
  76439. export * from "babylonjs/Misc/dataReader";
  76440. export * from "babylonjs/Misc/minMaxReducer";
  76441. export * from "babylonjs/Misc/depthReducer";
  76442. export * from "babylonjs/Misc/dataStorage";
  76443. }
  76444. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76445. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76446. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76447. import { Observable } from "babylonjs/Misc/observable";
  76448. import { Matrix } from "babylonjs/Maths/math.vector";
  76449. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76450. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76451. /**
  76452. * An interface for all Hit test features
  76453. */
  76454. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76455. /**
  76456. * Triggered when new babylon (transformed) hit test results are available
  76457. */
  76458. onHitTestResultObservable: Observable<T[]>;
  76459. }
  76460. /**
  76461. * Options used for hit testing
  76462. */
  76463. export interface IWebXRLegacyHitTestOptions {
  76464. /**
  76465. * Only test when user interacted with the scene. Default - hit test every frame
  76466. */
  76467. testOnPointerDownOnly?: boolean;
  76468. /**
  76469. * The node to use to transform the local results to world coordinates
  76470. */
  76471. worldParentNode?: TransformNode;
  76472. }
  76473. /**
  76474. * Interface defining the babylon result of raycasting/hit-test
  76475. */
  76476. export interface IWebXRLegacyHitResult {
  76477. /**
  76478. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76479. */
  76480. transformationMatrix: Matrix;
  76481. /**
  76482. * The native hit test result
  76483. */
  76484. xrHitResult: XRHitResult | XRHitTestResult;
  76485. }
  76486. /**
  76487. * The currently-working hit-test module.
  76488. * Hit test (or Ray-casting) is used to interact with the real world.
  76489. * For further information read here - https://github.com/immersive-web/hit-test
  76490. */
  76491. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76492. /**
  76493. * options to use when constructing this feature
  76494. */
  76495. readonly options: IWebXRLegacyHitTestOptions;
  76496. private _direction;
  76497. private _mat;
  76498. private _onSelectEnabled;
  76499. private _origin;
  76500. /**
  76501. * The module's name
  76502. */
  76503. static readonly Name: string;
  76504. /**
  76505. * The (Babylon) version of this module.
  76506. * This is an integer representing the implementation version.
  76507. * This number does not correspond to the WebXR specs version
  76508. */
  76509. static readonly Version: number;
  76510. /**
  76511. * Populated with the last native XR Hit Results
  76512. */
  76513. lastNativeXRHitResults: XRHitResult[];
  76514. /**
  76515. * Triggered when new babylon (transformed) hit test results are available
  76516. */
  76517. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76518. /**
  76519. * Creates a new instance of the (legacy version) hit test feature
  76520. * @param _xrSessionManager an instance of WebXRSessionManager
  76521. * @param options options to use when constructing this feature
  76522. */
  76523. constructor(_xrSessionManager: WebXRSessionManager,
  76524. /**
  76525. * options to use when constructing this feature
  76526. */
  76527. options?: IWebXRLegacyHitTestOptions);
  76528. /**
  76529. * execute a hit test with an XR Ray
  76530. *
  76531. * @param xrSession a native xrSession that will execute this hit test
  76532. * @param xrRay the ray (position and direction) to use for ray-casting
  76533. * @param referenceSpace native XR reference space to use for the hit-test
  76534. * @param filter filter function that will filter the results
  76535. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76536. */
  76537. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76538. /**
  76539. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76540. * @param event the (select) event to use to select with
  76541. * @param referenceSpace the reference space to use for this hit test
  76542. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76543. */
  76544. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76545. /**
  76546. * attach this feature
  76547. * Will usually be called by the features manager
  76548. *
  76549. * @returns true if successful.
  76550. */
  76551. attach(): boolean;
  76552. /**
  76553. * detach this feature.
  76554. * Will usually be called by the features manager
  76555. *
  76556. * @returns true if successful.
  76557. */
  76558. detach(): boolean;
  76559. /**
  76560. * Dispose this feature and all of the resources attached
  76561. */
  76562. dispose(): void;
  76563. protected _onXRFrame(frame: XRFrame): void;
  76564. private _onHitTestResults;
  76565. private _onSelect;
  76566. }
  76567. }
  76568. declare module "babylonjs/XR/features/WebXRHitTest" {
  76569. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76570. import { Observable } from "babylonjs/Misc/observable";
  76571. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76572. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76573. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76574. /**
  76575. * Options used for hit testing (version 2)
  76576. */
  76577. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76578. /**
  76579. * Do not create a permanent hit test. Will usually be used when only
  76580. * transient inputs are needed.
  76581. */
  76582. disablePermanentHitTest?: boolean;
  76583. /**
  76584. * Enable transient (for example touch-based) hit test inspections
  76585. */
  76586. enableTransientHitTest?: boolean;
  76587. /**
  76588. * Offset ray for the permanent hit test
  76589. */
  76590. offsetRay?: Vector3;
  76591. /**
  76592. * Offset ray for the transient hit test
  76593. */
  76594. transientOffsetRay?: Vector3;
  76595. /**
  76596. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76597. */
  76598. useReferenceSpace?: boolean;
  76599. }
  76600. /**
  76601. * Interface defining the babylon result of hit-test
  76602. */
  76603. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76604. /**
  76605. * The input source that generated this hit test (if transient)
  76606. */
  76607. inputSource?: XRInputSource;
  76608. /**
  76609. * Is this a transient hit test
  76610. */
  76611. isTransient?: boolean;
  76612. /**
  76613. * Position of the hit test result
  76614. */
  76615. position: Vector3;
  76616. /**
  76617. * Rotation of the hit test result
  76618. */
  76619. rotationQuaternion: Quaternion;
  76620. /**
  76621. * The native hit test result
  76622. */
  76623. xrHitResult: XRHitTestResult;
  76624. }
  76625. /**
  76626. * The currently-working hit-test module.
  76627. * Hit test (or Ray-casting) is used to interact with the real world.
  76628. * For further information read here - https://github.com/immersive-web/hit-test
  76629. *
  76630. * Tested on chrome (mobile) 80.
  76631. */
  76632. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76633. /**
  76634. * options to use when constructing this feature
  76635. */
  76636. readonly options: IWebXRHitTestOptions;
  76637. private _tmpMat;
  76638. private _tmpPos;
  76639. private _tmpQuat;
  76640. private _transientXrHitTestSource;
  76641. private _xrHitTestSource;
  76642. private initHitTestSource;
  76643. /**
  76644. * The module's name
  76645. */
  76646. static readonly Name: string;
  76647. /**
  76648. * The (Babylon) version of this module.
  76649. * This is an integer representing the implementation version.
  76650. * This number does not correspond to the WebXR specs version
  76651. */
  76652. static readonly Version: number;
  76653. /**
  76654. * When set to true, each hit test will have its own position/rotation objects
  76655. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76656. * the developers will clone them or copy them as they see fit.
  76657. */
  76658. autoCloneTransformation: boolean;
  76659. /**
  76660. * Triggered when new babylon (transformed) hit test results are available
  76661. */
  76662. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76663. /**
  76664. * Use this to temporarily pause hit test checks.
  76665. */
  76666. paused: boolean;
  76667. /**
  76668. * Creates a new instance of the hit test feature
  76669. * @param _xrSessionManager an instance of WebXRSessionManager
  76670. * @param options options to use when constructing this feature
  76671. */
  76672. constructor(_xrSessionManager: WebXRSessionManager,
  76673. /**
  76674. * options to use when constructing this feature
  76675. */
  76676. options?: IWebXRHitTestOptions);
  76677. /**
  76678. * attach this feature
  76679. * Will usually be called by the features manager
  76680. *
  76681. * @returns true if successful.
  76682. */
  76683. attach(): boolean;
  76684. /**
  76685. * detach this feature.
  76686. * Will usually be called by the features manager
  76687. *
  76688. * @returns true if successful.
  76689. */
  76690. detach(): boolean;
  76691. /**
  76692. * Dispose this feature and all of the resources attached
  76693. */
  76694. dispose(): void;
  76695. protected _onXRFrame(frame: XRFrame): void;
  76696. private _processWebXRHitTestResult;
  76697. }
  76698. }
  76699. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76700. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76701. import { Observable } from "babylonjs/Misc/observable";
  76702. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76703. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76704. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76705. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76706. /**
  76707. * Configuration options of the anchor system
  76708. */
  76709. export interface IWebXRAnchorSystemOptions {
  76710. /**
  76711. * a node that will be used to convert local to world coordinates
  76712. */
  76713. worldParentNode?: TransformNode;
  76714. /**
  76715. * If set to true a reference of the created anchors will be kept until the next session starts
  76716. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76717. */
  76718. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76719. }
  76720. /**
  76721. * A babylon container for an XR Anchor
  76722. */
  76723. export interface IWebXRAnchor {
  76724. /**
  76725. * A babylon-assigned ID for this anchor
  76726. */
  76727. id: number;
  76728. /**
  76729. * Transformation matrix to apply to an object attached to this anchor
  76730. */
  76731. transformationMatrix: Matrix;
  76732. /**
  76733. * The native anchor object
  76734. */
  76735. xrAnchor: XRAnchor;
  76736. /**
  76737. * if defined, this object will be constantly updated by the anchor's position and rotation
  76738. */
  76739. attachedNode?: TransformNode;
  76740. }
  76741. /**
  76742. * An implementation of the anchor system for WebXR.
  76743. * For further information see https://github.com/immersive-web/anchors/
  76744. */
  76745. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76746. private _options;
  76747. private _lastFrameDetected;
  76748. private _trackedAnchors;
  76749. private _referenceSpaceForFrameAnchors;
  76750. private _futureAnchors;
  76751. /**
  76752. * The module's name
  76753. */
  76754. static readonly Name: string;
  76755. /**
  76756. * The (Babylon) version of this module.
  76757. * This is an integer representing the implementation version.
  76758. * This number does not correspond to the WebXR specs version
  76759. */
  76760. static readonly Version: number;
  76761. /**
  76762. * Observers registered here will be executed when a new anchor was added to the session
  76763. */
  76764. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76765. /**
  76766. * Observers registered here will be executed when an anchor was removed from the session
  76767. */
  76768. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76769. /**
  76770. * Observers registered here will be executed when an existing anchor updates
  76771. * This can execute N times every frame
  76772. */
  76773. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76774. /**
  76775. * Set the reference space to use for anchor creation, when not using a hit test.
  76776. * Will default to the session's reference space if not defined
  76777. */
  76778. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76779. /**
  76780. * constructs a new anchor system
  76781. * @param _xrSessionManager an instance of WebXRSessionManager
  76782. * @param _options configuration object for this feature
  76783. */
  76784. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76785. private _tmpVector;
  76786. private _tmpQuaternion;
  76787. private _populateTmpTransformation;
  76788. /**
  76789. * Create a new anchor point using a hit test result at a specific point in the scene
  76790. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76791. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76792. *
  76793. * @param hitTestResult The hit test result to use for this anchor creation
  76794. * @param position an optional position offset for this anchor
  76795. * @param rotationQuaternion an optional rotation offset for this anchor
  76796. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76797. */
  76798. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76799. /**
  76800. * Add a new anchor at a specific position and rotation
  76801. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76802. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76803. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76804. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76805. *
  76806. * @param position the position in which to add an anchor
  76807. * @param rotationQuaternion an optional rotation for the anchor transformation
  76808. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76809. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76810. */
  76811. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76812. /**
  76813. * detach this feature.
  76814. * Will usually be called by the features manager
  76815. *
  76816. * @returns true if successful.
  76817. */
  76818. detach(): boolean;
  76819. /**
  76820. * Dispose this feature and all of the resources attached
  76821. */
  76822. dispose(): void;
  76823. protected _onXRFrame(frame: XRFrame): void;
  76824. /**
  76825. * avoiding using Array.find for global support.
  76826. * @param xrAnchor the plane to find in the array
  76827. */
  76828. private _findIndexInAnchorArray;
  76829. private _updateAnchorWithXRFrame;
  76830. private _createAnchorAtTransformation;
  76831. }
  76832. }
  76833. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  76834. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76835. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76836. import { Observable } from "babylonjs/Misc/observable";
  76837. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  76838. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76839. /**
  76840. * Options used in the plane detector module
  76841. */
  76842. export interface IWebXRPlaneDetectorOptions {
  76843. /**
  76844. * The node to use to transform the local results to world coordinates
  76845. */
  76846. worldParentNode?: TransformNode;
  76847. /**
  76848. * If set to true a reference of the created planes will be kept until the next session starts
  76849. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76850. */
  76851. doNotRemovePlanesOnSessionEnded?: boolean;
  76852. }
  76853. /**
  76854. * A babylon interface for a WebXR plane.
  76855. * A Plane is actually a polygon, built from N points in space
  76856. *
  76857. * Supported in chrome 79, not supported in canary 81 ATM
  76858. */
  76859. export interface IWebXRPlane {
  76860. /**
  76861. * a babylon-assigned ID for this polygon
  76862. */
  76863. id: number;
  76864. /**
  76865. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76866. */
  76867. polygonDefinition: Array<Vector3>;
  76868. /**
  76869. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76870. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76871. */
  76872. transformationMatrix: Matrix;
  76873. /**
  76874. * the native xr-plane object
  76875. */
  76876. xrPlane: XRPlane;
  76877. }
  76878. /**
  76879. * The plane detector is used to detect planes in the real world when in AR
  76880. * For more information see https://github.com/immersive-web/real-world-geometry/
  76881. */
  76882. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76883. private _options;
  76884. private _detectedPlanes;
  76885. private _enabled;
  76886. private _lastFrameDetected;
  76887. /**
  76888. * The module's name
  76889. */
  76890. static readonly Name: string;
  76891. /**
  76892. * The (Babylon) version of this module.
  76893. * This is an integer representing the implementation version.
  76894. * This number does not correspond to the WebXR specs version
  76895. */
  76896. static readonly Version: number;
  76897. /**
  76898. * Observers registered here will be executed when a new plane was added to the session
  76899. */
  76900. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76901. /**
  76902. * Observers registered here will be executed when a plane is no longer detected in the session
  76903. */
  76904. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76905. /**
  76906. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76907. * This can execute N times every frame
  76908. */
  76909. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76910. /**
  76911. * construct a new Plane Detector
  76912. * @param _xrSessionManager an instance of xr Session manager
  76913. * @param _options configuration to use when constructing this feature
  76914. */
  76915. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76916. /**
  76917. * detach this feature.
  76918. * Will usually be called by the features manager
  76919. *
  76920. * @returns true if successful.
  76921. */
  76922. detach(): boolean;
  76923. /**
  76924. * Dispose this feature and all of the resources attached
  76925. */
  76926. dispose(): void;
  76927. protected _onXRFrame(frame: XRFrame): void;
  76928. private _init;
  76929. private _updatePlaneWithXRPlane;
  76930. /**
  76931. * avoiding using Array.find for global support.
  76932. * @param xrPlane the plane to find in the array
  76933. */
  76934. private findIndexInPlaneArray;
  76935. }
  76936. }
  76937. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  76938. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76940. import { Observable } from "babylonjs/Misc/observable";
  76941. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76942. /**
  76943. * Options interface for the background remover plugin
  76944. */
  76945. export interface IWebXRBackgroundRemoverOptions {
  76946. /**
  76947. * Further background meshes to disable when entering AR
  76948. */
  76949. backgroundMeshes?: AbstractMesh[];
  76950. /**
  76951. * flags to configure the removal of the environment helper.
  76952. * If not set, the entire background will be removed. If set, flags should be set as well.
  76953. */
  76954. environmentHelperRemovalFlags?: {
  76955. /**
  76956. * Should the skybox be removed (default false)
  76957. */
  76958. skyBox?: boolean;
  76959. /**
  76960. * Should the ground be removed (default false)
  76961. */
  76962. ground?: boolean;
  76963. };
  76964. /**
  76965. * don't disable the environment helper
  76966. */
  76967. ignoreEnvironmentHelper?: boolean;
  76968. }
  76969. /**
  76970. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76971. */
  76972. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76973. /**
  76974. * read-only options to be used in this module
  76975. */
  76976. readonly options: IWebXRBackgroundRemoverOptions;
  76977. /**
  76978. * The module's name
  76979. */
  76980. static readonly Name: string;
  76981. /**
  76982. * The (Babylon) version of this module.
  76983. * This is an integer representing the implementation version.
  76984. * This number does not correspond to the WebXR specs version
  76985. */
  76986. static readonly Version: number;
  76987. /**
  76988. * registered observers will be triggered when the background state changes
  76989. */
  76990. onBackgroundStateChangedObservable: Observable<boolean>;
  76991. /**
  76992. * constructs a new background remover module
  76993. * @param _xrSessionManager the session manager for this module
  76994. * @param options read-only options to be used in this module
  76995. */
  76996. constructor(_xrSessionManager: WebXRSessionManager,
  76997. /**
  76998. * read-only options to be used in this module
  76999. */
  77000. options?: IWebXRBackgroundRemoverOptions);
  77001. /**
  77002. * attach this feature
  77003. * Will usually be called by the features manager
  77004. *
  77005. * @returns true if successful.
  77006. */
  77007. attach(): boolean;
  77008. /**
  77009. * detach this feature.
  77010. * Will usually be called by the features manager
  77011. *
  77012. * @returns true if successful.
  77013. */
  77014. detach(): boolean;
  77015. /**
  77016. * Dispose this feature and all of the resources attached
  77017. */
  77018. dispose(): void;
  77019. protected _onXRFrame(_xrFrame: XRFrame): void;
  77020. private _setBackgroundState;
  77021. }
  77022. }
  77023. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77024. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77025. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77026. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77027. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77028. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77029. import { Nullable } from "babylonjs/types";
  77030. /**
  77031. * Options for the controller physics feature
  77032. */
  77033. export class IWebXRControllerPhysicsOptions {
  77034. /**
  77035. * Should the headset get its own impostor
  77036. */
  77037. enableHeadsetImpostor?: boolean;
  77038. /**
  77039. * Optional parameters for the headset impostor
  77040. */
  77041. headsetImpostorParams?: {
  77042. /**
  77043. * The type of impostor to create. Default is sphere
  77044. */
  77045. impostorType: number;
  77046. /**
  77047. * the size of the impostor. Defaults to 10cm
  77048. */
  77049. impostorSize?: number | {
  77050. width: number;
  77051. height: number;
  77052. depth: number;
  77053. };
  77054. /**
  77055. * Friction definitions
  77056. */
  77057. friction?: number;
  77058. /**
  77059. * Restitution
  77060. */
  77061. restitution?: number;
  77062. };
  77063. /**
  77064. * The physics properties of the future impostors
  77065. */
  77066. physicsProperties?: {
  77067. /**
  77068. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77069. * Note that this requires a physics engine that supports mesh impostors!
  77070. */
  77071. useControllerMesh?: boolean;
  77072. /**
  77073. * The type of impostor to create. Default is sphere
  77074. */
  77075. impostorType?: number;
  77076. /**
  77077. * the size of the impostor. Defaults to 10cm
  77078. */
  77079. impostorSize?: number | {
  77080. width: number;
  77081. height: number;
  77082. depth: number;
  77083. };
  77084. /**
  77085. * Friction definitions
  77086. */
  77087. friction?: number;
  77088. /**
  77089. * Restitution
  77090. */
  77091. restitution?: number;
  77092. };
  77093. /**
  77094. * the xr input to use with this pointer selection
  77095. */
  77096. xrInput: WebXRInput;
  77097. }
  77098. /**
  77099. * Add physics impostor to your webxr controllers,
  77100. * including naive calculation of their linear and angular velocity
  77101. */
  77102. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77103. private readonly _options;
  77104. private _attachController;
  77105. private _controllers;
  77106. private _debugMode;
  77107. private _delta;
  77108. private _headsetImpostor?;
  77109. private _headsetMesh?;
  77110. private _lastTimestamp;
  77111. private _tmpQuaternion;
  77112. private _tmpVector;
  77113. /**
  77114. * The module's name
  77115. */
  77116. static readonly Name: string;
  77117. /**
  77118. * The (Babylon) version of this module.
  77119. * This is an integer representing the implementation version.
  77120. * This number does not correspond to the webxr specs version
  77121. */
  77122. static readonly Version: number;
  77123. /**
  77124. * Construct a new Controller Physics Feature
  77125. * @param _xrSessionManager the corresponding xr session manager
  77126. * @param _options options to create this feature with
  77127. */
  77128. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77129. /**
  77130. * @hidden
  77131. * enable debugging - will show console outputs and the impostor mesh
  77132. */
  77133. _enablePhysicsDebug(): void;
  77134. /**
  77135. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77136. * @param xrController the controller to add
  77137. */
  77138. addController(xrController: WebXRInputSource): void;
  77139. /**
  77140. * attach this feature
  77141. * Will usually be called by the features manager
  77142. *
  77143. * @returns true if successful.
  77144. */
  77145. attach(): boolean;
  77146. /**
  77147. * detach this feature.
  77148. * Will usually be called by the features manager
  77149. *
  77150. * @returns true if successful.
  77151. */
  77152. detach(): boolean;
  77153. /**
  77154. * Get the headset impostor, if enabled
  77155. * @returns the impostor
  77156. */
  77157. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77158. /**
  77159. * Get the physics impostor of a specific controller.
  77160. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77161. * @param controller the controller or the controller id of which to get the impostor
  77162. * @returns the impostor or null
  77163. */
  77164. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77165. /**
  77166. * Update the physics properties provided in the constructor
  77167. * @param newProperties the new properties object
  77168. */
  77169. setPhysicsProperties(newProperties: {
  77170. impostorType?: number;
  77171. impostorSize?: number | {
  77172. width: number;
  77173. height: number;
  77174. depth: number;
  77175. };
  77176. friction?: number;
  77177. restitution?: number;
  77178. }): void;
  77179. protected _onXRFrame(_xrFrame: any): void;
  77180. private _detachController;
  77181. }
  77182. }
  77183. declare module "babylonjs/XR/features/index" {
  77184. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77185. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77186. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77187. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77188. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77189. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77190. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77191. export * from "babylonjs/XR/features/WebXRHitTest";
  77192. }
  77193. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77194. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77196. import { Scene } from "babylonjs/scene";
  77197. /**
  77198. * The motion controller class for all microsoft mixed reality controllers
  77199. */
  77200. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77201. protected readonly _mapping: {
  77202. defaultButton: {
  77203. valueNodeName: string;
  77204. unpressedNodeName: string;
  77205. pressedNodeName: string;
  77206. };
  77207. defaultAxis: {
  77208. valueNodeName: string;
  77209. minNodeName: string;
  77210. maxNodeName: string;
  77211. };
  77212. buttons: {
  77213. "xr-standard-trigger": {
  77214. rootNodeName: string;
  77215. componentProperty: string;
  77216. states: string[];
  77217. };
  77218. "xr-standard-squeeze": {
  77219. rootNodeName: string;
  77220. componentProperty: string;
  77221. states: string[];
  77222. };
  77223. "xr-standard-touchpad": {
  77224. rootNodeName: string;
  77225. labelAnchorNodeName: string;
  77226. touchPointNodeName: string;
  77227. };
  77228. "xr-standard-thumbstick": {
  77229. rootNodeName: string;
  77230. componentProperty: string;
  77231. states: string[];
  77232. };
  77233. };
  77234. axes: {
  77235. "xr-standard-touchpad": {
  77236. "x-axis": {
  77237. rootNodeName: string;
  77238. };
  77239. "y-axis": {
  77240. rootNodeName: string;
  77241. };
  77242. };
  77243. "xr-standard-thumbstick": {
  77244. "x-axis": {
  77245. rootNodeName: string;
  77246. };
  77247. "y-axis": {
  77248. rootNodeName: string;
  77249. };
  77250. };
  77251. };
  77252. };
  77253. /**
  77254. * The base url used to load the left and right controller models
  77255. */
  77256. static MODEL_BASE_URL: string;
  77257. /**
  77258. * The name of the left controller model file
  77259. */
  77260. static MODEL_LEFT_FILENAME: string;
  77261. /**
  77262. * The name of the right controller model file
  77263. */
  77264. static MODEL_RIGHT_FILENAME: string;
  77265. profileId: string;
  77266. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77267. protected _getFilenameAndPath(): {
  77268. filename: string;
  77269. path: string;
  77270. };
  77271. protected _getModelLoadingConstraints(): boolean;
  77272. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77273. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77274. protected _updateModel(): void;
  77275. }
  77276. }
  77277. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77278. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77280. import { Scene } from "babylonjs/scene";
  77281. /**
  77282. * The motion controller class for oculus touch (quest, rift).
  77283. * This class supports legacy mapping as well the standard xr mapping
  77284. */
  77285. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77286. private _forceLegacyControllers;
  77287. private _modelRootNode;
  77288. /**
  77289. * The base url used to load the left and right controller models
  77290. */
  77291. static MODEL_BASE_URL: string;
  77292. /**
  77293. * The name of the left controller model file
  77294. */
  77295. static MODEL_LEFT_FILENAME: string;
  77296. /**
  77297. * The name of the right controller model file
  77298. */
  77299. static MODEL_RIGHT_FILENAME: string;
  77300. /**
  77301. * Base Url for the Quest controller model.
  77302. */
  77303. static QUEST_MODEL_BASE_URL: string;
  77304. profileId: string;
  77305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77306. protected _getFilenameAndPath(): {
  77307. filename: string;
  77308. path: string;
  77309. };
  77310. protected _getModelLoadingConstraints(): boolean;
  77311. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77312. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77313. protected _updateModel(): void;
  77314. /**
  77315. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77316. * between the touch and touch 2.
  77317. */
  77318. private _isQuest;
  77319. }
  77320. }
  77321. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77322. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77323. import { Scene } from "babylonjs/scene";
  77324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77325. /**
  77326. * The motion controller class for the standard HTC-Vive controllers
  77327. */
  77328. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77329. private _modelRootNode;
  77330. /**
  77331. * The base url used to load the left and right controller models
  77332. */
  77333. static MODEL_BASE_URL: string;
  77334. /**
  77335. * File name for the controller model.
  77336. */
  77337. static MODEL_FILENAME: string;
  77338. profileId: string;
  77339. /**
  77340. * Create a new Vive motion controller object
  77341. * @param scene the scene to use to create this controller
  77342. * @param gamepadObject the corresponding gamepad object
  77343. * @param handedness the handedness of the controller
  77344. */
  77345. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77346. protected _getFilenameAndPath(): {
  77347. filename: string;
  77348. path: string;
  77349. };
  77350. protected _getModelLoadingConstraints(): boolean;
  77351. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77352. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77353. protected _updateModel(): void;
  77354. }
  77355. }
  77356. declare module "babylonjs/XR/motionController/index" {
  77357. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77358. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77359. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77360. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77361. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77362. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77363. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77364. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77365. }
  77366. declare module "babylonjs/XR/index" {
  77367. export * from "babylonjs/XR/webXRCamera";
  77368. export * from "babylonjs/XR/webXREnterExitUI";
  77369. export * from "babylonjs/XR/webXRExperienceHelper";
  77370. export * from "babylonjs/XR/webXRInput";
  77371. export * from "babylonjs/XR/webXRInputSource";
  77372. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77373. export * from "babylonjs/XR/webXRTypes";
  77374. export * from "babylonjs/XR/webXRSessionManager";
  77375. export * from "babylonjs/XR/webXRDefaultExperience";
  77376. export * from "babylonjs/XR/webXRFeaturesManager";
  77377. export * from "babylonjs/XR/features/index";
  77378. export * from "babylonjs/XR/motionController/index";
  77379. }
  77380. declare module "babylonjs/index" {
  77381. export * from "babylonjs/abstractScene";
  77382. export * from "babylonjs/Actions/index";
  77383. export * from "babylonjs/Animations/index";
  77384. export * from "babylonjs/assetContainer";
  77385. export * from "babylonjs/Audio/index";
  77386. export * from "babylonjs/Behaviors/index";
  77387. export * from "babylonjs/Bones/index";
  77388. export * from "babylonjs/Cameras/index";
  77389. export * from "babylonjs/Collisions/index";
  77390. export * from "babylonjs/Culling/index";
  77391. export * from "babylonjs/Debug/index";
  77392. export * from "babylonjs/DeviceInput/index";
  77393. export * from "babylonjs/Engines/index";
  77394. export * from "babylonjs/Events/index";
  77395. export * from "babylonjs/Gamepads/index";
  77396. export * from "babylonjs/Gizmos/index";
  77397. export * from "babylonjs/Helpers/index";
  77398. export * from "babylonjs/Instrumentation/index";
  77399. export * from "babylonjs/Layers/index";
  77400. export * from "babylonjs/LensFlares/index";
  77401. export * from "babylonjs/Lights/index";
  77402. export * from "babylonjs/Loading/index";
  77403. export * from "babylonjs/Materials/index";
  77404. export * from "babylonjs/Maths/index";
  77405. export * from "babylonjs/Meshes/index";
  77406. export * from "babylonjs/Morph/index";
  77407. export * from "babylonjs/Navigation/index";
  77408. export * from "babylonjs/node";
  77409. export * from "babylonjs/Offline/index";
  77410. export * from "babylonjs/Particles/index";
  77411. export * from "babylonjs/Physics/index";
  77412. export * from "babylonjs/PostProcesses/index";
  77413. export * from "babylonjs/Probes/index";
  77414. export * from "babylonjs/Rendering/index";
  77415. export * from "babylonjs/scene";
  77416. export * from "babylonjs/sceneComponent";
  77417. export * from "babylonjs/Sprites/index";
  77418. export * from "babylonjs/States/index";
  77419. export * from "babylonjs/Misc/index";
  77420. export * from "babylonjs/XR/index";
  77421. export * from "babylonjs/types";
  77422. }
  77423. declare module "babylonjs/Animations/pathCursor" {
  77424. import { Vector3 } from "babylonjs/Maths/math.vector";
  77425. import { Path2 } from "babylonjs/Maths/math.path";
  77426. /**
  77427. * A cursor which tracks a point on a path
  77428. */
  77429. export class PathCursor {
  77430. private path;
  77431. /**
  77432. * Stores path cursor callbacks for when an onchange event is triggered
  77433. */
  77434. private _onchange;
  77435. /**
  77436. * The value of the path cursor
  77437. */
  77438. value: number;
  77439. /**
  77440. * The animation array of the path cursor
  77441. */
  77442. animations: Animation[];
  77443. /**
  77444. * Initializes the path cursor
  77445. * @param path The path to track
  77446. */
  77447. constructor(path: Path2);
  77448. /**
  77449. * Gets the cursor point on the path
  77450. * @returns A point on the path cursor at the cursor location
  77451. */
  77452. getPoint(): Vector3;
  77453. /**
  77454. * Moves the cursor ahead by the step amount
  77455. * @param step The amount to move the cursor forward
  77456. * @returns This path cursor
  77457. */
  77458. moveAhead(step?: number): PathCursor;
  77459. /**
  77460. * Moves the cursor behind by the step amount
  77461. * @param step The amount to move the cursor back
  77462. * @returns This path cursor
  77463. */
  77464. moveBack(step?: number): PathCursor;
  77465. /**
  77466. * Moves the cursor by the step amount
  77467. * If the step amount is greater than one, an exception is thrown
  77468. * @param step The amount to move the cursor
  77469. * @returns This path cursor
  77470. */
  77471. move(step: number): PathCursor;
  77472. /**
  77473. * Ensures that the value is limited between zero and one
  77474. * @returns This path cursor
  77475. */
  77476. private ensureLimits;
  77477. /**
  77478. * Runs onchange callbacks on change (used by the animation engine)
  77479. * @returns This path cursor
  77480. */
  77481. private raiseOnChange;
  77482. /**
  77483. * Executes a function on change
  77484. * @param f A path cursor onchange callback
  77485. * @returns This path cursor
  77486. */
  77487. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77488. }
  77489. }
  77490. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77491. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77492. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77493. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77494. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77495. }
  77496. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77497. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77498. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77499. }
  77500. declare module "babylonjs/Engines/Processors/index" {
  77501. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77502. export * from "babylonjs/Engines/Processors/Expressions/index";
  77503. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77504. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77505. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77506. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77507. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77508. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77509. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77510. }
  77511. declare module "babylonjs/Legacy/legacy" {
  77512. import * as Babylon from "babylonjs/index";
  77513. export * from "babylonjs/index";
  77514. }
  77515. declare module "babylonjs/Shaders/blur.fragment" {
  77516. /** @hidden */
  77517. export var blurPixelShader: {
  77518. name: string;
  77519. shader: string;
  77520. };
  77521. }
  77522. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77523. /** @hidden */
  77524. export var pointCloudVertexDeclaration: {
  77525. name: string;
  77526. shader: string;
  77527. };
  77528. }
  77529. declare module "babylonjs" {
  77530. export * from "babylonjs/Legacy/legacy";
  77531. }
  77532. declare module BABYLON {
  77533. /** Alias type for value that can be null */
  77534. export type Nullable<T> = T | null;
  77535. /**
  77536. * Alias type for number that are floats
  77537. * @ignorenaming
  77538. */
  77539. export type float = number;
  77540. /**
  77541. * Alias type for number that are doubles.
  77542. * @ignorenaming
  77543. */
  77544. export type double = number;
  77545. /**
  77546. * Alias type for number that are integer
  77547. * @ignorenaming
  77548. */
  77549. export type int = number;
  77550. /** Alias type for number array or Float32Array */
  77551. export type FloatArray = number[] | Float32Array;
  77552. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77553. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77554. /**
  77555. * Alias for types that can be used by a Buffer or VertexBuffer.
  77556. */
  77557. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77558. /**
  77559. * Alias type for primitive types
  77560. * @ignorenaming
  77561. */
  77562. type Primitive = undefined | null | boolean | string | number | Function;
  77563. /**
  77564. * Type modifier to make all the properties of an object Readonly
  77565. */
  77566. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77567. /**
  77568. * Type modifier to make all the properties of an object Readonly recursively
  77569. */
  77570. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77571. /**
  77572. * Type modifier to make object properties readonly.
  77573. */
  77574. export type DeepImmutableObject<T> = {
  77575. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77576. };
  77577. /** @hidden */
  77578. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77579. }
  77580. }
  77581. declare module BABYLON {
  77582. /**
  77583. * A class serves as a medium between the observable and its observers
  77584. */
  77585. export class EventState {
  77586. /**
  77587. * Create a new EventState
  77588. * @param mask defines the mask associated with this state
  77589. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77590. * @param target defines the original target of the state
  77591. * @param currentTarget defines the current target of the state
  77592. */
  77593. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77594. /**
  77595. * Initialize the current event state
  77596. * @param mask defines the mask associated with this state
  77597. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77598. * @param target defines the original target of the state
  77599. * @param currentTarget defines the current target of the state
  77600. * @returns the current event state
  77601. */
  77602. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77603. /**
  77604. * An Observer can set this property to true to prevent subsequent observers of being notified
  77605. */
  77606. skipNextObservers: boolean;
  77607. /**
  77608. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77609. */
  77610. mask: number;
  77611. /**
  77612. * The object that originally notified the event
  77613. */
  77614. target?: any;
  77615. /**
  77616. * The current object in the bubbling phase
  77617. */
  77618. currentTarget?: any;
  77619. /**
  77620. * This will be populated with the return value of the last function that was executed.
  77621. * If it is the first function in the callback chain it will be the event data.
  77622. */
  77623. lastReturnValue?: any;
  77624. }
  77625. /**
  77626. * Represent an Observer registered to a given Observable object.
  77627. */
  77628. export class Observer<T> {
  77629. /**
  77630. * Defines the callback to call when the observer is notified
  77631. */
  77632. callback: (eventData: T, eventState: EventState) => void;
  77633. /**
  77634. * Defines the mask of the observer (used to filter notifications)
  77635. */
  77636. mask: number;
  77637. /**
  77638. * Defines the current scope used to restore the JS context
  77639. */
  77640. scope: any;
  77641. /** @hidden */
  77642. _willBeUnregistered: boolean;
  77643. /**
  77644. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77645. */
  77646. unregisterOnNextCall: boolean;
  77647. /**
  77648. * Creates a new observer
  77649. * @param callback defines the callback to call when the observer is notified
  77650. * @param mask defines the mask of the observer (used to filter notifications)
  77651. * @param scope defines the current scope used to restore the JS context
  77652. */
  77653. constructor(
  77654. /**
  77655. * Defines the callback to call when the observer is notified
  77656. */
  77657. callback: (eventData: T, eventState: EventState) => void,
  77658. /**
  77659. * Defines the mask of the observer (used to filter notifications)
  77660. */
  77661. mask: number,
  77662. /**
  77663. * Defines the current scope used to restore the JS context
  77664. */
  77665. scope?: any);
  77666. }
  77667. /**
  77668. * Represent a list of observers registered to multiple Observables object.
  77669. */
  77670. export class MultiObserver<T> {
  77671. private _observers;
  77672. private _observables;
  77673. /**
  77674. * Release associated resources
  77675. */
  77676. dispose(): void;
  77677. /**
  77678. * Raise a callback when one of the observable will notify
  77679. * @param observables defines a list of observables to watch
  77680. * @param callback defines the callback to call on notification
  77681. * @param mask defines the mask used to filter notifications
  77682. * @param scope defines the current scope used to restore the JS context
  77683. * @returns the new MultiObserver
  77684. */
  77685. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77686. }
  77687. /**
  77688. * The Observable class is a simple implementation of the Observable pattern.
  77689. *
  77690. * 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.
  77691. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77692. * 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).
  77693. * 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.
  77694. */
  77695. export class Observable<T> {
  77696. private _observers;
  77697. private _eventState;
  77698. private _onObserverAdded;
  77699. /**
  77700. * Gets the list of observers
  77701. */
  77702. get observers(): Array<Observer<T>>;
  77703. /**
  77704. * Creates a new observable
  77705. * @param onObserverAdded defines a callback to call when a new observer is added
  77706. */
  77707. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77708. /**
  77709. * Create a new Observer with the specified callback
  77710. * @param callback the callback that will be executed for that Observer
  77711. * @param mask the mask used to filter observers
  77712. * @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.
  77713. * @param scope optional scope for the callback to be called from
  77714. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77715. * @returns the new observer created for the callback
  77716. */
  77717. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77718. /**
  77719. * Create a new Observer with the specified callback and unregisters after the next notification
  77720. * @param callback the callback that will be executed for that Observer
  77721. * @returns the new observer created for the callback
  77722. */
  77723. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77724. /**
  77725. * Remove an Observer from the Observable object
  77726. * @param observer the instance of the Observer to remove
  77727. * @returns false if it doesn't belong to this Observable
  77728. */
  77729. remove(observer: Nullable<Observer<T>>): boolean;
  77730. /**
  77731. * Remove a callback from the Observable object
  77732. * @param callback the callback to remove
  77733. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77734. * @returns false if it doesn't belong to this Observable
  77735. */
  77736. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77737. private _deferUnregister;
  77738. private _remove;
  77739. /**
  77740. * Moves the observable to the top of the observer list making it get called first when notified
  77741. * @param observer the observer to move
  77742. */
  77743. makeObserverTopPriority(observer: Observer<T>): void;
  77744. /**
  77745. * Moves the observable to the bottom of the observer list making it get called last when notified
  77746. * @param observer the observer to move
  77747. */
  77748. makeObserverBottomPriority(observer: Observer<T>): void;
  77749. /**
  77750. * Notify all Observers by calling their respective callback with the given data
  77751. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77752. * @param eventData defines the data to send to all observers
  77753. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77754. * @param target defines the original target of the state
  77755. * @param currentTarget defines the current target of the state
  77756. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77757. */
  77758. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77759. /**
  77760. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77761. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77762. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77763. * and it is crucial that all callbacks will be executed.
  77764. * The order of the callbacks is kept, callbacks are not executed parallel.
  77765. *
  77766. * @param eventData The data to be sent to each callback
  77767. * @param mask is used to filter observers defaults to -1
  77768. * @param target defines the callback target (see EventState)
  77769. * @param currentTarget defines he current object in the bubbling phase
  77770. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77771. */
  77772. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77773. /**
  77774. * Notify a specific observer
  77775. * @param observer defines the observer to notify
  77776. * @param eventData defines the data to be sent to each callback
  77777. * @param mask is used to filter observers defaults to -1
  77778. */
  77779. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77780. /**
  77781. * Gets a boolean indicating if the observable has at least one observer
  77782. * @returns true is the Observable has at least one Observer registered
  77783. */
  77784. hasObservers(): boolean;
  77785. /**
  77786. * Clear the list of observers
  77787. */
  77788. clear(): void;
  77789. /**
  77790. * Clone the current observable
  77791. * @returns a new observable
  77792. */
  77793. clone(): Observable<T>;
  77794. /**
  77795. * Does this observable handles observer registered with a given mask
  77796. * @param mask defines the mask to be tested
  77797. * @return whether or not one observer registered with the given mask is handeled
  77798. **/
  77799. hasSpecificMask(mask?: number): boolean;
  77800. }
  77801. }
  77802. declare module BABYLON {
  77803. /**
  77804. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77805. * Babylon.js
  77806. */
  77807. export class DomManagement {
  77808. /**
  77809. * Checks if the window object exists
  77810. * @returns true if the window object exists
  77811. */
  77812. static IsWindowObjectExist(): boolean;
  77813. /**
  77814. * Checks if the navigator object exists
  77815. * @returns true if the navigator object exists
  77816. */
  77817. static IsNavigatorAvailable(): boolean;
  77818. /**
  77819. * Check if the document object exists
  77820. * @returns true if the document object exists
  77821. */
  77822. static IsDocumentAvailable(): boolean;
  77823. /**
  77824. * Extracts text content from a DOM element hierarchy
  77825. * @param element defines the root element
  77826. * @returns a string
  77827. */
  77828. static GetDOMTextContent(element: HTMLElement): string;
  77829. }
  77830. }
  77831. declare module BABYLON {
  77832. /**
  77833. * Logger used througouht the application to allow configuration of
  77834. * the log level required for the messages.
  77835. */
  77836. export class Logger {
  77837. /**
  77838. * No log
  77839. */
  77840. static readonly NoneLogLevel: number;
  77841. /**
  77842. * Only message logs
  77843. */
  77844. static readonly MessageLogLevel: number;
  77845. /**
  77846. * Only warning logs
  77847. */
  77848. static readonly WarningLogLevel: number;
  77849. /**
  77850. * Only error logs
  77851. */
  77852. static readonly ErrorLogLevel: number;
  77853. /**
  77854. * All logs
  77855. */
  77856. static readonly AllLogLevel: number;
  77857. private static _LogCache;
  77858. /**
  77859. * Gets a value indicating the number of loading errors
  77860. * @ignorenaming
  77861. */
  77862. static errorsCount: number;
  77863. /**
  77864. * Callback called when a new log is added
  77865. */
  77866. static OnNewCacheEntry: (entry: string) => void;
  77867. private static _AddLogEntry;
  77868. private static _FormatMessage;
  77869. private static _LogDisabled;
  77870. private static _LogEnabled;
  77871. private static _WarnDisabled;
  77872. private static _WarnEnabled;
  77873. private static _ErrorDisabled;
  77874. private static _ErrorEnabled;
  77875. /**
  77876. * Log a message to the console
  77877. */
  77878. static Log: (message: string) => void;
  77879. /**
  77880. * Write a warning message to the console
  77881. */
  77882. static Warn: (message: string) => void;
  77883. /**
  77884. * Write an error message to the console
  77885. */
  77886. static Error: (message: string) => void;
  77887. /**
  77888. * Gets current log cache (list of logs)
  77889. */
  77890. static get LogCache(): string;
  77891. /**
  77892. * Clears the log cache
  77893. */
  77894. static ClearLogCache(): void;
  77895. /**
  77896. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  77897. */
  77898. static set LogLevels(level: number);
  77899. }
  77900. }
  77901. declare module BABYLON {
  77902. /** @hidden */
  77903. export class _TypeStore {
  77904. /** @hidden */
  77905. static RegisteredTypes: {
  77906. [key: string]: Object;
  77907. };
  77908. /** @hidden */
  77909. static GetClass(fqdn: string): any;
  77910. }
  77911. }
  77912. declare module BABYLON {
  77913. /**
  77914. * Helper to manipulate strings
  77915. */
  77916. export class StringTools {
  77917. /**
  77918. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  77919. * @param str Source string
  77920. * @param suffix Suffix to search for in the source string
  77921. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77922. */
  77923. static EndsWith(str: string, suffix: string): boolean;
  77924. /**
  77925. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  77926. * @param str Source string
  77927. * @param suffix Suffix to search for in the source string
  77928. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  77929. */
  77930. static StartsWith(str: string, suffix: string): boolean;
  77931. /**
  77932. * Decodes a buffer into a string
  77933. * @param buffer The buffer to decode
  77934. * @returns The decoded string
  77935. */
  77936. static Decode(buffer: Uint8Array | Uint16Array): string;
  77937. /**
  77938. * Encode a buffer to a base64 string
  77939. * @param buffer defines the buffer to encode
  77940. * @returns the encoded string
  77941. */
  77942. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  77943. /**
  77944. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  77945. * @param num the number to convert and pad
  77946. * @param length the expected length of the string
  77947. * @returns the padded string
  77948. */
  77949. static PadNumber(num: number, length: number): string;
  77950. }
  77951. }
  77952. declare module BABYLON {
  77953. /**
  77954. * Class containing a set of static utilities functions for deep copy.
  77955. */
  77956. export class DeepCopier {
  77957. /**
  77958. * Tries to copy an object by duplicating every property
  77959. * @param source defines the source object
  77960. * @param destination defines the target object
  77961. * @param doNotCopyList defines a list of properties to avoid
  77962. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  77963. */
  77964. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  77965. }
  77966. }
  77967. declare module BABYLON {
  77968. /**
  77969. * Class containing a set of static utilities functions for precision date
  77970. */
  77971. export class PrecisionDate {
  77972. /**
  77973. * Gets either window.performance.now() if supported or Date.now() else
  77974. */
  77975. static get Now(): number;
  77976. }
  77977. }
  77978. declare module BABYLON {
  77979. /** @hidden */
  77980. export class _DevTools {
  77981. static WarnImport(name: string): string;
  77982. }
  77983. }
  77984. declare module BABYLON {
  77985. /**
  77986. * Interface used to define the mechanism to get data from the network
  77987. */
  77988. export interface IWebRequest {
  77989. /**
  77990. * Returns client's response url
  77991. */
  77992. responseURL: string;
  77993. /**
  77994. * Returns client's status
  77995. */
  77996. status: number;
  77997. /**
  77998. * Returns client's status as a text
  77999. */
  78000. statusText: string;
  78001. }
  78002. }
  78003. declare module BABYLON {
  78004. /**
  78005. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78006. */
  78007. export class WebRequest implements IWebRequest {
  78008. private _xhr;
  78009. /**
  78010. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78011. * i.e. when loading files, where the server/service expects an Authorization header
  78012. */
  78013. static CustomRequestHeaders: {
  78014. [key: string]: string;
  78015. };
  78016. /**
  78017. * Add callback functions in this array to update all the requests before they get sent to the network
  78018. */
  78019. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78020. private _injectCustomRequestHeaders;
  78021. /**
  78022. * Gets or sets a function to be called when loading progress changes
  78023. */
  78024. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78025. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78026. /**
  78027. * Returns client's state
  78028. */
  78029. get readyState(): number;
  78030. /**
  78031. * Returns client's status
  78032. */
  78033. get status(): number;
  78034. /**
  78035. * Returns client's status as a text
  78036. */
  78037. get statusText(): string;
  78038. /**
  78039. * Returns client's response
  78040. */
  78041. get response(): any;
  78042. /**
  78043. * Returns client's response url
  78044. */
  78045. get responseURL(): string;
  78046. /**
  78047. * Returns client's response as text
  78048. */
  78049. get responseText(): string;
  78050. /**
  78051. * Gets or sets the expected response type
  78052. */
  78053. get responseType(): XMLHttpRequestResponseType;
  78054. set responseType(value: XMLHttpRequestResponseType);
  78055. /** @hidden */
  78056. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78057. /** @hidden */
  78058. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78059. /**
  78060. * Cancels any network activity
  78061. */
  78062. abort(): void;
  78063. /**
  78064. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78065. * @param body defines an optional request body
  78066. */
  78067. send(body?: Document | BodyInit | null): void;
  78068. /**
  78069. * Sets the request method, request URL
  78070. * @param method defines the method to use (GET, POST, etc..)
  78071. * @param url defines the url to connect with
  78072. */
  78073. open(method: string, url: string): void;
  78074. /**
  78075. * Sets the value of a request header.
  78076. * @param name The name of the header whose value is to be set
  78077. * @param value The value to set as the body of the header
  78078. */
  78079. setRequestHeader(name: string, value: string): void;
  78080. /**
  78081. * Get the string containing the text of a particular header's value.
  78082. * @param name The name of the header
  78083. * @returns The string containing the text of the given header name
  78084. */
  78085. getResponseHeader(name: string): Nullable<string>;
  78086. }
  78087. }
  78088. declare module BABYLON {
  78089. /**
  78090. * File request interface
  78091. */
  78092. export interface IFileRequest {
  78093. /**
  78094. * Raised when the request is complete (success or error).
  78095. */
  78096. onCompleteObservable: Observable<IFileRequest>;
  78097. /**
  78098. * Aborts the request for a file.
  78099. */
  78100. abort: () => void;
  78101. }
  78102. }
  78103. declare module BABYLON {
  78104. /**
  78105. * Define options used to create a render target texture
  78106. */
  78107. export class RenderTargetCreationOptions {
  78108. /**
  78109. * Specifies is mipmaps must be generated
  78110. */
  78111. generateMipMaps?: boolean;
  78112. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78113. generateDepthBuffer?: boolean;
  78114. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78115. generateStencilBuffer?: boolean;
  78116. /** Defines texture type (int by default) */
  78117. type?: number;
  78118. /** Defines sampling mode (trilinear by default) */
  78119. samplingMode?: number;
  78120. /** Defines format (RGBA by default) */
  78121. format?: number;
  78122. }
  78123. }
  78124. declare module BABYLON {
  78125. /** Defines the cross module used constants to avoid circular dependncies */
  78126. export class Constants {
  78127. /** Defines that alpha blending is disabled */
  78128. static readonly ALPHA_DISABLE: number;
  78129. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78130. static readonly ALPHA_ADD: number;
  78131. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78132. static readonly ALPHA_COMBINE: number;
  78133. /** Defines that alpha blending is DEST - SRC * DEST */
  78134. static readonly ALPHA_SUBTRACT: number;
  78135. /** Defines that alpha blending is SRC * DEST */
  78136. static readonly ALPHA_MULTIPLY: number;
  78137. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78138. static readonly ALPHA_MAXIMIZED: number;
  78139. /** Defines that alpha blending is SRC + DEST */
  78140. static readonly ALPHA_ONEONE: number;
  78141. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78142. static readonly ALPHA_PREMULTIPLIED: number;
  78143. /**
  78144. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78145. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78146. */
  78147. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78148. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78149. static readonly ALPHA_INTERPOLATE: number;
  78150. /**
  78151. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78152. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78153. */
  78154. static readonly ALPHA_SCREENMODE: number;
  78155. /**
  78156. * Defines that alpha blending is SRC + DST
  78157. * Alpha will be set to SRC ALPHA + DST ALPHA
  78158. */
  78159. static readonly ALPHA_ONEONE_ONEONE: number;
  78160. /**
  78161. * Defines that alpha blending is SRC * DST ALPHA + DST
  78162. * Alpha will be set to 0
  78163. */
  78164. static readonly ALPHA_ALPHATOCOLOR: number;
  78165. /**
  78166. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78167. */
  78168. static readonly ALPHA_REVERSEONEMINUS: number;
  78169. /**
  78170. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78171. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78172. */
  78173. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78174. /**
  78175. * Defines that alpha blending is SRC + DST
  78176. * Alpha will be set to SRC ALPHA
  78177. */
  78178. static readonly ALPHA_ONEONE_ONEZERO: number;
  78179. /**
  78180. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78181. * Alpha will be set to DST ALPHA
  78182. */
  78183. static readonly ALPHA_EXCLUSION: number;
  78184. /** Defines that alpha blending equation a SUM */
  78185. static readonly ALPHA_EQUATION_ADD: number;
  78186. /** Defines that alpha blending equation a SUBSTRACTION */
  78187. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78188. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78189. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78190. /** Defines that alpha blending equation a MAX operation */
  78191. static readonly ALPHA_EQUATION_MAX: number;
  78192. /** Defines that alpha blending equation a MIN operation */
  78193. static readonly ALPHA_EQUATION_MIN: number;
  78194. /**
  78195. * Defines that alpha blending equation a DARKEN operation:
  78196. * It takes the min of the src and sums the alpha channels.
  78197. */
  78198. static readonly ALPHA_EQUATION_DARKEN: number;
  78199. /** Defines that the ressource is not delayed*/
  78200. static readonly DELAYLOADSTATE_NONE: number;
  78201. /** Defines that the ressource was successfully delay loaded */
  78202. static readonly DELAYLOADSTATE_LOADED: number;
  78203. /** Defines that the ressource is currently delay loading */
  78204. static readonly DELAYLOADSTATE_LOADING: number;
  78205. /** Defines that the ressource is delayed and has not started loading */
  78206. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78207. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78208. static readonly NEVER: number;
  78209. /** 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 */
  78210. static readonly ALWAYS: number;
  78211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78212. static readonly LESS: number;
  78213. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78214. static readonly EQUAL: number;
  78215. /** 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 */
  78216. static readonly LEQUAL: number;
  78217. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78218. static readonly GREATER: number;
  78219. /** 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 */
  78220. static readonly GEQUAL: number;
  78221. /** 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 */
  78222. static readonly NOTEQUAL: number;
  78223. /** Passed to stencilOperation to specify that stencil value must be kept */
  78224. static readonly KEEP: number;
  78225. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78226. static readonly REPLACE: number;
  78227. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78228. static readonly INCR: number;
  78229. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78230. static readonly DECR: number;
  78231. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78232. static readonly INVERT: number;
  78233. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78234. static readonly INCR_WRAP: number;
  78235. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78236. static readonly DECR_WRAP: number;
  78237. /** Texture is not repeating outside of 0..1 UVs */
  78238. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78239. /** Texture is repeating outside of 0..1 UVs */
  78240. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78241. /** Texture is repeating and mirrored */
  78242. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78243. /** ALPHA */
  78244. static readonly TEXTUREFORMAT_ALPHA: number;
  78245. /** LUMINANCE */
  78246. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78247. /** LUMINANCE_ALPHA */
  78248. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78249. /** RGB */
  78250. static readonly TEXTUREFORMAT_RGB: number;
  78251. /** RGBA */
  78252. static readonly TEXTUREFORMAT_RGBA: number;
  78253. /** RED */
  78254. static readonly TEXTUREFORMAT_RED: number;
  78255. /** RED (2nd reference) */
  78256. static readonly TEXTUREFORMAT_R: number;
  78257. /** RG */
  78258. static readonly TEXTUREFORMAT_RG: number;
  78259. /** RED_INTEGER */
  78260. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78261. /** RED_INTEGER (2nd reference) */
  78262. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78263. /** RG_INTEGER */
  78264. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78265. /** RGB_INTEGER */
  78266. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78267. /** RGBA_INTEGER */
  78268. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78269. /** UNSIGNED_BYTE */
  78270. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78271. /** UNSIGNED_BYTE (2nd reference) */
  78272. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78273. /** FLOAT */
  78274. static readonly TEXTURETYPE_FLOAT: number;
  78275. /** HALF_FLOAT */
  78276. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78277. /** BYTE */
  78278. static readonly TEXTURETYPE_BYTE: number;
  78279. /** SHORT */
  78280. static readonly TEXTURETYPE_SHORT: number;
  78281. /** UNSIGNED_SHORT */
  78282. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78283. /** INT */
  78284. static readonly TEXTURETYPE_INT: number;
  78285. /** UNSIGNED_INT */
  78286. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78287. /** UNSIGNED_SHORT_4_4_4_4 */
  78288. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78289. /** UNSIGNED_SHORT_5_5_5_1 */
  78290. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78291. /** UNSIGNED_SHORT_5_6_5 */
  78292. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78293. /** UNSIGNED_INT_2_10_10_10_REV */
  78294. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78295. /** UNSIGNED_INT_24_8 */
  78296. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78297. /** UNSIGNED_INT_10F_11F_11F_REV */
  78298. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78299. /** UNSIGNED_INT_5_9_9_9_REV */
  78300. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78301. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78302. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78303. /** nearest is mag = nearest and min = nearest and no mip */
  78304. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78305. /** mag = nearest and min = nearest and mip = none */
  78306. static readonly TEXTURE_NEAREST_NEAREST: number;
  78307. /** Bilinear is mag = linear and min = linear and no mip */
  78308. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78309. /** mag = linear and min = linear and mip = none */
  78310. static readonly TEXTURE_LINEAR_LINEAR: number;
  78311. /** Trilinear is mag = linear and min = linear and mip = linear */
  78312. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78313. /** Trilinear is mag = linear and min = linear and mip = linear */
  78314. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78315. /** mag = nearest and min = nearest and mip = nearest */
  78316. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78317. /** mag = nearest and min = linear and mip = nearest */
  78318. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78319. /** mag = nearest and min = linear and mip = linear */
  78320. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78321. /** mag = nearest and min = linear and mip = none */
  78322. static readonly TEXTURE_NEAREST_LINEAR: number;
  78323. /** nearest is mag = nearest and min = nearest and mip = linear */
  78324. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78325. /** mag = linear and min = nearest and mip = nearest */
  78326. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78327. /** mag = linear and min = nearest and mip = linear */
  78328. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78329. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78330. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78331. /** mag = linear and min = nearest and mip = none */
  78332. static readonly TEXTURE_LINEAR_NEAREST: number;
  78333. /** Explicit coordinates mode */
  78334. static readonly TEXTURE_EXPLICIT_MODE: number;
  78335. /** Spherical coordinates mode */
  78336. static readonly TEXTURE_SPHERICAL_MODE: number;
  78337. /** Planar coordinates mode */
  78338. static readonly TEXTURE_PLANAR_MODE: number;
  78339. /** Cubic coordinates mode */
  78340. static readonly TEXTURE_CUBIC_MODE: number;
  78341. /** Projection coordinates mode */
  78342. static readonly TEXTURE_PROJECTION_MODE: number;
  78343. /** Skybox coordinates mode */
  78344. static readonly TEXTURE_SKYBOX_MODE: number;
  78345. /** Inverse Cubic coordinates mode */
  78346. static readonly TEXTURE_INVCUBIC_MODE: number;
  78347. /** Equirectangular coordinates mode */
  78348. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78349. /** Equirectangular Fixed coordinates mode */
  78350. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78351. /** Equirectangular Fixed Mirrored coordinates mode */
  78352. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78353. /** Offline (baking) quality for texture filtering */
  78354. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78355. /** High quality for texture filtering */
  78356. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78357. /** Medium quality for texture filtering */
  78358. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78359. /** Low quality for texture filtering */
  78360. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78361. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78362. static readonly SCALEMODE_FLOOR: number;
  78363. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78364. static readonly SCALEMODE_NEAREST: number;
  78365. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78366. static readonly SCALEMODE_CEILING: number;
  78367. /**
  78368. * The dirty texture flag value
  78369. */
  78370. static readonly MATERIAL_TextureDirtyFlag: number;
  78371. /**
  78372. * The dirty light flag value
  78373. */
  78374. static readonly MATERIAL_LightDirtyFlag: number;
  78375. /**
  78376. * The dirty fresnel flag value
  78377. */
  78378. static readonly MATERIAL_FresnelDirtyFlag: number;
  78379. /**
  78380. * The dirty attribute flag value
  78381. */
  78382. static readonly MATERIAL_AttributesDirtyFlag: number;
  78383. /**
  78384. * The dirty misc flag value
  78385. */
  78386. static readonly MATERIAL_MiscDirtyFlag: number;
  78387. /**
  78388. * The all dirty flag value
  78389. */
  78390. static readonly MATERIAL_AllDirtyFlag: number;
  78391. /**
  78392. * Returns the triangle fill mode
  78393. */
  78394. static readonly MATERIAL_TriangleFillMode: number;
  78395. /**
  78396. * Returns the wireframe mode
  78397. */
  78398. static readonly MATERIAL_WireFrameFillMode: number;
  78399. /**
  78400. * Returns the point fill mode
  78401. */
  78402. static readonly MATERIAL_PointFillMode: number;
  78403. /**
  78404. * Returns the point list draw mode
  78405. */
  78406. static readonly MATERIAL_PointListDrawMode: number;
  78407. /**
  78408. * Returns the line list draw mode
  78409. */
  78410. static readonly MATERIAL_LineListDrawMode: number;
  78411. /**
  78412. * Returns the line loop draw mode
  78413. */
  78414. static readonly MATERIAL_LineLoopDrawMode: number;
  78415. /**
  78416. * Returns the line strip draw mode
  78417. */
  78418. static readonly MATERIAL_LineStripDrawMode: number;
  78419. /**
  78420. * Returns the triangle strip draw mode
  78421. */
  78422. static readonly MATERIAL_TriangleStripDrawMode: number;
  78423. /**
  78424. * Returns the triangle fan draw mode
  78425. */
  78426. static readonly MATERIAL_TriangleFanDrawMode: number;
  78427. /**
  78428. * Stores the clock-wise side orientation
  78429. */
  78430. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78431. /**
  78432. * Stores the counter clock-wise side orientation
  78433. */
  78434. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78435. /**
  78436. * Nothing
  78437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78438. */
  78439. static readonly ACTION_NothingTrigger: number;
  78440. /**
  78441. * On pick
  78442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78443. */
  78444. static readonly ACTION_OnPickTrigger: number;
  78445. /**
  78446. * On left pick
  78447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78448. */
  78449. static readonly ACTION_OnLeftPickTrigger: number;
  78450. /**
  78451. * On right pick
  78452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78453. */
  78454. static readonly ACTION_OnRightPickTrigger: number;
  78455. /**
  78456. * On center pick
  78457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78458. */
  78459. static readonly ACTION_OnCenterPickTrigger: number;
  78460. /**
  78461. * On pick down
  78462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78463. */
  78464. static readonly ACTION_OnPickDownTrigger: number;
  78465. /**
  78466. * On double pick
  78467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78468. */
  78469. static readonly ACTION_OnDoublePickTrigger: number;
  78470. /**
  78471. * On pick up
  78472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78473. */
  78474. static readonly ACTION_OnPickUpTrigger: number;
  78475. /**
  78476. * On pick out.
  78477. * This trigger will only be raised if you also declared a OnPickDown
  78478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78479. */
  78480. static readonly ACTION_OnPickOutTrigger: number;
  78481. /**
  78482. * On long press
  78483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78484. */
  78485. static readonly ACTION_OnLongPressTrigger: number;
  78486. /**
  78487. * On pointer over
  78488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78489. */
  78490. static readonly ACTION_OnPointerOverTrigger: number;
  78491. /**
  78492. * On pointer out
  78493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78494. */
  78495. static readonly ACTION_OnPointerOutTrigger: number;
  78496. /**
  78497. * On every frame
  78498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78499. */
  78500. static readonly ACTION_OnEveryFrameTrigger: number;
  78501. /**
  78502. * On intersection enter
  78503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78504. */
  78505. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78506. /**
  78507. * On intersection exit
  78508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78509. */
  78510. static readonly ACTION_OnIntersectionExitTrigger: number;
  78511. /**
  78512. * On key down
  78513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78514. */
  78515. static readonly ACTION_OnKeyDownTrigger: number;
  78516. /**
  78517. * On key up
  78518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78519. */
  78520. static readonly ACTION_OnKeyUpTrigger: number;
  78521. /**
  78522. * Billboard mode will only apply to Y axis
  78523. */
  78524. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78525. /**
  78526. * Billboard mode will apply to all axes
  78527. */
  78528. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78529. /**
  78530. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78531. */
  78532. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78533. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78534. * Test order :
  78535. * Is the bounding sphere outside the frustum ?
  78536. * If not, are the bounding box vertices outside the frustum ?
  78537. * It not, then the cullable object is in the frustum.
  78538. */
  78539. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78540. /** Culling strategy : Bounding Sphere Only.
  78541. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78542. * It's also less accurate than the standard because some not visible objects can still be selected.
  78543. * Test : is the bounding sphere outside the frustum ?
  78544. * If not, then the cullable object is in the frustum.
  78545. */
  78546. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78547. /** Culling strategy : Optimistic Inclusion.
  78548. * This in an inclusion test first, then the standard exclusion test.
  78549. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78550. * 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.
  78551. * Anyway, it's as accurate as the standard strategy.
  78552. * Test :
  78553. * Is the cullable object bounding sphere center in the frustum ?
  78554. * If not, apply the default culling strategy.
  78555. */
  78556. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78557. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78558. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78559. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78560. * 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.
  78561. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78562. * Test :
  78563. * Is the cullable object bounding sphere center in the frustum ?
  78564. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78565. */
  78566. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78567. /**
  78568. * No logging while loading
  78569. */
  78570. static readonly SCENELOADER_NO_LOGGING: number;
  78571. /**
  78572. * Minimal logging while loading
  78573. */
  78574. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78575. /**
  78576. * Summary logging while loading
  78577. */
  78578. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78579. /**
  78580. * Detailled logging while loading
  78581. */
  78582. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78583. }
  78584. }
  78585. declare module BABYLON {
  78586. /**
  78587. * This represents the required contract to create a new type of texture loader.
  78588. */
  78589. export interface IInternalTextureLoader {
  78590. /**
  78591. * Defines wether the loader supports cascade loading the different faces.
  78592. */
  78593. supportCascades: boolean;
  78594. /**
  78595. * This returns if the loader support the current file information.
  78596. * @param extension defines the file extension of the file being loaded
  78597. * @returns true if the loader can load the specified file
  78598. */
  78599. canLoad(extension: string): boolean;
  78600. /**
  78601. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78602. * @param data contains the texture data
  78603. * @param texture defines the BabylonJS internal texture
  78604. * @param createPolynomials will be true if polynomials have been requested
  78605. * @param onLoad defines the callback to trigger once the texture is ready
  78606. * @param onError defines the callback to trigger in case of error
  78607. */
  78608. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78609. /**
  78610. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78611. * @param data contains the texture data
  78612. * @param texture defines the BabylonJS internal texture
  78613. * @param callback defines the method to call once ready to upload
  78614. */
  78615. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78616. }
  78617. }
  78618. declare module BABYLON {
  78619. /**
  78620. * Class used to store and describe the pipeline context associated with an effect
  78621. */
  78622. export interface IPipelineContext {
  78623. /**
  78624. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78625. */
  78626. isAsync: boolean;
  78627. /**
  78628. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78629. */
  78630. isReady: boolean;
  78631. /** @hidden */
  78632. _getVertexShaderCode(): string | null;
  78633. /** @hidden */
  78634. _getFragmentShaderCode(): string | null;
  78635. /** @hidden */
  78636. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78637. }
  78638. }
  78639. declare module BABYLON {
  78640. /**
  78641. * Class used to store gfx data (like WebGLBuffer)
  78642. */
  78643. export class DataBuffer {
  78644. /**
  78645. * Gets or sets the number of objects referencing this buffer
  78646. */
  78647. references: number;
  78648. /** Gets or sets the size of the underlying buffer */
  78649. capacity: number;
  78650. /**
  78651. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78652. */
  78653. is32Bits: boolean;
  78654. /**
  78655. * Gets the underlying buffer
  78656. */
  78657. get underlyingResource(): any;
  78658. }
  78659. }
  78660. declare module BABYLON {
  78661. /** @hidden */
  78662. export interface IShaderProcessor {
  78663. attributeProcessor?: (attribute: string) => string;
  78664. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78665. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78666. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78667. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78668. lineProcessor?: (line: string, isFragment: boolean) => string;
  78669. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78670. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78671. }
  78672. }
  78673. declare module BABYLON {
  78674. /** @hidden */
  78675. export interface ProcessingOptions {
  78676. defines: string[];
  78677. indexParameters: any;
  78678. isFragment: boolean;
  78679. shouldUseHighPrecisionShader: boolean;
  78680. supportsUniformBuffers: boolean;
  78681. shadersRepository: string;
  78682. includesShadersStore: {
  78683. [key: string]: string;
  78684. };
  78685. processor?: IShaderProcessor;
  78686. version: string;
  78687. platformName: string;
  78688. lookForClosingBracketForUniformBuffer?: boolean;
  78689. }
  78690. }
  78691. declare module BABYLON {
  78692. /** @hidden */
  78693. export class ShaderCodeNode {
  78694. line: string;
  78695. children: ShaderCodeNode[];
  78696. additionalDefineKey?: string;
  78697. additionalDefineValue?: string;
  78698. isValid(preprocessors: {
  78699. [key: string]: string;
  78700. }): boolean;
  78701. process(preprocessors: {
  78702. [key: string]: string;
  78703. }, options: ProcessingOptions): string;
  78704. }
  78705. }
  78706. declare module BABYLON {
  78707. /** @hidden */
  78708. export class ShaderCodeCursor {
  78709. private _lines;
  78710. lineIndex: number;
  78711. get currentLine(): string;
  78712. get canRead(): boolean;
  78713. set lines(value: string[]);
  78714. }
  78715. }
  78716. declare module BABYLON {
  78717. /** @hidden */
  78718. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78719. process(preprocessors: {
  78720. [key: string]: string;
  78721. }, options: ProcessingOptions): string;
  78722. }
  78723. }
  78724. declare module BABYLON {
  78725. /** @hidden */
  78726. export class ShaderDefineExpression {
  78727. isTrue(preprocessors: {
  78728. [key: string]: string;
  78729. }): boolean;
  78730. private static _OperatorPriority;
  78731. private static _Stack;
  78732. static postfixToInfix(postfix: string[]): string;
  78733. static infixToPostfix(infix: string): string[];
  78734. }
  78735. }
  78736. declare module BABYLON {
  78737. /** @hidden */
  78738. export class ShaderCodeTestNode extends ShaderCodeNode {
  78739. testExpression: ShaderDefineExpression;
  78740. isValid(preprocessors: {
  78741. [key: string]: string;
  78742. }): boolean;
  78743. }
  78744. }
  78745. declare module BABYLON {
  78746. /** @hidden */
  78747. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78748. define: string;
  78749. not: boolean;
  78750. constructor(define: string, not?: boolean);
  78751. isTrue(preprocessors: {
  78752. [key: string]: string;
  78753. }): boolean;
  78754. }
  78755. }
  78756. declare module BABYLON {
  78757. /** @hidden */
  78758. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78759. leftOperand: ShaderDefineExpression;
  78760. rightOperand: ShaderDefineExpression;
  78761. isTrue(preprocessors: {
  78762. [key: string]: string;
  78763. }): boolean;
  78764. }
  78765. }
  78766. declare module BABYLON {
  78767. /** @hidden */
  78768. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78769. leftOperand: ShaderDefineExpression;
  78770. rightOperand: ShaderDefineExpression;
  78771. isTrue(preprocessors: {
  78772. [key: string]: string;
  78773. }): boolean;
  78774. }
  78775. }
  78776. declare module BABYLON {
  78777. /** @hidden */
  78778. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78779. define: string;
  78780. operand: string;
  78781. testValue: string;
  78782. constructor(define: string, operand: string, testValue: string);
  78783. isTrue(preprocessors: {
  78784. [key: string]: string;
  78785. }): boolean;
  78786. }
  78787. }
  78788. declare module BABYLON {
  78789. /**
  78790. * Class used to enable access to offline support
  78791. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78792. */
  78793. export interface IOfflineProvider {
  78794. /**
  78795. * Gets a boolean indicating if scene must be saved in the database
  78796. */
  78797. enableSceneOffline: boolean;
  78798. /**
  78799. * Gets a boolean indicating if textures must be saved in the database
  78800. */
  78801. enableTexturesOffline: boolean;
  78802. /**
  78803. * Open the offline support and make it available
  78804. * @param successCallback defines the callback to call on success
  78805. * @param errorCallback defines the callback to call on error
  78806. */
  78807. open(successCallback: () => void, errorCallback: () => void): void;
  78808. /**
  78809. * Loads an image from the offline support
  78810. * @param url defines the url to load from
  78811. * @param image defines the target DOM image
  78812. */
  78813. loadImage(url: string, image: HTMLImageElement): void;
  78814. /**
  78815. * Loads a file from offline support
  78816. * @param url defines the URL to load from
  78817. * @param sceneLoaded defines a callback to call on success
  78818. * @param progressCallBack defines a callback to call when progress changed
  78819. * @param errorCallback defines a callback to call on error
  78820. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78821. */
  78822. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78823. }
  78824. }
  78825. declare module BABYLON {
  78826. /**
  78827. * Class used to help managing file picking and drag'n'drop
  78828. * File Storage
  78829. */
  78830. export class FilesInputStore {
  78831. /**
  78832. * List of files ready to be loaded
  78833. */
  78834. static FilesToLoad: {
  78835. [key: string]: File;
  78836. };
  78837. }
  78838. }
  78839. declare module BABYLON {
  78840. /**
  78841. * Class used to define a retry strategy when error happens while loading assets
  78842. */
  78843. export class RetryStrategy {
  78844. /**
  78845. * Function used to defines an exponential back off strategy
  78846. * @param maxRetries defines the maximum number of retries (3 by default)
  78847. * @param baseInterval defines the interval between retries
  78848. * @returns the strategy function to use
  78849. */
  78850. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  78851. }
  78852. }
  78853. declare module BABYLON {
  78854. /**
  78855. * @ignore
  78856. * Application error to support additional information when loading a file
  78857. */
  78858. export abstract class BaseError extends Error {
  78859. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  78860. }
  78861. }
  78862. declare module BABYLON {
  78863. /** @ignore */
  78864. export class LoadFileError extends BaseError {
  78865. request?: WebRequest;
  78866. file?: File;
  78867. /**
  78868. * Creates a new LoadFileError
  78869. * @param message defines the message of the error
  78870. * @param request defines the optional web request
  78871. * @param file defines the optional file
  78872. */
  78873. constructor(message: string, object?: WebRequest | File);
  78874. }
  78875. /** @ignore */
  78876. export class RequestFileError extends BaseError {
  78877. request: WebRequest;
  78878. /**
  78879. * Creates a new LoadFileError
  78880. * @param message defines the message of the error
  78881. * @param request defines the optional web request
  78882. */
  78883. constructor(message: string, request: WebRequest);
  78884. }
  78885. /** @ignore */
  78886. export class ReadFileError extends BaseError {
  78887. file: File;
  78888. /**
  78889. * Creates a new ReadFileError
  78890. * @param message defines the message of the error
  78891. * @param file defines the optional file
  78892. */
  78893. constructor(message: string, file: File);
  78894. }
  78895. /**
  78896. * @hidden
  78897. */
  78898. export class FileTools {
  78899. /**
  78900. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  78901. */
  78902. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  78903. /**
  78904. * Gets or sets the base URL to use to load assets
  78905. */
  78906. static BaseUrl: string;
  78907. /**
  78908. * Default behaviour for cors in the application.
  78909. * It can be a string if the expected behavior is identical in the entire app.
  78910. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  78911. */
  78912. static CorsBehavior: string | ((url: string | string[]) => string);
  78913. /**
  78914. * Gets or sets a function used to pre-process url before using them to load assets
  78915. */
  78916. static PreprocessUrl: (url: string) => string;
  78917. /**
  78918. * Removes unwanted characters from an url
  78919. * @param url defines the url to clean
  78920. * @returns the cleaned url
  78921. */
  78922. private static _CleanUrl;
  78923. /**
  78924. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  78925. * @param url define the url we are trying
  78926. * @param element define the dom element where to configure the cors policy
  78927. */
  78928. static SetCorsBehavior(url: string | string[], element: {
  78929. crossOrigin: string | null;
  78930. }): void;
  78931. /**
  78932. * Loads an image as an HTMLImageElement.
  78933. * @param input url string, ArrayBuffer, or Blob to load
  78934. * @param onLoad callback called when the image successfully loads
  78935. * @param onError callback called when the image fails to load
  78936. * @param offlineProvider offline provider for caching
  78937. * @param mimeType optional mime type
  78938. * @returns the HTMLImageElement of the loaded image
  78939. */
  78940. 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>;
  78941. /**
  78942. * Reads a file from a File object
  78943. * @param file defines the file to load
  78944. * @param onSuccess defines the callback to call when data is loaded
  78945. * @param onProgress defines the callback to call during loading process
  78946. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  78947. * @param onError defines the callback to call when an error occurs
  78948. * @returns a file request object
  78949. */
  78950. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  78951. /**
  78952. * Loads a file from a url
  78953. * @param url url to load
  78954. * @param onSuccess callback called when the file successfully loads
  78955. * @param onProgress callback called while file is loading (if the server supports this mode)
  78956. * @param offlineProvider defines the offline provider for caching
  78957. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78958. * @param onError callback called when the file fails to load
  78959. * @returns a file request object
  78960. */
  78961. 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;
  78962. /**
  78963. * Loads a file
  78964. * @param url url to load
  78965. * @param onSuccess callback called when the file successfully loads
  78966. * @param onProgress callback called while file is loading (if the server supports this mode)
  78967. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  78968. * @param onError callback called when the file fails to load
  78969. * @param onOpened callback called when the web request is opened
  78970. * @returns a file request object
  78971. */
  78972. 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;
  78973. /**
  78974. * Checks if the loaded document was accessed via `file:`-Protocol.
  78975. * @returns boolean
  78976. */
  78977. static IsFileURL(): boolean;
  78978. }
  78979. }
  78980. declare module BABYLON {
  78981. /** @hidden */
  78982. export class ShaderProcessor {
  78983. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  78984. private static _ProcessPrecision;
  78985. private static _ExtractOperation;
  78986. private static _BuildSubExpression;
  78987. private static _BuildExpression;
  78988. private static _MoveCursorWithinIf;
  78989. private static _MoveCursor;
  78990. private static _EvaluatePreProcessors;
  78991. private static _PreparePreProcessors;
  78992. private static _ProcessShaderConversion;
  78993. private static _ProcessIncludes;
  78994. /**
  78995. * Loads a file from a url
  78996. * @param url url to load
  78997. * @param onSuccess callback called when the file successfully loads
  78998. * @param onProgress callback called while file is loading (if the server supports this mode)
  78999. * @param offlineProvider defines the offline provider for caching
  79000. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79001. * @param onError callback called when the file fails to load
  79002. * @returns a file request object
  79003. * @hidden
  79004. */
  79005. 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;
  79006. }
  79007. }
  79008. declare module BABYLON {
  79009. /**
  79010. * @hidden
  79011. */
  79012. export interface IColor4Like {
  79013. r: float;
  79014. g: float;
  79015. b: float;
  79016. a: float;
  79017. }
  79018. /**
  79019. * @hidden
  79020. */
  79021. export interface IColor3Like {
  79022. r: float;
  79023. g: float;
  79024. b: float;
  79025. }
  79026. /**
  79027. * @hidden
  79028. */
  79029. export interface IVector4Like {
  79030. x: float;
  79031. y: float;
  79032. z: float;
  79033. w: float;
  79034. }
  79035. /**
  79036. * @hidden
  79037. */
  79038. export interface IVector3Like {
  79039. x: float;
  79040. y: float;
  79041. z: float;
  79042. }
  79043. /**
  79044. * @hidden
  79045. */
  79046. export interface IVector2Like {
  79047. x: float;
  79048. y: float;
  79049. }
  79050. /**
  79051. * @hidden
  79052. */
  79053. export interface IMatrixLike {
  79054. toArray(): DeepImmutable<Float32Array>;
  79055. updateFlag: int;
  79056. }
  79057. /**
  79058. * @hidden
  79059. */
  79060. export interface IViewportLike {
  79061. x: float;
  79062. y: float;
  79063. width: float;
  79064. height: float;
  79065. }
  79066. /**
  79067. * @hidden
  79068. */
  79069. export interface IPlaneLike {
  79070. normal: IVector3Like;
  79071. d: float;
  79072. normalize(): void;
  79073. }
  79074. }
  79075. declare module BABYLON {
  79076. /**
  79077. * Interface used to define common properties for effect fallbacks
  79078. */
  79079. export interface IEffectFallbacks {
  79080. /**
  79081. * Removes the defines that should be removed when falling back.
  79082. * @param currentDefines defines the current define statements for the shader.
  79083. * @param effect defines the current effect we try to compile
  79084. * @returns The resulting defines with defines of the current rank removed.
  79085. */
  79086. reduce(currentDefines: string, effect: Effect): string;
  79087. /**
  79088. * Removes the fallback from the bound mesh.
  79089. */
  79090. unBindMesh(): void;
  79091. /**
  79092. * Checks to see if more fallbacks are still availible.
  79093. */
  79094. hasMoreFallbacks: boolean;
  79095. }
  79096. }
  79097. declare module BABYLON {
  79098. /**
  79099. * Class used to evalaute queries containing `and` and `or` operators
  79100. */
  79101. export class AndOrNotEvaluator {
  79102. /**
  79103. * Evaluate a query
  79104. * @param query defines the query to evaluate
  79105. * @param evaluateCallback defines the callback used to filter result
  79106. * @returns true if the query matches
  79107. */
  79108. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79109. private static _HandleParenthesisContent;
  79110. private static _SimplifyNegation;
  79111. }
  79112. }
  79113. declare module BABYLON {
  79114. /**
  79115. * Class used to store custom tags
  79116. */
  79117. export class Tags {
  79118. /**
  79119. * Adds support for tags on the given object
  79120. * @param obj defines the object to use
  79121. */
  79122. static EnableFor(obj: any): void;
  79123. /**
  79124. * Removes tags support
  79125. * @param obj defines the object to use
  79126. */
  79127. static DisableFor(obj: any): void;
  79128. /**
  79129. * Gets a boolean indicating if the given object has tags
  79130. * @param obj defines the object to use
  79131. * @returns a boolean
  79132. */
  79133. static HasTags(obj: any): boolean;
  79134. /**
  79135. * Gets the tags available on a given object
  79136. * @param obj defines the object to use
  79137. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79138. * @returns the tags
  79139. */
  79140. static GetTags(obj: any, asString?: boolean): any;
  79141. /**
  79142. * Adds tags to an object
  79143. * @param obj defines the object to use
  79144. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79145. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79146. */
  79147. static AddTagsTo(obj: any, tagsString: string): void;
  79148. /**
  79149. * @hidden
  79150. */
  79151. static _AddTagTo(obj: any, tag: string): void;
  79152. /**
  79153. * Removes specific tags from a specific object
  79154. * @param obj defines the object to use
  79155. * @param tagsString defines the tags to remove
  79156. */
  79157. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79158. /**
  79159. * @hidden
  79160. */
  79161. static _RemoveTagFrom(obj: any, tag: string): void;
  79162. /**
  79163. * Defines if tags hosted on an object match a given query
  79164. * @param obj defines the object to use
  79165. * @param tagsQuery defines the tag query
  79166. * @returns a boolean
  79167. */
  79168. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79169. }
  79170. }
  79171. declare module BABYLON {
  79172. /**
  79173. * Scalar computation library
  79174. */
  79175. export class Scalar {
  79176. /**
  79177. * Two pi constants convenient for computation.
  79178. */
  79179. static TwoPi: number;
  79180. /**
  79181. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79182. * @param a number
  79183. * @param b number
  79184. * @param epsilon (default = 1.401298E-45)
  79185. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79186. */
  79187. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79188. /**
  79189. * Returns a string : the upper case translation of the number i to hexadecimal.
  79190. * @param i number
  79191. * @returns the upper case translation of the number i to hexadecimal.
  79192. */
  79193. static ToHex(i: number): string;
  79194. /**
  79195. * Returns -1 if value is negative and +1 is value is positive.
  79196. * @param value the value
  79197. * @returns the value itself if it's equal to zero.
  79198. */
  79199. static Sign(value: number): number;
  79200. /**
  79201. * Returns the value itself if it's between min and max.
  79202. * Returns min if the value is lower than min.
  79203. * Returns max if the value is greater than max.
  79204. * @param value the value to clmap
  79205. * @param min the min value to clamp to (default: 0)
  79206. * @param max the max value to clamp to (default: 1)
  79207. * @returns the clamped value
  79208. */
  79209. static Clamp(value: number, min?: number, max?: number): number;
  79210. /**
  79211. * the log2 of value.
  79212. * @param value the value to compute log2 of
  79213. * @returns the log2 of value.
  79214. */
  79215. static Log2(value: number): number;
  79216. /**
  79217. * Loops the value, so that it is never larger than length and never smaller than 0.
  79218. *
  79219. * This is similar to the modulo operator but it works with floating point numbers.
  79220. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79221. * With t = 5 and length = 2.5, the result would be 0.0.
  79222. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79223. * @param value the value
  79224. * @param length the length
  79225. * @returns the looped value
  79226. */
  79227. static Repeat(value: number, length: number): number;
  79228. /**
  79229. * Normalize the value between 0.0 and 1.0 using min and max values
  79230. * @param value value to normalize
  79231. * @param min max to normalize between
  79232. * @param max min to normalize between
  79233. * @returns the normalized value
  79234. */
  79235. static Normalize(value: number, min: number, max: number): number;
  79236. /**
  79237. * Denormalize the value from 0.0 and 1.0 using min and max values
  79238. * @param normalized value to denormalize
  79239. * @param min max to denormalize between
  79240. * @param max min to denormalize between
  79241. * @returns the denormalized value
  79242. */
  79243. static Denormalize(normalized: number, min: number, max: number): number;
  79244. /**
  79245. * Calculates the shortest difference between two given angles given in degrees.
  79246. * @param current current angle in degrees
  79247. * @param target target angle in degrees
  79248. * @returns the delta
  79249. */
  79250. static DeltaAngle(current: number, target: number): number;
  79251. /**
  79252. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79253. * @param tx value
  79254. * @param length length
  79255. * @returns The returned value will move back and forth between 0 and length
  79256. */
  79257. static PingPong(tx: number, length: number): number;
  79258. /**
  79259. * Interpolates between min and max with smoothing at the limits.
  79260. *
  79261. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79262. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79263. * @param from from
  79264. * @param to to
  79265. * @param tx value
  79266. * @returns the smooth stepped value
  79267. */
  79268. static SmoothStep(from: number, to: number, tx: number): number;
  79269. /**
  79270. * Moves a value current towards target.
  79271. *
  79272. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79273. * Negative values of maxDelta pushes the value away from target.
  79274. * @param current current value
  79275. * @param target target value
  79276. * @param maxDelta max distance to move
  79277. * @returns resulting value
  79278. */
  79279. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79280. /**
  79281. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79282. *
  79283. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79284. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79285. * @param current current value
  79286. * @param target target value
  79287. * @param maxDelta max distance to move
  79288. * @returns resulting angle
  79289. */
  79290. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79291. /**
  79292. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79293. * @param start start value
  79294. * @param end target value
  79295. * @param amount amount to lerp between
  79296. * @returns the lerped value
  79297. */
  79298. static Lerp(start: number, end: number, amount: number): number;
  79299. /**
  79300. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79301. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79302. * @param start start value
  79303. * @param end target value
  79304. * @param amount amount to lerp between
  79305. * @returns the lerped value
  79306. */
  79307. static LerpAngle(start: number, end: number, amount: number): number;
  79308. /**
  79309. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79310. * @param a start value
  79311. * @param b target value
  79312. * @param value value between a and b
  79313. * @returns the inverseLerp value
  79314. */
  79315. static InverseLerp(a: number, b: number, value: number): number;
  79316. /**
  79317. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79318. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79319. * @param value1 spline value
  79320. * @param tangent1 spline value
  79321. * @param value2 spline value
  79322. * @param tangent2 spline value
  79323. * @param amount input value
  79324. * @returns hermite result
  79325. */
  79326. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79327. /**
  79328. * Returns a random float number between and min and max values
  79329. * @param min min value of random
  79330. * @param max max value of random
  79331. * @returns random value
  79332. */
  79333. static RandomRange(min: number, max: number): number;
  79334. /**
  79335. * This function returns percentage of a number in a given range.
  79336. *
  79337. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79338. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79339. * @param number to convert to percentage
  79340. * @param min min range
  79341. * @param max max range
  79342. * @returns the percentage
  79343. */
  79344. static RangeToPercent(number: number, min: number, max: number): number;
  79345. /**
  79346. * This function returns number that corresponds to the percentage in a given range.
  79347. *
  79348. * PercentToRange(0.34,0,100) will return 34.
  79349. * @param percent to convert to number
  79350. * @param min min range
  79351. * @param max max range
  79352. * @returns the number
  79353. */
  79354. static PercentToRange(percent: number, min: number, max: number): number;
  79355. /**
  79356. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79357. * @param angle The angle to normalize in radian.
  79358. * @return The converted angle.
  79359. */
  79360. static NormalizeRadians(angle: number): number;
  79361. }
  79362. }
  79363. declare module BABYLON {
  79364. /**
  79365. * Constant used to convert a value to gamma space
  79366. * @ignorenaming
  79367. */
  79368. export const ToGammaSpace: number;
  79369. /**
  79370. * Constant used to convert a value to linear space
  79371. * @ignorenaming
  79372. */
  79373. export const ToLinearSpace = 2.2;
  79374. /**
  79375. * Constant used to define the minimal number value in Babylon.js
  79376. * @ignorenaming
  79377. */
  79378. let Epsilon: number;
  79379. }
  79380. declare module BABYLON {
  79381. /**
  79382. * Class used to represent a viewport on screen
  79383. */
  79384. export class Viewport {
  79385. /** viewport left coordinate */
  79386. x: number;
  79387. /** viewport top coordinate */
  79388. y: number;
  79389. /**viewport width */
  79390. width: number;
  79391. /** viewport height */
  79392. height: number;
  79393. /**
  79394. * Creates a Viewport object located at (x, y) and sized (width, height)
  79395. * @param x defines viewport left coordinate
  79396. * @param y defines viewport top coordinate
  79397. * @param width defines the viewport width
  79398. * @param height defines the viewport height
  79399. */
  79400. constructor(
  79401. /** viewport left coordinate */
  79402. x: number,
  79403. /** viewport top coordinate */
  79404. y: number,
  79405. /**viewport width */
  79406. width: number,
  79407. /** viewport height */
  79408. height: number);
  79409. /**
  79410. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79411. * @param renderWidth defines the rendering width
  79412. * @param renderHeight defines the rendering height
  79413. * @returns a new Viewport
  79414. */
  79415. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79416. /**
  79417. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79418. * @param renderWidth defines the rendering width
  79419. * @param renderHeight defines the rendering height
  79420. * @param ref defines the target viewport
  79421. * @returns the current viewport
  79422. */
  79423. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79424. /**
  79425. * Returns a new Viewport copied from the current one
  79426. * @returns a new Viewport
  79427. */
  79428. clone(): Viewport;
  79429. }
  79430. }
  79431. declare module BABYLON {
  79432. /**
  79433. * Class containing a set of static utilities functions for arrays.
  79434. */
  79435. export class ArrayTools {
  79436. /**
  79437. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79438. * @param size the number of element to construct and put in the array
  79439. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79440. * @returns a new array filled with new objects
  79441. */
  79442. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79443. }
  79444. }
  79445. declare module BABYLON {
  79446. /**
  79447. * Represens a plane by the equation ax + by + cz + d = 0
  79448. */
  79449. export class Plane {
  79450. private static _TmpMatrix;
  79451. /**
  79452. * Normal of the plane (a,b,c)
  79453. */
  79454. normal: Vector3;
  79455. /**
  79456. * d component of the plane
  79457. */
  79458. d: number;
  79459. /**
  79460. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79461. * @param a a component of the plane
  79462. * @param b b component of the plane
  79463. * @param c c component of the plane
  79464. * @param d d component of the plane
  79465. */
  79466. constructor(a: number, b: number, c: number, d: number);
  79467. /**
  79468. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79469. */
  79470. asArray(): number[];
  79471. /**
  79472. * @returns a new plane copied from the current Plane.
  79473. */
  79474. clone(): Plane;
  79475. /**
  79476. * @returns the string "Plane".
  79477. */
  79478. getClassName(): string;
  79479. /**
  79480. * @returns the Plane hash code.
  79481. */
  79482. getHashCode(): number;
  79483. /**
  79484. * Normalize the current Plane in place.
  79485. * @returns the updated Plane.
  79486. */
  79487. normalize(): Plane;
  79488. /**
  79489. * Applies a transformation the plane and returns the result
  79490. * @param transformation the transformation matrix to be applied to the plane
  79491. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79492. */
  79493. transform(transformation: DeepImmutable<Matrix>): Plane;
  79494. /**
  79495. * Compute the dot product between the point and the plane normal
  79496. * @param point point to calculate the dot product with
  79497. * @returns the dot product (float) of the point coordinates and the plane normal.
  79498. */
  79499. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79500. /**
  79501. * Updates the current Plane from the plane defined by the three given points.
  79502. * @param point1 one of the points used to contruct the plane
  79503. * @param point2 one of the points used to contruct the plane
  79504. * @param point3 one of the points used to contruct the plane
  79505. * @returns the updated Plane.
  79506. */
  79507. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79508. /**
  79509. * Checks if the plane is facing a given direction
  79510. * @param direction the direction to check if the plane is facing
  79511. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79512. * @returns True is the vector "direction" is the same side than the plane normal.
  79513. */
  79514. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79515. /**
  79516. * Calculates the distance to a point
  79517. * @param point point to calculate distance to
  79518. * @returns the signed distance (float) from the given point to the Plane.
  79519. */
  79520. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79521. /**
  79522. * Creates a plane from an array
  79523. * @param array the array to create a plane from
  79524. * @returns a new Plane from the given array.
  79525. */
  79526. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79527. /**
  79528. * Creates a plane from three points
  79529. * @param point1 point used to create the plane
  79530. * @param point2 point used to create the plane
  79531. * @param point3 point used to create the plane
  79532. * @returns a new Plane defined by the three given points.
  79533. */
  79534. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79535. /**
  79536. * Creates a plane from an origin point and a normal
  79537. * @param origin origin of the plane to be constructed
  79538. * @param normal normal of the plane to be constructed
  79539. * @returns a new Plane the normal vector to this plane at the given origin point.
  79540. * Note : the vector "normal" is updated because normalized.
  79541. */
  79542. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79543. /**
  79544. * Calculates the distance from a plane and a point
  79545. * @param origin origin of the plane to be constructed
  79546. * @param normal normal of the plane to be constructed
  79547. * @param point point to calculate distance to
  79548. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79549. */
  79550. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79551. }
  79552. }
  79553. declare module BABYLON {
  79554. /**
  79555. * Class representing a vector containing 2 coordinates
  79556. */
  79557. export class Vector2 {
  79558. /** defines the first coordinate */
  79559. x: number;
  79560. /** defines the second coordinate */
  79561. y: number;
  79562. /**
  79563. * Creates a new Vector2 from the given x and y coordinates
  79564. * @param x defines the first coordinate
  79565. * @param y defines the second coordinate
  79566. */
  79567. constructor(
  79568. /** defines the first coordinate */
  79569. x?: number,
  79570. /** defines the second coordinate */
  79571. y?: number);
  79572. /**
  79573. * Gets a string with the Vector2 coordinates
  79574. * @returns a string with the Vector2 coordinates
  79575. */
  79576. toString(): string;
  79577. /**
  79578. * Gets class name
  79579. * @returns the string "Vector2"
  79580. */
  79581. getClassName(): string;
  79582. /**
  79583. * Gets current vector hash code
  79584. * @returns the Vector2 hash code as a number
  79585. */
  79586. getHashCode(): number;
  79587. /**
  79588. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79589. * @param array defines the source array
  79590. * @param index defines the offset in source array
  79591. * @returns the current Vector2
  79592. */
  79593. toArray(array: FloatArray, index?: number): Vector2;
  79594. /**
  79595. * Copy the current vector to an array
  79596. * @returns a new array with 2 elements: the Vector2 coordinates.
  79597. */
  79598. asArray(): number[];
  79599. /**
  79600. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79601. * @param source defines the source Vector2
  79602. * @returns the current updated Vector2
  79603. */
  79604. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79605. /**
  79606. * Sets the Vector2 coordinates with the given floats
  79607. * @param x defines the first coordinate
  79608. * @param y defines the second coordinate
  79609. * @returns the current updated Vector2
  79610. */
  79611. copyFromFloats(x: number, y: number): Vector2;
  79612. /**
  79613. * Sets the Vector2 coordinates with the given floats
  79614. * @param x defines the first coordinate
  79615. * @param y defines the second coordinate
  79616. * @returns the current updated Vector2
  79617. */
  79618. set(x: number, y: number): Vector2;
  79619. /**
  79620. * Add another vector with the current one
  79621. * @param otherVector defines the other vector
  79622. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79623. */
  79624. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79625. /**
  79626. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79627. * @param otherVector defines the other vector
  79628. * @param result defines the target vector
  79629. * @returns the unmodified current Vector2
  79630. */
  79631. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79632. /**
  79633. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79634. * @param otherVector defines the other vector
  79635. * @returns the current updated Vector2
  79636. */
  79637. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79638. /**
  79639. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79640. * @param otherVector defines the other vector
  79641. * @returns a new Vector2
  79642. */
  79643. addVector3(otherVector: Vector3): Vector2;
  79644. /**
  79645. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79646. * @param otherVector defines the other vector
  79647. * @returns a new Vector2
  79648. */
  79649. subtract(otherVector: Vector2): Vector2;
  79650. /**
  79651. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79652. * @param otherVector defines the other vector
  79653. * @param result defines the target vector
  79654. * @returns the unmodified current Vector2
  79655. */
  79656. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79657. /**
  79658. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79659. * @param otherVector defines the other vector
  79660. * @returns the current updated Vector2
  79661. */
  79662. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79663. /**
  79664. * Multiplies in place the current Vector2 coordinates by the given ones
  79665. * @param otherVector defines the other vector
  79666. * @returns the current updated Vector2
  79667. */
  79668. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79669. /**
  79670. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79671. * @param otherVector defines the other vector
  79672. * @returns a new Vector2
  79673. */
  79674. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79675. /**
  79676. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79677. * @param otherVector defines the other vector
  79678. * @param result defines the target vector
  79679. * @returns the unmodified current Vector2
  79680. */
  79681. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79682. /**
  79683. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79684. * @param x defines the first coordinate
  79685. * @param y defines the second coordinate
  79686. * @returns a new Vector2
  79687. */
  79688. multiplyByFloats(x: number, y: number): Vector2;
  79689. /**
  79690. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79691. * @param otherVector defines the other vector
  79692. * @returns a new Vector2
  79693. */
  79694. divide(otherVector: Vector2): Vector2;
  79695. /**
  79696. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79697. * @param otherVector defines the other vector
  79698. * @param result defines the target vector
  79699. * @returns the unmodified current Vector2
  79700. */
  79701. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79702. /**
  79703. * Divides the current Vector2 coordinates by the given ones
  79704. * @param otherVector defines the other vector
  79705. * @returns the current updated Vector2
  79706. */
  79707. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79708. /**
  79709. * Gets a new Vector2 with current Vector2 negated coordinates
  79710. * @returns a new Vector2
  79711. */
  79712. negate(): Vector2;
  79713. /**
  79714. * Negate this vector in place
  79715. * @returns this
  79716. */
  79717. negateInPlace(): Vector2;
  79718. /**
  79719. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79720. * @param result defines the Vector3 object where to store the result
  79721. * @returns the current Vector2
  79722. */
  79723. negateToRef(result: Vector2): Vector2;
  79724. /**
  79725. * Multiply the Vector2 coordinates by scale
  79726. * @param scale defines the scaling factor
  79727. * @returns the current updated Vector2
  79728. */
  79729. scaleInPlace(scale: number): Vector2;
  79730. /**
  79731. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79732. * @param scale defines the scaling factor
  79733. * @returns a new Vector2
  79734. */
  79735. scale(scale: number): Vector2;
  79736. /**
  79737. * Scale the current Vector2 values by a factor to a given Vector2
  79738. * @param scale defines the scale factor
  79739. * @param result defines the Vector2 object where to store the result
  79740. * @returns the unmodified current Vector2
  79741. */
  79742. scaleToRef(scale: number, result: Vector2): Vector2;
  79743. /**
  79744. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79745. * @param scale defines the scale factor
  79746. * @param result defines the Vector2 object where to store the result
  79747. * @returns the unmodified current Vector2
  79748. */
  79749. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79750. /**
  79751. * Gets a boolean if two vectors are equals
  79752. * @param otherVector defines the other vector
  79753. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79754. */
  79755. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79756. /**
  79757. * Gets a boolean if two vectors are equals (using an epsilon value)
  79758. * @param otherVector defines the other vector
  79759. * @param epsilon defines the minimal distance to consider equality
  79760. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79761. */
  79762. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79763. /**
  79764. * Gets a new Vector2 from current Vector2 floored values
  79765. * @returns a new Vector2
  79766. */
  79767. floor(): Vector2;
  79768. /**
  79769. * Gets a new Vector2 from current Vector2 floored values
  79770. * @returns a new Vector2
  79771. */
  79772. fract(): Vector2;
  79773. /**
  79774. * Gets the length of the vector
  79775. * @returns the vector length (float)
  79776. */
  79777. length(): number;
  79778. /**
  79779. * Gets the vector squared length
  79780. * @returns the vector squared length (float)
  79781. */
  79782. lengthSquared(): number;
  79783. /**
  79784. * Normalize the vector
  79785. * @returns the current updated Vector2
  79786. */
  79787. normalize(): Vector2;
  79788. /**
  79789. * Gets a new Vector2 copied from the Vector2
  79790. * @returns a new Vector2
  79791. */
  79792. clone(): Vector2;
  79793. /**
  79794. * Gets a new Vector2(0, 0)
  79795. * @returns a new Vector2
  79796. */
  79797. static Zero(): Vector2;
  79798. /**
  79799. * Gets a new Vector2(1, 1)
  79800. * @returns a new Vector2
  79801. */
  79802. static One(): Vector2;
  79803. /**
  79804. * Gets a new Vector2 set from the given index element of the given array
  79805. * @param array defines the data source
  79806. * @param offset defines the offset in the data source
  79807. * @returns a new Vector2
  79808. */
  79809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79810. /**
  79811. * Sets "result" from the given index element of the given array
  79812. * @param array defines the data source
  79813. * @param offset defines the offset in the data source
  79814. * @param result defines the target vector
  79815. */
  79816. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79817. /**
  79818. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79819. * @param value1 defines 1st point of control
  79820. * @param value2 defines 2nd point of control
  79821. * @param value3 defines 3rd point of control
  79822. * @param value4 defines 4th point of control
  79823. * @param amount defines the interpolation factor
  79824. * @returns a new Vector2
  79825. */
  79826. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  79827. /**
  79828. * 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".
  79829. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  79830. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  79831. * @param value defines the value to clamp
  79832. * @param min defines the lower limit
  79833. * @param max defines the upper limit
  79834. * @returns a new Vector2
  79835. */
  79836. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  79837. /**
  79838. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  79839. * @param value1 defines the 1st control point
  79840. * @param tangent1 defines the outgoing tangent
  79841. * @param value2 defines the 2nd control point
  79842. * @param tangent2 defines the incoming tangent
  79843. * @param amount defines the interpolation factor
  79844. * @returns a new Vector2
  79845. */
  79846. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  79847. /**
  79848. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  79849. * @param start defines the start vector
  79850. * @param end defines the end vector
  79851. * @param amount defines the interpolation factor
  79852. * @returns a new Vector2
  79853. */
  79854. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  79855. /**
  79856. * Gets the dot product of the vector "left" and the vector "right"
  79857. * @param left defines first vector
  79858. * @param right defines second vector
  79859. * @returns the dot product (float)
  79860. */
  79861. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  79862. /**
  79863. * Returns a new Vector2 equal to the normalized given vector
  79864. * @param vector defines the vector to normalize
  79865. * @returns a new Vector2
  79866. */
  79867. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  79868. /**
  79869. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  79870. * @param left defines 1st vector
  79871. * @param right defines 2nd vector
  79872. * @returns a new Vector2
  79873. */
  79874. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79875. /**
  79876. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  79877. * @param left defines 1st vector
  79878. * @param right defines 2nd vector
  79879. * @returns a new Vector2
  79880. */
  79881. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  79882. /**
  79883. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  79884. * @param vector defines the vector to transform
  79885. * @param transformation defines the matrix to apply
  79886. * @returns a new Vector2
  79887. */
  79888. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  79889. /**
  79890. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  79891. * @param vector defines the vector to transform
  79892. * @param transformation defines the matrix to apply
  79893. * @param result defines the target vector
  79894. */
  79895. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  79896. /**
  79897. * Determines if a given vector is included in a triangle
  79898. * @param p defines the vector to test
  79899. * @param p0 defines 1st triangle point
  79900. * @param p1 defines 2nd triangle point
  79901. * @param p2 defines 3rd triangle point
  79902. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  79903. */
  79904. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  79905. /**
  79906. * Gets the distance between the vectors "value1" and "value2"
  79907. * @param value1 defines first vector
  79908. * @param value2 defines second vector
  79909. * @returns the distance between vectors
  79910. */
  79911. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79912. /**
  79913. * Returns the squared distance between the vectors "value1" and "value2"
  79914. * @param value1 defines first vector
  79915. * @param value2 defines second vector
  79916. * @returns the squared distance between vectors
  79917. */
  79918. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  79919. /**
  79920. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  79921. * @param value1 defines first vector
  79922. * @param value2 defines second vector
  79923. * @returns a new Vector2
  79924. */
  79925. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  79926. /**
  79927. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  79928. * @param p defines the middle point
  79929. * @param segA defines one point of the segment
  79930. * @param segB defines the other point of the segment
  79931. * @returns the shortest distance
  79932. */
  79933. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  79934. }
  79935. /**
  79936. * Class used to store (x,y,z) vector representation
  79937. * A Vector3 is the main object used in 3D geometry
  79938. * It can represent etiher the coordinates of a point the space, either a direction
  79939. * Reminder: js uses a left handed forward facing system
  79940. */
  79941. export class Vector3 {
  79942. /**
  79943. * Defines the first coordinates (on X axis)
  79944. */
  79945. x: number;
  79946. /**
  79947. * Defines the second coordinates (on Y axis)
  79948. */
  79949. y: number;
  79950. /**
  79951. * Defines the third coordinates (on Z axis)
  79952. */
  79953. z: number;
  79954. private static _UpReadOnly;
  79955. private static _ZeroReadOnly;
  79956. /**
  79957. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  79958. * @param x defines the first coordinates (on X axis)
  79959. * @param y defines the second coordinates (on Y axis)
  79960. * @param z defines the third coordinates (on Z axis)
  79961. */
  79962. constructor(
  79963. /**
  79964. * Defines the first coordinates (on X axis)
  79965. */
  79966. x?: number,
  79967. /**
  79968. * Defines the second coordinates (on Y axis)
  79969. */
  79970. y?: number,
  79971. /**
  79972. * Defines the third coordinates (on Z axis)
  79973. */
  79974. z?: number);
  79975. /**
  79976. * Creates a string representation of the Vector3
  79977. * @returns a string with the Vector3 coordinates.
  79978. */
  79979. toString(): string;
  79980. /**
  79981. * Gets the class name
  79982. * @returns the string "Vector3"
  79983. */
  79984. getClassName(): string;
  79985. /**
  79986. * Creates the Vector3 hash code
  79987. * @returns a number which tends to be unique between Vector3 instances
  79988. */
  79989. getHashCode(): number;
  79990. /**
  79991. * Creates an array containing three elements : the coordinates of the Vector3
  79992. * @returns a new array of numbers
  79993. */
  79994. asArray(): number[];
  79995. /**
  79996. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  79997. * @param array defines the destination array
  79998. * @param index defines the offset in the destination array
  79999. * @returns the current Vector3
  80000. */
  80001. toArray(array: FloatArray, index?: number): Vector3;
  80002. /**
  80003. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80004. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80005. */
  80006. toQuaternion(): Quaternion;
  80007. /**
  80008. * Adds the given vector to the current Vector3
  80009. * @param otherVector defines the second operand
  80010. * @returns the current updated Vector3
  80011. */
  80012. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80013. /**
  80014. * Adds the given coordinates to the current Vector3
  80015. * @param x defines the x coordinate of the operand
  80016. * @param y defines the y coordinate of the operand
  80017. * @param z defines the z coordinate of the operand
  80018. * @returns the current updated Vector3
  80019. */
  80020. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80021. /**
  80022. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80023. * @param otherVector defines the second operand
  80024. * @returns the resulting Vector3
  80025. */
  80026. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80027. /**
  80028. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80029. * @param otherVector defines the second operand
  80030. * @param result defines the Vector3 object where to store the result
  80031. * @returns the current Vector3
  80032. */
  80033. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80034. /**
  80035. * Subtract the given vector from the current Vector3
  80036. * @param otherVector defines the second operand
  80037. * @returns the current updated Vector3
  80038. */
  80039. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80040. /**
  80041. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80042. * @param otherVector defines the second operand
  80043. * @returns the resulting Vector3
  80044. */
  80045. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80046. /**
  80047. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80048. * @param otherVector defines the second operand
  80049. * @param result defines the Vector3 object where to store the result
  80050. * @returns the current Vector3
  80051. */
  80052. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80053. /**
  80054. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80055. * @param x defines the x coordinate of the operand
  80056. * @param y defines the y coordinate of the operand
  80057. * @param z defines the z coordinate of the operand
  80058. * @returns the resulting Vector3
  80059. */
  80060. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80061. /**
  80062. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80063. * @param x defines the x coordinate of the operand
  80064. * @param y defines the y coordinate of the operand
  80065. * @param z defines the z coordinate of the operand
  80066. * @param result defines the Vector3 object where to store the result
  80067. * @returns the current Vector3
  80068. */
  80069. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80070. /**
  80071. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80072. * @returns a new Vector3
  80073. */
  80074. negate(): Vector3;
  80075. /**
  80076. * Negate this vector in place
  80077. * @returns this
  80078. */
  80079. negateInPlace(): Vector3;
  80080. /**
  80081. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80082. * @param result defines the Vector3 object where to store the result
  80083. * @returns the current Vector3
  80084. */
  80085. negateToRef(result: Vector3): Vector3;
  80086. /**
  80087. * Multiplies the Vector3 coordinates by the float "scale"
  80088. * @param scale defines the multiplier factor
  80089. * @returns the current updated Vector3
  80090. */
  80091. scaleInPlace(scale: number): Vector3;
  80092. /**
  80093. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80094. * @param scale defines the multiplier factor
  80095. * @returns a new Vector3
  80096. */
  80097. scale(scale: number): Vector3;
  80098. /**
  80099. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80100. * @param scale defines the multiplier factor
  80101. * @param result defines the Vector3 object where to store the result
  80102. * @returns the current Vector3
  80103. */
  80104. scaleToRef(scale: number, result: Vector3): Vector3;
  80105. /**
  80106. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80107. * @param scale defines the scale factor
  80108. * @param result defines the Vector3 object where to store the result
  80109. * @returns the unmodified current Vector3
  80110. */
  80111. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80112. /**
  80113. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80114. * @param origin defines the origin of the projection ray
  80115. * @param plane defines the plane to project to
  80116. * @returns the projected vector3
  80117. */
  80118. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80119. /**
  80120. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80121. * @param origin defines the origin of the projection ray
  80122. * @param plane defines the plane to project to
  80123. * @param result defines the Vector3 where to store the result
  80124. */
  80125. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80126. /**
  80127. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80128. * @param otherVector defines the second operand
  80129. * @returns true if both vectors are equals
  80130. */
  80131. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80132. /**
  80133. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80134. * @param otherVector defines the second operand
  80135. * @param epsilon defines the minimal distance to define values as equals
  80136. * @returns true if both vectors are distant less than epsilon
  80137. */
  80138. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80139. /**
  80140. * Returns true if the current Vector3 coordinates equals the given floats
  80141. * @param x defines the x coordinate of the operand
  80142. * @param y defines the y coordinate of the operand
  80143. * @param z defines the z coordinate of the operand
  80144. * @returns true if both vectors are equals
  80145. */
  80146. equalsToFloats(x: number, y: number, z: number): boolean;
  80147. /**
  80148. * Multiplies the current Vector3 coordinates by the given ones
  80149. * @param otherVector defines the second operand
  80150. * @returns the current updated Vector3
  80151. */
  80152. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80153. /**
  80154. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80155. * @param otherVector defines the second operand
  80156. * @returns the new Vector3
  80157. */
  80158. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80159. /**
  80160. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80161. * @param otherVector defines the second operand
  80162. * @param result defines the Vector3 object where to store the result
  80163. * @returns the current Vector3
  80164. */
  80165. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80166. /**
  80167. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80168. * @param x defines the x coordinate of the operand
  80169. * @param y defines the y coordinate of the operand
  80170. * @param z defines the z coordinate of the operand
  80171. * @returns the new Vector3
  80172. */
  80173. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80174. /**
  80175. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80176. * @param otherVector defines the second operand
  80177. * @returns the new Vector3
  80178. */
  80179. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80180. /**
  80181. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80182. * @param otherVector defines the second operand
  80183. * @param result defines the Vector3 object where to store the result
  80184. * @returns the current Vector3
  80185. */
  80186. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80187. /**
  80188. * Divides the current Vector3 coordinates by the given ones.
  80189. * @param otherVector defines the second operand
  80190. * @returns the current updated Vector3
  80191. */
  80192. divideInPlace(otherVector: Vector3): Vector3;
  80193. /**
  80194. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80195. * @param other defines the second operand
  80196. * @returns the current updated Vector3
  80197. */
  80198. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80199. /**
  80200. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80201. * @param other defines the second operand
  80202. * @returns the current updated Vector3
  80203. */
  80204. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80205. /**
  80206. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80207. * @param x defines the x coordinate of the operand
  80208. * @param y defines the y coordinate of the operand
  80209. * @param z defines the z coordinate of the operand
  80210. * @returns the current updated Vector3
  80211. */
  80212. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80213. /**
  80214. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80215. * @param x defines the x coordinate of the operand
  80216. * @param y defines the y coordinate of the operand
  80217. * @param z defines the z coordinate of the operand
  80218. * @returns the current updated Vector3
  80219. */
  80220. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80221. /**
  80222. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80223. * Check if is non uniform within a certain amount of decimal places to account for this
  80224. * @param epsilon the amount the values can differ
  80225. * @returns if the the vector is non uniform to a certain number of decimal places
  80226. */
  80227. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80228. /**
  80229. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80230. */
  80231. get isNonUniform(): boolean;
  80232. /**
  80233. * Gets a new Vector3 from current Vector3 floored values
  80234. * @returns a new Vector3
  80235. */
  80236. floor(): Vector3;
  80237. /**
  80238. * Gets a new Vector3 from current Vector3 floored values
  80239. * @returns a new Vector3
  80240. */
  80241. fract(): Vector3;
  80242. /**
  80243. * Gets the length of the Vector3
  80244. * @returns the length of the Vector3
  80245. */
  80246. length(): number;
  80247. /**
  80248. * Gets the squared length of the Vector3
  80249. * @returns squared length of the Vector3
  80250. */
  80251. lengthSquared(): number;
  80252. /**
  80253. * Normalize the current Vector3.
  80254. * Please note that this is an in place operation.
  80255. * @returns the current updated Vector3
  80256. */
  80257. normalize(): Vector3;
  80258. /**
  80259. * Reorders the x y z properties of the vector in place
  80260. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80261. * @returns the current updated vector
  80262. */
  80263. reorderInPlace(order: string): this;
  80264. /**
  80265. * Rotates the vector around 0,0,0 by a quaternion
  80266. * @param quaternion the rotation quaternion
  80267. * @param result vector to store the result
  80268. * @returns the resulting vector
  80269. */
  80270. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80271. /**
  80272. * Rotates a vector around a given point
  80273. * @param quaternion the rotation quaternion
  80274. * @param point the point to rotate around
  80275. * @param result vector to store the result
  80276. * @returns the resulting vector
  80277. */
  80278. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80279. /**
  80280. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80281. * The cross product is then orthogonal to both current and "other"
  80282. * @param other defines the right operand
  80283. * @returns the cross product
  80284. */
  80285. cross(other: Vector3): Vector3;
  80286. /**
  80287. * Normalize the current Vector3 with the given input length.
  80288. * Please note that this is an in place operation.
  80289. * @param len the length of the vector
  80290. * @returns the current updated Vector3
  80291. */
  80292. normalizeFromLength(len: number): Vector3;
  80293. /**
  80294. * Normalize the current Vector3 to a new vector
  80295. * @returns the new Vector3
  80296. */
  80297. normalizeToNew(): Vector3;
  80298. /**
  80299. * Normalize the current Vector3 to the reference
  80300. * @param reference define the Vector3 to update
  80301. * @returns the updated Vector3
  80302. */
  80303. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  80304. /**
  80305. * Creates a new Vector3 copied from the current Vector3
  80306. * @returns the new Vector3
  80307. */
  80308. clone(): Vector3;
  80309. /**
  80310. * Copies the given vector coordinates to the current Vector3 ones
  80311. * @param source defines the source Vector3
  80312. * @returns the current updated Vector3
  80313. */
  80314. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80315. /**
  80316. * Copies the given floats to the current Vector3 coordinates
  80317. * @param x defines the x coordinate of the operand
  80318. * @param y defines the y coordinate of the operand
  80319. * @param z defines the z coordinate of the operand
  80320. * @returns the current updated Vector3
  80321. */
  80322. copyFromFloats(x: number, y: number, z: number): Vector3;
  80323. /**
  80324. * Copies the given floats to the current Vector3 coordinates
  80325. * @param x defines the x coordinate of the operand
  80326. * @param y defines the y coordinate of the operand
  80327. * @param z defines the z coordinate of the operand
  80328. * @returns the current updated Vector3
  80329. */
  80330. set(x: number, y: number, z: number): Vector3;
  80331. /**
  80332. * Copies the given float to the current Vector3 coordinates
  80333. * @param v defines the x, y and z coordinates of the operand
  80334. * @returns the current updated Vector3
  80335. */
  80336. setAll(v: number): Vector3;
  80337. /**
  80338. * Get the clip factor between two vectors
  80339. * @param vector0 defines the first operand
  80340. * @param vector1 defines the second operand
  80341. * @param axis defines the axis to use
  80342. * @param size defines the size along the axis
  80343. * @returns the clip factor
  80344. */
  80345. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80346. /**
  80347. * Get angle between two vectors
  80348. * @param vector0 angle between vector0 and vector1
  80349. * @param vector1 angle between vector0 and vector1
  80350. * @param normal direction of the normal
  80351. * @return the angle between vector0 and vector1
  80352. */
  80353. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80354. /**
  80355. * Returns a new Vector3 set from the index "offset" of the given array
  80356. * @param array defines the source array
  80357. * @param offset defines the offset in the source array
  80358. * @returns the new Vector3
  80359. */
  80360. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80361. /**
  80362. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80363. * @param array defines the source array
  80364. * @param offset defines the offset in the source array
  80365. * @returns the new Vector3
  80366. * @deprecated Please use FromArray instead.
  80367. */
  80368. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80369. /**
  80370. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80371. * @param array defines the source array
  80372. * @param offset defines the offset in the source array
  80373. * @param result defines the Vector3 where to store the result
  80374. */
  80375. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80376. /**
  80377. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80378. * @param array defines the source array
  80379. * @param offset defines the offset in the source array
  80380. * @param result defines the Vector3 where to store the result
  80381. * @deprecated Please use FromArrayToRef instead.
  80382. */
  80383. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80384. /**
  80385. * Sets the given vector "result" with the given floats.
  80386. * @param x defines the x coordinate of the source
  80387. * @param y defines the y coordinate of the source
  80388. * @param z defines the z coordinate of the source
  80389. * @param result defines the Vector3 where to store the result
  80390. */
  80391. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80392. /**
  80393. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80394. * @returns a new empty Vector3
  80395. */
  80396. static Zero(): Vector3;
  80397. /**
  80398. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80399. * @returns a new unit Vector3
  80400. */
  80401. static One(): Vector3;
  80402. /**
  80403. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80404. * @returns a new up Vector3
  80405. */
  80406. static Up(): Vector3;
  80407. /**
  80408. * Gets a up Vector3 that must not be updated
  80409. */
  80410. static get UpReadOnly(): DeepImmutable<Vector3>;
  80411. /**
  80412. * Gets a zero Vector3 that must not be updated
  80413. */
  80414. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80415. /**
  80416. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80417. * @returns a new down Vector3
  80418. */
  80419. static Down(): Vector3;
  80420. /**
  80421. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80422. * @param rightHandedSystem is the scene right-handed (negative z)
  80423. * @returns a new forward Vector3
  80424. */
  80425. static Forward(rightHandedSystem?: boolean): Vector3;
  80426. /**
  80427. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80428. * @param rightHandedSystem is the scene right-handed (negative-z)
  80429. * @returns a new forward Vector3
  80430. */
  80431. static Backward(rightHandedSystem?: boolean): Vector3;
  80432. /**
  80433. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80434. * @returns a new right Vector3
  80435. */
  80436. static Right(): Vector3;
  80437. /**
  80438. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80439. * @returns a new left Vector3
  80440. */
  80441. static Left(): Vector3;
  80442. /**
  80443. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80444. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80445. * @param vector defines the Vector3 to transform
  80446. * @param transformation defines the transformation matrix
  80447. * @returns the transformed Vector3
  80448. */
  80449. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80450. /**
  80451. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80452. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80453. * @param vector defines the Vector3 to transform
  80454. * @param transformation defines the transformation matrix
  80455. * @param result defines the Vector3 where to store the result
  80456. */
  80457. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80458. /**
  80459. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80460. * This method computes tranformed coordinates only, not transformed direction vectors
  80461. * @param x define the x coordinate of the source vector
  80462. * @param y define the y coordinate of the source vector
  80463. * @param z define the z coordinate of the source vector
  80464. * @param transformation defines the transformation matrix
  80465. * @param result defines the Vector3 where to store the result
  80466. */
  80467. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80468. /**
  80469. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80470. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80471. * @param vector defines the Vector3 to transform
  80472. * @param transformation defines the transformation matrix
  80473. * @returns the new Vector3
  80474. */
  80475. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80476. /**
  80477. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80478. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80479. * @param vector defines the Vector3 to transform
  80480. * @param transformation defines the transformation matrix
  80481. * @param result defines the Vector3 where to store the result
  80482. */
  80483. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80484. /**
  80485. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80486. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80487. * @param x define the x coordinate of the source vector
  80488. * @param y define the y coordinate of the source vector
  80489. * @param z define the z coordinate of the source vector
  80490. * @param transformation defines the transformation matrix
  80491. * @param result defines the Vector3 where to store the result
  80492. */
  80493. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80494. /**
  80495. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80496. * @param value1 defines the first control point
  80497. * @param value2 defines the second control point
  80498. * @param value3 defines the third control point
  80499. * @param value4 defines the fourth control point
  80500. * @param amount defines the amount on the spline to use
  80501. * @returns the new Vector3
  80502. */
  80503. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80504. /**
  80505. * 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"
  80506. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80507. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80508. * @param value defines the current value
  80509. * @param min defines the lower range value
  80510. * @param max defines the upper range value
  80511. * @returns the new Vector3
  80512. */
  80513. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80514. /**
  80515. * 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"
  80516. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80517. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80518. * @param value defines the current value
  80519. * @param min defines the lower range value
  80520. * @param max defines the upper range value
  80521. * @param result defines the Vector3 where to store the result
  80522. */
  80523. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80524. /**
  80525. * Checks if a given vector is inside a specific range
  80526. * @param v defines the vector to test
  80527. * @param min defines the minimum range
  80528. * @param max defines the maximum range
  80529. */
  80530. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80531. /**
  80532. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80533. * @param value1 defines the first control point
  80534. * @param tangent1 defines the first tangent vector
  80535. * @param value2 defines the second control point
  80536. * @param tangent2 defines the second tangent vector
  80537. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80538. * @returns the new Vector3
  80539. */
  80540. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80541. /**
  80542. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80543. * @param start defines the start value
  80544. * @param end defines the end value
  80545. * @param amount max defines amount between both (between 0 and 1)
  80546. * @returns the new Vector3
  80547. */
  80548. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80549. /**
  80550. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80551. * @param start defines the start value
  80552. * @param end defines the end value
  80553. * @param amount max defines amount between both (between 0 and 1)
  80554. * @param result defines the Vector3 where to store the result
  80555. */
  80556. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80557. /**
  80558. * Returns the dot product (float) between the vectors "left" and "right"
  80559. * @param left defines the left operand
  80560. * @param right defines the right operand
  80561. * @returns the dot product
  80562. */
  80563. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80564. /**
  80565. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80566. * The cross product is then orthogonal to both "left" and "right"
  80567. * @param left defines the left operand
  80568. * @param right defines the right operand
  80569. * @returns the cross product
  80570. */
  80571. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80572. /**
  80573. * Sets the given vector "result" with the cross product of "left" and "right"
  80574. * The cross product is then orthogonal to both "left" and "right"
  80575. * @param left defines the left operand
  80576. * @param right defines the right operand
  80577. * @param result defines the Vector3 where to store the result
  80578. */
  80579. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  80580. /**
  80581. * Returns a new Vector3 as the normalization of the given vector
  80582. * @param vector defines the Vector3 to normalize
  80583. * @returns the new Vector3
  80584. */
  80585. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80586. /**
  80587. * Sets the given vector "result" with the normalization of the given first vector
  80588. * @param vector defines the Vector3 to normalize
  80589. * @param result defines the Vector3 where to store the result
  80590. */
  80591. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80592. /**
  80593. * Project a Vector3 onto screen space
  80594. * @param vector defines the Vector3 to project
  80595. * @param world defines the world matrix to use
  80596. * @param transform defines the transform (view x projection) matrix to use
  80597. * @param viewport defines the screen viewport to use
  80598. * @returns the new Vector3
  80599. */
  80600. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80601. /** @hidden */
  80602. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80603. /**
  80604. * Unproject from screen space to object space
  80605. * @param source defines the screen space Vector3 to use
  80606. * @param viewportWidth defines the current width of the viewport
  80607. * @param viewportHeight defines the current height of the viewport
  80608. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80609. * @param transform defines the transform (view x projection) matrix to use
  80610. * @returns the new Vector3
  80611. */
  80612. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80613. /**
  80614. * Unproject from screen space to object space
  80615. * @param source defines the screen space Vector3 to use
  80616. * @param viewportWidth defines the current width of the viewport
  80617. * @param viewportHeight defines the current height of the viewport
  80618. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80619. * @param view defines the view matrix to use
  80620. * @param projection defines the projection matrix to use
  80621. * @returns the new Vector3
  80622. */
  80623. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80624. /**
  80625. * Unproject from screen space to object space
  80626. * @param source defines the screen space Vector3 to use
  80627. * @param viewportWidth defines the current width of the viewport
  80628. * @param viewportHeight defines the current height of the viewport
  80629. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80630. * @param view defines the view matrix to use
  80631. * @param projection defines the projection matrix to use
  80632. * @param result defines the Vector3 where to store the result
  80633. */
  80634. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80635. /**
  80636. * Unproject from screen space to object space
  80637. * @param sourceX defines the screen space x coordinate to use
  80638. * @param sourceY defines the screen space y coordinate to use
  80639. * @param sourceZ defines the screen space z coordinate to use
  80640. * @param viewportWidth defines the current width of the viewport
  80641. * @param viewportHeight defines the current height of the viewport
  80642. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80643. * @param view defines the view matrix to use
  80644. * @param projection defines the projection matrix to use
  80645. * @param result defines the Vector3 where to store the result
  80646. */
  80647. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80648. /**
  80649. * Gets the minimal coordinate values between two Vector3
  80650. * @param left defines the first operand
  80651. * @param right defines the second operand
  80652. * @returns the new Vector3
  80653. */
  80654. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80655. /**
  80656. * Gets the maximal coordinate values between two Vector3
  80657. * @param left defines the first operand
  80658. * @param right defines the second operand
  80659. * @returns the new Vector3
  80660. */
  80661. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80662. /**
  80663. * Returns the distance between the vectors "value1" and "value2"
  80664. * @param value1 defines the first operand
  80665. * @param value2 defines the second operand
  80666. * @returns the distance
  80667. */
  80668. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80669. /**
  80670. * Returns the squared distance between the vectors "value1" and "value2"
  80671. * @param value1 defines the first operand
  80672. * @param value2 defines the second operand
  80673. * @returns the squared distance
  80674. */
  80675. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80676. /**
  80677. * Returns a new Vector3 located at the center between "value1" and "value2"
  80678. * @param value1 defines the first operand
  80679. * @param value2 defines the second operand
  80680. * @returns the new Vector3
  80681. */
  80682. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80683. /**
  80684. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80685. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80686. * to something in order to rotate it from its local system to the given target system
  80687. * Note: axis1, axis2 and axis3 are normalized during this operation
  80688. * @param axis1 defines the first axis
  80689. * @param axis2 defines the second axis
  80690. * @param axis3 defines the third axis
  80691. * @returns a new Vector3
  80692. */
  80693. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80694. /**
  80695. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80696. * @param axis1 defines the first axis
  80697. * @param axis2 defines the second axis
  80698. * @param axis3 defines the third axis
  80699. * @param ref defines the Vector3 where to store the result
  80700. */
  80701. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80702. }
  80703. /**
  80704. * Vector4 class created for EulerAngle class conversion to Quaternion
  80705. */
  80706. export class Vector4 {
  80707. /** x value of the vector */
  80708. x: number;
  80709. /** y value of the vector */
  80710. y: number;
  80711. /** z value of the vector */
  80712. z: number;
  80713. /** w value of the vector */
  80714. w: number;
  80715. /**
  80716. * Creates a Vector4 object from the given floats.
  80717. * @param x x value of the vector
  80718. * @param y y value of the vector
  80719. * @param z z value of the vector
  80720. * @param w w value of the vector
  80721. */
  80722. constructor(
  80723. /** x value of the vector */
  80724. x: number,
  80725. /** y value of the vector */
  80726. y: number,
  80727. /** z value of the vector */
  80728. z: number,
  80729. /** w value of the vector */
  80730. w: number);
  80731. /**
  80732. * Returns the string with the Vector4 coordinates.
  80733. * @returns a string containing all the vector values
  80734. */
  80735. toString(): string;
  80736. /**
  80737. * Returns the string "Vector4".
  80738. * @returns "Vector4"
  80739. */
  80740. getClassName(): string;
  80741. /**
  80742. * Returns the Vector4 hash code.
  80743. * @returns a unique hash code
  80744. */
  80745. getHashCode(): number;
  80746. /**
  80747. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80748. * @returns the resulting array
  80749. */
  80750. asArray(): number[];
  80751. /**
  80752. * Populates the given array from the given index with the Vector4 coordinates.
  80753. * @param array array to populate
  80754. * @param index index of the array to start at (default: 0)
  80755. * @returns the Vector4.
  80756. */
  80757. toArray(array: FloatArray, index?: number): Vector4;
  80758. /**
  80759. * Adds the given vector to the current Vector4.
  80760. * @param otherVector the vector to add
  80761. * @returns the updated Vector4.
  80762. */
  80763. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80764. /**
  80765. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80766. * @param otherVector the vector to add
  80767. * @returns the resulting vector
  80768. */
  80769. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80770. /**
  80771. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80772. * @param otherVector the vector to add
  80773. * @param result the vector to store the result
  80774. * @returns the current Vector4.
  80775. */
  80776. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80777. /**
  80778. * Subtract in place the given vector from the current Vector4.
  80779. * @param otherVector the vector to subtract
  80780. * @returns the updated Vector4.
  80781. */
  80782. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80783. /**
  80784. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80785. * @param otherVector the vector to add
  80786. * @returns the new vector with the result
  80787. */
  80788. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80789. /**
  80790. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80791. * @param otherVector the vector to subtract
  80792. * @param result the vector to store the result
  80793. * @returns the current Vector4.
  80794. */
  80795. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80796. /**
  80797. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80798. */
  80799. /**
  80800. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80801. * @param x value to subtract
  80802. * @param y value to subtract
  80803. * @param z value to subtract
  80804. * @param w value to subtract
  80805. * @returns new vector containing the result
  80806. */
  80807. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80808. /**
  80809. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80810. * @param x value to subtract
  80811. * @param y value to subtract
  80812. * @param z value to subtract
  80813. * @param w value to subtract
  80814. * @param result the vector to store the result in
  80815. * @returns the current Vector4.
  80816. */
  80817. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80818. /**
  80819. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80820. * @returns a new vector with the negated values
  80821. */
  80822. negate(): Vector4;
  80823. /**
  80824. * Negate this vector in place
  80825. * @returns this
  80826. */
  80827. negateInPlace(): Vector4;
  80828. /**
  80829. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80830. * @param result defines the Vector3 object where to store the result
  80831. * @returns the current Vector4
  80832. */
  80833. negateToRef(result: Vector4): Vector4;
  80834. /**
  80835. * Multiplies the current Vector4 coordinates by scale (float).
  80836. * @param scale the number to scale with
  80837. * @returns the updated Vector4.
  80838. */
  80839. scaleInPlace(scale: number): Vector4;
  80840. /**
  80841. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  80842. * @param scale the number to scale with
  80843. * @returns a new vector with the result
  80844. */
  80845. scale(scale: number): Vector4;
  80846. /**
  80847. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  80848. * @param scale the number to scale with
  80849. * @param result a vector to store the result in
  80850. * @returns the current Vector4.
  80851. */
  80852. scaleToRef(scale: number, result: Vector4): Vector4;
  80853. /**
  80854. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  80855. * @param scale defines the scale factor
  80856. * @param result defines the Vector4 object where to store the result
  80857. * @returns the unmodified current Vector4
  80858. */
  80859. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  80860. /**
  80861. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  80862. * @param otherVector the vector to compare against
  80863. * @returns true if they are equal
  80864. */
  80865. equals(otherVector: DeepImmutable<Vector4>): boolean;
  80866. /**
  80867. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  80868. * @param otherVector vector to compare against
  80869. * @param epsilon (Default: very small number)
  80870. * @returns true if they are equal
  80871. */
  80872. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  80873. /**
  80874. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  80875. * @param x x value to compare against
  80876. * @param y y value to compare against
  80877. * @param z z value to compare against
  80878. * @param w w value to compare against
  80879. * @returns true if equal
  80880. */
  80881. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  80882. /**
  80883. * Multiplies in place the current Vector4 by the given one.
  80884. * @param otherVector vector to multiple with
  80885. * @returns the updated Vector4.
  80886. */
  80887. multiplyInPlace(otherVector: Vector4): Vector4;
  80888. /**
  80889. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  80890. * @param otherVector vector to multiple with
  80891. * @returns resulting new vector
  80892. */
  80893. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  80894. /**
  80895. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  80896. * @param otherVector vector to multiple with
  80897. * @param result vector to store the result
  80898. * @returns the current Vector4.
  80899. */
  80900. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80901. /**
  80902. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  80903. * @param x x value multiply with
  80904. * @param y y value multiply with
  80905. * @param z z value multiply with
  80906. * @param w w value multiply with
  80907. * @returns resulting new vector
  80908. */
  80909. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  80910. /**
  80911. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  80912. * @param otherVector vector to devide with
  80913. * @returns resulting new vector
  80914. */
  80915. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  80916. /**
  80917. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  80918. * @param otherVector vector to devide with
  80919. * @param result vector to store the result
  80920. * @returns the current Vector4.
  80921. */
  80922. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80923. /**
  80924. * Divides the current Vector3 coordinates by the given ones.
  80925. * @param otherVector vector to devide with
  80926. * @returns the updated Vector3.
  80927. */
  80928. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80929. /**
  80930. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  80931. * @param other defines the second operand
  80932. * @returns the current updated Vector4
  80933. */
  80934. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80935. /**
  80936. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  80937. * @param other defines the second operand
  80938. * @returns the current updated Vector4
  80939. */
  80940. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  80941. /**
  80942. * Gets a new Vector4 from current Vector4 floored values
  80943. * @returns a new Vector4
  80944. */
  80945. floor(): Vector4;
  80946. /**
  80947. * Gets a new Vector4 from current Vector3 floored values
  80948. * @returns a new Vector4
  80949. */
  80950. fract(): Vector4;
  80951. /**
  80952. * Returns the Vector4 length (float).
  80953. * @returns the length
  80954. */
  80955. length(): number;
  80956. /**
  80957. * Returns the Vector4 squared length (float).
  80958. * @returns the length squared
  80959. */
  80960. lengthSquared(): number;
  80961. /**
  80962. * Normalizes in place the Vector4.
  80963. * @returns the updated Vector4.
  80964. */
  80965. normalize(): Vector4;
  80966. /**
  80967. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  80968. * @returns this converted to a new vector3
  80969. */
  80970. toVector3(): Vector3;
  80971. /**
  80972. * Returns a new Vector4 copied from the current one.
  80973. * @returns the new cloned vector
  80974. */
  80975. clone(): Vector4;
  80976. /**
  80977. * Updates the current Vector4 with the given one coordinates.
  80978. * @param source the source vector to copy from
  80979. * @returns the updated Vector4.
  80980. */
  80981. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  80982. /**
  80983. * Updates the current Vector4 coordinates with the given floats.
  80984. * @param x float to copy from
  80985. * @param y float to copy from
  80986. * @param z float to copy from
  80987. * @param w float to copy from
  80988. * @returns the updated Vector4.
  80989. */
  80990. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80991. /**
  80992. * Updates the current Vector4 coordinates with the given floats.
  80993. * @param x float to set from
  80994. * @param y float to set from
  80995. * @param z float to set from
  80996. * @param w float to set from
  80997. * @returns the updated Vector4.
  80998. */
  80999. set(x: number, y: number, z: number, w: number): Vector4;
  81000. /**
  81001. * Copies the given float to the current Vector3 coordinates
  81002. * @param v defines the x, y, z and w coordinates of the operand
  81003. * @returns the current updated Vector3
  81004. */
  81005. setAll(v: number): Vector4;
  81006. /**
  81007. * Returns a new Vector4 set from the starting index of the given array.
  81008. * @param array the array to pull values from
  81009. * @param offset the offset into the array to start at
  81010. * @returns the new vector
  81011. */
  81012. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81013. /**
  81014. * Updates the given vector "result" from the starting index of the given array.
  81015. * @param array the array to pull values from
  81016. * @param offset the offset into the array to start at
  81017. * @param result the vector to store the result in
  81018. */
  81019. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81020. /**
  81021. * Updates the given vector "result" from the starting index of the given Float32Array.
  81022. * @param array the array to pull values from
  81023. * @param offset the offset into the array to start at
  81024. * @param result the vector to store the result in
  81025. */
  81026. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81027. /**
  81028. * Updates the given vector "result" coordinates from the given floats.
  81029. * @param x float to set from
  81030. * @param y float to set from
  81031. * @param z float to set from
  81032. * @param w float to set from
  81033. * @param result the vector to the floats in
  81034. */
  81035. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81036. /**
  81037. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81038. * @returns the new vector
  81039. */
  81040. static Zero(): Vector4;
  81041. /**
  81042. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81043. * @returns the new vector
  81044. */
  81045. static One(): Vector4;
  81046. /**
  81047. * Returns a new normalized Vector4 from the given one.
  81048. * @param vector the vector to normalize
  81049. * @returns the vector
  81050. */
  81051. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81052. /**
  81053. * Updates the given vector "result" from the normalization of the given one.
  81054. * @param vector the vector to normalize
  81055. * @param result the vector to store the result in
  81056. */
  81057. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81058. /**
  81059. * Returns a vector with the minimum values from the left and right vectors
  81060. * @param left left vector to minimize
  81061. * @param right right vector to minimize
  81062. * @returns a new vector with the minimum of the left and right vector values
  81063. */
  81064. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81065. /**
  81066. * Returns a vector with the maximum values from the left and right vectors
  81067. * @param left left vector to maximize
  81068. * @param right right vector to maximize
  81069. * @returns a new vector with the maximum of the left and right vector values
  81070. */
  81071. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81072. /**
  81073. * Returns the distance (float) between the vectors "value1" and "value2".
  81074. * @param value1 value to calulate the distance between
  81075. * @param value2 value to calulate the distance between
  81076. * @return the distance between the two vectors
  81077. */
  81078. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81079. /**
  81080. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81081. * @param value1 value to calulate the distance between
  81082. * @param value2 value to calulate the distance between
  81083. * @return the distance between the two vectors squared
  81084. */
  81085. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81086. /**
  81087. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81088. * @param value1 value to calulate the center between
  81089. * @param value2 value to calulate the center between
  81090. * @return the center between the two vectors
  81091. */
  81092. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81093. /**
  81094. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81095. * This methods computes transformed normalized direction vectors only.
  81096. * @param vector the vector to transform
  81097. * @param transformation the transformation matrix to apply
  81098. * @returns the new vector
  81099. */
  81100. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81101. /**
  81102. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81103. * This methods computes transformed normalized direction vectors only.
  81104. * @param vector the vector to transform
  81105. * @param transformation the transformation matrix to apply
  81106. * @param result the vector to store the result in
  81107. */
  81108. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81109. /**
  81110. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81111. * This methods computes transformed normalized direction vectors only.
  81112. * @param x value to transform
  81113. * @param y value to transform
  81114. * @param z value to transform
  81115. * @param w value to transform
  81116. * @param transformation the transformation matrix to apply
  81117. * @param result the vector to store the results in
  81118. */
  81119. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81120. /**
  81121. * Creates a new Vector4 from a Vector3
  81122. * @param source defines the source data
  81123. * @param w defines the 4th component (default is 0)
  81124. * @returns a new Vector4
  81125. */
  81126. static FromVector3(source: Vector3, w?: number): Vector4;
  81127. }
  81128. /**
  81129. * Class used to store quaternion data
  81130. * @see https://en.wikipedia.org/wiki/Quaternion
  81131. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  81132. */
  81133. export class Quaternion {
  81134. /** defines the first component (0 by default) */
  81135. x: number;
  81136. /** defines the second component (0 by default) */
  81137. y: number;
  81138. /** defines the third component (0 by default) */
  81139. z: number;
  81140. /** defines the fourth component (1.0 by default) */
  81141. w: number;
  81142. /**
  81143. * Creates a new Quaternion from the given floats
  81144. * @param x defines the first component (0 by default)
  81145. * @param y defines the second component (0 by default)
  81146. * @param z defines the third component (0 by default)
  81147. * @param w defines the fourth component (1.0 by default)
  81148. */
  81149. constructor(
  81150. /** defines the first component (0 by default) */
  81151. x?: number,
  81152. /** defines the second component (0 by default) */
  81153. y?: number,
  81154. /** defines the third component (0 by default) */
  81155. z?: number,
  81156. /** defines the fourth component (1.0 by default) */
  81157. w?: number);
  81158. /**
  81159. * Gets a string representation for the current quaternion
  81160. * @returns a string with the Quaternion coordinates
  81161. */
  81162. toString(): string;
  81163. /**
  81164. * Gets the class name of the quaternion
  81165. * @returns the string "Quaternion"
  81166. */
  81167. getClassName(): string;
  81168. /**
  81169. * Gets a hash code for this quaternion
  81170. * @returns the quaternion hash code
  81171. */
  81172. getHashCode(): number;
  81173. /**
  81174. * Copy the quaternion to an array
  81175. * @returns a new array populated with 4 elements from the quaternion coordinates
  81176. */
  81177. asArray(): number[];
  81178. /**
  81179. * Check if two quaternions are equals
  81180. * @param otherQuaternion defines the second operand
  81181. * @return true if the current quaternion and the given one coordinates are strictly equals
  81182. */
  81183. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81184. /**
  81185. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81186. * @param otherQuaternion defines the other quaternion
  81187. * @param epsilon defines the minimal distance to consider equality
  81188. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81189. */
  81190. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81191. /**
  81192. * Clone the current quaternion
  81193. * @returns a new quaternion copied from the current one
  81194. */
  81195. clone(): Quaternion;
  81196. /**
  81197. * Copy a quaternion to the current one
  81198. * @param other defines the other quaternion
  81199. * @returns the updated current quaternion
  81200. */
  81201. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81202. /**
  81203. * Updates the current quaternion with the given float coordinates
  81204. * @param x defines the x coordinate
  81205. * @param y defines the y coordinate
  81206. * @param z defines the z coordinate
  81207. * @param w defines the w coordinate
  81208. * @returns the updated current quaternion
  81209. */
  81210. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81211. /**
  81212. * Updates the current quaternion from the given float coordinates
  81213. * @param x defines the x coordinate
  81214. * @param y defines the y coordinate
  81215. * @param z defines the z coordinate
  81216. * @param w defines the w coordinate
  81217. * @returns the updated current quaternion
  81218. */
  81219. set(x: number, y: number, z: number, w: number): Quaternion;
  81220. /**
  81221. * Adds two quaternions
  81222. * @param other defines the second operand
  81223. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81224. */
  81225. add(other: DeepImmutable<Quaternion>): Quaternion;
  81226. /**
  81227. * Add a quaternion to the current one
  81228. * @param other defines the quaternion to add
  81229. * @returns the current quaternion
  81230. */
  81231. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81232. /**
  81233. * Subtract two quaternions
  81234. * @param other defines the second operand
  81235. * @returns a new quaternion as the subtraction result of the given one from the current one
  81236. */
  81237. subtract(other: Quaternion): Quaternion;
  81238. /**
  81239. * Multiplies the current quaternion by a scale factor
  81240. * @param value defines the scale factor
  81241. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81242. */
  81243. scale(value: number): Quaternion;
  81244. /**
  81245. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81246. * @param scale defines the scale factor
  81247. * @param result defines the Quaternion object where to store the result
  81248. * @returns the unmodified current quaternion
  81249. */
  81250. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81251. /**
  81252. * Multiplies in place the current quaternion by a scale factor
  81253. * @param value defines the scale factor
  81254. * @returns the current modified quaternion
  81255. */
  81256. scaleInPlace(value: number): Quaternion;
  81257. /**
  81258. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81259. * @param scale defines the scale factor
  81260. * @param result defines the Quaternion object where to store the result
  81261. * @returns the unmodified current quaternion
  81262. */
  81263. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81264. /**
  81265. * Multiplies two quaternions
  81266. * @param q1 defines the second operand
  81267. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81268. */
  81269. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81270. /**
  81271. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81272. * @param q1 defines the second operand
  81273. * @param result defines the target quaternion
  81274. * @returns the current quaternion
  81275. */
  81276. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81277. /**
  81278. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81279. * @param q1 defines the second operand
  81280. * @returns the currentupdated quaternion
  81281. */
  81282. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81283. /**
  81284. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81285. * @param ref defines the target quaternion
  81286. * @returns the current quaternion
  81287. */
  81288. conjugateToRef(ref: Quaternion): Quaternion;
  81289. /**
  81290. * Conjugates in place (1-q) the current quaternion
  81291. * @returns the current updated quaternion
  81292. */
  81293. conjugateInPlace(): Quaternion;
  81294. /**
  81295. * Conjugates in place (1-q) the current quaternion
  81296. * @returns a new quaternion
  81297. */
  81298. conjugate(): Quaternion;
  81299. /**
  81300. * Gets length of current quaternion
  81301. * @returns the quaternion length (float)
  81302. */
  81303. length(): number;
  81304. /**
  81305. * Normalize in place the current quaternion
  81306. * @returns the current updated quaternion
  81307. */
  81308. normalize(): Quaternion;
  81309. /**
  81310. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81311. * @param order is a reserved parameter and is ignore for now
  81312. * @returns a new Vector3 containing the Euler angles
  81313. */
  81314. toEulerAngles(order?: string): Vector3;
  81315. /**
  81316. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81317. * @param result defines the vector which will be filled with the Euler angles
  81318. * @param order is a reserved parameter and is ignore for now
  81319. * @returns the current unchanged quaternion
  81320. */
  81321. toEulerAnglesToRef(result: Vector3): Quaternion;
  81322. /**
  81323. * Updates the given rotation matrix with the current quaternion values
  81324. * @param result defines the target matrix
  81325. * @returns the current unchanged quaternion
  81326. */
  81327. toRotationMatrix(result: Matrix): Quaternion;
  81328. /**
  81329. * Updates the current quaternion from the given rotation matrix values
  81330. * @param matrix defines the source matrix
  81331. * @returns the current updated quaternion
  81332. */
  81333. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81334. /**
  81335. * Creates a new quaternion from a rotation matrix
  81336. * @param matrix defines the source matrix
  81337. * @returns a new quaternion created from the given rotation matrix values
  81338. */
  81339. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81340. /**
  81341. * Updates the given quaternion with the given rotation matrix values
  81342. * @param matrix defines the source matrix
  81343. * @param result defines the target quaternion
  81344. */
  81345. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81346. /**
  81347. * Returns the dot product (float) between the quaternions "left" and "right"
  81348. * @param left defines the left operand
  81349. * @param right defines the right operand
  81350. * @returns the dot product
  81351. */
  81352. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81353. /**
  81354. * Checks if the two quaternions are close to each other
  81355. * @param quat0 defines the first quaternion to check
  81356. * @param quat1 defines the second quaternion to check
  81357. * @returns true if the two quaternions are close to each other
  81358. */
  81359. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81360. /**
  81361. * Creates an empty quaternion
  81362. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81363. */
  81364. static Zero(): Quaternion;
  81365. /**
  81366. * Inverse a given quaternion
  81367. * @param q defines the source quaternion
  81368. * @returns a new quaternion as the inverted current quaternion
  81369. */
  81370. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81371. /**
  81372. * Inverse a given quaternion
  81373. * @param q defines the source quaternion
  81374. * @param result the quaternion the result will be stored in
  81375. * @returns the result quaternion
  81376. */
  81377. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81378. /**
  81379. * Creates an identity quaternion
  81380. * @returns the identity quaternion
  81381. */
  81382. static Identity(): Quaternion;
  81383. /**
  81384. * Gets a boolean indicating if the given quaternion is identity
  81385. * @param quaternion defines the quaternion to check
  81386. * @returns true if the quaternion is identity
  81387. */
  81388. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81389. /**
  81390. * Creates a quaternion from a rotation around an axis
  81391. * @param axis defines the axis to use
  81392. * @param angle defines the angle to use
  81393. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81394. */
  81395. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81396. /**
  81397. * Creates a rotation around an axis and stores it into the given quaternion
  81398. * @param axis defines the axis to use
  81399. * @param angle defines the angle to use
  81400. * @param result defines the target quaternion
  81401. * @returns the target quaternion
  81402. */
  81403. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81404. /**
  81405. * Creates a new quaternion from data stored into an array
  81406. * @param array defines the data source
  81407. * @param offset defines the offset in the source array where the data starts
  81408. * @returns a new quaternion
  81409. */
  81410. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81411. /**
  81412. * Updates the given quaternion "result" from the starting index of the given array.
  81413. * @param array the array to pull values from
  81414. * @param offset the offset into the array to start at
  81415. * @param result the quaternion to store the result in
  81416. */
  81417. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81418. /**
  81419. * Create a quaternion from Euler rotation angles
  81420. * @param x Pitch
  81421. * @param y Yaw
  81422. * @param z Roll
  81423. * @returns the new Quaternion
  81424. */
  81425. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81426. /**
  81427. * Updates a quaternion from Euler rotation angles
  81428. * @param x Pitch
  81429. * @param y Yaw
  81430. * @param z Roll
  81431. * @param result the quaternion to store the result
  81432. * @returns the updated quaternion
  81433. */
  81434. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81435. /**
  81436. * Create a quaternion from Euler rotation vector
  81437. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81438. * @returns the new Quaternion
  81439. */
  81440. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81441. /**
  81442. * Updates a quaternion from Euler rotation vector
  81443. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81444. * @param result the quaternion to store the result
  81445. * @returns the updated quaternion
  81446. */
  81447. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81448. /**
  81449. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81450. * @param yaw defines the rotation around Y axis
  81451. * @param pitch defines the rotation around X axis
  81452. * @param roll defines the rotation around Z axis
  81453. * @returns the new quaternion
  81454. */
  81455. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81456. /**
  81457. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81458. * @param yaw defines the rotation around Y axis
  81459. * @param pitch defines the rotation around X axis
  81460. * @param roll defines the rotation around Z axis
  81461. * @param result defines the target quaternion
  81462. */
  81463. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81464. /**
  81465. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81466. * @param alpha defines the rotation around first axis
  81467. * @param beta defines the rotation around second axis
  81468. * @param gamma defines the rotation around third axis
  81469. * @returns the new quaternion
  81470. */
  81471. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81472. /**
  81473. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81474. * @param alpha defines the rotation around first axis
  81475. * @param beta defines the rotation around second axis
  81476. * @param gamma defines the rotation around third axis
  81477. * @param result defines the target quaternion
  81478. */
  81479. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81480. /**
  81481. * 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)
  81482. * @param axis1 defines the first axis
  81483. * @param axis2 defines the second axis
  81484. * @param axis3 defines the third axis
  81485. * @returns the new quaternion
  81486. */
  81487. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81488. /**
  81489. * 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
  81490. * @param axis1 defines the first axis
  81491. * @param axis2 defines the second axis
  81492. * @param axis3 defines the third axis
  81493. * @param ref defines the target quaternion
  81494. */
  81495. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81496. /**
  81497. * Interpolates between two quaternions
  81498. * @param left defines first quaternion
  81499. * @param right defines second quaternion
  81500. * @param amount defines the gradient to use
  81501. * @returns the new interpolated quaternion
  81502. */
  81503. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81504. /**
  81505. * Interpolates between two quaternions and stores it into a target quaternion
  81506. * @param left defines first quaternion
  81507. * @param right defines second quaternion
  81508. * @param amount defines the gradient to use
  81509. * @param result defines the target quaternion
  81510. */
  81511. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81512. /**
  81513. * Interpolate between two quaternions using Hermite interpolation
  81514. * @param value1 defines first quaternion
  81515. * @param tangent1 defines the incoming tangent
  81516. * @param value2 defines second quaternion
  81517. * @param tangent2 defines the outgoing tangent
  81518. * @param amount defines the target quaternion
  81519. * @returns the new interpolated quaternion
  81520. */
  81521. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81522. }
  81523. /**
  81524. * Class used to store matrix data (4x4)
  81525. */
  81526. export class Matrix {
  81527. private static _updateFlagSeed;
  81528. private static _identityReadOnly;
  81529. private _isIdentity;
  81530. private _isIdentityDirty;
  81531. private _isIdentity3x2;
  81532. private _isIdentity3x2Dirty;
  81533. /**
  81534. * Gets the update flag of the matrix which is an unique number for the matrix.
  81535. * It will be incremented every time the matrix data change.
  81536. * You can use it to speed the comparison between two versions of the same matrix.
  81537. */
  81538. updateFlag: number;
  81539. private readonly _m;
  81540. /**
  81541. * Gets the internal data of the matrix
  81542. */
  81543. get m(): DeepImmutable<Float32Array>;
  81544. /** @hidden */
  81545. _markAsUpdated(): void;
  81546. /** @hidden */
  81547. private _updateIdentityStatus;
  81548. /**
  81549. * Creates an empty matrix (filled with zeros)
  81550. */
  81551. constructor();
  81552. /**
  81553. * Check if the current matrix is identity
  81554. * @returns true is the matrix is the identity matrix
  81555. */
  81556. isIdentity(): boolean;
  81557. /**
  81558. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81559. * @returns true is the matrix is the identity matrix
  81560. */
  81561. isIdentityAs3x2(): boolean;
  81562. /**
  81563. * Gets the determinant of the matrix
  81564. * @returns the matrix determinant
  81565. */
  81566. determinant(): number;
  81567. /**
  81568. * Returns the matrix as a Float32Array
  81569. * @returns the matrix underlying array
  81570. */
  81571. toArray(): DeepImmutable<Float32Array>;
  81572. /**
  81573. * Returns the matrix as a Float32Array
  81574. * @returns the matrix underlying array.
  81575. */
  81576. asArray(): DeepImmutable<Float32Array>;
  81577. /**
  81578. * Inverts the current matrix in place
  81579. * @returns the current inverted matrix
  81580. */
  81581. invert(): Matrix;
  81582. /**
  81583. * Sets all the matrix elements to zero
  81584. * @returns the current matrix
  81585. */
  81586. reset(): Matrix;
  81587. /**
  81588. * Adds the current matrix with a second one
  81589. * @param other defines the matrix to add
  81590. * @returns a new matrix as the addition of the current matrix and the given one
  81591. */
  81592. add(other: DeepImmutable<Matrix>): Matrix;
  81593. /**
  81594. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81595. * @param other defines the matrix to add
  81596. * @param result defines the target matrix
  81597. * @returns the current matrix
  81598. */
  81599. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81600. /**
  81601. * Adds in place the given matrix to the current matrix
  81602. * @param other defines the second operand
  81603. * @returns the current updated matrix
  81604. */
  81605. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81606. /**
  81607. * Sets the given matrix to the current inverted Matrix
  81608. * @param other defines the target matrix
  81609. * @returns the unmodified current matrix
  81610. */
  81611. invertToRef(other: Matrix): Matrix;
  81612. /**
  81613. * add a value at the specified position in the current Matrix
  81614. * @param index the index of the value within the matrix. between 0 and 15.
  81615. * @param value the value to be added
  81616. * @returns the current updated matrix
  81617. */
  81618. addAtIndex(index: number, value: number): Matrix;
  81619. /**
  81620. * mutiply the specified position in the current Matrix by a value
  81621. * @param index the index of the value within the matrix. between 0 and 15.
  81622. * @param value the value to be added
  81623. * @returns the current updated matrix
  81624. */
  81625. multiplyAtIndex(index: number, value: number): Matrix;
  81626. /**
  81627. * Inserts the translation vector (using 3 floats) in the current matrix
  81628. * @param x defines the 1st component of the translation
  81629. * @param y defines the 2nd component of the translation
  81630. * @param z defines the 3rd component of the translation
  81631. * @returns the current updated matrix
  81632. */
  81633. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81634. /**
  81635. * Adds the translation vector (using 3 floats) in the current matrix
  81636. * @param x defines the 1st component of the translation
  81637. * @param y defines the 2nd component of the translation
  81638. * @param z defines the 3rd component of the translation
  81639. * @returns the current updated matrix
  81640. */
  81641. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81642. /**
  81643. * Inserts the translation vector in the current matrix
  81644. * @param vector3 defines the translation to insert
  81645. * @returns the current updated matrix
  81646. */
  81647. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81648. /**
  81649. * Gets the translation value of the current matrix
  81650. * @returns a new Vector3 as the extracted translation from the matrix
  81651. */
  81652. getTranslation(): Vector3;
  81653. /**
  81654. * Fill a Vector3 with the extracted translation from the matrix
  81655. * @param result defines the Vector3 where to store the translation
  81656. * @returns the current matrix
  81657. */
  81658. getTranslationToRef(result: Vector3): Matrix;
  81659. /**
  81660. * Remove rotation and scaling part from the matrix
  81661. * @returns the updated matrix
  81662. */
  81663. removeRotationAndScaling(): Matrix;
  81664. /**
  81665. * Multiply two matrices
  81666. * @param other defines the second operand
  81667. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81668. */
  81669. multiply(other: DeepImmutable<Matrix>): Matrix;
  81670. /**
  81671. * Copy the current matrix from the given one
  81672. * @param other defines the source matrix
  81673. * @returns the current updated matrix
  81674. */
  81675. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81676. /**
  81677. * Populates the given array from the starting index with the current matrix values
  81678. * @param array defines the target array
  81679. * @param offset defines the offset in the target array where to start storing values
  81680. * @returns the current matrix
  81681. */
  81682. copyToArray(array: Float32Array, offset?: number): Matrix;
  81683. /**
  81684. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81685. * @param other defines the second operand
  81686. * @param result defines the matrix where to store the multiplication
  81687. * @returns the current matrix
  81688. */
  81689. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81690. /**
  81691. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81692. * @param other defines the second operand
  81693. * @param result defines the array where to store the multiplication
  81694. * @param offset defines the offset in the target array where to start storing values
  81695. * @returns the current matrix
  81696. */
  81697. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81698. /**
  81699. * Check equality between this matrix and a second one
  81700. * @param value defines the second matrix to compare
  81701. * @returns true is the current matrix and the given one values are strictly equal
  81702. */
  81703. equals(value: DeepImmutable<Matrix>): boolean;
  81704. /**
  81705. * Clone the current matrix
  81706. * @returns a new matrix from the current matrix
  81707. */
  81708. clone(): Matrix;
  81709. /**
  81710. * Returns the name of the current matrix class
  81711. * @returns the string "Matrix"
  81712. */
  81713. getClassName(): string;
  81714. /**
  81715. * Gets the hash code of the current matrix
  81716. * @returns the hash code
  81717. */
  81718. getHashCode(): number;
  81719. /**
  81720. * Decomposes the current Matrix into a translation, rotation and scaling components
  81721. * @param scale defines the scale vector3 given as a reference to update
  81722. * @param rotation defines the rotation quaternion given as a reference to update
  81723. * @param translation defines the translation vector3 given as a reference to update
  81724. * @returns true if operation was successful
  81725. */
  81726. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81727. /**
  81728. * Gets specific row of the matrix
  81729. * @param index defines the number of the row to get
  81730. * @returns the index-th row of the current matrix as a new Vector4
  81731. */
  81732. getRow(index: number): Nullable<Vector4>;
  81733. /**
  81734. * Sets the index-th row of the current matrix to the vector4 values
  81735. * @param index defines the number of the row to set
  81736. * @param row defines the target vector4
  81737. * @returns the updated current matrix
  81738. */
  81739. setRow(index: number, row: Vector4): Matrix;
  81740. /**
  81741. * Compute the transpose of the matrix
  81742. * @returns the new transposed matrix
  81743. */
  81744. transpose(): Matrix;
  81745. /**
  81746. * Compute the transpose of the matrix and store it in a given matrix
  81747. * @param result defines the target matrix
  81748. * @returns the current matrix
  81749. */
  81750. transposeToRef(result: Matrix): Matrix;
  81751. /**
  81752. * Sets the index-th row of the current matrix with the given 4 x float values
  81753. * @param index defines the row index
  81754. * @param x defines the x component to set
  81755. * @param y defines the y component to set
  81756. * @param z defines the z component to set
  81757. * @param w defines the w component to set
  81758. * @returns the updated current matrix
  81759. */
  81760. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81761. /**
  81762. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81763. * @param scale defines the scale factor
  81764. * @returns a new matrix
  81765. */
  81766. scale(scale: number): Matrix;
  81767. /**
  81768. * Scale the current matrix values by a factor to a given result matrix
  81769. * @param scale defines the scale factor
  81770. * @param result defines the matrix to store the result
  81771. * @returns the current matrix
  81772. */
  81773. scaleToRef(scale: number, result: Matrix): Matrix;
  81774. /**
  81775. * Scale the current matrix values by a factor and add the result to a given matrix
  81776. * @param scale defines the scale factor
  81777. * @param result defines the Matrix to store the result
  81778. * @returns the current matrix
  81779. */
  81780. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81781. /**
  81782. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81783. * @param ref matrix to store the result
  81784. */
  81785. toNormalMatrix(ref: Matrix): void;
  81786. /**
  81787. * Gets only rotation part of the current matrix
  81788. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81789. */
  81790. getRotationMatrix(): Matrix;
  81791. /**
  81792. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81793. * @param result defines the target matrix to store data to
  81794. * @returns the current matrix
  81795. */
  81796. getRotationMatrixToRef(result: Matrix): Matrix;
  81797. /**
  81798. * Toggles model matrix from being right handed to left handed in place and vice versa
  81799. */
  81800. toggleModelMatrixHandInPlace(): void;
  81801. /**
  81802. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81803. */
  81804. toggleProjectionMatrixHandInPlace(): void;
  81805. /**
  81806. * Creates a matrix from an array
  81807. * @param array defines the source array
  81808. * @param offset defines an offset in the source array
  81809. * @returns a new Matrix set from the starting index of the given array
  81810. */
  81811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81812. /**
  81813. * Copy the content of an array into a given matrix
  81814. * @param array defines the source array
  81815. * @param offset defines an offset in the source array
  81816. * @param result defines the target matrix
  81817. */
  81818. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81819. /**
  81820. * Stores an array into a matrix after having multiplied each component by a given factor
  81821. * @param array defines the source array
  81822. * @param offset defines the offset in the source array
  81823. * @param scale defines the scaling factor
  81824. * @param result defines the target matrix
  81825. */
  81826. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  81827. /**
  81828. * Gets an identity matrix that must not be updated
  81829. */
  81830. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  81831. /**
  81832. * Stores a list of values (16) inside a given matrix
  81833. * @param initialM11 defines 1st value of 1st row
  81834. * @param initialM12 defines 2nd value of 1st row
  81835. * @param initialM13 defines 3rd value of 1st row
  81836. * @param initialM14 defines 4th value of 1st row
  81837. * @param initialM21 defines 1st value of 2nd row
  81838. * @param initialM22 defines 2nd value of 2nd row
  81839. * @param initialM23 defines 3rd value of 2nd row
  81840. * @param initialM24 defines 4th value of 2nd row
  81841. * @param initialM31 defines 1st value of 3rd row
  81842. * @param initialM32 defines 2nd value of 3rd row
  81843. * @param initialM33 defines 3rd value of 3rd row
  81844. * @param initialM34 defines 4th value of 3rd row
  81845. * @param initialM41 defines 1st value of 4th row
  81846. * @param initialM42 defines 2nd value of 4th row
  81847. * @param initialM43 defines 3rd value of 4th row
  81848. * @param initialM44 defines 4th value of 4th row
  81849. * @param result defines the target matrix
  81850. */
  81851. 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;
  81852. /**
  81853. * Creates new matrix from a list of values (16)
  81854. * @param initialM11 defines 1st value of 1st row
  81855. * @param initialM12 defines 2nd value of 1st row
  81856. * @param initialM13 defines 3rd value of 1st row
  81857. * @param initialM14 defines 4th value of 1st row
  81858. * @param initialM21 defines 1st value of 2nd row
  81859. * @param initialM22 defines 2nd value of 2nd row
  81860. * @param initialM23 defines 3rd value of 2nd row
  81861. * @param initialM24 defines 4th value of 2nd row
  81862. * @param initialM31 defines 1st value of 3rd row
  81863. * @param initialM32 defines 2nd value of 3rd row
  81864. * @param initialM33 defines 3rd value of 3rd row
  81865. * @param initialM34 defines 4th value of 3rd row
  81866. * @param initialM41 defines 1st value of 4th row
  81867. * @param initialM42 defines 2nd value of 4th row
  81868. * @param initialM43 defines 3rd value of 4th row
  81869. * @param initialM44 defines 4th value of 4th row
  81870. * @returns the new matrix
  81871. */
  81872. 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;
  81873. /**
  81874. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81875. * @param scale defines the scale vector3
  81876. * @param rotation defines the rotation quaternion
  81877. * @param translation defines the translation vector3
  81878. * @returns a new matrix
  81879. */
  81880. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  81881. /**
  81882. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  81883. * @param scale defines the scale vector3
  81884. * @param rotation defines the rotation quaternion
  81885. * @param translation defines the translation vector3
  81886. * @param result defines the target matrix
  81887. */
  81888. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  81889. /**
  81890. * Creates a new identity matrix
  81891. * @returns a new identity matrix
  81892. */
  81893. static Identity(): Matrix;
  81894. /**
  81895. * Creates a new identity matrix and stores the result in a given matrix
  81896. * @param result defines the target matrix
  81897. */
  81898. static IdentityToRef(result: Matrix): void;
  81899. /**
  81900. * Creates a new zero matrix
  81901. * @returns a new zero matrix
  81902. */
  81903. static Zero(): Matrix;
  81904. /**
  81905. * Creates a new rotation matrix for "angle" radians around the X axis
  81906. * @param angle defines the angle (in radians) to use
  81907. * @return the new matrix
  81908. */
  81909. static RotationX(angle: number): Matrix;
  81910. /**
  81911. * Creates a new matrix as the invert of a given matrix
  81912. * @param source defines the source matrix
  81913. * @returns the new matrix
  81914. */
  81915. static Invert(source: DeepImmutable<Matrix>): Matrix;
  81916. /**
  81917. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  81918. * @param angle defines the angle (in radians) to use
  81919. * @param result defines the target matrix
  81920. */
  81921. static RotationXToRef(angle: number, result: Matrix): void;
  81922. /**
  81923. * Creates a new rotation matrix for "angle" radians around the Y axis
  81924. * @param angle defines the angle (in radians) to use
  81925. * @return the new matrix
  81926. */
  81927. static RotationY(angle: number): Matrix;
  81928. /**
  81929. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  81930. * @param angle defines the angle (in radians) to use
  81931. * @param result defines the target matrix
  81932. */
  81933. static RotationYToRef(angle: number, result: Matrix): void;
  81934. /**
  81935. * Creates a new rotation matrix for "angle" radians around the Z axis
  81936. * @param angle defines the angle (in radians) to use
  81937. * @return the new matrix
  81938. */
  81939. static RotationZ(angle: number): Matrix;
  81940. /**
  81941. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  81942. * @param angle defines the angle (in radians) to use
  81943. * @param result defines the target matrix
  81944. */
  81945. static RotationZToRef(angle: number, result: Matrix): void;
  81946. /**
  81947. * Creates a new rotation matrix for "angle" radians around the given axis
  81948. * @param axis defines the axis to use
  81949. * @param angle defines the angle (in radians) to use
  81950. * @return the new matrix
  81951. */
  81952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  81953. /**
  81954. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  81955. * @param axis defines the axis to use
  81956. * @param angle defines the angle (in radians) to use
  81957. * @param result defines the target matrix
  81958. */
  81959. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  81960. /**
  81961. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  81962. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  81963. * @param from defines the vector to align
  81964. * @param to defines the vector to align to
  81965. * @param result defines the target matrix
  81966. */
  81967. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  81968. /**
  81969. * Creates a rotation matrix
  81970. * @param yaw defines the yaw angle in radians (Y axis)
  81971. * @param pitch defines the pitch angle in radians (X axis)
  81972. * @param roll defines the roll angle in radians (X axis)
  81973. * @returns the new rotation matrix
  81974. */
  81975. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  81976. /**
  81977. * Creates a rotation matrix and stores it in a given matrix
  81978. * @param yaw defines the yaw angle in radians (Y axis)
  81979. * @param pitch defines the pitch angle in radians (X axis)
  81980. * @param roll defines the roll angle in radians (X axis)
  81981. * @param result defines the target matrix
  81982. */
  81983. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  81984. /**
  81985. * Creates a scaling matrix
  81986. * @param x defines the scale factor on X axis
  81987. * @param y defines the scale factor on Y axis
  81988. * @param z defines the scale factor on Z axis
  81989. * @returns the new matrix
  81990. */
  81991. static Scaling(x: number, y: number, z: number): Matrix;
  81992. /**
  81993. * Creates a scaling matrix and stores it in a given matrix
  81994. * @param x defines the scale factor on X axis
  81995. * @param y defines the scale factor on Y axis
  81996. * @param z defines the scale factor on Z axis
  81997. * @param result defines the target matrix
  81998. */
  81999. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82000. /**
  82001. * Creates a translation matrix
  82002. * @param x defines the translation on X axis
  82003. * @param y defines the translation on Y axis
  82004. * @param z defines the translationon Z axis
  82005. * @returns the new matrix
  82006. */
  82007. static Translation(x: number, y: number, z: number): Matrix;
  82008. /**
  82009. * Creates a translation matrix and stores it in a given matrix
  82010. * @param x defines the translation on X axis
  82011. * @param y defines the translation on Y axis
  82012. * @param z defines the translationon Z axis
  82013. * @param result defines the target matrix
  82014. */
  82015. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82016. /**
  82017. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82018. * @param startValue defines the start value
  82019. * @param endValue defines the end value
  82020. * @param gradient defines the gradient factor
  82021. * @returns the new matrix
  82022. */
  82023. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82024. /**
  82025. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82026. * @param startValue defines the start value
  82027. * @param endValue defines the end value
  82028. * @param gradient defines the gradient factor
  82029. * @param result defines the Matrix object where to store data
  82030. */
  82031. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82032. /**
  82033. * Builds a new matrix whose values are computed by:
  82034. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82035. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82036. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82037. * @param startValue defines the first matrix
  82038. * @param endValue defines the second matrix
  82039. * @param gradient defines the gradient between the two matrices
  82040. * @returns the new matrix
  82041. */
  82042. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82043. /**
  82044. * Update a matrix to values which are computed by:
  82045. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82046. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82047. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82048. * @param startValue defines the first matrix
  82049. * @param endValue defines the second matrix
  82050. * @param gradient defines the gradient between the two matrices
  82051. * @param result defines the target matrix
  82052. */
  82053. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82054. /**
  82055. * 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"
  82056. * This function works in left handed mode
  82057. * @param eye defines the final position of the entity
  82058. * @param target defines where the entity should look at
  82059. * @param up defines the up vector for the entity
  82060. * @returns the new matrix
  82061. */
  82062. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82063. /**
  82064. * 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".
  82065. * This function works in left handed mode
  82066. * @param eye defines the final position of the entity
  82067. * @param target defines where the entity should look at
  82068. * @param up defines the up vector for the entity
  82069. * @param result defines the target matrix
  82070. */
  82071. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82072. /**
  82073. * 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"
  82074. * This function works in right handed mode
  82075. * @param eye defines the final position of the entity
  82076. * @param target defines where the entity should look at
  82077. * @param up defines the up vector for the entity
  82078. * @returns the new matrix
  82079. */
  82080. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82081. /**
  82082. * 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".
  82083. * This function works in right handed mode
  82084. * @param eye defines the final position of the entity
  82085. * @param target defines where the entity should look at
  82086. * @param up defines the up vector for the entity
  82087. * @param result defines the target matrix
  82088. */
  82089. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82090. /**
  82091. * Create a left-handed orthographic projection matrix
  82092. * @param width defines the viewport width
  82093. * @param height defines the viewport height
  82094. * @param znear defines the near clip plane
  82095. * @param zfar defines the far clip plane
  82096. * @returns a new matrix as a left-handed orthographic projection matrix
  82097. */
  82098. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82099. /**
  82100. * Store a left-handed orthographic projection to a given matrix
  82101. * @param width defines the viewport width
  82102. * @param height defines the viewport height
  82103. * @param znear defines the near clip plane
  82104. * @param zfar defines the far clip plane
  82105. * @param result defines the target matrix
  82106. */
  82107. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82108. /**
  82109. * Create a left-handed orthographic projection matrix
  82110. * @param left defines the viewport left coordinate
  82111. * @param right defines the viewport right coordinate
  82112. * @param bottom defines the viewport bottom coordinate
  82113. * @param top defines the viewport top coordinate
  82114. * @param znear defines the near clip plane
  82115. * @param zfar defines the far clip plane
  82116. * @returns a new matrix as a left-handed orthographic projection matrix
  82117. */
  82118. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82119. /**
  82120. * Stores a left-handed orthographic projection into a given matrix
  82121. * @param left defines the viewport left coordinate
  82122. * @param right defines the viewport right coordinate
  82123. * @param bottom defines the viewport bottom coordinate
  82124. * @param top defines the viewport top coordinate
  82125. * @param znear defines the near clip plane
  82126. * @param zfar defines the far clip plane
  82127. * @param result defines the target matrix
  82128. */
  82129. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82130. /**
  82131. * Creates a right-handed orthographic projection matrix
  82132. * @param left defines the viewport left coordinate
  82133. * @param right defines the viewport right coordinate
  82134. * @param bottom defines the viewport bottom coordinate
  82135. * @param top defines the viewport top coordinate
  82136. * @param znear defines the near clip plane
  82137. * @param zfar defines the far clip plane
  82138. * @returns a new matrix as a right-handed orthographic projection matrix
  82139. */
  82140. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82141. /**
  82142. * Stores a right-handed orthographic projection into a given matrix
  82143. * @param left defines the viewport left coordinate
  82144. * @param right defines the viewport right coordinate
  82145. * @param bottom defines the viewport bottom coordinate
  82146. * @param top defines the viewport top coordinate
  82147. * @param znear defines the near clip plane
  82148. * @param zfar defines the far clip plane
  82149. * @param result defines the target matrix
  82150. */
  82151. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82152. /**
  82153. * Creates a left-handed perspective projection matrix
  82154. * @param width defines the viewport width
  82155. * @param height defines the viewport height
  82156. * @param znear defines the near clip plane
  82157. * @param zfar defines the far clip plane
  82158. * @returns a new matrix as a left-handed perspective projection matrix
  82159. */
  82160. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82161. /**
  82162. * Creates a left-handed perspective projection matrix
  82163. * @param fov defines the horizontal field of view
  82164. * @param aspect defines the aspect ratio
  82165. * @param znear defines the near clip plane
  82166. * @param zfar defines the far clip plane
  82167. * @returns a new matrix as a left-handed perspective projection matrix
  82168. */
  82169. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82170. /**
  82171. * Stores a left-handed perspective projection into a given matrix
  82172. * @param fov defines the horizontal field of view
  82173. * @param aspect defines the aspect ratio
  82174. * @param znear defines the near clip plane
  82175. * @param zfar defines the far clip plane
  82176. * @param result defines the target matrix
  82177. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82178. */
  82179. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82180. /**
  82181. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82182. * @param fov defines the horizontal field of view
  82183. * @param aspect defines the aspect ratio
  82184. * @param znear defines the near clip plane
  82185. * @param zfar not used as infinity is used as far clip
  82186. * @param result defines the target matrix
  82187. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82188. */
  82189. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82190. /**
  82191. * Creates a right-handed perspective projection matrix
  82192. * @param fov defines the horizontal field of view
  82193. * @param aspect defines the aspect ratio
  82194. * @param znear defines the near clip plane
  82195. * @param zfar defines the far clip plane
  82196. * @returns a new matrix as a right-handed perspective projection matrix
  82197. */
  82198. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82199. /**
  82200. * Stores a right-handed perspective projection into a given matrix
  82201. * @param fov defines the horizontal field of view
  82202. * @param aspect defines the aspect ratio
  82203. * @param znear defines the near clip plane
  82204. * @param zfar defines the far clip plane
  82205. * @param result defines the target matrix
  82206. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82207. */
  82208. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82209. /**
  82210. * Stores a right-handed perspective projection into a given matrix
  82211. * @param fov defines the horizontal field of view
  82212. * @param aspect defines the aspect ratio
  82213. * @param znear defines the near clip plane
  82214. * @param zfar not used as infinity is used as far clip
  82215. * @param result defines the target matrix
  82216. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82217. */
  82218. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82219. /**
  82220. * Stores a perspective projection for WebVR info a given matrix
  82221. * @param fov defines the field of view
  82222. * @param znear defines the near clip plane
  82223. * @param zfar defines the far clip plane
  82224. * @param result defines the target matrix
  82225. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82226. */
  82227. static PerspectiveFovWebVRToRef(fov: {
  82228. upDegrees: number;
  82229. downDegrees: number;
  82230. leftDegrees: number;
  82231. rightDegrees: number;
  82232. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82233. /**
  82234. * Computes a complete transformation matrix
  82235. * @param viewport defines the viewport to use
  82236. * @param world defines the world matrix
  82237. * @param view defines the view matrix
  82238. * @param projection defines the projection matrix
  82239. * @param zmin defines the near clip plane
  82240. * @param zmax defines the far clip plane
  82241. * @returns the transformation matrix
  82242. */
  82243. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82244. /**
  82245. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82246. * @param matrix defines the matrix to use
  82247. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82248. */
  82249. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82250. /**
  82251. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82252. * @param matrix defines the matrix to use
  82253. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82254. */
  82255. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82256. /**
  82257. * Compute the transpose of a given matrix
  82258. * @param matrix defines the matrix to transpose
  82259. * @returns the new matrix
  82260. */
  82261. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82262. /**
  82263. * Compute the transpose of a matrix and store it in a target matrix
  82264. * @param matrix defines the matrix to transpose
  82265. * @param result defines the target matrix
  82266. */
  82267. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82268. /**
  82269. * Computes a reflection matrix from a plane
  82270. * @param plane defines the reflection plane
  82271. * @returns a new matrix
  82272. */
  82273. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82274. /**
  82275. * Computes a reflection matrix from a plane
  82276. * @param plane defines the reflection plane
  82277. * @param result defines the target matrix
  82278. */
  82279. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82280. /**
  82281. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82282. * @param xaxis defines the value of the 1st axis
  82283. * @param yaxis defines the value of the 2nd axis
  82284. * @param zaxis defines the value of the 3rd axis
  82285. * @param result defines the target matrix
  82286. */
  82287. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82288. /**
  82289. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82290. * @param quat defines the quaternion to use
  82291. * @param result defines the target matrix
  82292. */
  82293. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82294. }
  82295. /**
  82296. * @hidden
  82297. */
  82298. export class TmpVectors {
  82299. static Vector2: Vector2[];
  82300. static Vector3: Vector3[];
  82301. static Vector4: Vector4[];
  82302. static Quaternion: Quaternion[];
  82303. static Matrix: Matrix[];
  82304. }
  82305. }
  82306. declare module BABYLON {
  82307. /**
  82308. * Defines potential orientation for back face culling
  82309. */
  82310. export enum Orientation {
  82311. /**
  82312. * Clockwise
  82313. */
  82314. CW = 0,
  82315. /** Counter clockwise */
  82316. CCW = 1
  82317. }
  82318. /** Class used to represent a Bezier curve */
  82319. export class BezierCurve {
  82320. /**
  82321. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82322. * @param t defines the time
  82323. * @param x1 defines the left coordinate on X axis
  82324. * @param y1 defines the left coordinate on Y axis
  82325. * @param x2 defines the right coordinate on X axis
  82326. * @param y2 defines the right coordinate on Y axis
  82327. * @returns the interpolated value
  82328. */
  82329. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82330. }
  82331. /**
  82332. * Defines angle representation
  82333. */
  82334. export class Angle {
  82335. private _radians;
  82336. /**
  82337. * Creates an Angle object of "radians" radians (float).
  82338. * @param radians the angle in radians
  82339. */
  82340. constructor(radians: number);
  82341. /**
  82342. * Get value in degrees
  82343. * @returns the Angle value in degrees (float)
  82344. */
  82345. degrees(): number;
  82346. /**
  82347. * Get value in radians
  82348. * @returns the Angle value in radians (float)
  82349. */
  82350. radians(): number;
  82351. /**
  82352. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82353. * @param a defines first vector
  82354. * @param b defines second vector
  82355. * @returns a new Angle
  82356. */
  82357. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82358. /**
  82359. * Gets a new Angle object from the given float in radians
  82360. * @param radians defines the angle value in radians
  82361. * @returns a new Angle
  82362. */
  82363. static FromRadians(radians: number): Angle;
  82364. /**
  82365. * Gets a new Angle object from the given float in degrees
  82366. * @param degrees defines the angle value in degrees
  82367. * @returns a new Angle
  82368. */
  82369. static FromDegrees(degrees: number): Angle;
  82370. }
  82371. /**
  82372. * This represents an arc in a 2d space.
  82373. */
  82374. export class Arc2 {
  82375. /** Defines the start point of the arc */
  82376. startPoint: Vector2;
  82377. /** Defines the mid point of the arc */
  82378. midPoint: Vector2;
  82379. /** Defines the end point of the arc */
  82380. endPoint: Vector2;
  82381. /**
  82382. * Defines the center point of the arc.
  82383. */
  82384. centerPoint: Vector2;
  82385. /**
  82386. * Defines the radius of the arc.
  82387. */
  82388. radius: number;
  82389. /**
  82390. * Defines the angle of the arc (from mid point to end point).
  82391. */
  82392. angle: Angle;
  82393. /**
  82394. * Defines the start angle of the arc (from start point to middle point).
  82395. */
  82396. startAngle: Angle;
  82397. /**
  82398. * Defines the orientation of the arc (clock wise/counter clock wise).
  82399. */
  82400. orientation: Orientation;
  82401. /**
  82402. * Creates an Arc object from the three given points : start, middle and end.
  82403. * @param startPoint Defines the start point of the arc
  82404. * @param midPoint Defines the midlle point of the arc
  82405. * @param endPoint Defines the end point of the arc
  82406. */
  82407. constructor(
  82408. /** Defines the start point of the arc */
  82409. startPoint: Vector2,
  82410. /** Defines the mid point of the arc */
  82411. midPoint: Vector2,
  82412. /** Defines the end point of the arc */
  82413. endPoint: Vector2);
  82414. }
  82415. /**
  82416. * Represents a 2D path made up of multiple 2D points
  82417. */
  82418. export class Path2 {
  82419. private _points;
  82420. private _length;
  82421. /**
  82422. * If the path start and end point are the same
  82423. */
  82424. closed: boolean;
  82425. /**
  82426. * Creates a Path2 object from the starting 2D coordinates x and y.
  82427. * @param x the starting points x value
  82428. * @param y the starting points y value
  82429. */
  82430. constructor(x: number, y: number);
  82431. /**
  82432. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82433. * @param x the added points x value
  82434. * @param y the added points y value
  82435. * @returns the updated Path2.
  82436. */
  82437. addLineTo(x: number, y: number): Path2;
  82438. /**
  82439. * 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.
  82440. * @param midX middle point x value
  82441. * @param midY middle point y value
  82442. * @param endX end point x value
  82443. * @param endY end point y value
  82444. * @param numberOfSegments (default: 36)
  82445. * @returns the updated Path2.
  82446. */
  82447. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82448. /**
  82449. * Closes the Path2.
  82450. * @returns the Path2.
  82451. */
  82452. close(): Path2;
  82453. /**
  82454. * Gets the sum of the distance between each sequential point in the path
  82455. * @returns the Path2 total length (float).
  82456. */
  82457. length(): number;
  82458. /**
  82459. * Gets the points which construct the path
  82460. * @returns the Path2 internal array of points.
  82461. */
  82462. getPoints(): Vector2[];
  82463. /**
  82464. * Retreives the point at the distance aways from the starting point
  82465. * @param normalizedLengthPosition the length along the path to retreive the point from
  82466. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82467. */
  82468. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82469. /**
  82470. * Creates a new path starting from an x and y position
  82471. * @param x starting x value
  82472. * @param y starting y value
  82473. * @returns a new Path2 starting at the coordinates (x, y).
  82474. */
  82475. static StartingAt(x: number, y: number): Path2;
  82476. }
  82477. /**
  82478. * Represents a 3D path made up of multiple 3D points
  82479. */
  82480. export class Path3D {
  82481. /**
  82482. * an array of Vector3, the curve axis of the Path3D
  82483. */
  82484. path: Vector3[];
  82485. private _curve;
  82486. private _distances;
  82487. private _tangents;
  82488. private _normals;
  82489. private _binormals;
  82490. private _raw;
  82491. private _alignTangentsWithPath;
  82492. private readonly _pointAtData;
  82493. /**
  82494. * new Path3D(path, normal, raw)
  82495. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82496. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82497. * @param path an array of Vector3, the curve axis of the Path3D
  82498. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82499. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82500. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82501. */
  82502. constructor(
  82503. /**
  82504. * an array of Vector3, the curve axis of the Path3D
  82505. */
  82506. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82507. /**
  82508. * Returns the Path3D array of successive Vector3 designing its curve.
  82509. * @returns the Path3D array of successive Vector3 designing its curve.
  82510. */
  82511. getCurve(): Vector3[];
  82512. /**
  82513. * Returns the Path3D array of successive Vector3 designing its curve.
  82514. * @returns the Path3D array of successive Vector3 designing its curve.
  82515. */
  82516. getPoints(): Vector3[];
  82517. /**
  82518. * @returns the computed length (float) of the path.
  82519. */
  82520. length(): number;
  82521. /**
  82522. * Returns an array populated with tangent vectors on each Path3D curve point.
  82523. * @returns an array populated with tangent vectors on each Path3D curve point.
  82524. */
  82525. getTangents(): Vector3[];
  82526. /**
  82527. * Returns an array populated with normal vectors on each Path3D curve point.
  82528. * @returns an array populated with normal vectors on each Path3D curve point.
  82529. */
  82530. getNormals(): Vector3[];
  82531. /**
  82532. * Returns an array populated with binormal vectors on each Path3D curve point.
  82533. * @returns an array populated with binormal vectors on each Path3D curve point.
  82534. */
  82535. getBinormals(): Vector3[];
  82536. /**
  82537. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82538. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82539. */
  82540. getDistances(): number[];
  82541. /**
  82542. * Returns an interpolated point along this path
  82543. * @param position the position of the point along this path, from 0.0 to 1.0
  82544. * @returns a new Vector3 as the point
  82545. */
  82546. getPointAt(position: number): Vector3;
  82547. /**
  82548. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82549. * @param position the position of the point along this path, from 0.0 to 1.0
  82550. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82551. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82552. */
  82553. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82554. /**
  82555. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82556. * @param position the position of the point along this path, from 0.0 to 1.0
  82557. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82558. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82559. */
  82560. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82561. /**
  82562. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82563. * @param position the position of the point along this path, from 0.0 to 1.0
  82564. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82565. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82566. */
  82567. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82568. /**
  82569. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82570. * @param position the position of the point along this path, from 0.0 to 1.0
  82571. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82572. */
  82573. getDistanceAt(position: number): number;
  82574. /**
  82575. * Returns the array index of the previous point of an interpolated point along this path
  82576. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82577. * @returns the array index
  82578. */
  82579. getPreviousPointIndexAt(position: number): number;
  82580. /**
  82581. * 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)
  82582. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82583. * @returns the sub position
  82584. */
  82585. getSubPositionAt(position: number): number;
  82586. /**
  82587. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82588. * @param target the vector of which to get the closest position to
  82589. * @returns the position of the closest virtual point on this path to the target vector
  82590. */
  82591. getClosestPositionTo(target: Vector3): number;
  82592. /**
  82593. * Returns a sub path (slice) of this path
  82594. * @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
  82595. * @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
  82596. * @returns a sub path (slice) of this path
  82597. */
  82598. slice(start?: number, end?: number): Path3D;
  82599. /**
  82600. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82601. * @param path path which all values are copied into the curves points
  82602. * @param firstNormal which should be projected onto the curve
  82603. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82604. * @returns the same object updated.
  82605. */
  82606. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82607. private _compute;
  82608. private _getFirstNonNullVector;
  82609. private _getLastNonNullVector;
  82610. private _normalVector;
  82611. /**
  82612. * Updates the point at data for an interpolated point along this curve
  82613. * @param position the position of the point along this curve, from 0.0 to 1.0
  82614. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82615. * @returns the (updated) point at data
  82616. */
  82617. private _updatePointAtData;
  82618. /**
  82619. * Updates the point at data from the specified parameters
  82620. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82621. * @param point the interpolated point
  82622. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82623. */
  82624. private _setPointAtData;
  82625. /**
  82626. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82627. */
  82628. private _updateInterpolationMatrix;
  82629. }
  82630. /**
  82631. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82632. * A Curve3 is designed from a series of successive Vector3.
  82633. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82634. */
  82635. export class Curve3 {
  82636. private _points;
  82637. private _length;
  82638. /**
  82639. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82640. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82641. * @param v1 (Vector3) the control point
  82642. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82643. * @param nbPoints (integer) the wanted number of points in the curve
  82644. * @returns the created Curve3
  82645. */
  82646. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82647. /**
  82648. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82649. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82650. * @param v1 (Vector3) the first control point
  82651. * @param v2 (Vector3) the second control point
  82652. * @param v3 (Vector3) the end point of the Cubic Bezier
  82653. * @param nbPoints (integer) the wanted number of points in the curve
  82654. * @returns the created Curve3
  82655. */
  82656. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82657. /**
  82658. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82659. * @param p1 (Vector3) the origin point of the Hermite Spline
  82660. * @param t1 (Vector3) the tangent vector at the origin point
  82661. * @param p2 (Vector3) the end point of the Hermite Spline
  82662. * @param t2 (Vector3) the tangent vector at the end point
  82663. * @param nbPoints (integer) the wanted number of points in the curve
  82664. * @returns the created Curve3
  82665. */
  82666. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82667. /**
  82668. * Returns a Curve3 object along a CatmullRom Spline curve :
  82669. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82670. * @param nbPoints (integer) the wanted number of points between each curve control points
  82671. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82672. * @returns the created Curve3
  82673. */
  82674. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82675. /**
  82676. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82677. * A Curve3 is designed from a series of successive Vector3.
  82678. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82679. * @param points points which make up the curve
  82680. */
  82681. constructor(points: Vector3[]);
  82682. /**
  82683. * @returns the Curve3 stored array of successive Vector3
  82684. */
  82685. getPoints(): Vector3[];
  82686. /**
  82687. * @returns the computed length (float) of the curve.
  82688. */
  82689. length(): number;
  82690. /**
  82691. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82692. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82693. * curveA and curveB keep unchanged.
  82694. * @param curve the curve to continue from this curve
  82695. * @returns the newly constructed curve
  82696. */
  82697. continue(curve: DeepImmutable<Curve3>): Curve3;
  82698. private _computeLength;
  82699. }
  82700. }
  82701. declare module BABYLON {
  82702. /**
  82703. * This represents the main contract an easing function should follow.
  82704. * Easing functions are used throughout the animation system.
  82705. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82706. */
  82707. export interface IEasingFunction {
  82708. /**
  82709. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82710. * of the easing function.
  82711. * The link below provides some of the most common examples of easing functions.
  82712. * @see https://easings.net/
  82713. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82714. * @returns the corresponding value on the curve defined by the easing function
  82715. */
  82716. ease(gradient: number): number;
  82717. }
  82718. /**
  82719. * Base class used for every default easing function.
  82720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82721. */
  82722. export class EasingFunction implements IEasingFunction {
  82723. /**
  82724. * Interpolation follows the mathematical formula associated with the easing function.
  82725. */
  82726. static readonly EASINGMODE_EASEIN: number;
  82727. /**
  82728. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82729. */
  82730. static readonly EASINGMODE_EASEOUT: number;
  82731. /**
  82732. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82733. */
  82734. static readonly EASINGMODE_EASEINOUT: number;
  82735. private _easingMode;
  82736. /**
  82737. * Sets the easing mode of the current function.
  82738. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82739. */
  82740. setEasingMode(easingMode: number): void;
  82741. /**
  82742. * Gets the current easing mode.
  82743. * @returns the easing mode
  82744. */
  82745. getEasingMode(): number;
  82746. /**
  82747. * @hidden
  82748. */
  82749. easeInCore(gradient: number): number;
  82750. /**
  82751. * Given an input gradient between 0 and 1, this returns the corresponding value
  82752. * of the easing function.
  82753. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82754. * @returns the corresponding value on the curve defined by the easing function
  82755. */
  82756. ease(gradient: number): number;
  82757. }
  82758. /**
  82759. * Easing function with a circle shape (see link below).
  82760. * @see https://easings.net/#easeInCirc
  82761. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82762. */
  82763. export class CircleEase extends EasingFunction implements IEasingFunction {
  82764. /** @hidden */
  82765. easeInCore(gradient: number): number;
  82766. }
  82767. /**
  82768. * Easing function with a ease back shape (see link below).
  82769. * @see https://easings.net/#easeInBack
  82770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82771. */
  82772. export class BackEase extends EasingFunction implements IEasingFunction {
  82773. /** Defines the amplitude of the function */
  82774. amplitude: number;
  82775. /**
  82776. * Instantiates a back ease easing
  82777. * @see https://easings.net/#easeInBack
  82778. * @param amplitude Defines the amplitude of the function
  82779. */
  82780. constructor(
  82781. /** Defines the amplitude of the function */
  82782. amplitude?: number);
  82783. /** @hidden */
  82784. easeInCore(gradient: number): number;
  82785. }
  82786. /**
  82787. * Easing function with a bouncing shape (see link below).
  82788. * @see https://easings.net/#easeInBounce
  82789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82790. */
  82791. export class BounceEase extends EasingFunction implements IEasingFunction {
  82792. /** Defines the number of bounces */
  82793. bounces: number;
  82794. /** Defines the amplitude of the bounce */
  82795. bounciness: number;
  82796. /**
  82797. * Instantiates a bounce easing
  82798. * @see https://easings.net/#easeInBounce
  82799. * @param bounces Defines the number of bounces
  82800. * @param bounciness Defines the amplitude of the bounce
  82801. */
  82802. constructor(
  82803. /** Defines the number of bounces */
  82804. bounces?: number,
  82805. /** Defines the amplitude of the bounce */
  82806. bounciness?: number);
  82807. /** @hidden */
  82808. easeInCore(gradient: number): number;
  82809. }
  82810. /**
  82811. * Easing function with a power of 3 shape (see link below).
  82812. * @see https://easings.net/#easeInCubic
  82813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82814. */
  82815. export class CubicEase extends EasingFunction implements IEasingFunction {
  82816. /** @hidden */
  82817. easeInCore(gradient: number): number;
  82818. }
  82819. /**
  82820. * Easing function with an elastic shape (see link below).
  82821. * @see https://easings.net/#easeInElastic
  82822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82823. */
  82824. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82825. /** Defines the number of oscillations*/
  82826. oscillations: number;
  82827. /** Defines the amplitude of the oscillations*/
  82828. springiness: number;
  82829. /**
  82830. * Instantiates an elastic easing function
  82831. * @see https://easings.net/#easeInElastic
  82832. * @param oscillations Defines the number of oscillations
  82833. * @param springiness Defines the amplitude of the oscillations
  82834. */
  82835. constructor(
  82836. /** Defines the number of oscillations*/
  82837. oscillations?: number,
  82838. /** Defines the amplitude of the oscillations*/
  82839. springiness?: number);
  82840. /** @hidden */
  82841. easeInCore(gradient: number): number;
  82842. }
  82843. /**
  82844. * Easing function with an exponential shape (see link below).
  82845. * @see https://easings.net/#easeInExpo
  82846. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82847. */
  82848. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  82849. /** Defines the exponent of the function */
  82850. exponent: number;
  82851. /**
  82852. * Instantiates an exponential easing function
  82853. * @see https://easings.net/#easeInExpo
  82854. * @param exponent Defines the exponent of the function
  82855. */
  82856. constructor(
  82857. /** Defines the exponent of the function */
  82858. exponent?: number);
  82859. /** @hidden */
  82860. easeInCore(gradient: number): number;
  82861. }
  82862. /**
  82863. * Easing function with a power shape (see link below).
  82864. * @see https://easings.net/#easeInQuad
  82865. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82866. */
  82867. export class PowerEase extends EasingFunction implements IEasingFunction {
  82868. /** Defines the power of the function */
  82869. power: number;
  82870. /**
  82871. * Instantiates an power base easing function
  82872. * @see https://easings.net/#easeInQuad
  82873. * @param power Defines the power of the function
  82874. */
  82875. constructor(
  82876. /** Defines the power of the function */
  82877. power?: number);
  82878. /** @hidden */
  82879. easeInCore(gradient: number): number;
  82880. }
  82881. /**
  82882. * Easing function with a power of 2 shape (see link below).
  82883. * @see https://easings.net/#easeInQuad
  82884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82885. */
  82886. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  82887. /** @hidden */
  82888. easeInCore(gradient: number): number;
  82889. }
  82890. /**
  82891. * Easing function with a power of 4 shape (see link below).
  82892. * @see https://easings.net/#easeInQuart
  82893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82894. */
  82895. export class QuarticEase extends EasingFunction implements IEasingFunction {
  82896. /** @hidden */
  82897. easeInCore(gradient: number): number;
  82898. }
  82899. /**
  82900. * Easing function with a power of 5 shape (see link below).
  82901. * @see https://easings.net/#easeInQuint
  82902. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82903. */
  82904. export class QuinticEase extends EasingFunction implements IEasingFunction {
  82905. /** @hidden */
  82906. easeInCore(gradient: number): number;
  82907. }
  82908. /**
  82909. * Easing function with a sin shape (see link below).
  82910. * @see https://easings.net/#easeInSine
  82911. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82912. */
  82913. export class SineEase extends EasingFunction implements IEasingFunction {
  82914. /** @hidden */
  82915. easeInCore(gradient: number): number;
  82916. }
  82917. /**
  82918. * Easing function with a bezier shape (see link below).
  82919. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82920. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82921. */
  82922. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  82923. /** Defines the x component of the start tangent in the bezier curve */
  82924. x1: number;
  82925. /** Defines the y component of the start tangent in the bezier curve */
  82926. y1: number;
  82927. /** Defines the x component of the end tangent in the bezier curve */
  82928. x2: number;
  82929. /** Defines the y component of the end tangent in the bezier curve */
  82930. y2: number;
  82931. /**
  82932. * Instantiates a bezier function
  82933. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  82934. * @param x1 Defines the x component of the start tangent in the bezier curve
  82935. * @param y1 Defines the y component of the start tangent in the bezier curve
  82936. * @param x2 Defines the x component of the end tangent in the bezier curve
  82937. * @param y2 Defines the y component of the end tangent in the bezier curve
  82938. */
  82939. constructor(
  82940. /** Defines the x component of the start tangent in the bezier curve */
  82941. x1?: number,
  82942. /** Defines the y component of the start tangent in the bezier curve */
  82943. y1?: number,
  82944. /** Defines the x component of the end tangent in the bezier curve */
  82945. x2?: number,
  82946. /** Defines the y component of the end tangent in the bezier curve */
  82947. y2?: number);
  82948. /** @hidden */
  82949. easeInCore(gradient: number): number;
  82950. }
  82951. }
  82952. declare module BABYLON {
  82953. /**
  82954. * Class used to hold a RBG color
  82955. */
  82956. export class Color3 {
  82957. /**
  82958. * Defines the red component (between 0 and 1, default is 0)
  82959. */
  82960. r: number;
  82961. /**
  82962. * Defines the green component (between 0 and 1, default is 0)
  82963. */
  82964. g: number;
  82965. /**
  82966. * Defines the blue component (between 0 and 1, default is 0)
  82967. */
  82968. b: number;
  82969. /**
  82970. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  82971. * @param r defines the red component (between 0 and 1, default is 0)
  82972. * @param g defines the green component (between 0 and 1, default is 0)
  82973. * @param b defines the blue component (between 0 and 1, default is 0)
  82974. */
  82975. constructor(
  82976. /**
  82977. * Defines the red component (between 0 and 1, default is 0)
  82978. */
  82979. r?: number,
  82980. /**
  82981. * Defines the green component (between 0 and 1, default is 0)
  82982. */
  82983. g?: number,
  82984. /**
  82985. * Defines the blue component (between 0 and 1, default is 0)
  82986. */
  82987. b?: number);
  82988. /**
  82989. * Creates a string with the Color3 current values
  82990. * @returns the string representation of the Color3 object
  82991. */
  82992. toString(): string;
  82993. /**
  82994. * Returns the string "Color3"
  82995. * @returns "Color3"
  82996. */
  82997. getClassName(): string;
  82998. /**
  82999. * Compute the Color3 hash code
  83000. * @returns an unique number that can be used to hash Color3 objects
  83001. */
  83002. getHashCode(): number;
  83003. /**
  83004. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83005. * @param array defines the array where to store the r,g,b components
  83006. * @param index defines an optional index in the target array to define where to start storing values
  83007. * @returns the current Color3 object
  83008. */
  83009. toArray(array: FloatArray, index?: number): Color3;
  83010. /**
  83011. * Returns a new Color4 object from the current Color3 and the given alpha
  83012. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83013. * @returns a new Color4 object
  83014. */
  83015. toColor4(alpha?: number): Color4;
  83016. /**
  83017. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83018. * @returns the new array
  83019. */
  83020. asArray(): number[];
  83021. /**
  83022. * Returns the luminance value
  83023. * @returns a float value
  83024. */
  83025. toLuminance(): number;
  83026. /**
  83027. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83028. * @param otherColor defines the second operand
  83029. * @returns the new Color3 object
  83030. */
  83031. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83032. /**
  83033. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83034. * @param otherColor defines the second operand
  83035. * @param result defines the Color3 object where to store the result
  83036. * @returns the current Color3
  83037. */
  83038. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83039. /**
  83040. * Determines equality between Color3 objects
  83041. * @param otherColor defines the second operand
  83042. * @returns true if the rgb values are equal to the given ones
  83043. */
  83044. equals(otherColor: DeepImmutable<Color3>): boolean;
  83045. /**
  83046. * Determines equality between the current Color3 object and a set of r,b,g values
  83047. * @param r defines the red component to check
  83048. * @param g defines the green component to check
  83049. * @param b defines the blue component to check
  83050. * @returns true if the rgb values are equal to the given ones
  83051. */
  83052. equalsFloats(r: number, g: number, b: number): boolean;
  83053. /**
  83054. * Multiplies in place each rgb value by scale
  83055. * @param scale defines the scaling factor
  83056. * @returns the updated Color3
  83057. */
  83058. scale(scale: number): Color3;
  83059. /**
  83060. * Multiplies the rgb values by scale and stores the result into "result"
  83061. * @param scale defines the scaling factor
  83062. * @param result defines the Color3 object where to store the result
  83063. * @returns the unmodified current Color3
  83064. */
  83065. scaleToRef(scale: number, result: Color3): Color3;
  83066. /**
  83067. * Scale the current Color3 values by a factor and add the result to a given Color3
  83068. * @param scale defines the scale factor
  83069. * @param result defines color to store the result into
  83070. * @returns the unmodified current Color3
  83071. */
  83072. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83073. /**
  83074. * Clamps the rgb values by the min and max values and stores the result into "result"
  83075. * @param min defines minimum clamping value (default is 0)
  83076. * @param max defines maximum clamping value (default is 1)
  83077. * @param result defines color to store the result into
  83078. * @returns the original Color3
  83079. */
  83080. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83081. /**
  83082. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83083. * @param otherColor defines the second operand
  83084. * @returns the new Color3
  83085. */
  83086. add(otherColor: DeepImmutable<Color3>): Color3;
  83087. /**
  83088. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83089. * @param otherColor defines the second operand
  83090. * @param result defines Color3 object to store the result into
  83091. * @returns the unmodified current Color3
  83092. */
  83093. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83094. /**
  83095. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83096. * @param otherColor defines the second operand
  83097. * @returns the new Color3
  83098. */
  83099. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83100. /**
  83101. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83102. * @param otherColor defines the second operand
  83103. * @param result defines Color3 object to store the result into
  83104. * @returns the unmodified current Color3
  83105. */
  83106. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83107. /**
  83108. * Copy the current object
  83109. * @returns a new Color3 copied the current one
  83110. */
  83111. clone(): Color3;
  83112. /**
  83113. * Copies the rgb values from the source in the current Color3
  83114. * @param source defines the source Color3 object
  83115. * @returns the updated Color3 object
  83116. */
  83117. copyFrom(source: DeepImmutable<Color3>): Color3;
  83118. /**
  83119. * Updates the Color3 rgb values from the given floats
  83120. * @param r defines the red component to read from
  83121. * @param g defines the green component to read from
  83122. * @param b defines the blue component to read from
  83123. * @returns the current Color3 object
  83124. */
  83125. copyFromFloats(r: number, g: number, b: number): Color3;
  83126. /**
  83127. * Updates the Color3 rgb values from the given floats
  83128. * @param r defines the red component to read from
  83129. * @param g defines the green component to read from
  83130. * @param b defines the blue component to read from
  83131. * @returns the current Color3 object
  83132. */
  83133. set(r: number, g: number, b: number): Color3;
  83134. /**
  83135. * Compute the Color3 hexadecimal code as a string
  83136. * @returns a string containing the hexadecimal representation of the Color3 object
  83137. */
  83138. toHexString(): string;
  83139. /**
  83140. * Computes a new Color3 converted from the current one to linear space
  83141. * @returns a new Color3 object
  83142. */
  83143. toLinearSpace(): Color3;
  83144. /**
  83145. * Converts current color in rgb space to HSV values
  83146. * @returns a new color3 representing the HSV values
  83147. */
  83148. toHSV(): Color3;
  83149. /**
  83150. * Converts current color in rgb space to HSV values
  83151. * @param result defines the Color3 where to store the HSV values
  83152. */
  83153. toHSVToRef(result: Color3): void;
  83154. /**
  83155. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83156. * @param convertedColor defines the Color3 object where to store the linear space version
  83157. * @returns the unmodified Color3
  83158. */
  83159. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83160. /**
  83161. * Computes a new Color3 converted from the current one to gamma space
  83162. * @returns a new Color3 object
  83163. */
  83164. toGammaSpace(): Color3;
  83165. /**
  83166. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83167. * @param convertedColor defines the Color3 object where to store the gamma space version
  83168. * @returns the unmodified Color3
  83169. */
  83170. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83171. private static _BlackReadOnly;
  83172. /**
  83173. * Convert Hue, saturation and value to a Color3 (RGB)
  83174. * @param hue defines the hue
  83175. * @param saturation defines the saturation
  83176. * @param value defines the value
  83177. * @param result defines the Color3 where to store the RGB values
  83178. */
  83179. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83180. /**
  83181. * Creates a new Color3 from the string containing valid hexadecimal values
  83182. * @param hex defines a string containing valid hexadecimal values
  83183. * @returns a new Color3 object
  83184. */
  83185. static FromHexString(hex: string): Color3;
  83186. /**
  83187. * Creates a new Color3 from the starting index of the given array
  83188. * @param array defines the source array
  83189. * @param offset defines an offset in the source array
  83190. * @returns a new Color3 object
  83191. */
  83192. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83193. /**
  83194. * Creates a new Color3 from integer values (< 256)
  83195. * @param r defines the red component to read from (value between 0 and 255)
  83196. * @param g defines the green component to read from (value between 0 and 255)
  83197. * @param b defines the blue component to read from (value between 0 and 255)
  83198. * @returns a new Color3 object
  83199. */
  83200. static FromInts(r: number, g: number, b: number): Color3;
  83201. /**
  83202. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83203. * @param start defines the start Color3 value
  83204. * @param end defines the end Color3 value
  83205. * @param amount defines the gradient value between start and end
  83206. * @returns a new Color3 object
  83207. */
  83208. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83209. /**
  83210. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83211. * @param left defines the start value
  83212. * @param right defines the end value
  83213. * @param amount defines the gradient factor
  83214. * @param result defines the Color3 object where to store the result
  83215. */
  83216. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83217. /**
  83218. * Returns a Color3 value containing a red color
  83219. * @returns a new Color3 object
  83220. */
  83221. static Red(): Color3;
  83222. /**
  83223. * Returns a Color3 value containing a green color
  83224. * @returns a new Color3 object
  83225. */
  83226. static Green(): Color3;
  83227. /**
  83228. * Returns a Color3 value containing a blue color
  83229. * @returns a new Color3 object
  83230. */
  83231. static Blue(): Color3;
  83232. /**
  83233. * Returns a Color3 value containing a black color
  83234. * @returns a new Color3 object
  83235. */
  83236. static Black(): Color3;
  83237. /**
  83238. * Gets a Color3 value containing a black color that must not be updated
  83239. */
  83240. static get BlackReadOnly(): DeepImmutable<Color3>;
  83241. /**
  83242. * Returns a Color3 value containing a white color
  83243. * @returns a new Color3 object
  83244. */
  83245. static White(): Color3;
  83246. /**
  83247. * Returns a Color3 value containing a purple color
  83248. * @returns a new Color3 object
  83249. */
  83250. static Purple(): Color3;
  83251. /**
  83252. * Returns a Color3 value containing a magenta color
  83253. * @returns a new Color3 object
  83254. */
  83255. static Magenta(): Color3;
  83256. /**
  83257. * Returns a Color3 value containing a yellow color
  83258. * @returns a new Color3 object
  83259. */
  83260. static Yellow(): Color3;
  83261. /**
  83262. * Returns a Color3 value containing a gray color
  83263. * @returns a new Color3 object
  83264. */
  83265. static Gray(): Color3;
  83266. /**
  83267. * Returns a Color3 value containing a teal color
  83268. * @returns a new Color3 object
  83269. */
  83270. static Teal(): Color3;
  83271. /**
  83272. * Returns a Color3 value containing a random color
  83273. * @returns a new Color3 object
  83274. */
  83275. static Random(): Color3;
  83276. }
  83277. /**
  83278. * Class used to hold a RBGA color
  83279. */
  83280. export class Color4 {
  83281. /**
  83282. * Defines the red component (between 0 and 1, default is 0)
  83283. */
  83284. r: number;
  83285. /**
  83286. * Defines the green component (between 0 and 1, default is 0)
  83287. */
  83288. g: number;
  83289. /**
  83290. * Defines the blue component (between 0 and 1, default is 0)
  83291. */
  83292. b: number;
  83293. /**
  83294. * Defines the alpha component (between 0 and 1, default is 1)
  83295. */
  83296. a: number;
  83297. /**
  83298. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83299. * @param r defines the red component (between 0 and 1, default is 0)
  83300. * @param g defines the green component (between 0 and 1, default is 0)
  83301. * @param b defines the blue component (between 0 and 1, default is 0)
  83302. * @param a defines the alpha component (between 0 and 1, default is 1)
  83303. */
  83304. constructor(
  83305. /**
  83306. * Defines the red component (between 0 and 1, default is 0)
  83307. */
  83308. r?: number,
  83309. /**
  83310. * Defines the green component (between 0 and 1, default is 0)
  83311. */
  83312. g?: number,
  83313. /**
  83314. * Defines the blue component (between 0 and 1, default is 0)
  83315. */
  83316. b?: number,
  83317. /**
  83318. * Defines the alpha component (between 0 and 1, default is 1)
  83319. */
  83320. a?: number);
  83321. /**
  83322. * Adds in place the given Color4 values to the current Color4 object
  83323. * @param right defines the second operand
  83324. * @returns the current updated Color4 object
  83325. */
  83326. addInPlace(right: DeepImmutable<Color4>): Color4;
  83327. /**
  83328. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83329. * @returns the new array
  83330. */
  83331. asArray(): number[];
  83332. /**
  83333. * Stores from the starting index in the given array the Color4 successive values
  83334. * @param array defines the array where to store the r,g,b components
  83335. * @param index defines an optional index in the target array to define where to start storing values
  83336. * @returns the current Color4 object
  83337. */
  83338. toArray(array: number[], index?: number): Color4;
  83339. /**
  83340. * Determines equality between Color4 objects
  83341. * @param otherColor defines the second operand
  83342. * @returns true if the rgba values are equal to the given ones
  83343. */
  83344. equals(otherColor: DeepImmutable<Color4>): boolean;
  83345. /**
  83346. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83347. * @param right defines the second operand
  83348. * @returns a new Color4 object
  83349. */
  83350. add(right: DeepImmutable<Color4>): Color4;
  83351. /**
  83352. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83353. * @param right defines the second operand
  83354. * @returns a new Color4 object
  83355. */
  83356. subtract(right: DeepImmutable<Color4>): Color4;
  83357. /**
  83358. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83359. * @param right defines the second operand
  83360. * @param result defines the Color4 object where to store the result
  83361. * @returns the current Color4 object
  83362. */
  83363. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83364. /**
  83365. * Creates a new Color4 with the current Color4 values multiplied by scale
  83366. * @param scale defines the scaling factor to apply
  83367. * @returns a new Color4 object
  83368. */
  83369. scale(scale: number): Color4;
  83370. /**
  83371. * Multiplies the current Color4 values by scale and stores the result in "result"
  83372. * @param scale defines the scaling factor to apply
  83373. * @param result defines the Color4 object where to store the result
  83374. * @returns the current unmodified Color4
  83375. */
  83376. scaleToRef(scale: number, result: Color4): Color4;
  83377. /**
  83378. * Scale the current Color4 values by a factor and add the result to a given Color4
  83379. * @param scale defines the scale factor
  83380. * @param result defines the Color4 object where to store the result
  83381. * @returns the unmodified current Color4
  83382. */
  83383. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83384. /**
  83385. * Clamps the rgb values by the min and max values and stores the result into "result"
  83386. * @param min defines minimum clamping value (default is 0)
  83387. * @param max defines maximum clamping value (default is 1)
  83388. * @param result defines color to store the result into.
  83389. * @returns the cuurent Color4
  83390. */
  83391. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83392. /**
  83393. * Multipy an Color4 value by another and return a new Color4 object
  83394. * @param color defines the Color4 value to multiply by
  83395. * @returns a new Color4 object
  83396. */
  83397. multiply(color: Color4): Color4;
  83398. /**
  83399. * Multipy a Color4 value by another and push the result in a reference value
  83400. * @param color defines the Color4 value to multiply by
  83401. * @param result defines the Color4 to fill the result in
  83402. * @returns the result Color4
  83403. */
  83404. multiplyToRef(color: Color4, result: Color4): Color4;
  83405. /**
  83406. * Creates a string with the Color4 current values
  83407. * @returns the string representation of the Color4 object
  83408. */
  83409. toString(): string;
  83410. /**
  83411. * Returns the string "Color4"
  83412. * @returns "Color4"
  83413. */
  83414. getClassName(): string;
  83415. /**
  83416. * Compute the Color4 hash code
  83417. * @returns an unique number that can be used to hash Color4 objects
  83418. */
  83419. getHashCode(): number;
  83420. /**
  83421. * Creates a new Color4 copied from the current one
  83422. * @returns a new Color4 object
  83423. */
  83424. clone(): Color4;
  83425. /**
  83426. * Copies the given Color4 values into the current one
  83427. * @param source defines the source Color4 object
  83428. * @returns the current updated Color4 object
  83429. */
  83430. copyFrom(source: Color4): Color4;
  83431. /**
  83432. * Copies the given float values into the current one
  83433. * @param r defines the red component to read from
  83434. * @param g defines the green component to read from
  83435. * @param b defines the blue component to read from
  83436. * @param a defines the alpha component to read from
  83437. * @returns the current updated Color4 object
  83438. */
  83439. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83440. /**
  83441. * Copies the given float values into the current one
  83442. * @param r defines the red component to read from
  83443. * @param g defines the green component to read from
  83444. * @param b defines the blue component to read from
  83445. * @param a defines the alpha component to read from
  83446. * @returns the current updated Color4 object
  83447. */
  83448. set(r: number, g: number, b: number, a: number): Color4;
  83449. /**
  83450. * Compute the Color4 hexadecimal code as a string
  83451. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83452. * @returns a string containing the hexadecimal representation of the Color4 object
  83453. */
  83454. toHexString(returnAsColor3?: boolean): string;
  83455. /**
  83456. * Computes a new Color4 converted from the current one to linear space
  83457. * @returns a new Color4 object
  83458. */
  83459. toLinearSpace(): Color4;
  83460. /**
  83461. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83462. * @param convertedColor defines the Color4 object where to store the linear space version
  83463. * @returns the unmodified Color4
  83464. */
  83465. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83466. /**
  83467. * Computes a new Color4 converted from the current one to gamma space
  83468. * @returns a new Color4 object
  83469. */
  83470. toGammaSpace(): Color4;
  83471. /**
  83472. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83473. * @param convertedColor defines the Color4 object where to store the gamma space version
  83474. * @returns the unmodified Color4
  83475. */
  83476. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83477. /**
  83478. * Creates a new Color4 from the string containing valid hexadecimal values
  83479. * @param hex defines a string containing valid hexadecimal values
  83480. * @returns a new Color4 object
  83481. */
  83482. static FromHexString(hex: string): Color4;
  83483. /**
  83484. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83485. * @param left defines the start value
  83486. * @param right defines the end value
  83487. * @param amount defines the gradient factor
  83488. * @returns a new Color4 object
  83489. */
  83490. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83491. /**
  83492. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83493. * @param left defines the start value
  83494. * @param right defines the end value
  83495. * @param amount defines the gradient factor
  83496. * @param result defines the Color4 object where to store data
  83497. */
  83498. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83499. /**
  83500. * Creates a new Color4 from a Color3 and an alpha value
  83501. * @param color3 defines the source Color3 to read from
  83502. * @param alpha defines the alpha component (1.0 by default)
  83503. * @returns a new Color4 object
  83504. */
  83505. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83506. /**
  83507. * Creates a new Color4 from the starting index element of the given array
  83508. * @param array defines the source array to read from
  83509. * @param offset defines the offset in the source array
  83510. * @returns a new Color4 object
  83511. */
  83512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83513. /**
  83514. * Creates a new Color3 from integer values (< 256)
  83515. * @param r defines the red component to read from (value between 0 and 255)
  83516. * @param g defines the green component to read from (value between 0 and 255)
  83517. * @param b defines the blue component to read from (value between 0 and 255)
  83518. * @param a defines the alpha component to read from (value between 0 and 255)
  83519. * @returns a new Color3 object
  83520. */
  83521. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83522. /**
  83523. * Check the content of a given array and convert it to an array containing RGBA data
  83524. * If the original array was already containing count * 4 values then it is returned directly
  83525. * @param colors defines the array to check
  83526. * @param count defines the number of RGBA data to expect
  83527. * @returns an array containing count * 4 values (RGBA)
  83528. */
  83529. static CheckColors4(colors: number[], count: number): number[];
  83530. }
  83531. /**
  83532. * @hidden
  83533. */
  83534. export class TmpColors {
  83535. static Color3: Color3[];
  83536. static Color4: Color4[];
  83537. }
  83538. }
  83539. declare module BABYLON {
  83540. /**
  83541. * Defines an interface which represents an animation key frame
  83542. */
  83543. export interface IAnimationKey {
  83544. /**
  83545. * Frame of the key frame
  83546. */
  83547. frame: number;
  83548. /**
  83549. * Value at the specifies key frame
  83550. */
  83551. value: any;
  83552. /**
  83553. * The input tangent for the cubic hermite spline
  83554. */
  83555. inTangent?: any;
  83556. /**
  83557. * The output tangent for the cubic hermite spline
  83558. */
  83559. outTangent?: any;
  83560. /**
  83561. * The animation interpolation type
  83562. */
  83563. interpolation?: AnimationKeyInterpolation;
  83564. }
  83565. /**
  83566. * Enum for the animation key frame interpolation type
  83567. */
  83568. export enum AnimationKeyInterpolation {
  83569. /**
  83570. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83571. */
  83572. STEP = 1
  83573. }
  83574. }
  83575. declare module BABYLON {
  83576. /**
  83577. * Represents the range of an animation
  83578. */
  83579. export class AnimationRange {
  83580. /**The name of the animation range**/
  83581. name: string;
  83582. /**The starting frame of the animation */
  83583. from: number;
  83584. /**The ending frame of the animation*/
  83585. to: number;
  83586. /**
  83587. * Initializes the range of an animation
  83588. * @param name The name of the animation range
  83589. * @param from The starting frame of the animation
  83590. * @param to The ending frame of the animation
  83591. */
  83592. constructor(
  83593. /**The name of the animation range**/
  83594. name: string,
  83595. /**The starting frame of the animation */
  83596. from: number,
  83597. /**The ending frame of the animation*/
  83598. to: number);
  83599. /**
  83600. * Makes a copy of the animation range
  83601. * @returns A copy of the animation range
  83602. */
  83603. clone(): AnimationRange;
  83604. }
  83605. }
  83606. declare module BABYLON {
  83607. /**
  83608. * Composed of a frame, and an action function
  83609. */
  83610. export class AnimationEvent {
  83611. /** The frame for which the event is triggered **/
  83612. frame: number;
  83613. /** The event to perform when triggered **/
  83614. action: (currentFrame: number) => void;
  83615. /** Specifies if the event should be triggered only once**/
  83616. onlyOnce?: boolean | undefined;
  83617. /**
  83618. * Specifies if the animation event is done
  83619. */
  83620. isDone: boolean;
  83621. /**
  83622. * Initializes the animation event
  83623. * @param frame The frame for which the event is triggered
  83624. * @param action The event to perform when triggered
  83625. * @param onlyOnce Specifies if the event should be triggered only once
  83626. */
  83627. constructor(
  83628. /** The frame for which the event is triggered **/
  83629. frame: number,
  83630. /** The event to perform when triggered **/
  83631. action: (currentFrame: number) => void,
  83632. /** Specifies if the event should be triggered only once**/
  83633. onlyOnce?: boolean | undefined);
  83634. /** @hidden */
  83635. _clone(): AnimationEvent;
  83636. }
  83637. }
  83638. declare module BABYLON {
  83639. /**
  83640. * Interface used to define a behavior
  83641. */
  83642. export interface Behavior<T> {
  83643. /** gets or sets behavior's name */
  83644. name: string;
  83645. /**
  83646. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83647. */
  83648. init(): void;
  83649. /**
  83650. * Called when the behavior is attached to a target
  83651. * @param target defines the target where the behavior is attached to
  83652. */
  83653. attach(target: T): void;
  83654. /**
  83655. * Called when the behavior is detached from its target
  83656. */
  83657. detach(): void;
  83658. }
  83659. /**
  83660. * Interface implemented by classes supporting behaviors
  83661. */
  83662. export interface IBehaviorAware<T> {
  83663. /**
  83664. * Attach a behavior
  83665. * @param behavior defines the behavior to attach
  83666. * @returns the current host
  83667. */
  83668. addBehavior(behavior: Behavior<T>): T;
  83669. /**
  83670. * Remove a behavior from the current object
  83671. * @param behavior defines the behavior to detach
  83672. * @returns the current host
  83673. */
  83674. removeBehavior(behavior: Behavior<T>): T;
  83675. /**
  83676. * Gets a behavior using its name to search
  83677. * @param name defines the name to search
  83678. * @returns the behavior or null if not found
  83679. */
  83680. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83681. }
  83682. }
  83683. declare module BABYLON {
  83684. /**
  83685. * Defines an array and its length.
  83686. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83687. */
  83688. export interface ISmartArrayLike<T> {
  83689. /**
  83690. * The data of the array.
  83691. */
  83692. data: Array<T>;
  83693. /**
  83694. * The active length of the array.
  83695. */
  83696. length: number;
  83697. }
  83698. /**
  83699. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83700. */
  83701. export class SmartArray<T> implements ISmartArrayLike<T> {
  83702. /**
  83703. * The full set of data from the array.
  83704. */
  83705. data: Array<T>;
  83706. /**
  83707. * The active length of the array.
  83708. */
  83709. length: number;
  83710. protected _id: number;
  83711. /**
  83712. * Instantiates a Smart Array.
  83713. * @param capacity defines the default capacity of the array.
  83714. */
  83715. constructor(capacity: number);
  83716. /**
  83717. * Pushes a value at the end of the active data.
  83718. * @param value defines the object to push in the array.
  83719. */
  83720. push(value: T): void;
  83721. /**
  83722. * Iterates over the active data and apply the lambda to them.
  83723. * @param func defines the action to apply on each value.
  83724. */
  83725. forEach(func: (content: T) => void): void;
  83726. /**
  83727. * Sorts the full sets of data.
  83728. * @param compareFn defines the comparison function to apply.
  83729. */
  83730. sort(compareFn: (a: T, b: T) => number): void;
  83731. /**
  83732. * Resets the active data to an empty array.
  83733. */
  83734. reset(): void;
  83735. /**
  83736. * Releases all the data from the array as well as the array.
  83737. */
  83738. dispose(): void;
  83739. /**
  83740. * Concats the active data with a given array.
  83741. * @param array defines the data to concatenate with.
  83742. */
  83743. concat(array: any): void;
  83744. /**
  83745. * Returns the position of a value in the active data.
  83746. * @param value defines the value to find the index for
  83747. * @returns the index if found in the active data otherwise -1
  83748. */
  83749. indexOf(value: T): number;
  83750. /**
  83751. * Returns whether an element is part of the active data.
  83752. * @param value defines the value to look for
  83753. * @returns true if found in the active data otherwise false
  83754. */
  83755. contains(value: T): boolean;
  83756. private static _GlobalId;
  83757. }
  83758. /**
  83759. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83760. * The data in this array can only be present once
  83761. */
  83762. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83763. private _duplicateId;
  83764. /**
  83765. * Pushes a value at the end of the active data.
  83766. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83767. * @param value defines the object to push in the array.
  83768. */
  83769. push(value: T): void;
  83770. /**
  83771. * Pushes a value at the end of the active data.
  83772. * If the data is already present, it won t be added again
  83773. * @param value defines the object to push in the array.
  83774. * @returns true if added false if it was already present
  83775. */
  83776. pushNoDuplicate(value: T): boolean;
  83777. /**
  83778. * Resets the active data to an empty array.
  83779. */
  83780. reset(): void;
  83781. /**
  83782. * Concats the active data with a given array.
  83783. * This ensures no dupplicate will be present in the result.
  83784. * @param array defines the data to concatenate with.
  83785. */
  83786. concatWithNoDuplicate(array: any): void;
  83787. }
  83788. }
  83789. declare module BABYLON {
  83790. /**
  83791. * @ignore
  83792. * This is a list of all the different input types that are available in the application.
  83793. * Fo instance: ArcRotateCameraGamepadInput...
  83794. */
  83795. export var CameraInputTypes: {};
  83796. /**
  83797. * This is the contract to implement in order to create a new input class.
  83798. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83799. */
  83800. export interface ICameraInput<TCamera extends Camera> {
  83801. /**
  83802. * Defines the camera the input is attached to.
  83803. */
  83804. camera: Nullable<TCamera>;
  83805. /**
  83806. * Gets the class name of the current intput.
  83807. * @returns the class name
  83808. */
  83809. getClassName(): string;
  83810. /**
  83811. * Get the friendly name associated with the input class.
  83812. * @returns the input friendly name
  83813. */
  83814. getSimpleName(): string;
  83815. /**
  83816. * Attach the input controls to a specific dom element to get the input from.
  83817. * @param element Defines the element the controls should be listened from
  83818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83819. */
  83820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83821. /**
  83822. * Detach the current controls from the specified dom element.
  83823. * @param element Defines the element to stop listening the inputs from
  83824. */
  83825. detachControl(element: Nullable<HTMLElement>): void;
  83826. /**
  83827. * Update the current camera state depending on the inputs that have been used this frame.
  83828. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83829. */
  83830. checkInputs?: () => void;
  83831. }
  83832. /**
  83833. * Represents a map of input types to input instance or input index to input instance.
  83834. */
  83835. export interface CameraInputsMap<TCamera extends Camera> {
  83836. /**
  83837. * Accessor to the input by input type.
  83838. */
  83839. [name: string]: ICameraInput<TCamera>;
  83840. /**
  83841. * Accessor to the input by input index.
  83842. */
  83843. [idx: number]: ICameraInput<TCamera>;
  83844. }
  83845. /**
  83846. * This represents the input manager used within a camera.
  83847. * It helps dealing with all the different kind of input attached to a camera.
  83848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83849. */
  83850. export class CameraInputsManager<TCamera extends Camera> {
  83851. /**
  83852. * Defines the list of inputs attahed to the camera.
  83853. */
  83854. attached: CameraInputsMap<TCamera>;
  83855. /**
  83856. * Defines the dom element the camera is collecting inputs from.
  83857. * This is null if the controls have not been attached.
  83858. */
  83859. attachedElement: Nullable<HTMLElement>;
  83860. /**
  83861. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83862. */
  83863. noPreventDefault: boolean;
  83864. /**
  83865. * Defined the camera the input manager belongs to.
  83866. */
  83867. camera: TCamera;
  83868. /**
  83869. * Update the current camera state depending on the inputs that have been used this frame.
  83870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83871. */
  83872. checkInputs: () => void;
  83873. /**
  83874. * Instantiate a new Camera Input Manager.
  83875. * @param camera Defines the camera the input manager blongs to
  83876. */
  83877. constructor(camera: TCamera);
  83878. /**
  83879. * Add an input method to a camera
  83880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83881. * @param input camera input method
  83882. */
  83883. add(input: ICameraInput<TCamera>): void;
  83884. /**
  83885. * Remove a specific input method from a camera
  83886. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  83887. * @param inputToRemove camera input method
  83888. */
  83889. remove(inputToRemove: ICameraInput<TCamera>): void;
  83890. /**
  83891. * Remove a specific input type from a camera
  83892. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  83893. * @param inputType the type of the input to remove
  83894. */
  83895. removeByType(inputType: string): void;
  83896. private _addCheckInputs;
  83897. /**
  83898. * Attach the input controls to the currently attached dom element to listen the events from.
  83899. * @param input Defines the input to attach
  83900. */
  83901. attachInput(input: ICameraInput<TCamera>): void;
  83902. /**
  83903. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  83904. * @param element Defines the dom element to collect the events from
  83905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83906. */
  83907. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  83908. /**
  83909. * Detach the current manager inputs controls from a specific dom element.
  83910. * @param element Defines the dom element to collect the events from
  83911. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  83912. */
  83913. detachElement(element: HTMLElement, disconnect?: boolean): void;
  83914. /**
  83915. * Rebuild the dynamic inputCheck function from the current list of
  83916. * defined inputs in the manager.
  83917. */
  83918. rebuildInputCheck(): void;
  83919. /**
  83920. * Remove all attached input methods from a camera
  83921. */
  83922. clear(): void;
  83923. /**
  83924. * Serialize the current input manager attached to a camera.
  83925. * This ensures than once parsed,
  83926. * the input associated to the camera will be identical to the current ones
  83927. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  83928. */
  83929. serialize(serializedCamera: any): void;
  83930. /**
  83931. * Parses an input manager serialized JSON to restore the previous list of inputs
  83932. * and states associated to a camera.
  83933. * @param parsedCamera Defines the JSON to parse
  83934. */
  83935. parse(parsedCamera: any): void;
  83936. }
  83937. }
  83938. declare module BABYLON {
  83939. /**
  83940. * Class used to store data that will be store in GPU memory
  83941. */
  83942. export class Buffer {
  83943. private _engine;
  83944. private _buffer;
  83945. /** @hidden */
  83946. _data: Nullable<DataArray>;
  83947. private _updatable;
  83948. private _instanced;
  83949. private _divisor;
  83950. /**
  83951. * Gets the byte stride.
  83952. */
  83953. readonly byteStride: number;
  83954. /**
  83955. * Constructor
  83956. * @param engine the engine
  83957. * @param data the data to use for this buffer
  83958. * @param updatable whether the data is updatable
  83959. * @param stride the stride (optional)
  83960. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83961. * @param instanced whether the buffer is instanced (optional)
  83962. * @param useBytes set to true if the stride in in bytes (optional)
  83963. * @param divisor sets an optional divisor for instances (1 by default)
  83964. */
  83965. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  83966. /**
  83967. * Create a new VertexBuffer based on the current buffer
  83968. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83969. * @param offset defines offset in the buffer (0 by default)
  83970. * @param size defines the size in floats of attributes (position is 3 for instance)
  83971. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83972. * @param instanced defines if the vertex buffer contains indexed data
  83973. * @param useBytes defines if the offset and stride are in bytes *
  83974. * @param divisor sets an optional divisor for instances (1 by default)
  83975. * @returns the new vertex buffer
  83976. */
  83977. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  83978. /**
  83979. * Gets a boolean indicating if the Buffer is updatable?
  83980. * @returns true if the buffer is updatable
  83981. */
  83982. isUpdatable(): boolean;
  83983. /**
  83984. * Gets current buffer's data
  83985. * @returns a DataArray or null
  83986. */
  83987. getData(): Nullable<DataArray>;
  83988. /**
  83989. * Gets underlying native buffer
  83990. * @returns underlying native buffer
  83991. */
  83992. getBuffer(): Nullable<DataBuffer>;
  83993. /**
  83994. * Gets the stride in float32 units (i.e. byte stride / 4).
  83995. * May not be an integer if the byte stride is not divisible by 4.
  83996. * @returns the stride in float32 units
  83997. * @deprecated Please use byteStride instead.
  83998. */
  83999. getStrideSize(): number;
  84000. /**
  84001. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84002. * @param data defines the data to store
  84003. */
  84004. create(data?: Nullable<DataArray>): void;
  84005. /** @hidden */
  84006. _rebuild(): void;
  84007. /**
  84008. * Update current buffer data
  84009. * @param data defines the data to store
  84010. */
  84011. update(data: DataArray): void;
  84012. /**
  84013. * Updates the data directly.
  84014. * @param data the new data
  84015. * @param offset the new offset
  84016. * @param vertexCount the vertex count (optional)
  84017. * @param useBytes set to true if the offset is in bytes
  84018. */
  84019. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84020. /**
  84021. * Release all resources
  84022. */
  84023. dispose(): void;
  84024. }
  84025. /**
  84026. * Specialized buffer used to store vertex data
  84027. */
  84028. export class VertexBuffer {
  84029. /** @hidden */
  84030. _buffer: Buffer;
  84031. private _kind;
  84032. private _size;
  84033. private _ownsBuffer;
  84034. private _instanced;
  84035. private _instanceDivisor;
  84036. /**
  84037. * The byte type.
  84038. */
  84039. static readonly BYTE: number;
  84040. /**
  84041. * The unsigned byte type.
  84042. */
  84043. static readonly UNSIGNED_BYTE: number;
  84044. /**
  84045. * The short type.
  84046. */
  84047. static readonly SHORT: number;
  84048. /**
  84049. * The unsigned short type.
  84050. */
  84051. static readonly UNSIGNED_SHORT: number;
  84052. /**
  84053. * The integer type.
  84054. */
  84055. static readonly INT: number;
  84056. /**
  84057. * The unsigned integer type.
  84058. */
  84059. static readonly UNSIGNED_INT: number;
  84060. /**
  84061. * The float type.
  84062. */
  84063. static readonly FLOAT: number;
  84064. /**
  84065. * Gets or sets the instance divisor when in instanced mode
  84066. */
  84067. get instanceDivisor(): number;
  84068. set instanceDivisor(value: number);
  84069. /**
  84070. * Gets the byte stride.
  84071. */
  84072. readonly byteStride: number;
  84073. /**
  84074. * Gets the byte offset.
  84075. */
  84076. readonly byteOffset: number;
  84077. /**
  84078. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84079. */
  84080. readonly normalized: boolean;
  84081. /**
  84082. * Gets the data type of each component in the array.
  84083. */
  84084. readonly type: number;
  84085. /**
  84086. * Constructor
  84087. * @param engine the engine
  84088. * @param data the data to use for this vertex buffer
  84089. * @param kind the vertex buffer kind
  84090. * @param updatable whether the data is updatable
  84091. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84092. * @param stride the stride (optional)
  84093. * @param instanced whether the buffer is instanced (optional)
  84094. * @param offset the offset of the data (optional)
  84095. * @param size the number of components (optional)
  84096. * @param type the type of the component (optional)
  84097. * @param normalized whether the data contains normalized data (optional)
  84098. * @param useBytes set to true if stride and offset are in bytes (optional)
  84099. * @param divisor defines the instance divisor to use (1 by default)
  84100. */
  84101. 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);
  84102. /** @hidden */
  84103. _rebuild(): void;
  84104. /**
  84105. * Returns the kind of the VertexBuffer (string)
  84106. * @returns a string
  84107. */
  84108. getKind(): string;
  84109. /**
  84110. * Gets a boolean indicating if the VertexBuffer is updatable?
  84111. * @returns true if the buffer is updatable
  84112. */
  84113. isUpdatable(): boolean;
  84114. /**
  84115. * Gets current buffer's data
  84116. * @returns a DataArray or null
  84117. */
  84118. getData(): Nullable<DataArray>;
  84119. /**
  84120. * Gets underlying native buffer
  84121. * @returns underlying native buffer
  84122. */
  84123. getBuffer(): Nullable<DataBuffer>;
  84124. /**
  84125. * Gets the stride in float32 units (i.e. byte stride / 4).
  84126. * May not be an integer if the byte stride is not divisible by 4.
  84127. * @returns the stride in float32 units
  84128. * @deprecated Please use byteStride instead.
  84129. */
  84130. getStrideSize(): number;
  84131. /**
  84132. * Returns the offset as a multiple of the type byte length.
  84133. * @returns the offset in bytes
  84134. * @deprecated Please use byteOffset instead.
  84135. */
  84136. getOffset(): number;
  84137. /**
  84138. * Returns the number of components per vertex attribute (integer)
  84139. * @returns the size in float
  84140. */
  84141. getSize(): number;
  84142. /**
  84143. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84144. * @returns true if this buffer is instanced
  84145. */
  84146. getIsInstanced(): boolean;
  84147. /**
  84148. * Returns the instancing divisor, zero for non-instanced (integer).
  84149. * @returns a number
  84150. */
  84151. getInstanceDivisor(): number;
  84152. /**
  84153. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84154. * @param data defines the data to store
  84155. */
  84156. create(data?: DataArray): void;
  84157. /**
  84158. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84159. * This function will create a new buffer if the current one is not updatable
  84160. * @param data defines the data to store
  84161. */
  84162. update(data: DataArray): void;
  84163. /**
  84164. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84165. * Returns the directly updated WebGLBuffer.
  84166. * @param data the new data
  84167. * @param offset the new offset
  84168. * @param useBytes set to true if the offset is in bytes
  84169. */
  84170. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84171. /**
  84172. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84173. */
  84174. dispose(): void;
  84175. /**
  84176. * Enumerates each value of this vertex buffer as numbers.
  84177. * @param count the number of values to enumerate
  84178. * @param callback the callback function called for each value
  84179. */
  84180. forEach(count: number, callback: (value: number, index: number) => void): void;
  84181. /**
  84182. * Positions
  84183. */
  84184. static readonly PositionKind: string;
  84185. /**
  84186. * Normals
  84187. */
  84188. static readonly NormalKind: string;
  84189. /**
  84190. * Tangents
  84191. */
  84192. static readonly TangentKind: string;
  84193. /**
  84194. * Texture coordinates
  84195. */
  84196. static readonly UVKind: string;
  84197. /**
  84198. * Texture coordinates 2
  84199. */
  84200. static readonly UV2Kind: string;
  84201. /**
  84202. * Texture coordinates 3
  84203. */
  84204. static readonly UV3Kind: string;
  84205. /**
  84206. * Texture coordinates 4
  84207. */
  84208. static readonly UV4Kind: string;
  84209. /**
  84210. * Texture coordinates 5
  84211. */
  84212. static readonly UV5Kind: string;
  84213. /**
  84214. * Texture coordinates 6
  84215. */
  84216. static readonly UV6Kind: string;
  84217. /**
  84218. * Colors
  84219. */
  84220. static readonly ColorKind: string;
  84221. /**
  84222. * Matrix indices (for bones)
  84223. */
  84224. static readonly MatricesIndicesKind: string;
  84225. /**
  84226. * Matrix weights (for bones)
  84227. */
  84228. static readonly MatricesWeightsKind: string;
  84229. /**
  84230. * Additional matrix indices (for bones)
  84231. */
  84232. static readonly MatricesIndicesExtraKind: string;
  84233. /**
  84234. * Additional matrix weights (for bones)
  84235. */
  84236. static readonly MatricesWeightsExtraKind: string;
  84237. /**
  84238. * Deduces the stride given a kind.
  84239. * @param kind The kind string to deduce
  84240. * @returns The deduced stride
  84241. */
  84242. static DeduceStride(kind: string): number;
  84243. /**
  84244. * Gets the byte length of the given type.
  84245. * @param type the type
  84246. * @returns the number of bytes
  84247. */
  84248. static GetTypeByteLength(type: number): number;
  84249. /**
  84250. * Enumerates each value of the given parameters as numbers.
  84251. * @param data the data to enumerate
  84252. * @param byteOffset the byte offset of the data
  84253. * @param byteStride the byte stride of the data
  84254. * @param componentCount the number of components per element
  84255. * @param componentType the type of the component
  84256. * @param count the number of values to enumerate
  84257. * @param normalized whether the data is normalized
  84258. * @param callback the callback function called for each value
  84259. */
  84260. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84261. private static _GetFloatValue;
  84262. }
  84263. }
  84264. declare module BABYLON {
  84265. /**
  84266. * @hidden
  84267. */
  84268. export class IntersectionInfo {
  84269. bu: Nullable<number>;
  84270. bv: Nullable<number>;
  84271. distance: number;
  84272. faceId: number;
  84273. subMeshId: number;
  84274. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84275. }
  84276. }
  84277. declare module BABYLON {
  84278. /**
  84279. * Class used to store bounding sphere information
  84280. */
  84281. export class BoundingSphere {
  84282. /**
  84283. * Gets the center of the bounding sphere in local space
  84284. */
  84285. readonly center: Vector3;
  84286. /**
  84287. * Radius of the bounding sphere in local space
  84288. */
  84289. radius: number;
  84290. /**
  84291. * Gets the center of the bounding sphere in world space
  84292. */
  84293. readonly centerWorld: Vector3;
  84294. /**
  84295. * Radius of the bounding sphere in world space
  84296. */
  84297. radiusWorld: number;
  84298. /**
  84299. * Gets the minimum vector in local space
  84300. */
  84301. readonly minimum: Vector3;
  84302. /**
  84303. * Gets the maximum vector in local space
  84304. */
  84305. readonly maximum: Vector3;
  84306. private _worldMatrix;
  84307. private static readonly TmpVector3;
  84308. /**
  84309. * Creates a new bounding sphere
  84310. * @param min defines the minimum vector (in local space)
  84311. * @param max defines the maximum vector (in local space)
  84312. * @param worldMatrix defines the new world matrix
  84313. */
  84314. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84315. /**
  84316. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84317. * @param min defines the new minimum vector (in local space)
  84318. * @param max defines the new maximum vector (in local space)
  84319. * @param worldMatrix defines the new world matrix
  84320. */
  84321. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84322. /**
  84323. * Scale the current bounding sphere by applying a scale factor
  84324. * @param factor defines the scale factor to apply
  84325. * @returns the current bounding box
  84326. */
  84327. scale(factor: number): BoundingSphere;
  84328. /**
  84329. * Gets the world matrix of the bounding box
  84330. * @returns a matrix
  84331. */
  84332. getWorldMatrix(): DeepImmutable<Matrix>;
  84333. /** @hidden */
  84334. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84335. /**
  84336. * Tests if the bounding sphere is intersecting the frustum planes
  84337. * @param frustumPlanes defines the frustum planes to test
  84338. * @returns true if there is an intersection
  84339. */
  84340. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84341. /**
  84342. * Tests if the bounding sphere center is in between the frustum planes.
  84343. * Used for optimistic fast inclusion.
  84344. * @param frustumPlanes defines the frustum planes to test
  84345. * @returns true if the sphere center is in between the frustum planes
  84346. */
  84347. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84348. /**
  84349. * Tests if a point is inside the bounding sphere
  84350. * @param point defines the point to test
  84351. * @returns true if the point is inside the bounding sphere
  84352. */
  84353. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84354. /**
  84355. * Checks if two sphere intersct
  84356. * @param sphere0 sphere 0
  84357. * @param sphere1 sphere 1
  84358. * @returns true if the speres intersect
  84359. */
  84360. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84361. }
  84362. }
  84363. declare module BABYLON {
  84364. /**
  84365. * Class used to store bounding box information
  84366. */
  84367. export class BoundingBox implements ICullable {
  84368. /**
  84369. * Gets the 8 vectors representing the bounding box in local space
  84370. */
  84371. readonly vectors: Vector3[];
  84372. /**
  84373. * Gets the center of the bounding box in local space
  84374. */
  84375. readonly center: Vector3;
  84376. /**
  84377. * Gets the center of the bounding box in world space
  84378. */
  84379. readonly centerWorld: Vector3;
  84380. /**
  84381. * Gets the extend size in local space
  84382. */
  84383. readonly extendSize: Vector3;
  84384. /**
  84385. * Gets the extend size in world space
  84386. */
  84387. readonly extendSizeWorld: Vector3;
  84388. /**
  84389. * Gets the OBB (object bounding box) directions
  84390. */
  84391. readonly directions: Vector3[];
  84392. /**
  84393. * Gets the 8 vectors representing the bounding box in world space
  84394. */
  84395. readonly vectorsWorld: Vector3[];
  84396. /**
  84397. * Gets the minimum vector in world space
  84398. */
  84399. readonly minimumWorld: Vector3;
  84400. /**
  84401. * Gets the maximum vector in world space
  84402. */
  84403. readonly maximumWorld: Vector3;
  84404. /**
  84405. * Gets the minimum vector in local space
  84406. */
  84407. readonly minimum: Vector3;
  84408. /**
  84409. * Gets the maximum vector in local space
  84410. */
  84411. readonly maximum: Vector3;
  84412. private _worldMatrix;
  84413. private static readonly TmpVector3;
  84414. /**
  84415. * @hidden
  84416. */
  84417. _tag: number;
  84418. /**
  84419. * Creates a new bounding box
  84420. * @param min defines the minimum vector (in local space)
  84421. * @param max defines the maximum vector (in local space)
  84422. * @param worldMatrix defines the new world matrix
  84423. */
  84424. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84425. /**
  84426. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84427. * @param min defines the new minimum vector (in local space)
  84428. * @param max defines the new maximum vector (in local space)
  84429. * @param worldMatrix defines the new world matrix
  84430. */
  84431. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84432. /**
  84433. * Scale the current bounding box by applying a scale factor
  84434. * @param factor defines the scale factor to apply
  84435. * @returns the current bounding box
  84436. */
  84437. scale(factor: number): BoundingBox;
  84438. /**
  84439. * Gets the world matrix of the bounding box
  84440. * @returns a matrix
  84441. */
  84442. getWorldMatrix(): DeepImmutable<Matrix>;
  84443. /** @hidden */
  84444. _update(world: DeepImmutable<Matrix>): void;
  84445. /**
  84446. * Tests if the bounding box is intersecting the frustum planes
  84447. * @param frustumPlanes defines the frustum planes to test
  84448. * @returns true if there is an intersection
  84449. */
  84450. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84451. /**
  84452. * Tests if the bounding box is entirely inside the frustum planes
  84453. * @param frustumPlanes defines the frustum planes to test
  84454. * @returns true if there is an inclusion
  84455. */
  84456. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84457. /**
  84458. * Tests if a point is inside the bounding box
  84459. * @param point defines the point to test
  84460. * @returns true if the point is inside the bounding box
  84461. */
  84462. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84463. /**
  84464. * Tests if the bounding box intersects with a bounding sphere
  84465. * @param sphere defines the sphere to test
  84466. * @returns true if there is an intersection
  84467. */
  84468. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84469. /**
  84470. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84471. * @param min defines the min vector to use
  84472. * @param max defines the max vector to use
  84473. * @returns true if there is an intersection
  84474. */
  84475. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84476. /**
  84477. * Tests if two bounding boxes are intersections
  84478. * @param box0 defines the first box to test
  84479. * @param box1 defines the second box to test
  84480. * @returns true if there is an intersection
  84481. */
  84482. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84483. /**
  84484. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84485. * @param minPoint defines the minimum vector of the bounding box
  84486. * @param maxPoint defines the maximum vector of the bounding box
  84487. * @param sphereCenter defines the sphere center
  84488. * @param sphereRadius defines the sphere radius
  84489. * @returns true if there is an intersection
  84490. */
  84491. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84492. /**
  84493. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84494. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84495. * @param frustumPlanes defines the frustum planes to test
  84496. * @return true if there is an inclusion
  84497. */
  84498. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84499. /**
  84500. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84501. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84502. * @param frustumPlanes defines the frustum planes to test
  84503. * @return true if there is an intersection
  84504. */
  84505. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84506. }
  84507. }
  84508. declare module BABYLON {
  84509. /** @hidden */
  84510. export class Collider {
  84511. /** Define if a collision was found */
  84512. collisionFound: boolean;
  84513. /**
  84514. * Define last intersection point in local space
  84515. */
  84516. intersectionPoint: Vector3;
  84517. /**
  84518. * Define last collided mesh
  84519. */
  84520. collidedMesh: Nullable<AbstractMesh>;
  84521. private _collisionPoint;
  84522. private _planeIntersectionPoint;
  84523. private _tempVector;
  84524. private _tempVector2;
  84525. private _tempVector3;
  84526. private _tempVector4;
  84527. private _edge;
  84528. private _baseToVertex;
  84529. private _destinationPoint;
  84530. private _slidePlaneNormal;
  84531. private _displacementVector;
  84532. /** @hidden */
  84533. _radius: Vector3;
  84534. /** @hidden */
  84535. _retry: number;
  84536. private _velocity;
  84537. private _basePoint;
  84538. private _epsilon;
  84539. /** @hidden */
  84540. _velocityWorldLength: number;
  84541. /** @hidden */
  84542. _basePointWorld: Vector3;
  84543. private _velocityWorld;
  84544. private _normalizedVelocity;
  84545. /** @hidden */
  84546. _initialVelocity: Vector3;
  84547. /** @hidden */
  84548. _initialPosition: Vector3;
  84549. private _nearestDistance;
  84550. private _collisionMask;
  84551. get collisionMask(): number;
  84552. set collisionMask(mask: number);
  84553. /**
  84554. * Gets the plane normal used to compute the sliding response (in local space)
  84555. */
  84556. get slidePlaneNormal(): Vector3;
  84557. /** @hidden */
  84558. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84559. /** @hidden */
  84560. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84561. /** @hidden */
  84562. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84563. /** @hidden */
  84564. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84565. /** @hidden */
  84566. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84567. /** @hidden */
  84568. _getResponse(pos: Vector3, vel: Vector3): void;
  84569. }
  84570. }
  84571. declare module BABYLON {
  84572. /**
  84573. * Interface for cullable objects
  84574. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84575. */
  84576. export interface ICullable {
  84577. /**
  84578. * Checks if the object or part of the object is in the frustum
  84579. * @param frustumPlanes Camera near/planes
  84580. * @returns true if the object is in frustum otherwise false
  84581. */
  84582. isInFrustum(frustumPlanes: Plane[]): boolean;
  84583. /**
  84584. * Checks if a cullable object (mesh...) is in the camera frustum
  84585. * Unlike isInFrustum this cheks the full bounding box
  84586. * @param frustumPlanes Camera near/planes
  84587. * @returns true if the object is in frustum otherwise false
  84588. */
  84589. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84590. }
  84591. /**
  84592. * Info for a bounding data of a mesh
  84593. */
  84594. export class BoundingInfo implements ICullable {
  84595. /**
  84596. * Bounding box for the mesh
  84597. */
  84598. readonly boundingBox: BoundingBox;
  84599. /**
  84600. * Bounding sphere for the mesh
  84601. */
  84602. readonly boundingSphere: BoundingSphere;
  84603. private _isLocked;
  84604. private static readonly TmpVector3;
  84605. /**
  84606. * Constructs bounding info
  84607. * @param minimum min vector of the bounding box/sphere
  84608. * @param maximum max vector of the bounding box/sphere
  84609. * @param worldMatrix defines the new world matrix
  84610. */
  84611. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84612. /**
  84613. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84614. * @param min defines the new minimum vector (in local space)
  84615. * @param max defines the new maximum vector (in local space)
  84616. * @param worldMatrix defines the new world matrix
  84617. */
  84618. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84619. /**
  84620. * min vector of the bounding box/sphere
  84621. */
  84622. get minimum(): Vector3;
  84623. /**
  84624. * max vector of the bounding box/sphere
  84625. */
  84626. get maximum(): Vector3;
  84627. /**
  84628. * If the info is locked and won't be updated to avoid perf overhead
  84629. */
  84630. get isLocked(): boolean;
  84631. set isLocked(value: boolean);
  84632. /**
  84633. * Updates the bounding sphere and box
  84634. * @param world world matrix to be used to update
  84635. */
  84636. update(world: DeepImmutable<Matrix>): void;
  84637. /**
  84638. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84639. * @param center New center of the bounding info
  84640. * @param extend New extend of the bounding info
  84641. * @returns the current bounding info
  84642. */
  84643. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84644. /**
  84645. * Scale the current bounding info by applying a scale factor
  84646. * @param factor defines the scale factor to apply
  84647. * @returns the current bounding info
  84648. */
  84649. scale(factor: number): BoundingInfo;
  84650. /**
  84651. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84652. * @param frustumPlanes defines the frustum to test
  84653. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84654. * @returns true if the bounding info is in the frustum planes
  84655. */
  84656. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84657. /**
  84658. * Gets the world distance between the min and max points of the bounding box
  84659. */
  84660. get diagonalLength(): number;
  84661. /**
  84662. * Checks if a cullable object (mesh...) is in the camera frustum
  84663. * Unlike isInFrustum this cheks the full bounding box
  84664. * @param frustumPlanes Camera near/planes
  84665. * @returns true if the object is in frustum otherwise false
  84666. */
  84667. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84668. /** @hidden */
  84669. _checkCollision(collider: Collider): boolean;
  84670. /**
  84671. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84672. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84673. * @param point the point to check intersection with
  84674. * @returns if the point intersects
  84675. */
  84676. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84677. /**
  84678. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84679. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84680. * @param boundingInfo the bounding info to check intersection with
  84681. * @param precise if the intersection should be done using OBB
  84682. * @returns if the bounding info intersects
  84683. */
  84684. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84685. }
  84686. }
  84687. declare module BABYLON {
  84688. /**
  84689. * Extracts minimum and maximum values from a list of indexed positions
  84690. * @param positions defines the positions to use
  84691. * @param indices defines the indices to the positions
  84692. * @param indexStart defines the start index
  84693. * @param indexCount defines the end index
  84694. * @param bias defines bias value to add to the result
  84695. * @return minimum and maximum values
  84696. */
  84697. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84698. minimum: Vector3;
  84699. maximum: Vector3;
  84700. };
  84701. /**
  84702. * Extracts minimum and maximum values from a list of positions
  84703. * @param positions defines the positions to use
  84704. * @param start defines the start index in the positions array
  84705. * @param count defines the number of positions to handle
  84706. * @param bias defines bias value to add to the result
  84707. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84708. * @return minimum and maximum values
  84709. */
  84710. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84711. minimum: Vector3;
  84712. maximum: Vector3;
  84713. };
  84714. }
  84715. declare module BABYLON {
  84716. /** @hidden */
  84717. export class WebGLDataBuffer extends DataBuffer {
  84718. private _buffer;
  84719. constructor(resource: WebGLBuffer);
  84720. get underlyingResource(): any;
  84721. }
  84722. }
  84723. declare module BABYLON {
  84724. /** @hidden */
  84725. export class WebGLPipelineContext implements IPipelineContext {
  84726. engine: ThinEngine;
  84727. program: Nullable<WebGLProgram>;
  84728. context?: WebGLRenderingContext;
  84729. vertexShader?: WebGLShader;
  84730. fragmentShader?: WebGLShader;
  84731. isParallelCompiled: boolean;
  84732. onCompiled?: () => void;
  84733. transformFeedback?: WebGLTransformFeedback | null;
  84734. vertexCompilationError: Nullable<string>;
  84735. fragmentCompilationError: Nullable<string>;
  84736. programLinkError: Nullable<string>;
  84737. programValidationError: Nullable<string>;
  84738. get isAsync(): boolean;
  84739. get isReady(): boolean;
  84740. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84741. _getVertexShaderCode(): string | null;
  84742. _getFragmentShaderCode(): string | null;
  84743. }
  84744. }
  84745. declare module BABYLON {
  84746. interface ThinEngine {
  84747. /**
  84748. * Create an uniform buffer
  84749. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84750. * @param elements defines the content of the uniform buffer
  84751. * @returns the webGL uniform buffer
  84752. */
  84753. createUniformBuffer(elements: FloatArray): DataBuffer;
  84754. /**
  84755. * Create a dynamic uniform buffer
  84756. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84757. * @param elements defines the content of the uniform buffer
  84758. * @returns the webGL uniform buffer
  84759. */
  84760. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84761. /**
  84762. * Update an existing uniform buffer
  84763. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84764. * @param uniformBuffer defines the target uniform buffer
  84765. * @param elements defines the content to update
  84766. * @param offset defines the offset in the uniform buffer where update should start
  84767. * @param count defines the size of the data to update
  84768. */
  84769. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84770. /**
  84771. * Bind an uniform buffer to the current webGL context
  84772. * @param buffer defines the buffer to bind
  84773. */
  84774. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84775. /**
  84776. * Bind a buffer to the current webGL context at a given location
  84777. * @param buffer defines the buffer to bind
  84778. * @param location defines the index where to bind the buffer
  84779. */
  84780. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84781. /**
  84782. * Bind a specific block at a given index in a specific shader program
  84783. * @param pipelineContext defines the pipeline context to use
  84784. * @param blockName defines the block name
  84785. * @param index defines the index where to bind the block
  84786. */
  84787. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84788. }
  84789. }
  84790. declare module BABYLON {
  84791. /**
  84792. * Uniform buffer objects.
  84793. *
  84794. * Handles blocks of uniform on the GPU.
  84795. *
  84796. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84797. *
  84798. * For more information, please refer to :
  84799. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84800. */
  84801. export class UniformBuffer {
  84802. private _engine;
  84803. private _buffer;
  84804. private _data;
  84805. private _bufferData;
  84806. private _dynamic?;
  84807. private _uniformLocations;
  84808. private _uniformSizes;
  84809. private _uniformLocationPointer;
  84810. private _needSync;
  84811. private _noUBO;
  84812. private _currentEffect;
  84813. /** @hidden */
  84814. _alreadyBound: boolean;
  84815. private static _MAX_UNIFORM_SIZE;
  84816. private static _tempBuffer;
  84817. /**
  84818. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84819. * This is dynamic to allow compat with webgl 1 and 2.
  84820. * You will need to pass the name of the uniform as well as the value.
  84821. */
  84822. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84823. /**
  84824. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84825. * This is dynamic to allow compat with webgl 1 and 2.
  84826. * You will need to pass the name of the uniform as well as the value.
  84827. */
  84828. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84829. /**
  84830. * Lambda to Update a single float in a uniform buffer.
  84831. * This is dynamic to allow compat with webgl 1 and 2.
  84832. * You will need to pass the name of the uniform as well as the value.
  84833. */
  84834. updateFloat: (name: string, x: number) => void;
  84835. /**
  84836. * Lambda to Update a vec2 of float in a uniform buffer.
  84837. * This is dynamic to allow compat with webgl 1 and 2.
  84838. * You will need to pass the name of the uniform as well as the value.
  84839. */
  84840. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84841. /**
  84842. * Lambda to Update a vec3 of float in a uniform buffer.
  84843. * This is dynamic to allow compat with webgl 1 and 2.
  84844. * You will need to pass the name of the uniform as well as the value.
  84845. */
  84846. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84847. /**
  84848. * Lambda to Update a vec4 of float in a uniform buffer.
  84849. * This is dynamic to allow compat with webgl 1 and 2.
  84850. * You will need to pass the name of the uniform as well as the value.
  84851. */
  84852. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84853. /**
  84854. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84855. * This is dynamic to allow compat with webgl 1 and 2.
  84856. * You will need to pass the name of the uniform as well as the value.
  84857. */
  84858. updateMatrix: (name: string, mat: Matrix) => void;
  84859. /**
  84860. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84861. * This is dynamic to allow compat with webgl 1 and 2.
  84862. * You will need to pass the name of the uniform as well as the value.
  84863. */
  84864. updateVector3: (name: string, vector: Vector3) => void;
  84865. /**
  84866. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84867. * This is dynamic to allow compat with webgl 1 and 2.
  84868. * You will need to pass the name of the uniform as well as the value.
  84869. */
  84870. updateVector4: (name: string, vector: Vector4) => void;
  84871. /**
  84872. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84873. * This is dynamic to allow compat with webgl 1 and 2.
  84874. * You will need to pass the name of the uniform as well as the value.
  84875. */
  84876. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84877. /**
  84878. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84879. * This is dynamic to allow compat with webgl 1 and 2.
  84880. * You will need to pass the name of the uniform as well as the value.
  84881. */
  84882. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84883. /**
  84884. * Instantiates a new Uniform buffer objects.
  84885. *
  84886. * Handles blocks of uniform on the GPU.
  84887. *
  84888. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84889. *
  84890. * For more information, please refer to :
  84891. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84892. * @param engine Define the engine the buffer is associated with
  84893. * @param data Define the data contained in the buffer
  84894. * @param dynamic Define if the buffer is updatable
  84895. */
  84896. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84897. /**
  84898. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84899. * or just falling back on setUniformXXX calls.
  84900. */
  84901. get useUbo(): boolean;
  84902. /**
  84903. * Indicates if the WebGL underlying uniform buffer is in sync
  84904. * with the javascript cache data.
  84905. */
  84906. get isSync(): boolean;
  84907. /**
  84908. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84909. * Also, a dynamic UniformBuffer will disable cache verification and always
  84910. * update the underlying WebGL uniform buffer to the GPU.
  84911. * @returns if Dynamic, otherwise false
  84912. */
  84913. isDynamic(): boolean;
  84914. /**
  84915. * The data cache on JS side.
  84916. * @returns the underlying data as a float array
  84917. */
  84918. getData(): Float32Array;
  84919. /**
  84920. * The underlying WebGL Uniform buffer.
  84921. * @returns the webgl buffer
  84922. */
  84923. getBuffer(): Nullable<DataBuffer>;
  84924. /**
  84925. * std140 layout specifies how to align data within an UBO structure.
  84926. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84927. * for specs.
  84928. */
  84929. private _fillAlignment;
  84930. /**
  84931. * Adds an uniform in the buffer.
  84932. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84933. * for the layout to be correct !
  84934. * @param name Name of the uniform, as used in the uniform block in the shader.
  84935. * @param size Data size, or data directly.
  84936. */
  84937. addUniform(name: string, size: number | number[]): void;
  84938. /**
  84939. * Adds a Matrix 4x4 to the uniform buffer.
  84940. * @param name Name of the uniform, as used in the uniform block in the shader.
  84941. * @param mat A 4x4 matrix.
  84942. */
  84943. addMatrix(name: string, mat: Matrix): void;
  84944. /**
  84945. * Adds a vec2 to the uniform buffer.
  84946. * @param name Name of the uniform, as used in the uniform block in the shader.
  84947. * @param x Define the x component value of the vec2
  84948. * @param y Define the y component value of the vec2
  84949. */
  84950. addFloat2(name: string, x: number, y: number): void;
  84951. /**
  84952. * Adds a vec3 to the uniform buffer.
  84953. * @param name Name of the uniform, as used in the uniform block in the shader.
  84954. * @param x Define the x component value of the vec3
  84955. * @param y Define the y component value of the vec3
  84956. * @param z Define the z component value of the vec3
  84957. */
  84958. addFloat3(name: string, x: number, y: number, z: number): void;
  84959. /**
  84960. * Adds a vec3 to the uniform buffer.
  84961. * @param name Name of the uniform, as used in the uniform block in the shader.
  84962. * @param color Define the vec3 from a Color
  84963. */
  84964. addColor3(name: string, color: Color3): void;
  84965. /**
  84966. * Adds a vec4 to the uniform buffer.
  84967. * @param name Name of the uniform, as used in the uniform block in the shader.
  84968. * @param color Define the rgb components from a Color
  84969. * @param alpha Define the a component of the vec4
  84970. */
  84971. addColor4(name: string, color: Color3, alpha: number): void;
  84972. /**
  84973. * Adds a vec3 to the uniform buffer.
  84974. * @param name Name of the uniform, as used in the uniform block in the shader.
  84975. * @param vector Define the vec3 components from a Vector
  84976. */
  84977. addVector3(name: string, vector: Vector3): void;
  84978. /**
  84979. * Adds a Matrix 3x3 to the uniform buffer.
  84980. * @param name Name of the uniform, as used in the uniform block in the shader.
  84981. */
  84982. addMatrix3x3(name: string): void;
  84983. /**
  84984. * Adds a Matrix 2x2 to the uniform buffer.
  84985. * @param name Name of the uniform, as used in the uniform block in the shader.
  84986. */
  84987. addMatrix2x2(name: string): void;
  84988. /**
  84989. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84990. */
  84991. create(): void;
  84992. /** @hidden */
  84993. _rebuild(): void;
  84994. /**
  84995. * Updates the WebGL Uniform Buffer on the GPU.
  84996. * If the `dynamic` flag is set to true, no cache comparison is done.
  84997. * Otherwise, the buffer will be updated only if the cache differs.
  84998. */
  84999. update(): void;
  85000. /**
  85001. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85002. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85003. * @param data Define the flattened data
  85004. * @param size Define the size of the data.
  85005. */
  85006. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85007. private _valueCache;
  85008. private _cacheMatrix;
  85009. private _updateMatrix3x3ForUniform;
  85010. private _updateMatrix3x3ForEffect;
  85011. private _updateMatrix2x2ForEffect;
  85012. private _updateMatrix2x2ForUniform;
  85013. private _updateFloatForEffect;
  85014. private _updateFloatForUniform;
  85015. private _updateFloat2ForEffect;
  85016. private _updateFloat2ForUniform;
  85017. private _updateFloat3ForEffect;
  85018. private _updateFloat3ForUniform;
  85019. private _updateFloat4ForEffect;
  85020. private _updateFloat4ForUniform;
  85021. private _updateMatrixForEffect;
  85022. private _updateMatrixForUniform;
  85023. private _updateVector3ForEffect;
  85024. private _updateVector3ForUniform;
  85025. private _updateVector4ForEffect;
  85026. private _updateVector4ForUniform;
  85027. private _updateColor3ForEffect;
  85028. private _updateColor3ForUniform;
  85029. private _updateColor4ForEffect;
  85030. private _updateColor4ForUniform;
  85031. /**
  85032. * Sets a sampler uniform on the effect.
  85033. * @param name Define the name of the sampler.
  85034. * @param texture Define the texture to set in the sampler
  85035. */
  85036. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85037. /**
  85038. * Directly updates the value of the uniform in the cache AND on the GPU.
  85039. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85040. * @param data Define the flattened data
  85041. */
  85042. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85043. /**
  85044. * Binds this uniform buffer to an effect.
  85045. * @param effect Define the effect to bind the buffer to
  85046. * @param name Name of the uniform block in the shader.
  85047. */
  85048. bindToEffect(effect: Effect, name: string): void;
  85049. /**
  85050. * Disposes the uniform buffer.
  85051. */
  85052. dispose(): void;
  85053. }
  85054. }
  85055. declare module BABYLON {
  85056. /**
  85057. * Enum that determines the text-wrapping mode to use.
  85058. */
  85059. export enum InspectableType {
  85060. /**
  85061. * Checkbox for booleans
  85062. */
  85063. Checkbox = 0,
  85064. /**
  85065. * Sliders for numbers
  85066. */
  85067. Slider = 1,
  85068. /**
  85069. * Vector3
  85070. */
  85071. Vector3 = 2,
  85072. /**
  85073. * Quaternions
  85074. */
  85075. Quaternion = 3,
  85076. /**
  85077. * Color3
  85078. */
  85079. Color3 = 4,
  85080. /**
  85081. * String
  85082. */
  85083. String = 5
  85084. }
  85085. /**
  85086. * Interface used to define custom inspectable properties.
  85087. * This interface is used by the inspector to display custom property grids
  85088. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85089. */
  85090. export interface IInspectable {
  85091. /**
  85092. * Gets the label to display
  85093. */
  85094. label: string;
  85095. /**
  85096. * Gets the name of the property to edit
  85097. */
  85098. propertyName: string;
  85099. /**
  85100. * Gets the type of the editor to use
  85101. */
  85102. type: InspectableType;
  85103. /**
  85104. * Gets the minimum value of the property when using in "slider" mode
  85105. */
  85106. min?: number;
  85107. /**
  85108. * Gets the maximum value of the property when using in "slider" mode
  85109. */
  85110. max?: number;
  85111. /**
  85112. * Gets the setp to use when using in "slider" mode
  85113. */
  85114. step?: number;
  85115. }
  85116. }
  85117. declare module BABYLON {
  85118. /**
  85119. * Class used to provide helper for timing
  85120. */
  85121. export class TimingTools {
  85122. /**
  85123. * Polyfill for setImmediate
  85124. * @param action defines the action to execute after the current execution block
  85125. */
  85126. static SetImmediate(action: () => void): void;
  85127. }
  85128. }
  85129. declare module BABYLON {
  85130. /**
  85131. * Class used to enable instatition of objects by class name
  85132. */
  85133. export class InstantiationTools {
  85134. /**
  85135. * Use this object to register external classes like custom textures or material
  85136. * to allow the laoders to instantiate them
  85137. */
  85138. static RegisteredExternalClasses: {
  85139. [key: string]: Object;
  85140. };
  85141. /**
  85142. * Tries to instantiate a new object from a given class name
  85143. * @param className defines the class name to instantiate
  85144. * @returns the new object or null if the system was not able to do the instantiation
  85145. */
  85146. static Instantiate(className: string): any;
  85147. }
  85148. }
  85149. declare module BABYLON {
  85150. /**
  85151. * Define options used to create a depth texture
  85152. */
  85153. export class DepthTextureCreationOptions {
  85154. /** Specifies whether or not a stencil should be allocated in the texture */
  85155. generateStencil?: boolean;
  85156. /** Specifies whether or not bilinear filtering is enable on the texture */
  85157. bilinearFiltering?: boolean;
  85158. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85159. comparisonFunction?: number;
  85160. /** Specifies if the created texture is a cube texture */
  85161. isCube?: boolean;
  85162. }
  85163. }
  85164. declare module BABYLON {
  85165. interface ThinEngine {
  85166. /**
  85167. * Creates a depth stencil cube texture.
  85168. * This is only available in WebGL 2.
  85169. * @param size The size of face edge in the cube texture.
  85170. * @param options The options defining the cube texture.
  85171. * @returns The cube texture
  85172. */
  85173. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85174. /**
  85175. * Creates a cube texture
  85176. * @param rootUrl defines the url where the files to load is located
  85177. * @param scene defines the current scene
  85178. * @param files defines the list of files to load (1 per face)
  85179. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85180. * @param onLoad defines an optional callback raised when the texture is loaded
  85181. * @param onError defines an optional callback raised if there is an issue to load the texture
  85182. * @param format defines the format of the data
  85183. * @param forcedExtension defines the extension to use to pick the right loader
  85184. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85185. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85186. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85187. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85188. * @returns the cube texture as an InternalTexture
  85189. */
  85190. 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;
  85191. /**
  85192. * Creates a cube texture
  85193. * @param rootUrl defines the url where the files to load is located
  85194. * @param scene defines the current scene
  85195. * @param files defines the list of files to load (1 per face)
  85196. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85197. * @param onLoad defines an optional callback raised when the texture is loaded
  85198. * @param onError defines an optional callback raised if there is an issue to load the texture
  85199. * @param format defines the format of the data
  85200. * @param forcedExtension defines the extension to use to pick the right loader
  85201. * @returns the cube texture as an InternalTexture
  85202. */
  85203. 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;
  85204. /**
  85205. * Creates a cube texture
  85206. * @param rootUrl defines the url where the files to load is located
  85207. * @param scene defines the current scene
  85208. * @param files defines the list of files to load (1 per face)
  85209. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85210. * @param onLoad defines an optional callback raised when the texture is loaded
  85211. * @param onError defines an optional callback raised if there is an issue to load the texture
  85212. * @param format defines the format of the data
  85213. * @param forcedExtension defines the extension to use to pick the right loader
  85214. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85215. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85216. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85217. * @returns the cube texture as an InternalTexture
  85218. */
  85219. 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;
  85220. /** @hidden */
  85221. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85222. /** @hidden */
  85223. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85224. /** @hidden */
  85225. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85226. /** @hidden */
  85227. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85228. /**
  85229. * @hidden
  85230. */
  85231. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85232. }
  85233. }
  85234. declare module BABYLON {
  85235. /**
  85236. * Class for creating a cube texture
  85237. */
  85238. export class CubeTexture extends BaseTexture {
  85239. private _delayedOnLoad;
  85240. /**
  85241. * Observable triggered once the texture has been loaded.
  85242. */
  85243. onLoadObservable: Observable<CubeTexture>;
  85244. /**
  85245. * The url of the texture
  85246. */
  85247. url: string;
  85248. /**
  85249. * Gets or sets the center of the bounding box associated with the cube texture.
  85250. * It must define where the camera used to render the texture was set
  85251. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85252. */
  85253. boundingBoxPosition: Vector3;
  85254. private _boundingBoxSize;
  85255. /**
  85256. * Gets or sets the size of the bounding box associated with the cube texture
  85257. * When defined, the cubemap will switch to local mode
  85258. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85259. * @example https://www.babylonjs-playground.com/#RNASML
  85260. */
  85261. set boundingBoxSize(value: Vector3);
  85262. /**
  85263. * Returns the bounding box size
  85264. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85265. */
  85266. get boundingBoxSize(): Vector3;
  85267. protected _rotationY: number;
  85268. /**
  85269. * Sets texture matrix rotation angle around Y axis in radians.
  85270. */
  85271. set rotationY(value: number);
  85272. /**
  85273. * Gets texture matrix rotation angle around Y axis radians.
  85274. */
  85275. get rotationY(): number;
  85276. /**
  85277. * Are mip maps generated for this texture or not.
  85278. */
  85279. get noMipmap(): boolean;
  85280. private _noMipmap;
  85281. private _files;
  85282. protected _forcedExtension: Nullable<string>;
  85283. private _extensions;
  85284. private _textureMatrix;
  85285. private _format;
  85286. private _createPolynomials;
  85287. /**
  85288. * Creates a cube texture from an array of image urls
  85289. * @param files defines an array of image urls
  85290. * @param scene defines the hosting scene
  85291. * @param noMipmap specifies if mip maps are not used
  85292. * @returns a cube texture
  85293. */
  85294. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85295. /**
  85296. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85297. * @param url defines the url of the prefiltered texture
  85298. * @param scene defines the scene the texture is attached to
  85299. * @param forcedExtension defines the extension of the file if different from the url
  85300. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85301. * @return the prefiltered texture
  85302. */
  85303. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85304. /**
  85305. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85306. * as prefiltered data.
  85307. * @param rootUrl defines the url of the texture or the root name of the six images
  85308. * @param null defines the scene or engine the texture is attached to
  85309. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85310. * @param noMipmap defines if mipmaps should be created or not
  85311. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85312. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85313. * @param onError defines a callback triggered in case of error during load
  85314. * @param format defines the internal format to use for the texture once loaded
  85315. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85316. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85317. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85318. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85319. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85320. * @return the cube texture
  85321. */
  85322. 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);
  85323. /**
  85324. * Get the current class name of the texture useful for serialization or dynamic coding.
  85325. * @returns "CubeTexture"
  85326. */
  85327. getClassName(): string;
  85328. /**
  85329. * Update the url (and optional buffer) of this texture if url was null during construction.
  85330. * @param url the url of the texture
  85331. * @param forcedExtension defines the extension to use
  85332. * @param onLoad callback called when the texture is loaded (defaults to null)
  85333. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85334. */
  85335. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85336. /**
  85337. * Delays loading of the cube texture
  85338. * @param forcedExtension defines the extension to use
  85339. */
  85340. delayLoad(forcedExtension?: string): void;
  85341. /**
  85342. * Returns the reflection texture matrix
  85343. * @returns the reflection texture matrix
  85344. */
  85345. getReflectionTextureMatrix(): Matrix;
  85346. /**
  85347. * Sets the reflection texture matrix
  85348. * @param value Reflection texture matrix
  85349. */
  85350. setReflectionTextureMatrix(value: Matrix): void;
  85351. /**
  85352. * Parses text to create a cube texture
  85353. * @param parsedTexture define the serialized text to read from
  85354. * @param scene defines the hosting scene
  85355. * @param rootUrl defines the root url of the cube texture
  85356. * @returns a cube texture
  85357. */
  85358. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85359. /**
  85360. * Makes a clone, or deep copy, of the cube texture
  85361. * @returns a new cube texture
  85362. */
  85363. clone(): CubeTexture;
  85364. }
  85365. }
  85366. declare module BABYLON {
  85367. /**
  85368. * Manages the defines for the Material
  85369. */
  85370. export class MaterialDefines {
  85371. /** @hidden */
  85372. protected _keys: string[];
  85373. private _isDirty;
  85374. /** @hidden */
  85375. _renderId: number;
  85376. /** @hidden */
  85377. _areLightsDirty: boolean;
  85378. /** @hidden */
  85379. _areLightsDisposed: boolean;
  85380. /** @hidden */
  85381. _areAttributesDirty: boolean;
  85382. /** @hidden */
  85383. _areTexturesDirty: boolean;
  85384. /** @hidden */
  85385. _areFresnelDirty: boolean;
  85386. /** @hidden */
  85387. _areMiscDirty: boolean;
  85388. /** @hidden */
  85389. _areImageProcessingDirty: boolean;
  85390. /** @hidden */
  85391. _normals: boolean;
  85392. /** @hidden */
  85393. _uvs: boolean;
  85394. /** @hidden */
  85395. _needNormals: boolean;
  85396. /** @hidden */
  85397. _needUVs: boolean;
  85398. [id: string]: any;
  85399. /**
  85400. * Specifies if the material needs to be re-calculated
  85401. */
  85402. get isDirty(): boolean;
  85403. /**
  85404. * Marks the material to indicate that it has been re-calculated
  85405. */
  85406. markAsProcessed(): void;
  85407. /**
  85408. * Marks the material to indicate that it needs to be re-calculated
  85409. */
  85410. markAsUnprocessed(): void;
  85411. /**
  85412. * Marks the material to indicate all of its defines need to be re-calculated
  85413. */
  85414. markAllAsDirty(): void;
  85415. /**
  85416. * Marks the material to indicate that image processing needs to be re-calculated
  85417. */
  85418. markAsImageProcessingDirty(): void;
  85419. /**
  85420. * Marks the material to indicate the lights need to be re-calculated
  85421. * @param disposed Defines whether the light is dirty due to dispose or not
  85422. */
  85423. markAsLightDirty(disposed?: boolean): void;
  85424. /**
  85425. * Marks the attribute state as changed
  85426. */
  85427. markAsAttributesDirty(): void;
  85428. /**
  85429. * Marks the texture state as changed
  85430. */
  85431. markAsTexturesDirty(): void;
  85432. /**
  85433. * Marks the fresnel state as changed
  85434. */
  85435. markAsFresnelDirty(): void;
  85436. /**
  85437. * Marks the misc state as changed
  85438. */
  85439. markAsMiscDirty(): void;
  85440. /**
  85441. * Rebuilds the material defines
  85442. */
  85443. rebuild(): void;
  85444. /**
  85445. * Specifies if two material defines are equal
  85446. * @param other - A material define instance to compare to
  85447. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85448. */
  85449. isEqual(other: MaterialDefines): boolean;
  85450. /**
  85451. * Clones this instance's defines to another instance
  85452. * @param other - material defines to clone values to
  85453. */
  85454. cloneTo(other: MaterialDefines): void;
  85455. /**
  85456. * Resets the material define values
  85457. */
  85458. reset(): void;
  85459. /**
  85460. * Converts the material define values to a string
  85461. * @returns - String of material define information
  85462. */
  85463. toString(): string;
  85464. }
  85465. }
  85466. declare module BABYLON {
  85467. /**
  85468. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85469. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85470. * 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;
  85471. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85472. */
  85473. export class ColorCurves {
  85474. private _dirty;
  85475. private _tempColor;
  85476. private _globalCurve;
  85477. private _highlightsCurve;
  85478. private _midtonesCurve;
  85479. private _shadowsCurve;
  85480. private _positiveCurve;
  85481. private _negativeCurve;
  85482. private _globalHue;
  85483. private _globalDensity;
  85484. private _globalSaturation;
  85485. private _globalExposure;
  85486. /**
  85487. * Gets the global Hue value.
  85488. * 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).
  85489. */
  85490. get globalHue(): number;
  85491. /**
  85492. * Sets the global Hue value.
  85493. * 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).
  85494. */
  85495. set globalHue(value: number);
  85496. /**
  85497. * Gets the global Density value.
  85498. * 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.
  85499. * Values less than zero provide a filter of opposite hue.
  85500. */
  85501. get globalDensity(): number;
  85502. /**
  85503. * Sets the global Density value.
  85504. * 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.
  85505. * Values less than zero provide a filter of opposite hue.
  85506. */
  85507. set globalDensity(value: number);
  85508. /**
  85509. * Gets the global Saturation value.
  85510. * 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.
  85511. */
  85512. get globalSaturation(): number;
  85513. /**
  85514. * Sets the global Saturation value.
  85515. * 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.
  85516. */
  85517. set globalSaturation(value: number);
  85518. /**
  85519. * Gets the global Exposure value.
  85520. * 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.
  85521. */
  85522. get globalExposure(): number;
  85523. /**
  85524. * Sets the global Exposure value.
  85525. * 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.
  85526. */
  85527. set globalExposure(value: number);
  85528. private _highlightsHue;
  85529. private _highlightsDensity;
  85530. private _highlightsSaturation;
  85531. private _highlightsExposure;
  85532. /**
  85533. * Gets the highlights Hue value.
  85534. * 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).
  85535. */
  85536. get highlightsHue(): number;
  85537. /**
  85538. * Sets the highlights Hue value.
  85539. * 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).
  85540. */
  85541. set highlightsHue(value: number);
  85542. /**
  85543. * Gets the highlights Density value.
  85544. * 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.
  85545. * Values less than zero provide a filter of opposite hue.
  85546. */
  85547. get highlightsDensity(): number;
  85548. /**
  85549. * Sets the highlights Density value.
  85550. * 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.
  85551. * Values less than zero provide a filter of opposite hue.
  85552. */
  85553. set highlightsDensity(value: number);
  85554. /**
  85555. * Gets the highlights Saturation value.
  85556. * 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.
  85557. */
  85558. get highlightsSaturation(): number;
  85559. /**
  85560. * Sets the highlights Saturation value.
  85561. * 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.
  85562. */
  85563. set highlightsSaturation(value: number);
  85564. /**
  85565. * Gets the highlights Exposure value.
  85566. * 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.
  85567. */
  85568. get highlightsExposure(): number;
  85569. /**
  85570. * Sets the highlights Exposure value.
  85571. * 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.
  85572. */
  85573. set highlightsExposure(value: number);
  85574. private _midtonesHue;
  85575. private _midtonesDensity;
  85576. private _midtonesSaturation;
  85577. private _midtonesExposure;
  85578. /**
  85579. * Gets the midtones Hue value.
  85580. * 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).
  85581. */
  85582. get midtonesHue(): number;
  85583. /**
  85584. * Sets the midtones Hue value.
  85585. * 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).
  85586. */
  85587. set midtonesHue(value: number);
  85588. /**
  85589. * Gets the midtones Density value.
  85590. * 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.
  85591. * Values less than zero provide a filter of opposite hue.
  85592. */
  85593. get midtonesDensity(): number;
  85594. /**
  85595. * Sets the midtones Density value.
  85596. * 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.
  85597. * Values less than zero provide a filter of opposite hue.
  85598. */
  85599. set midtonesDensity(value: number);
  85600. /**
  85601. * Gets the midtones Saturation value.
  85602. * 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.
  85603. */
  85604. get midtonesSaturation(): number;
  85605. /**
  85606. * Sets the midtones Saturation value.
  85607. * 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.
  85608. */
  85609. set midtonesSaturation(value: number);
  85610. /**
  85611. * Gets the midtones Exposure value.
  85612. * 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.
  85613. */
  85614. get midtonesExposure(): number;
  85615. /**
  85616. * Sets the midtones Exposure value.
  85617. * 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.
  85618. */
  85619. set midtonesExposure(value: number);
  85620. private _shadowsHue;
  85621. private _shadowsDensity;
  85622. private _shadowsSaturation;
  85623. private _shadowsExposure;
  85624. /**
  85625. * Gets the shadows Hue value.
  85626. * 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).
  85627. */
  85628. get shadowsHue(): number;
  85629. /**
  85630. * Sets the shadows Hue value.
  85631. * 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).
  85632. */
  85633. set shadowsHue(value: number);
  85634. /**
  85635. * Gets the shadows Density value.
  85636. * 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.
  85637. * Values less than zero provide a filter of opposite hue.
  85638. */
  85639. get shadowsDensity(): number;
  85640. /**
  85641. * Sets the shadows Density value.
  85642. * 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.
  85643. * Values less than zero provide a filter of opposite hue.
  85644. */
  85645. set shadowsDensity(value: number);
  85646. /**
  85647. * Gets the shadows Saturation value.
  85648. * 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.
  85649. */
  85650. get shadowsSaturation(): number;
  85651. /**
  85652. * Sets the shadows Saturation value.
  85653. * 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.
  85654. */
  85655. set shadowsSaturation(value: number);
  85656. /**
  85657. * Gets the shadows Exposure value.
  85658. * 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.
  85659. */
  85660. get shadowsExposure(): number;
  85661. /**
  85662. * Sets the shadows Exposure value.
  85663. * 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.
  85664. */
  85665. set shadowsExposure(value: number);
  85666. /**
  85667. * Returns the class name
  85668. * @returns The class name
  85669. */
  85670. getClassName(): string;
  85671. /**
  85672. * Binds the color curves to the shader.
  85673. * @param colorCurves The color curve to bind
  85674. * @param effect The effect to bind to
  85675. * @param positiveUniform The positive uniform shader parameter
  85676. * @param neutralUniform The neutral uniform shader parameter
  85677. * @param negativeUniform The negative uniform shader parameter
  85678. */
  85679. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85680. /**
  85681. * Prepare the list of uniforms associated with the ColorCurves effects.
  85682. * @param uniformsList The list of uniforms used in the effect
  85683. */
  85684. static PrepareUniforms(uniformsList: string[]): void;
  85685. /**
  85686. * Returns color grading data based on a hue, density, saturation and exposure value.
  85687. * @param filterHue The hue of the color filter.
  85688. * @param filterDensity The density of the color filter.
  85689. * @param saturation The saturation.
  85690. * @param exposure The exposure.
  85691. * @param result The result data container.
  85692. */
  85693. private getColorGradingDataToRef;
  85694. /**
  85695. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85696. * @param value The input slider value in range [-100,100].
  85697. * @returns Adjusted value.
  85698. */
  85699. private static applyColorGradingSliderNonlinear;
  85700. /**
  85701. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85702. * @param hue The hue (H) input.
  85703. * @param saturation The saturation (S) input.
  85704. * @param brightness The brightness (B) input.
  85705. * @result An RGBA color represented as Vector4.
  85706. */
  85707. private static fromHSBToRef;
  85708. /**
  85709. * Returns a value clamped between min and max
  85710. * @param value The value to clamp
  85711. * @param min The minimum of value
  85712. * @param max The maximum of value
  85713. * @returns The clamped value.
  85714. */
  85715. private static clamp;
  85716. /**
  85717. * Clones the current color curve instance.
  85718. * @return The cloned curves
  85719. */
  85720. clone(): ColorCurves;
  85721. /**
  85722. * Serializes the current color curve instance to a json representation.
  85723. * @return a JSON representation
  85724. */
  85725. serialize(): any;
  85726. /**
  85727. * Parses the color curve from a json representation.
  85728. * @param source the JSON source to parse
  85729. * @return The parsed curves
  85730. */
  85731. static Parse(source: any): ColorCurves;
  85732. }
  85733. }
  85734. declare module BABYLON {
  85735. /**
  85736. * Interface to follow in your material defines to integrate easily the
  85737. * Image proccessing functions.
  85738. * @hidden
  85739. */
  85740. export interface IImageProcessingConfigurationDefines {
  85741. IMAGEPROCESSING: boolean;
  85742. VIGNETTE: boolean;
  85743. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85744. VIGNETTEBLENDMODEOPAQUE: boolean;
  85745. TONEMAPPING: boolean;
  85746. TONEMAPPING_ACES: boolean;
  85747. CONTRAST: boolean;
  85748. EXPOSURE: boolean;
  85749. COLORCURVES: boolean;
  85750. COLORGRADING: boolean;
  85751. COLORGRADING3D: boolean;
  85752. SAMPLER3DGREENDEPTH: boolean;
  85753. SAMPLER3DBGRMAP: boolean;
  85754. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85755. }
  85756. /**
  85757. * @hidden
  85758. */
  85759. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85760. IMAGEPROCESSING: boolean;
  85761. VIGNETTE: boolean;
  85762. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85763. VIGNETTEBLENDMODEOPAQUE: boolean;
  85764. TONEMAPPING: boolean;
  85765. TONEMAPPING_ACES: boolean;
  85766. CONTRAST: boolean;
  85767. COLORCURVES: boolean;
  85768. COLORGRADING: boolean;
  85769. COLORGRADING3D: boolean;
  85770. SAMPLER3DGREENDEPTH: boolean;
  85771. SAMPLER3DBGRMAP: boolean;
  85772. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85773. EXPOSURE: boolean;
  85774. constructor();
  85775. }
  85776. /**
  85777. * This groups together the common properties used for image processing either in direct forward pass
  85778. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85779. * or not.
  85780. */
  85781. export class ImageProcessingConfiguration {
  85782. /**
  85783. * Default tone mapping applied in BabylonJS.
  85784. */
  85785. static readonly TONEMAPPING_STANDARD: number;
  85786. /**
  85787. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85788. * to other engines rendering to increase portability.
  85789. */
  85790. static readonly TONEMAPPING_ACES: number;
  85791. /**
  85792. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85793. */
  85794. colorCurves: Nullable<ColorCurves>;
  85795. private _colorCurvesEnabled;
  85796. /**
  85797. * Gets wether the color curves effect is enabled.
  85798. */
  85799. get colorCurvesEnabled(): boolean;
  85800. /**
  85801. * Sets wether the color curves effect is enabled.
  85802. */
  85803. set colorCurvesEnabled(value: boolean);
  85804. private _colorGradingTexture;
  85805. /**
  85806. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85807. */
  85808. get colorGradingTexture(): Nullable<BaseTexture>;
  85809. /**
  85810. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85811. */
  85812. set colorGradingTexture(value: Nullable<BaseTexture>);
  85813. private _colorGradingEnabled;
  85814. /**
  85815. * Gets wether the color grading effect is enabled.
  85816. */
  85817. get colorGradingEnabled(): boolean;
  85818. /**
  85819. * Sets wether the color grading effect is enabled.
  85820. */
  85821. set colorGradingEnabled(value: boolean);
  85822. private _colorGradingWithGreenDepth;
  85823. /**
  85824. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85825. */
  85826. get colorGradingWithGreenDepth(): boolean;
  85827. /**
  85828. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85829. */
  85830. set colorGradingWithGreenDepth(value: boolean);
  85831. private _colorGradingBGR;
  85832. /**
  85833. * Gets wether the color grading texture contains BGR values.
  85834. */
  85835. get colorGradingBGR(): boolean;
  85836. /**
  85837. * Sets wether the color grading texture contains BGR values.
  85838. */
  85839. set colorGradingBGR(value: boolean);
  85840. /** @hidden */
  85841. _exposure: number;
  85842. /**
  85843. * Gets the Exposure used in the effect.
  85844. */
  85845. get exposure(): number;
  85846. /**
  85847. * Sets the Exposure used in the effect.
  85848. */
  85849. set exposure(value: number);
  85850. private _toneMappingEnabled;
  85851. /**
  85852. * Gets wether the tone mapping effect is enabled.
  85853. */
  85854. get toneMappingEnabled(): boolean;
  85855. /**
  85856. * Sets wether the tone mapping effect is enabled.
  85857. */
  85858. set toneMappingEnabled(value: boolean);
  85859. private _toneMappingType;
  85860. /**
  85861. * Gets the type of tone mapping effect.
  85862. */
  85863. get toneMappingType(): number;
  85864. /**
  85865. * Sets the type of tone mapping effect used in BabylonJS.
  85866. */
  85867. set toneMappingType(value: number);
  85868. protected _contrast: number;
  85869. /**
  85870. * Gets the contrast used in the effect.
  85871. */
  85872. get contrast(): number;
  85873. /**
  85874. * Sets the contrast used in the effect.
  85875. */
  85876. set contrast(value: number);
  85877. /**
  85878. * Vignette stretch size.
  85879. */
  85880. vignetteStretch: number;
  85881. /**
  85882. * Vignette centre X Offset.
  85883. */
  85884. vignetteCentreX: number;
  85885. /**
  85886. * Vignette centre Y Offset.
  85887. */
  85888. vignetteCentreY: number;
  85889. /**
  85890. * Vignette weight or intensity of the vignette effect.
  85891. */
  85892. vignetteWeight: number;
  85893. /**
  85894. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85895. * if vignetteEnabled is set to true.
  85896. */
  85897. vignetteColor: Color4;
  85898. /**
  85899. * Camera field of view used by the Vignette effect.
  85900. */
  85901. vignetteCameraFov: number;
  85902. private _vignetteBlendMode;
  85903. /**
  85904. * Gets the vignette blend mode allowing different kind of effect.
  85905. */
  85906. get vignetteBlendMode(): number;
  85907. /**
  85908. * Sets the vignette blend mode allowing different kind of effect.
  85909. */
  85910. set vignetteBlendMode(value: number);
  85911. private _vignetteEnabled;
  85912. /**
  85913. * Gets wether the vignette effect is enabled.
  85914. */
  85915. get vignetteEnabled(): boolean;
  85916. /**
  85917. * Sets wether the vignette effect is enabled.
  85918. */
  85919. set vignetteEnabled(value: boolean);
  85920. private _applyByPostProcess;
  85921. /**
  85922. * Gets wether the image processing is applied through a post process or not.
  85923. */
  85924. get applyByPostProcess(): boolean;
  85925. /**
  85926. * Sets wether the image processing is applied through a post process or not.
  85927. */
  85928. set applyByPostProcess(value: boolean);
  85929. private _isEnabled;
  85930. /**
  85931. * Gets wether the image processing is enabled or not.
  85932. */
  85933. get isEnabled(): boolean;
  85934. /**
  85935. * Sets wether the image processing is enabled or not.
  85936. */
  85937. set isEnabled(value: boolean);
  85938. /**
  85939. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85940. */
  85941. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85942. /**
  85943. * Method called each time the image processing information changes requires to recompile the effect.
  85944. */
  85945. protected _updateParameters(): void;
  85946. /**
  85947. * Gets the current class name.
  85948. * @return "ImageProcessingConfiguration"
  85949. */
  85950. getClassName(): string;
  85951. /**
  85952. * Prepare the list of uniforms associated with the Image Processing effects.
  85953. * @param uniforms The list of uniforms used in the effect
  85954. * @param defines the list of defines currently in use
  85955. */
  85956. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85957. /**
  85958. * Prepare the list of samplers associated with the Image Processing effects.
  85959. * @param samplersList The list of uniforms used in the effect
  85960. * @param defines the list of defines currently in use
  85961. */
  85962. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85963. /**
  85964. * Prepare the list of defines associated to the shader.
  85965. * @param defines the list of defines to complete
  85966. * @param forPostProcess Define if we are currently in post process mode or not
  85967. */
  85968. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85969. /**
  85970. * Returns true if all the image processing information are ready.
  85971. * @returns True if ready, otherwise, false
  85972. */
  85973. isReady(): boolean;
  85974. /**
  85975. * Binds the image processing to the shader.
  85976. * @param effect The effect to bind to
  85977. * @param overrideAspectRatio Override the aspect ratio of the effect
  85978. */
  85979. bind(effect: Effect, overrideAspectRatio?: number): void;
  85980. /**
  85981. * Clones the current image processing instance.
  85982. * @return The cloned image processing
  85983. */
  85984. clone(): ImageProcessingConfiguration;
  85985. /**
  85986. * Serializes the current image processing instance to a json representation.
  85987. * @return a JSON representation
  85988. */
  85989. serialize(): any;
  85990. /**
  85991. * Parses the image processing from a json representation.
  85992. * @param source the JSON source to parse
  85993. * @return The parsed image processing
  85994. */
  85995. static Parse(source: any): ImageProcessingConfiguration;
  85996. private static _VIGNETTEMODE_MULTIPLY;
  85997. private static _VIGNETTEMODE_OPAQUE;
  85998. /**
  85999. * Used to apply the vignette as a mix with the pixel color.
  86000. */
  86001. static get VIGNETTEMODE_MULTIPLY(): number;
  86002. /**
  86003. * Used to apply the vignette as a replacement of the pixel color.
  86004. */
  86005. static get VIGNETTEMODE_OPAQUE(): number;
  86006. }
  86007. }
  86008. declare module BABYLON {
  86009. /** @hidden */
  86010. export var postprocessVertexShader: {
  86011. name: string;
  86012. shader: string;
  86013. };
  86014. }
  86015. declare module BABYLON {
  86016. interface ThinEngine {
  86017. /**
  86018. * Creates a new render target texture
  86019. * @param size defines the size of the texture
  86020. * @param options defines the options used to create the texture
  86021. * @returns a new render target texture stored in an InternalTexture
  86022. */
  86023. createRenderTargetTexture(size: number | {
  86024. width: number;
  86025. height: number;
  86026. layers?: number;
  86027. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86028. /**
  86029. * Creates a depth stencil texture.
  86030. * This is only available in WebGL 2 or with the depth texture extension available.
  86031. * @param size The size of face edge in the texture.
  86032. * @param options The options defining the texture.
  86033. * @returns The texture
  86034. */
  86035. createDepthStencilTexture(size: number | {
  86036. width: number;
  86037. height: number;
  86038. layers?: number;
  86039. }, options: DepthTextureCreationOptions): InternalTexture;
  86040. /** @hidden */
  86041. _createDepthStencilTexture(size: number | {
  86042. width: number;
  86043. height: number;
  86044. layers?: number;
  86045. }, options: DepthTextureCreationOptions): InternalTexture;
  86046. }
  86047. }
  86048. declare module BABYLON {
  86049. /**
  86050. * Defines the kind of connection point for node based material
  86051. */
  86052. export enum NodeMaterialBlockConnectionPointTypes {
  86053. /** Float */
  86054. Float = 1,
  86055. /** Int */
  86056. Int = 2,
  86057. /** Vector2 */
  86058. Vector2 = 4,
  86059. /** Vector3 */
  86060. Vector3 = 8,
  86061. /** Vector4 */
  86062. Vector4 = 16,
  86063. /** Color3 */
  86064. Color3 = 32,
  86065. /** Color4 */
  86066. Color4 = 64,
  86067. /** Matrix */
  86068. Matrix = 128,
  86069. /** Custom object */
  86070. Object = 256,
  86071. /** Detect type based on connection */
  86072. AutoDetect = 1024,
  86073. /** Output type that will be defined by input type */
  86074. BasedOnInput = 2048
  86075. }
  86076. }
  86077. declare module BABYLON {
  86078. /**
  86079. * Enum used to define the target of a block
  86080. */
  86081. export enum NodeMaterialBlockTargets {
  86082. /** Vertex shader */
  86083. Vertex = 1,
  86084. /** Fragment shader */
  86085. Fragment = 2,
  86086. /** Neutral */
  86087. Neutral = 4,
  86088. /** Vertex and Fragment */
  86089. VertexAndFragment = 3
  86090. }
  86091. }
  86092. declare module BABYLON {
  86093. /**
  86094. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86095. */
  86096. export enum NodeMaterialBlockConnectionPointMode {
  86097. /** Value is an uniform */
  86098. Uniform = 0,
  86099. /** Value is a mesh attribute */
  86100. Attribute = 1,
  86101. /** Value is a varying between vertex and fragment shaders */
  86102. Varying = 2,
  86103. /** Mode is undefined */
  86104. Undefined = 3
  86105. }
  86106. }
  86107. declare module BABYLON {
  86108. /**
  86109. * Enum used to define system values e.g. values automatically provided by the system
  86110. */
  86111. export enum NodeMaterialSystemValues {
  86112. /** World */
  86113. World = 1,
  86114. /** View */
  86115. View = 2,
  86116. /** Projection */
  86117. Projection = 3,
  86118. /** ViewProjection */
  86119. ViewProjection = 4,
  86120. /** WorldView */
  86121. WorldView = 5,
  86122. /** WorldViewProjection */
  86123. WorldViewProjection = 6,
  86124. /** CameraPosition */
  86125. CameraPosition = 7,
  86126. /** Fog Color */
  86127. FogColor = 8,
  86128. /** Delta time */
  86129. DeltaTime = 9
  86130. }
  86131. }
  86132. declare module BABYLON {
  86133. /** Defines supported spaces */
  86134. export enum Space {
  86135. /** Local (object) space */
  86136. LOCAL = 0,
  86137. /** World space */
  86138. WORLD = 1,
  86139. /** Bone space */
  86140. BONE = 2
  86141. }
  86142. /** Defines the 3 main axes */
  86143. export class Axis {
  86144. /** X axis */
  86145. static X: Vector3;
  86146. /** Y axis */
  86147. static Y: Vector3;
  86148. /** Z axis */
  86149. static Z: Vector3;
  86150. }
  86151. }
  86152. declare module BABYLON {
  86153. /**
  86154. * Represents a camera frustum
  86155. */
  86156. export class Frustum {
  86157. /**
  86158. * Gets the planes representing the frustum
  86159. * @param transform matrix to be applied to the returned planes
  86160. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86161. */
  86162. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86163. /**
  86164. * Gets the near frustum plane transformed by the transform matrix
  86165. * @param transform transformation matrix to be applied to the resulting frustum plane
  86166. * @param frustumPlane the resuling frustum plane
  86167. */
  86168. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86169. /**
  86170. * Gets the far frustum plane transformed by the transform matrix
  86171. * @param transform transformation matrix to be applied to the resulting frustum plane
  86172. * @param frustumPlane the resuling frustum plane
  86173. */
  86174. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86175. /**
  86176. * Gets the left frustum plane transformed by the transform matrix
  86177. * @param transform transformation matrix to be applied to the resulting frustum plane
  86178. * @param frustumPlane the resuling frustum plane
  86179. */
  86180. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86181. /**
  86182. * Gets the right frustum plane transformed by the transform matrix
  86183. * @param transform transformation matrix to be applied to the resulting frustum plane
  86184. * @param frustumPlane the resuling frustum plane
  86185. */
  86186. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86187. /**
  86188. * Gets the top frustum plane transformed by the transform matrix
  86189. * @param transform transformation matrix to be applied to the resulting frustum plane
  86190. * @param frustumPlane the resuling frustum plane
  86191. */
  86192. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86193. /**
  86194. * Gets the bottom frustum plane transformed by the transform matrix
  86195. * @param transform transformation matrix to be applied to the resulting frustum plane
  86196. * @param frustumPlane the resuling frustum plane
  86197. */
  86198. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86199. /**
  86200. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86201. * @param transform transformation matrix to be applied to the resulting frustum planes
  86202. * @param frustumPlanes the resuling frustum planes
  86203. */
  86204. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86205. }
  86206. }
  86207. declare module BABYLON {
  86208. /**
  86209. * Interface for the size containing width and height
  86210. */
  86211. export interface ISize {
  86212. /**
  86213. * Width
  86214. */
  86215. width: number;
  86216. /**
  86217. * Heighht
  86218. */
  86219. height: number;
  86220. }
  86221. /**
  86222. * Size containing widht and height
  86223. */
  86224. export class Size implements ISize {
  86225. /**
  86226. * Width
  86227. */
  86228. width: number;
  86229. /**
  86230. * Height
  86231. */
  86232. height: number;
  86233. /**
  86234. * Creates a Size object from the given width and height (floats).
  86235. * @param width width of the new size
  86236. * @param height height of the new size
  86237. */
  86238. constructor(width: number, height: number);
  86239. /**
  86240. * Returns a string with the Size width and height
  86241. * @returns a string with the Size width and height
  86242. */
  86243. toString(): string;
  86244. /**
  86245. * "Size"
  86246. * @returns the string "Size"
  86247. */
  86248. getClassName(): string;
  86249. /**
  86250. * Returns the Size hash code.
  86251. * @returns a hash code for a unique width and height
  86252. */
  86253. getHashCode(): number;
  86254. /**
  86255. * Updates the current size from the given one.
  86256. * @param src the given size
  86257. */
  86258. copyFrom(src: Size): void;
  86259. /**
  86260. * Updates in place the current Size from the given floats.
  86261. * @param width width of the new size
  86262. * @param height height of the new size
  86263. * @returns the updated Size.
  86264. */
  86265. copyFromFloats(width: number, height: number): Size;
  86266. /**
  86267. * Updates in place the current Size from the given floats.
  86268. * @param width width to set
  86269. * @param height height to set
  86270. * @returns the updated Size.
  86271. */
  86272. set(width: number, height: number): Size;
  86273. /**
  86274. * Multiplies the width and height by numbers
  86275. * @param w factor to multiple the width by
  86276. * @param h factor to multiple the height by
  86277. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86278. */
  86279. multiplyByFloats(w: number, h: number): Size;
  86280. /**
  86281. * Clones the size
  86282. * @returns a new Size copied from the given one.
  86283. */
  86284. clone(): Size;
  86285. /**
  86286. * True if the current Size and the given one width and height are strictly equal.
  86287. * @param other the other size to compare against
  86288. * @returns True if the current Size and the given one width and height are strictly equal.
  86289. */
  86290. equals(other: Size): boolean;
  86291. /**
  86292. * The surface of the Size : width * height (float).
  86293. */
  86294. get surface(): number;
  86295. /**
  86296. * Create a new size of zero
  86297. * @returns a new Size set to (0.0, 0.0)
  86298. */
  86299. static Zero(): Size;
  86300. /**
  86301. * Sums the width and height of two sizes
  86302. * @param otherSize size to add to this size
  86303. * @returns a new Size set as the addition result of the current Size and the given one.
  86304. */
  86305. add(otherSize: Size): Size;
  86306. /**
  86307. * Subtracts the width and height of two
  86308. * @param otherSize size to subtract to this size
  86309. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86310. */
  86311. subtract(otherSize: Size): Size;
  86312. /**
  86313. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86314. * @param start starting size to lerp between
  86315. * @param end end size to lerp between
  86316. * @param amount amount to lerp between the start and end values
  86317. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86318. */
  86319. static Lerp(start: Size, end: Size, amount: number): Size;
  86320. }
  86321. }
  86322. declare module BABYLON {
  86323. /**
  86324. * Contains position and normal vectors for a vertex
  86325. */
  86326. export class PositionNormalVertex {
  86327. /** the position of the vertex (defaut: 0,0,0) */
  86328. position: Vector3;
  86329. /** the normal of the vertex (defaut: 0,1,0) */
  86330. normal: Vector3;
  86331. /**
  86332. * Creates a PositionNormalVertex
  86333. * @param position the position of the vertex (defaut: 0,0,0)
  86334. * @param normal the normal of the vertex (defaut: 0,1,0)
  86335. */
  86336. constructor(
  86337. /** the position of the vertex (defaut: 0,0,0) */
  86338. position?: Vector3,
  86339. /** the normal of the vertex (defaut: 0,1,0) */
  86340. normal?: Vector3);
  86341. /**
  86342. * Clones the PositionNormalVertex
  86343. * @returns the cloned PositionNormalVertex
  86344. */
  86345. clone(): PositionNormalVertex;
  86346. }
  86347. /**
  86348. * Contains position, normal and uv vectors for a vertex
  86349. */
  86350. export class PositionNormalTextureVertex {
  86351. /** the position of the vertex (defaut: 0,0,0) */
  86352. position: Vector3;
  86353. /** the normal of the vertex (defaut: 0,1,0) */
  86354. normal: Vector3;
  86355. /** the uv of the vertex (default: 0,0) */
  86356. uv: Vector2;
  86357. /**
  86358. * Creates a PositionNormalTextureVertex
  86359. * @param position the position of the vertex (defaut: 0,0,0)
  86360. * @param normal the normal of the vertex (defaut: 0,1,0)
  86361. * @param uv the uv of the vertex (default: 0,0)
  86362. */
  86363. constructor(
  86364. /** the position of the vertex (defaut: 0,0,0) */
  86365. position?: Vector3,
  86366. /** the normal of the vertex (defaut: 0,1,0) */
  86367. normal?: Vector3,
  86368. /** the uv of the vertex (default: 0,0) */
  86369. uv?: Vector2);
  86370. /**
  86371. * Clones the PositionNormalTextureVertex
  86372. * @returns the cloned PositionNormalTextureVertex
  86373. */
  86374. clone(): PositionNormalTextureVertex;
  86375. }
  86376. }
  86377. declare module BABYLON {
  86378. /**
  86379. * Enum defining the type of animations supported by InputBlock
  86380. */
  86381. export enum AnimatedInputBlockTypes {
  86382. /** No animation */
  86383. None = 0,
  86384. /** Time based animation. Will only work for floats */
  86385. Time = 1
  86386. }
  86387. }
  86388. declare module BABYLON {
  86389. /**
  86390. * Interface describing all the common properties and methods a shadow light needs to implement.
  86391. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86392. * as well as binding the different shadow properties to the effects.
  86393. */
  86394. export interface IShadowLight extends Light {
  86395. /**
  86396. * The light id in the scene (used in scene.findLighById for instance)
  86397. */
  86398. id: string;
  86399. /**
  86400. * The position the shdow will be casted from.
  86401. */
  86402. position: Vector3;
  86403. /**
  86404. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86405. */
  86406. direction: Vector3;
  86407. /**
  86408. * The transformed position. Position of the light in world space taking parenting in account.
  86409. */
  86410. transformedPosition: Vector3;
  86411. /**
  86412. * The transformed direction. Direction of the light in world space taking parenting in account.
  86413. */
  86414. transformedDirection: Vector3;
  86415. /**
  86416. * The friendly name of the light in the scene.
  86417. */
  86418. name: string;
  86419. /**
  86420. * Defines the shadow projection clipping minimum z value.
  86421. */
  86422. shadowMinZ: number;
  86423. /**
  86424. * Defines the shadow projection clipping maximum z value.
  86425. */
  86426. shadowMaxZ: number;
  86427. /**
  86428. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86429. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86430. */
  86431. computeTransformedInformation(): boolean;
  86432. /**
  86433. * Gets the scene the light belongs to.
  86434. * @returns The scene
  86435. */
  86436. getScene(): Scene;
  86437. /**
  86438. * Callback defining a custom Projection Matrix Builder.
  86439. * This can be used to override the default projection matrix computation.
  86440. */
  86441. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86442. /**
  86443. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86444. * @param matrix The materix to updated with the projection information
  86445. * @param viewMatrix The transform matrix of the light
  86446. * @param renderList The list of mesh to render in the map
  86447. * @returns The current light
  86448. */
  86449. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86450. /**
  86451. * Gets the current depth scale used in ESM.
  86452. * @returns The scale
  86453. */
  86454. getDepthScale(): number;
  86455. /**
  86456. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86457. * @returns true if a cube texture needs to be use
  86458. */
  86459. needCube(): boolean;
  86460. /**
  86461. * Detects if the projection matrix requires to be recomputed this frame.
  86462. * @returns true if it requires to be recomputed otherwise, false.
  86463. */
  86464. needProjectionMatrixCompute(): boolean;
  86465. /**
  86466. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86467. */
  86468. forceProjectionMatrixCompute(): void;
  86469. /**
  86470. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86471. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86472. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86473. */
  86474. getShadowDirection(faceIndex?: number): Vector3;
  86475. /**
  86476. * Gets the minZ used for shadow according to both the scene and the light.
  86477. * @param activeCamera The camera we are returning the min for
  86478. * @returns the depth min z
  86479. */
  86480. getDepthMinZ(activeCamera: Camera): number;
  86481. /**
  86482. * Gets the maxZ used for shadow according to both the scene and the light.
  86483. * @param activeCamera The camera we are returning the max for
  86484. * @returns the depth max z
  86485. */
  86486. getDepthMaxZ(activeCamera: Camera): number;
  86487. }
  86488. /**
  86489. * Base implementation IShadowLight
  86490. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86491. */
  86492. export abstract class ShadowLight extends Light implements IShadowLight {
  86493. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86494. protected _position: Vector3;
  86495. protected _setPosition(value: Vector3): void;
  86496. /**
  86497. * Sets the position the shadow will be casted from. Also use as the light position for both
  86498. * point and spot lights.
  86499. */
  86500. get position(): Vector3;
  86501. /**
  86502. * Sets the position the shadow will be casted from. Also use as the light position for both
  86503. * point and spot lights.
  86504. */
  86505. set position(value: Vector3);
  86506. protected _direction: Vector3;
  86507. protected _setDirection(value: Vector3): void;
  86508. /**
  86509. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86510. * Also use as the light direction on spot and directional lights.
  86511. */
  86512. get direction(): Vector3;
  86513. /**
  86514. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86515. * Also use as the light direction on spot and directional lights.
  86516. */
  86517. set direction(value: Vector3);
  86518. protected _shadowMinZ: number;
  86519. /**
  86520. * Gets the shadow projection clipping minimum z value.
  86521. */
  86522. get shadowMinZ(): number;
  86523. /**
  86524. * Sets the shadow projection clipping minimum z value.
  86525. */
  86526. set shadowMinZ(value: number);
  86527. protected _shadowMaxZ: number;
  86528. /**
  86529. * Sets the shadow projection clipping maximum z value.
  86530. */
  86531. get shadowMaxZ(): number;
  86532. /**
  86533. * Gets the shadow projection clipping maximum z value.
  86534. */
  86535. set shadowMaxZ(value: number);
  86536. /**
  86537. * Callback defining a custom Projection Matrix Builder.
  86538. * This can be used to override the default projection matrix computation.
  86539. */
  86540. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86541. /**
  86542. * The transformed position. Position of the light in world space taking parenting in account.
  86543. */
  86544. transformedPosition: Vector3;
  86545. /**
  86546. * The transformed direction. Direction of the light in world space taking parenting in account.
  86547. */
  86548. transformedDirection: Vector3;
  86549. private _needProjectionMatrixCompute;
  86550. /**
  86551. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86552. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86553. */
  86554. computeTransformedInformation(): boolean;
  86555. /**
  86556. * Return the depth scale used for the shadow map.
  86557. * @returns the depth scale.
  86558. */
  86559. getDepthScale(): number;
  86560. /**
  86561. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86562. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86563. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86564. */
  86565. getShadowDirection(faceIndex?: number): Vector3;
  86566. /**
  86567. * Returns the ShadowLight absolute position in the World.
  86568. * @returns the position vector in world space
  86569. */
  86570. getAbsolutePosition(): Vector3;
  86571. /**
  86572. * Sets the ShadowLight direction toward the passed target.
  86573. * @param target The point to target in local space
  86574. * @returns the updated ShadowLight direction
  86575. */
  86576. setDirectionToTarget(target: Vector3): Vector3;
  86577. /**
  86578. * Returns the light rotation in euler definition.
  86579. * @returns the x y z rotation in local space.
  86580. */
  86581. getRotation(): Vector3;
  86582. /**
  86583. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86584. * @returns true if a cube texture needs to be use
  86585. */
  86586. needCube(): boolean;
  86587. /**
  86588. * Detects if the projection matrix requires to be recomputed this frame.
  86589. * @returns true if it requires to be recomputed otherwise, false.
  86590. */
  86591. needProjectionMatrixCompute(): boolean;
  86592. /**
  86593. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86594. */
  86595. forceProjectionMatrixCompute(): void;
  86596. /** @hidden */
  86597. _initCache(): void;
  86598. /** @hidden */
  86599. _isSynchronized(): boolean;
  86600. /**
  86601. * Computes the world matrix of the node
  86602. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86603. * @returns the world matrix
  86604. */
  86605. computeWorldMatrix(force?: boolean): Matrix;
  86606. /**
  86607. * Gets the minZ used for shadow according to both the scene and the light.
  86608. * @param activeCamera The camera we are returning the min for
  86609. * @returns the depth min z
  86610. */
  86611. getDepthMinZ(activeCamera: Camera): number;
  86612. /**
  86613. * Gets the maxZ used for shadow according to both the scene and the light.
  86614. * @param activeCamera The camera we are returning the max for
  86615. * @returns the depth max z
  86616. */
  86617. getDepthMaxZ(activeCamera: Camera): number;
  86618. /**
  86619. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86620. * @param matrix The materix to updated with the projection information
  86621. * @param viewMatrix The transform matrix of the light
  86622. * @param renderList The list of mesh to render in the map
  86623. * @returns The current light
  86624. */
  86625. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86626. }
  86627. }
  86628. declare module BABYLON {
  86629. /** @hidden */
  86630. export var packingFunctions: {
  86631. name: string;
  86632. shader: string;
  86633. };
  86634. }
  86635. declare module BABYLON {
  86636. /** @hidden */
  86637. export var bayerDitherFunctions: {
  86638. name: string;
  86639. shader: string;
  86640. };
  86641. }
  86642. declare module BABYLON {
  86643. /** @hidden */
  86644. export var shadowMapFragmentDeclaration: {
  86645. name: string;
  86646. shader: string;
  86647. };
  86648. }
  86649. declare module BABYLON {
  86650. /** @hidden */
  86651. export var clipPlaneFragmentDeclaration: {
  86652. name: string;
  86653. shader: string;
  86654. };
  86655. }
  86656. declare module BABYLON {
  86657. /** @hidden */
  86658. export var clipPlaneFragment: {
  86659. name: string;
  86660. shader: string;
  86661. };
  86662. }
  86663. declare module BABYLON {
  86664. /** @hidden */
  86665. export var shadowMapFragment: {
  86666. name: string;
  86667. shader: string;
  86668. };
  86669. }
  86670. declare module BABYLON {
  86671. /** @hidden */
  86672. export var shadowMapPixelShader: {
  86673. name: string;
  86674. shader: string;
  86675. };
  86676. }
  86677. declare module BABYLON {
  86678. /** @hidden */
  86679. export var bonesDeclaration: {
  86680. name: string;
  86681. shader: string;
  86682. };
  86683. }
  86684. declare module BABYLON {
  86685. /** @hidden */
  86686. export var morphTargetsVertexGlobalDeclaration: {
  86687. name: string;
  86688. shader: string;
  86689. };
  86690. }
  86691. declare module BABYLON {
  86692. /** @hidden */
  86693. export var morphTargetsVertexDeclaration: {
  86694. name: string;
  86695. shader: string;
  86696. };
  86697. }
  86698. declare module BABYLON {
  86699. /** @hidden */
  86700. export var instancesDeclaration: {
  86701. name: string;
  86702. shader: string;
  86703. };
  86704. }
  86705. declare module BABYLON {
  86706. /** @hidden */
  86707. export var helperFunctions: {
  86708. name: string;
  86709. shader: string;
  86710. };
  86711. }
  86712. declare module BABYLON {
  86713. /** @hidden */
  86714. export var shadowMapVertexDeclaration: {
  86715. name: string;
  86716. shader: string;
  86717. };
  86718. }
  86719. declare module BABYLON {
  86720. /** @hidden */
  86721. export var clipPlaneVertexDeclaration: {
  86722. name: string;
  86723. shader: string;
  86724. };
  86725. }
  86726. declare module BABYLON {
  86727. /** @hidden */
  86728. export var morphTargetsVertex: {
  86729. name: string;
  86730. shader: string;
  86731. };
  86732. }
  86733. declare module BABYLON {
  86734. /** @hidden */
  86735. export var instancesVertex: {
  86736. name: string;
  86737. shader: string;
  86738. };
  86739. }
  86740. declare module BABYLON {
  86741. /** @hidden */
  86742. export var bonesVertex: {
  86743. name: string;
  86744. shader: string;
  86745. };
  86746. }
  86747. declare module BABYLON {
  86748. /** @hidden */
  86749. export var shadowMapVertexNormalBias: {
  86750. name: string;
  86751. shader: string;
  86752. };
  86753. }
  86754. declare module BABYLON {
  86755. /** @hidden */
  86756. export var shadowMapVertexMetric: {
  86757. name: string;
  86758. shader: string;
  86759. };
  86760. }
  86761. declare module BABYLON {
  86762. /** @hidden */
  86763. export var clipPlaneVertex: {
  86764. name: string;
  86765. shader: string;
  86766. };
  86767. }
  86768. declare module BABYLON {
  86769. /** @hidden */
  86770. export var shadowMapVertexShader: {
  86771. name: string;
  86772. shader: string;
  86773. };
  86774. }
  86775. declare module BABYLON {
  86776. /** @hidden */
  86777. export var depthBoxBlurPixelShader: {
  86778. name: string;
  86779. shader: string;
  86780. };
  86781. }
  86782. declare module BABYLON {
  86783. /** @hidden */
  86784. export var shadowMapFragmentSoftTransparentShadow: {
  86785. name: string;
  86786. shader: string;
  86787. };
  86788. }
  86789. declare module BABYLON {
  86790. /**
  86791. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86792. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86793. */
  86794. export class EffectFallbacks implements IEffectFallbacks {
  86795. private _defines;
  86796. private _currentRank;
  86797. private _maxRank;
  86798. private _mesh;
  86799. /**
  86800. * Removes the fallback from the bound mesh.
  86801. */
  86802. unBindMesh(): void;
  86803. /**
  86804. * Adds a fallback on the specified property.
  86805. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86806. * @param define The name of the define in the shader
  86807. */
  86808. addFallback(rank: number, define: string): void;
  86809. /**
  86810. * Sets the mesh to use CPU skinning when needing to fallback.
  86811. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86812. * @param mesh The mesh to use the fallbacks.
  86813. */
  86814. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86815. /**
  86816. * Checks to see if more fallbacks are still availible.
  86817. */
  86818. get hasMoreFallbacks(): boolean;
  86819. /**
  86820. * Removes the defines that should be removed when falling back.
  86821. * @param currentDefines defines the current define statements for the shader.
  86822. * @param effect defines the current effect we try to compile
  86823. * @returns The resulting defines with defines of the current rank removed.
  86824. */
  86825. reduce(currentDefines: string, effect: Effect): string;
  86826. }
  86827. }
  86828. declare module BABYLON {
  86829. /**
  86830. * Interface used to define Action
  86831. */
  86832. export interface IAction {
  86833. /**
  86834. * Trigger for the action
  86835. */
  86836. trigger: number;
  86837. /** Options of the trigger */
  86838. triggerOptions: any;
  86839. /**
  86840. * Gets the trigger parameters
  86841. * @returns the trigger parameters
  86842. */
  86843. getTriggerParameter(): any;
  86844. /**
  86845. * Internal only - executes current action event
  86846. * @hidden
  86847. */
  86848. _executeCurrent(evt?: ActionEvent): void;
  86849. /**
  86850. * Serialize placeholder for child classes
  86851. * @param parent of child
  86852. * @returns the serialized object
  86853. */
  86854. serialize(parent: any): any;
  86855. /**
  86856. * Internal only
  86857. * @hidden
  86858. */
  86859. _prepare(): void;
  86860. /**
  86861. * Internal only - manager for action
  86862. * @hidden
  86863. */
  86864. _actionManager: AbstractActionManager;
  86865. /**
  86866. * Adds action to chain of actions, may be a DoNothingAction
  86867. * @param action defines the next action to execute
  86868. * @returns The action passed in
  86869. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86870. */
  86871. then(action: IAction): IAction;
  86872. }
  86873. /**
  86874. * The action to be carried out following a trigger
  86875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  86876. */
  86877. export class Action implements IAction {
  86878. /** the trigger, with or without parameters, for the action */
  86879. triggerOptions: any;
  86880. /**
  86881. * Trigger for the action
  86882. */
  86883. trigger: number;
  86884. /**
  86885. * Internal only - manager for action
  86886. * @hidden
  86887. */
  86888. _actionManager: ActionManager;
  86889. private _nextActiveAction;
  86890. private _child;
  86891. private _condition?;
  86892. private _triggerParameter;
  86893. /**
  86894. * An event triggered prior to action being executed.
  86895. */
  86896. onBeforeExecuteObservable: Observable<Action>;
  86897. /**
  86898. * Creates a new Action
  86899. * @param triggerOptions the trigger, with or without parameters, for the action
  86900. * @param condition an optional determinant of action
  86901. */
  86902. constructor(
  86903. /** the trigger, with or without parameters, for the action */
  86904. triggerOptions: any, condition?: Condition);
  86905. /**
  86906. * Internal only
  86907. * @hidden
  86908. */
  86909. _prepare(): void;
  86910. /**
  86911. * Gets the trigger parameters
  86912. * @returns the trigger parameters
  86913. */
  86914. getTriggerParameter(): any;
  86915. /**
  86916. * Internal only - executes current action event
  86917. * @hidden
  86918. */
  86919. _executeCurrent(evt?: ActionEvent): void;
  86920. /**
  86921. * Execute placeholder for child classes
  86922. * @param evt optional action event
  86923. */
  86924. execute(evt?: ActionEvent): void;
  86925. /**
  86926. * Skips to next active action
  86927. */
  86928. skipToNextActiveAction(): void;
  86929. /**
  86930. * Adds action to chain of actions, may be a DoNothingAction
  86931. * @param action defines the next action to execute
  86932. * @returns The action passed in
  86933. * @see https://www.babylonjs-playground.com/#1T30HR#0
  86934. */
  86935. then(action: Action): Action;
  86936. /**
  86937. * Internal only
  86938. * @hidden
  86939. */
  86940. _getProperty(propertyPath: string): string;
  86941. /**
  86942. * Internal only
  86943. * @hidden
  86944. */
  86945. _getEffectiveTarget(target: any, propertyPath: string): any;
  86946. /**
  86947. * Serialize placeholder for child classes
  86948. * @param parent of child
  86949. * @returns the serialized object
  86950. */
  86951. serialize(parent: any): any;
  86952. /**
  86953. * Internal only called by serialize
  86954. * @hidden
  86955. */
  86956. protected _serialize(serializedAction: any, parent?: any): any;
  86957. /**
  86958. * Internal only
  86959. * @hidden
  86960. */
  86961. static _SerializeValueAsString: (value: any) => string;
  86962. /**
  86963. * Internal only
  86964. * @hidden
  86965. */
  86966. static _GetTargetProperty: (target: Node | Scene) => {
  86967. name: string;
  86968. targetType: string;
  86969. value: string;
  86970. };
  86971. }
  86972. }
  86973. declare module BABYLON {
  86974. /**
  86975. * A Condition applied to an Action
  86976. */
  86977. export class Condition {
  86978. /**
  86979. * Internal only - manager for action
  86980. * @hidden
  86981. */
  86982. _actionManager: ActionManager;
  86983. /**
  86984. * Internal only
  86985. * @hidden
  86986. */
  86987. _evaluationId: number;
  86988. /**
  86989. * Internal only
  86990. * @hidden
  86991. */
  86992. _currentResult: boolean;
  86993. /**
  86994. * Creates a new Condition
  86995. * @param actionManager the manager of the action the condition is applied to
  86996. */
  86997. constructor(actionManager: ActionManager);
  86998. /**
  86999. * Check if the current condition is valid
  87000. * @returns a boolean
  87001. */
  87002. isValid(): boolean;
  87003. /**
  87004. * Internal only
  87005. * @hidden
  87006. */
  87007. _getProperty(propertyPath: string): string;
  87008. /**
  87009. * Internal only
  87010. * @hidden
  87011. */
  87012. _getEffectiveTarget(target: any, propertyPath: string): any;
  87013. /**
  87014. * Serialize placeholder for child classes
  87015. * @returns the serialized object
  87016. */
  87017. serialize(): any;
  87018. /**
  87019. * Internal only
  87020. * @hidden
  87021. */
  87022. protected _serialize(serializedCondition: any): any;
  87023. }
  87024. /**
  87025. * Defines specific conditional operators as extensions of Condition
  87026. */
  87027. export class ValueCondition extends Condition {
  87028. /** path to specify the property of the target the conditional operator uses */
  87029. propertyPath: string;
  87030. /** the value compared by the conditional operator against the current value of the property */
  87031. value: any;
  87032. /** the conditional operator, default ValueCondition.IsEqual */
  87033. operator: number;
  87034. /**
  87035. * Internal only
  87036. * @hidden
  87037. */
  87038. private static _IsEqual;
  87039. /**
  87040. * Internal only
  87041. * @hidden
  87042. */
  87043. private static _IsDifferent;
  87044. /**
  87045. * Internal only
  87046. * @hidden
  87047. */
  87048. private static _IsGreater;
  87049. /**
  87050. * Internal only
  87051. * @hidden
  87052. */
  87053. private static _IsLesser;
  87054. /**
  87055. * returns the number for IsEqual
  87056. */
  87057. static get IsEqual(): number;
  87058. /**
  87059. * Returns the number for IsDifferent
  87060. */
  87061. static get IsDifferent(): number;
  87062. /**
  87063. * Returns the number for IsGreater
  87064. */
  87065. static get IsGreater(): number;
  87066. /**
  87067. * Returns the number for IsLesser
  87068. */
  87069. static get IsLesser(): number;
  87070. /**
  87071. * Internal only The action manager for the condition
  87072. * @hidden
  87073. */
  87074. _actionManager: ActionManager;
  87075. /**
  87076. * Internal only
  87077. * @hidden
  87078. */
  87079. private _target;
  87080. /**
  87081. * Internal only
  87082. * @hidden
  87083. */
  87084. private _effectiveTarget;
  87085. /**
  87086. * Internal only
  87087. * @hidden
  87088. */
  87089. private _property;
  87090. /**
  87091. * Creates a new ValueCondition
  87092. * @param actionManager manager for the action the condition applies to
  87093. * @param target for the action
  87094. * @param propertyPath path to specify the property of the target the conditional operator uses
  87095. * @param value the value compared by the conditional operator against the current value of the property
  87096. * @param operator the conditional operator, default ValueCondition.IsEqual
  87097. */
  87098. constructor(actionManager: ActionManager, target: any,
  87099. /** path to specify the property of the target the conditional operator uses */
  87100. propertyPath: string,
  87101. /** the value compared by the conditional operator against the current value of the property */
  87102. value: any,
  87103. /** the conditional operator, default ValueCondition.IsEqual */
  87104. operator?: number);
  87105. /**
  87106. * Compares the given value with the property value for the specified conditional operator
  87107. * @returns the result of the comparison
  87108. */
  87109. isValid(): boolean;
  87110. /**
  87111. * Serialize the ValueCondition into a JSON compatible object
  87112. * @returns serialization object
  87113. */
  87114. serialize(): any;
  87115. /**
  87116. * Gets the name of the conditional operator for the ValueCondition
  87117. * @param operator the conditional operator
  87118. * @returns the name
  87119. */
  87120. static GetOperatorName(operator: number): string;
  87121. }
  87122. /**
  87123. * Defines a predicate condition as an extension of Condition
  87124. */
  87125. export class PredicateCondition extends Condition {
  87126. /** defines the predicate function used to validate the condition */
  87127. predicate: () => boolean;
  87128. /**
  87129. * Internal only - manager for action
  87130. * @hidden
  87131. */
  87132. _actionManager: ActionManager;
  87133. /**
  87134. * Creates a new PredicateCondition
  87135. * @param actionManager manager for the action the condition applies to
  87136. * @param predicate defines the predicate function used to validate the condition
  87137. */
  87138. constructor(actionManager: ActionManager,
  87139. /** defines the predicate function used to validate the condition */
  87140. predicate: () => boolean);
  87141. /**
  87142. * @returns the validity of the predicate condition
  87143. */
  87144. isValid(): boolean;
  87145. }
  87146. /**
  87147. * Defines a state condition as an extension of Condition
  87148. */
  87149. export class StateCondition extends Condition {
  87150. /** Value to compare with target state */
  87151. value: string;
  87152. /**
  87153. * Internal only - manager for action
  87154. * @hidden
  87155. */
  87156. _actionManager: ActionManager;
  87157. /**
  87158. * Internal only
  87159. * @hidden
  87160. */
  87161. private _target;
  87162. /**
  87163. * Creates a new StateCondition
  87164. * @param actionManager manager for the action the condition applies to
  87165. * @param target of the condition
  87166. * @param value to compare with target state
  87167. */
  87168. constructor(actionManager: ActionManager, target: any,
  87169. /** Value to compare with target state */
  87170. value: string);
  87171. /**
  87172. * Gets a boolean indicating if the current condition is met
  87173. * @returns the validity of the state
  87174. */
  87175. isValid(): boolean;
  87176. /**
  87177. * Serialize the StateCondition into a JSON compatible object
  87178. * @returns serialization object
  87179. */
  87180. serialize(): any;
  87181. }
  87182. }
  87183. declare module BABYLON {
  87184. /**
  87185. * This defines an action responsible to toggle a boolean once triggered.
  87186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87187. */
  87188. export class SwitchBooleanAction extends Action {
  87189. /**
  87190. * The path to the boolean property in the target object
  87191. */
  87192. propertyPath: string;
  87193. private _target;
  87194. private _effectiveTarget;
  87195. private _property;
  87196. /**
  87197. * Instantiate the action
  87198. * @param triggerOptions defines the trigger options
  87199. * @param target defines the object containing the boolean
  87200. * @param propertyPath defines the path to the boolean property in the target object
  87201. * @param condition defines the trigger related conditions
  87202. */
  87203. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87204. /** @hidden */
  87205. _prepare(): void;
  87206. /**
  87207. * Execute the action toggle the boolean value.
  87208. */
  87209. execute(): void;
  87210. /**
  87211. * Serializes the actions and its related information.
  87212. * @param parent defines the object to serialize in
  87213. * @returns the serialized object
  87214. */
  87215. serialize(parent: any): any;
  87216. }
  87217. /**
  87218. * This defines an action responsible to set a the state field of the target
  87219. * to a desired value once triggered.
  87220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87221. */
  87222. export class SetStateAction extends Action {
  87223. /**
  87224. * The value to store in the state field.
  87225. */
  87226. value: string;
  87227. private _target;
  87228. /**
  87229. * Instantiate the action
  87230. * @param triggerOptions defines the trigger options
  87231. * @param target defines the object containing the state property
  87232. * @param value defines the value to store in the state field
  87233. * @param condition defines the trigger related conditions
  87234. */
  87235. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87236. /**
  87237. * Execute the action and store the value on the target state property.
  87238. */
  87239. execute(): void;
  87240. /**
  87241. * Serializes the actions and its related information.
  87242. * @param parent defines the object to serialize in
  87243. * @returns the serialized object
  87244. */
  87245. serialize(parent: any): any;
  87246. }
  87247. /**
  87248. * This defines an action responsible to set a property of the target
  87249. * to a desired value once triggered.
  87250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87251. */
  87252. export class SetValueAction extends Action {
  87253. /**
  87254. * The path of the property to set in the target.
  87255. */
  87256. propertyPath: string;
  87257. /**
  87258. * The value to set in the property
  87259. */
  87260. value: any;
  87261. private _target;
  87262. private _effectiveTarget;
  87263. private _property;
  87264. /**
  87265. * Instantiate the action
  87266. * @param triggerOptions defines the trigger options
  87267. * @param target defines the object containing the property
  87268. * @param propertyPath defines the path of the property to set in the target
  87269. * @param value defines the value to set in the property
  87270. * @param condition defines the trigger related conditions
  87271. */
  87272. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87273. /** @hidden */
  87274. _prepare(): void;
  87275. /**
  87276. * Execute the action and set the targetted property to the desired value.
  87277. */
  87278. execute(): void;
  87279. /**
  87280. * Serializes the actions and its related information.
  87281. * @param parent defines the object to serialize in
  87282. * @returns the serialized object
  87283. */
  87284. serialize(parent: any): any;
  87285. }
  87286. /**
  87287. * This defines an action responsible to increment the target value
  87288. * to a desired value once triggered.
  87289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87290. */
  87291. export class IncrementValueAction extends Action {
  87292. /**
  87293. * The path of the property to increment in the target.
  87294. */
  87295. propertyPath: string;
  87296. /**
  87297. * The value we should increment the property by.
  87298. */
  87299. value: any;
  87300. private _target;
  87301. private _effectiveTarget;
  87302. private _property;
  87303. /**
  87304. * Instantiate the action
  87305. * @param triggerOptions defines the trigger options
  87306. * @param target defines the object containing the property
  87307. * @param propertyPath defines the path of the property to increment in the target
  87308. * @param value defines the value value we should increment the property by
  87309. * @param condition defines the trigger related conditions
  87310. */
  87311. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87312. /** @hidden */
  87313. _prepare(): void;
  87314. /**
  87315. * Execute the action and increment the target of the value amount.
  87316. */
  87317. execute(): void;
  87318. /**
  87319. * Serializes the actions and its related information.
  87320. * @param parent defines the object to serialize in
  87321. * @returns the serialized object
  87322. */
  87323. serialize(parent: any): any;
  87324. }
  87325. /**
  87326. * This defines an action responsible to start an animation once triggered.
  87327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87328. */
  87329. export class PlayAnimationAction extends Action {
  87330. /**
  87331. * Where the animation should start (animation frame)
  87332. */
  87333. from: number;
  87334. /**
  87335. * Where the animation should stop (animation frame)
  87336. */
  87337. to: number;
  87338. /**
  87339. * Define if the animation should loop or stop after the first play.
  87340. */
  87341. loop?: boolean;
  87342. private _target;
  87343. /**
  87344. * Instantiate the action
  87345. * @param triggerOptions defines the trigger options
  87346. * @param target defines the target animation or animation name
  87347. * @param from defines from where the animation should start (animation frame)
  87348. * @param end defines where the animation should stop (animation frame)
  87349. * @param loop defines if the animation should loop or stop after the first play
  87350. * @param condition defines the trigger related conditions
  87351. */
  87352. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87353. /** @hidden */
  87354. _prepare(): void;
  87355. /**
  87356. * Execute the action and play the animation.
  87357. */
  87358. execute(): void;
  87359. /**
  87360. * Serializes the actions and its related information.
  87361. * @param parent defines the object to serialize in
  87362. * @returns the serialized object
  87363. */
  87364. serialize(parent: any): any;
  87365. }
  87366. /**
  87367. * This defines an action responsible to stop an animation once triggered.
  87368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87369. */
  87370. export class StopAnimationAction extends Action {
  87371. private _target;
  87372. /**
  87373. * Instantiate the action
  87374. * @param triggerOptions defines the trigger options
  87375. * @param target defines the target animation or animation name
  87376. * @param condition defines the trigger related conditions
  87377. */
  87378. constructor(triggerOptions: any, target: any, condition?: Condition);
  87379. /** @hidden */
  87380. _prepare(): void;
  87381. /**
  87382. * Execute the action and stop the animation.
  87383. */
  87384. execute(): void;
  87385. /**
  87386. * Serializes the actions and its related information.
  87387. * @param parent defines the object to serialize in
  87388. * @returns the serialized object
  87389. */
  87390. serialize(parent: any): any;
  87391. }
  87392. /**
  87393. * This defines an action responsible that does nothing once triggered.
  87394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87395. */
  87396. export class DoNothingAction extends Action {
  87397. /**
  87398. * Instantiate the action
  87399. * @param triggerOptions defines the trigger options
  87400. * @param condition defines the trigger related conditions
  87401. */
  87402. constructor(triggerOptions?: any, condition?: Condition);
  87403. /**
  87404. * Execute the action and do nothing.
  87405. */
  87406. execute(): void;
  87407. /**
  87408. * Serializes the actions and its related information.
  87409. * @param parent defines the object to serialize in
  87410. * @returns the serialized object
  87411. */
  87412. serialize(parent: any): any;
  87413. }
  87414. /**
  87415. * This defines an action responsible to trigger several actions once triggered.
  87416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87417. */
  87418. export class CombineAction extends Action {
  87419. /**
  87420. * The list of aggregated animations to run.
  87421. */
  87422. children: Action[];
  87423. /**
  87424. * Instantiate the action
  87425. * @param triggerOptions defines the trigger options
  87426. * @param children defines the list of aggregated animations to run
  87427. * @param condition defines the trigger related conditions
  87428. */
  87429. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87430. /** @hidden */
  87431. _prepare(): void;
  87432. /**
  87433. * Execute the action and executes all the aggregated actions.
  87434. */
  87435. execute(evt: ActionEvent): void;
  87436. /**
  87437. * Serializes the actions and its related information.
  87438. * @param parent defines the object to serialize in
  87439. * @returns the serialized object
  87440. */
  87441. serialize(parent: any): any;
  87442. }
  87443. /**
  87444. * This defines an action responsible to run code (external event) once triggered.
  87445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87446. */
  87447. export class ExecuteCodeAction extends Action {
  87448. /**
  87449. * The callback function to run.
  87450. */
  87451. func: (evt: ActionEvent) => void;
  87452. /**
  87453. * Instantiate the action
  87454. * @param triggerOptions defines the trigger options
  87455. * @param func defines the callback function to run
  87456. * @param condition defines the trigger related conditions
  87457. */
  87458. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87459. /**
  87460. * Execute the action and run the attached code.
  87461. */
  87462. execute(evt: ActionEvent): void;
  87463. }
  87464. /**
  87465. * This defines an action responsible to set the parent property of the target once triggered.
  87466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87467. */
  87468. export class SetParentAction extends Action {
  87469. private _parent;
  87470. private _target;
  87471. /**
  87472. * Instantiate the action
  87473. * @param triggerOptions defines the trigger options
  87474. * @param target defines the target containing the parent property
  87475. * @param parent defines from where the animation should start (animation frame)
  87476. * @param condition defines the trigger related conditions
  87477. */
  87478. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87479. /** @hidden */
  87480. _prepare(): void;
  87481. /**
  87482. * Execute the action and set the parent property.
  87483. */
  87484. execute(): void;
  87485. /**
  87486. * Serializes the actions and its related information.
  87487. * @param parent defines the object to serialize in
  87488. * @returns the serialized object
  87489. */
  87490. serialize(parent: any): any;
  87491. }
  87492. }
  87493. declare module BABYLON {
  87494. /**
  87495. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87496. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87498. */
  87499. export class ActionManager extends AbstractActionManager {
  87500. /**
  87501. * Nothing
  87502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87503. */
  87504. static readonly NothingTrigger: number;
  87505. /**
  87506. * On pick
  87507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87508. */
  87509. static readonly OnPickTrigger: number;
  87510. /**
  87511. * On left pick
  87512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87513. */
  87514. static readonly OnLeftPickTrigger: number;
  87515. /**
  87516. * On right pick
  87517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87518. */
  87519. static readonly OnRightPickTrigger: number;
  87520. /**
  87521. * On center pick
  87522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87523. */
  87524. static readonly OnCenterPickTrigger: number;
  87525. /**
  87526. * On pick down
  87527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87528. */
  87529. static readonly OnPickDownTrigger: number;
  87530. /**
  87531. * On double pick
  87532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87533. */
  87534. static readonly OnDoublePickTrigger: number;
  87535. /**
  87536. * On pick up
  87537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87538. */
  87539. static readonly OnPickUpTrigger: number;
  87540. /**
  87541. * On pick out.
  87542. * This trigger will only be raised if you also declared a OnPickDown
  87543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87544. */
  87545. static readonly OnPickOutTrigger: number;
  87546. /**
  87547. * On long press
  87548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87549. */
  87550. static readonly OnLongPressTrigger: number;
  87551. /**
  87552. * On pointer over
  87553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87554. */
  87555. static readonly OnPointerOverTrigger: number;
  87556. /**
  87557. * On pointer out
  87558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87559. */
  87560. static readonly OnPointerOutTrigger: number;
  87561. /**
  87562. * On every frame
  87563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87564. */
  87565. static readonly OnEveryFrameTrigger: number;
  87566. /**
  87567. * On intersection enter
  87568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87569. */
  87570. static readonly OnIntersectionEnterTrigger: number;
  87571. /**
  87572. * On intersection exit
  87573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87574. */
  87575. static readonly OnIntersectionExitTrigger: number;
  87576. /**
  87577. * On key down
  87578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87579. */
  87580. static readonly OnKeyDownTrigger: number;
  87581. /**
  87582. * On key up
  87583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87584. */
  87585. static readonly OnKeyUpTrigger: number;
  87586. private _scene;
  87587. /**
  87588. * Creates a new action manager
  87589. * @param scene defines the hosting scene
  87590. */
  87591. constructor(scene: Scene);
  87592. /**
  87593. * Releases all associated resources
  87594. */
  87595. dispose(): void;
  87596. /**
  87597. * Gets hosting scene
  87598. * @returns the hosting scene
  87599. */
  87600. getScene(): Scene;
  87601. /**
  87602. * Does this action manager handles actions of any of the given triggers
  87603. * @param triggers defines the triggers to be tested
  87604. * @return a boolean indicating whether one (or more) of the triggers is handled
  87605. */
  87606. hasSpecificTriggers(triggers: number[]): boolean;
  87607. /**
  87608. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87609. * speed.
  87610. * @param triggerA defines the trigger to be tested
  87611. * @param triggerB defines the trigger to be tested
  87612. * @return a boolean indicating whether one (or more) of the triggers is handled
  87613. */
  87614. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87615. /**
  87616. * Does this action manager handles actions of a given trigger
  87617. * @param trigger defines the trigger to be tested
  87618. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87619. * @return whether the trigger is handled
  87620. */
  87621. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87622. /**
  87623. * Does this action manager has pointer triggers
  87624. */
  87625. get hasPointerTriggers(): boolean;
  87626. /**
  87627. * Does this action manager has pick triggers
  87628. */
  87629. get hasPickTriggers(): boolean;
  87630. /**
  87631. * Registers an action to this action manager
  87632. * @param action defines the action to be registered
  87633. * @return the action amended (prepared) after registration
  87634. */
  87635. registerAction(action: IAction): Nullable<IAction>;
  87636. /**
  87637. * Unregisters an action to this action manager
  87638. * @param action defines the action to be unregistered
  87639. * @return a boolean indicating whether the action has been unregistered
  87640. */
  87641. unregisterAction(action: IAction): Boolean;
  87642. /**
  87643. * Process a specific trigger
  87644. * @param trigger defines the trigger to process
  87645. * @param evt defines the event details to be processed
  87646. */
  87647. processTrigger(trigger: number, evt?: IActionEvent): void;
  87648. /** @hidden */
  87649. _getEffectiveTarget(target: any, propertyPath: string): any;
  87650. /** @hidden */
  87651. _getProperty(propertyPath: string): string;
  87652. /**
  87653. * Serialize this manager to a JSON object
  87654. * @param name defines the property name to store this manager
  87655. * @returns a JSON representation of this manager
  87656. */
  87657. serialize(name: string): any;
  87658. /**
  87659. * Creates a new ActionManager from a JSON data
  87660. * @param parsedActions defines the JSON data to read from
  87661. * @param object defines the hosting mesh
  87662. * @param scene defines the hosting scene
  87663. */
  87664. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87665. /**
  87666. * Get a trigger name by index
  87667. * @param trigger defines the trigger index
  87668. * @returns a trigger name
  87669. */
  87670. static GetTriggerName(trigger: number): string;
  87671. }
  87672. }
  87673. declare module BABYLON {
  87674. /**
  87675. * Class used to represent a sprite
  87676. * @see http://doc.babylonjs.com/babylon101/sprites
  87677. */
  87678. export class Sprite implements IAnimatable {
  87679. /** defines the name */
  87680. name: string;
  87681. /** Gets or sets the current world position */
  87682. position: Vector3;
  87683. /** Gets or sets the main color */
  87684. color: Color4;
  87685. /** Gets or sets the width */
  87686. width: number;
  87687. /** Gets or sets the height */
  87688. height: number;
  87689. /** Gets or sets rotation angle */
  87690. angle: number;
  87691. /** Gets or sets the cell index in the sprite sheet */
  87692. cellIndex: number;
  87693. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87694. cellRef: string;
  87695. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87696. invertU: boolean;
  87697. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87698. invertV: boolean;
  87699. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87700. disposeWhenFinishedAnimating: boolean;
  87701. /** Gets the list of attached animations */
  87702. animations: Nullable<Array<Animation>>;
  87703. /** Gets or sets a boolean indicating if the sprite can be picked */
  87704. isPickable: boolean;
  87705. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87706. useAlphaForPicking: boolean;
  87707. /** @hidden */
  87708. _xOffset: number;
  87709. /** @hidden */
  87710. _yOffset: number;
  87711. /** @hidden */
  87712. _xSize: number;
  87713. /** @hidden */
  87714. _ySize: number;
  87715. /**
  87716. * Gets or sets the associated action manager
  87717. */
  87718. actionManager: Nullable<ActionManager>;
  87719. /**
  87720. * An event triggered when the control has been disposed
  87721. */
  87722. onDisposeObservable: Observable<Sprite>;
  87723. private _animationStarted;
  87724. private _loopAnimation;
  87725. private _fromIndex;
  87726. private _toIndex;
  87727. private _delay;
  87728. private _direction;
  87729. private _manager;
  87730. private _time;
  87731. private _onAnimationEnd;
  87732. /**
  87733. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87734. */
  87735. isVisible: boolean;
  87736. /**
  87737. * Gets or sets the sprite size
  87738. */
  87739. get size(): number;
  87740. set size(value: number);
  87741. /**
  87742. * Returns a boolean indicating if the animation is started
  87743. */
  87744. get animationStarted(): boolean;
  87745. /**
  87746. * Gets or sets the unique id of the sprite
  87747. */
  87748. uniqueId: number;
  87749. /**
  87750. * Gets the manager of this sprite
  87751. */
  87752. get manager(): ISpriteManager;
  87753. /**
  87754. * Creates a new Sprite
  87755. * @param name defines the name
  87756. * @param manager defines the manager
  87757. */
  87758. constructor(
  87759. /** defines the name */
  87760. name: string, manager: ISpriteManager);
  87761. /**
  87762. * Returns the string "Sprite"
  87763. * @returns "Sprite"
  87764. */
  87765. getClassName(): string;
  87766. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87767. get fromIndex(): number;
  87768. set fromIndex(value: number);
  87769. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87770. get toIndex(): number;
  87771. set toIndex(value: number);
  87772. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87773. get loopAnimation(): boolean;
  87774. set loopAnimation(value: boolean);
  87775. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87776. get delay(): number;
  87777. set delay(value: number);
  87778. /**
  87779. * Starts an animation
  87780. * @param from defines the initial key
  87781. * @param to defines the end key
  87782. * @param loop defines if the animation must loop
  87783. * @param delay defines the start delay (in ms)
  87784. * @param onAnimationEnd defines a callback to call when animation ends
  87785. */
  87786. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87787. /** Stops current animation (if any) */
  87788. stopAnimation(): void;
  87789. /** @hidden */
  87790. _animate(deltaTime: number): void;
  87791. /** Release associated resources */
  87792. dispose(): void;
  87793. /**
  87794. * Serializes the sprite to a JSON object
  87795. * @returns the JSON object
  87796. */
  87797. serialize(): any;
  87798. /**
  87799. * Parses a JSON object to create a new sprite
  87800. * @param parsedSprite The JSON object to parse
  87801. * @param manager defines the hosting manager
  87802. * @returns the new sprite
  87803. */
  87804. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87805. }
  87806. }
  87807. declare module BABYLON {
  87808. /**
  87809. * Information about the result of picking within a scene
  87810. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87811. */
  87812. export class PickingInfo {
  87813. /** @hidden */
  87814. _pickingUnavailable: boolean;
  87815. /**
  87816. * If the pick collided with an object
  87817. */
  87818. hit: boolean;
  87819. /**
  87820. * Distance away where the pick collided
  87821. */
  87822. distance: number;
  87823. /**
  87824. * The location of pick collision
  87825. */
  87826. pickedPoint: Nullable<Vector3>;
  87827. /**
  87828. * The mesh corresponding the the pick collision
  87829. */
  87830. pickedMesh: Nullable<AbstractMesh>;
  87831. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  87832. bu: number;
  87833. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  87834. bv: number;
  87835. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87836. faceId: number;
  87837. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  87838. subMeshFaceId: number;
  87839. /** Id of the the submesh that was picked */
  87840. subMeshId: number;
  87841. /** If a sprite was picked, this will be the sprite the pick collided with */
  87842. pickedSprite: Nullable<Sprite>;
  87843. /**
  87844. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  87845. */
  87846. originMesh: Nullable<AbstractMesh>;
  87847. /**
  87848. * The ray that was used to perform the picking.
  87849. */
  87850. ray: Nullable<Ray>;
  87851. /**
  87852. * Gets the normal correspodning to the face the pick collided with
  87853. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  87854. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  87855. * @returns The normal correspodning to the face the pick collided with
  87856. */
  87857. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  87858. /**
  87859. * Gets the texture coordinates of where the pick occured
  87860. * @returns the vector containing the coordnates of the texture
  87861. */
  87862. getTextureCoordinates(): Nullable<Vector2>;
  87863. }
  87864. }
  87865. declare module BABYLON {
  87866. /**
  87867. * Class representing a ray with position and direction
  87868. */
  87869. export class Ray {
  87870. /** origin point */
  87871. origin: Vector3;
  87872. /** direction */
  87873. direction: Vector3;
  87874. /** length of the ray */
  87875. length: number;
  87876. private static readonly TmpVector3;
  87877. private _tmpRay;
  87878. /**
  87879. * Creates a new ray
  87880. * @param origin origin point
  87881. * @param direction direction
  87882. * @param length length of the ray
  87883. */
  87884. constructor(
  87885. /** origin point */
  87886. origin: Vector3,
  87887. /** direction */
  87888. direction: Vector3,
  87889. /** length of the ray */
  87890. length?: number);
  87891. /**
  87892. * Checks if the ray intersects a box
  87893. * This does not account for the ray lenght by design to improve perfs.
  87894. * @param minimum bound of the box
  87895. * @param maximum bound of the box
  87896. * @param intersectionTreshold extra extend to be added to the box in all direction
  87897. * @returns if the box was hit
  87898. */
  87899. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  87900. /**
  87901. * Checks if the ray intersects a box
  87902. * This does not account for the ray lenght by design to improve perfs.
  87903. * @param box the bounding box to check
  87904. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  87905. * @returns if the box was hit
  87906. */
  87907. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  87908. /**
  87909. * If the ray hits a sphere
  87910. * @param sphere the bounding sphere to check
  87911. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  87912. * @returns true if it hits the sphere
  87913. */
  87914. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  87915. /**
  87916. * If the ray hits a triange
  87917. * @param vertex0 triangle vertex
  87918. * @param vertex1 triangle vertex
  87919. * @param vertex2 triangle vertex
  87920. * @returns intersection information if hit
  87921. */
  87922. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  87923. /**
  87924. * Checks if ray intersects a plane
  87925. * @param plane the plane to check
  87926. * @returns the distance away it was hit
  87927. */
  87928. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  87929. /**
  87930. * Calculate the intercept of a ray on a given axis
  87931. * @param axis to check 'x' | 'y' | 'z'
  87932. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  87933. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  87934. */
  87935. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  87936. /**
  87937. * Checks if ray intersects a mesh
  87938. * @param mesh the mesh to check
  87939. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87940. * @returns picking info of the intersecton
  87941. */
  87942. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  87943. /**
  87944. * Checks if ray intersects a mesh
  87945. * @param meshes the meshes to check
  87946. * @param fastCheck defines if the first intersection will be used (and not the closest)
  87947. * @param results array to store result in
  87948. * @returns Array of picking infos
  87949. */
  87950. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  87951. private _comparePickingInfo;
  87952. private static smallnum;
  87953. private static rayl;
  87954. /**
  87955. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  87956. * @param sega the first point of the segment to test the intersection against
  87957. * @param segb the second point of the segment to test the intersection against
  87958. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  87959. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  87960. */
  87961. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  87962. /**
  87963. * Update the ray from viewport position
  87964. * @param x position
  87965. * @param y y position
  87966. * @param viewportWidth viewport width
  87967. * @param viewportHeight viewport height
  87968. * @param world world matrix
  87969. * @param view view matrix
  87970. * @param projection projection matrix
  87971. * @returns this ray updated
  87972. */
  87973. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87974. /**
  87975. * Creates a ray with origin and direction of 0,0,0
  87976. * @returns the new ray
  87977. */
  87978. static Zero(): Ray;
  87979. /**
  87980. * Creates a new ray from screen space and viewport
  87981. * @param x position
  87982. * @param y y position
  87983. * @param viewportWidth viewport width
  87984. * @param viewportHeight viewport height
  87985. * @param world world matrix
  87986. * @param view view matrix
  87987. * @param projection projection matrix
  87988. * @returns new ray
  87989. */
  87990. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  87991. /**
  87992. * 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
  87993. * transformed to the given world matrix.
  87994. * @param origin The origin point
  87995. * @param end The end point
  87996. * @param world a matrix to transform the ray to. Default is the identity matrix.
  87997. * @returns the new ray
  87998. */
  87999. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  88000. /**
  88001. * Transforms a ray by a matrix
  88002. * @param ray ray to transform
  88003. * @param matrix matrix to apply
  88004. * @returns the resulting new ray
  88005. */
  88006. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88007. /**
  88008. * Transforms a ray by a matrix
  88009. * @param ray ray to transform
  88010. * @param matrix matrix to apply
  88011. * @param result ray to store result in
  88012. */
  88013. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88014. /**
  88015. * Unproject a ray from screen space to object space
  88016. * @param sourceX defines the screen space x coordinate to use
  88017. * @param sourceY defines the screen space y coordinate to use
  88018. * @param viewportWidth defines the current width of the viewport
  88019. * @param viewportHeight defines the current height of the viewport
  88020. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88021. * @param view defines the view matrix to use
  88022. * @param projection defines the projection matrix to use
  88023. */
  88024. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88025. }
  88026. /**
  88027. * Type used to define predicate used to select faces when a mesh intersection is detected
  88028. */
  88029. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88030. interface Scene {
  88031. /** @hidden */
  88032. _tempPickingRay: Nullable<Ray>;
  88033. /** @hidden */
  88034. _cachedRayForTransform: Ray;
  88035. /** @hidden */
  88036. _pickWithRayInverseMatrix: Matrix;
  88037. /** @hidden */
  88038. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88039. /** @hidden */
  88040. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88041. }
  88042. }
  88043. declare module BABYLON {
  88044. /**
  88045. * Groups all the scene component constants in one place to ease maintenance.
  88046. * @hidden
  88047. */
  88048. export class SceneComponentConstants {
  88049. static readonly NAME_EFFECTLAYER: string;
  88050. static readonly NAME_LAYER: string;
  88051. static readonly NAME_LENSFLARESYSTEM: string;
  88052. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88053. static readonly NAME_PARTICLESYSTEM: string;
  88054. static readonly NAME_GAMEPAD: string;
  88055. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88056. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88057. static readonly NAME_DEPTHRENDERER: string;
  88058. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88059. static readonly NAME_SPRITE: string;
  88060. static readonly NAME_OUTLINERENDERER: string;
  88061. static readonly NAME_PROCEDURALTEXTURE: string;
  88062. static readonly NAME_SHADOWGENERATOR: string;
  88063. static readonly NAME_OCTREE: string;
  88064. static readonly NAME_PHYSICSENGINE: string;
  88065. static readonly NAME_AUDIO: string;
  88066. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88067. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88068. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88069. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88070. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88071. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88072. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88073. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88074. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88075. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88076. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88077. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88078. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88079. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88080. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88081. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88082. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88083. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88084. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88085. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88086. static readonly STEP_AFTERRENDER_AUDIO: number;
  88087. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88088. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88089. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88090. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88091. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88092. static readonly STEP_POINTERMOVE_SPRITE: number;
  88093. static readonly STEP_POINTERDOWN_SPRITE: number;
  88094. static readonly STEP_POINTERUP_SPRITE: number;
  88095. }
  88096. /**
  88097. * This represents a scene component.
  88098. *
  88099. * This is used to decouple the dependency the scene is having on the different workloads like
  88100. * layers, post processes...
  88101. */
  88102. export interface ISceneComponent {
  88103. /**
  88104. * The name of the component. Each component must have a unique name.
  88105. */
  88106. name: string;
  88107. /**
  88108. * The scene the component belongs to.
  88109. */
  88110. scene: Scene;
  88111. /**
  88112. * Register the component to one instance of a scene.
  88113. */
  88114. register(): void;
  88115. /**
  88116. * Rebuilds the elements related to this component in case of
  88117. * context lost for instance.
  88118. */
  88119. rebuild(): void;
  88120. /**
  88121. * Disposes the component and the associated ressources.
  88122. */
  88123. dispose(): void;
  88124. }
  88125. /**
  88126. * This represents a SERIALIZABLE scene component.
  88127. *
  88128. * This extends Scene Component to add Serialization methods on top.
  88129. */
  88130. export interface ISceneSerializableComponent extends ISceneComponent {
  88131. /**
  88132. * Adds all the elements from the container to the scene
  88133. * @param container the container holding the elements
  88134. */
  88135. addFromContainer(container: AbstractScene): void;
  88136. /**
  88137. * Removes all the elements in the container from the scene
  88138. * @param container contains the elements to remove
  88139. * @param dispose if the removed element should be disposed (default: false)
  88140. */
  88141. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88142. /**
  88143. * Serializes the component data to the specified json object
  88144. * @param serializationObject The object to serialize to
  88145. */
  88146. serialize(serializationObject: any): void;
  88147. }
  88148. /**
  88149. * Strong typing of a Mesh related stage step action
  88150. */
  88151. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88152. /**
  88153. * Strong typing of a Evaluate Sub Mesh related stage step action
  88154. */
  88155. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88156. /**
  88157. * Strong typing of a Active Mesh related stage step action
  88158. */
  88159. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88160. /**
  88161. * Strong typing of a Camera related stage step action
  88162. */
  88163. export type CameraStageAction = (camera: Camera) => void;
  88164. /**
  88165. * Strong typing of a Camera Frame buffer related stage step action
  88166. */
  88167. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88168. /**
  88169. * Strong typing of a Render Target related stage step action
  88170. */
  88171. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88172. /**
  88173. * Strong typing of a RenderingGroup related stage step action
  88174. */
  88175. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88176. /**
  88177. * Strong typing of a Mesh Render related stage step action
  88178. */
  88179. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88180. /**
  88181. * Strong typing of a simple stage step action
  88182. */
  88183. export type SimpleStageAction = () => void;
  88184. /**
  88185. * Strong typing of a render target action.
  88186. */
  88187. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88188. /**
  88189. * Strong typing of a pointer move action.
  88190. */
  88191. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88192. /**
  88193. * Strong typing of a pointer up/down action.
  88194. */
  88195. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88196. /**
  88197. * Representation of a stage in the scene (Basically a list of ordered steps)
  88198. * @hidden
  88199. */
  88200. export class Stage<T extends Function> extends Array<{
  88201. index: number;
  88202. component: ISceneComponent;
  88203. action: T;
  88204. }> {
  88205. /**
  88206. * Hide ctor from the rest of the world.
  88207. * @param items The items to add.
  88208. */
  88209. private constructor();
  88210. /**
  88211. * Creates a new Stage.
  88212. * @returns A new instance of a Stage
  88213. */
  88214. static Create<T extends Function>(): Stage<T>;
  88215. /**
  88216. * Registers a step in an ordered way in the targeted stage.
  88217. * @param index Defines the position to register the step in
  88218. * @param component Defines the component attached to the step
  88219. * @param action Defines the action to launch during the step
  88220. */
  88221. registerStep(index: number, component: ISceneComponent, action: T): void;
  88222. /**
  88223. * Clears all the steps from the stage.
  88224. */
  88225. clear(): void;
  88226. }
  88227. }
  88228. declare module BABYLON {
  88229. interface Scene {
  88230. /** @hidden */
  88231. _pointerOverSprite: Nullable<Sprite>;
  88232. /** @hidden */
  88233. _pickedDownSprite: Nullable<Sprite>;
  88234. /** @hidden */
  88235. _tempSpritePickingRay: Nullable<Ray>;
  88236. /**
  88237. * All of the sprite managers added to this scene
  88238. * @see http://doc.babylonjs.com/babylon101/sprites
  88239. */
  88240. spriteManagers: Array<ISpriteManager>;
  88241. /**
  88242. * An event triggered when sprites rendering is about to start
  88243. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88244. */
  88245. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88246. /**
  88247. * An event triggered when sprites rendering is done
  88248. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88249. */
  88250. onAfterSpritesRenderingObservable: Observable<Scene>;
  88251. /** @hidden */
  88252. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88253. /** Launch a ray to try to pick a sprite in the scene
  88254. * @param x position on screen
  88255. * @param y position on screen
  88256. * @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
  88257. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88258. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88259. * @returns a PickingInfo
  88260. */
  88261. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88262. /** Use the given ray to pick a sprite in the scene
  88263. * @param ray The ray (in world space) to use to pick meshes
  88264. * @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
  88265. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88266. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88267. * @returns a PickingInfo
  88268. */
  88269. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88270. /** @hidden */
  88271. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88272. /** Launch a ray to try to pick sprites in the scene
  88273. * @param x position on screen
  88274. * @param y position on screen
  88275. * @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
  88276. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88277. * @returns a PickingInfo array
  88278. */
  88279. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88280. /** Use the given ray to pick sprites in the scene
  88281. * @param ray The ray (in world space) to use to pick meshes
  88282. * @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
  88283. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88284. * @returns a PickingInfo array
  88285. */
  88286. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88287. /**
  88288. * Force the sprite under the pointer
  88289. * @param sprite defines the sprite to use
  88290. */
  88291. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88292. /**
  88293. * Gets the sprite under the pointer
  88294. * @returns a Sprite or null if no sprite is under the pointer
  88295. */
  88296. getPointerOverSprite(): Nullable<Sprite>;
  88297. }
  88298. /**
  88299. * Defines the sprite scene component responsible to manage sprites
  88300. * in a given scene.
  88301. */
  88302. export class SpriteSceneComponent implements ISceneComponent {
  88303. /**
  88304. * The component name helpfull to identify the component in the list of scene components.
  88305. */
  88306. readonly name: string;
  88307. /**
  88308. * The scene the component belongs to.
  88309. */
  88310. scene: Scene;
  88311. /** @hidden */
  88312. private _spritePredicate;
  88313. /**
  88314. * Creates a new instance of the component for the given scene
  88315. * @param scene Defines the scene to register the component in
  88316. */
  88317. constructor(scene: Scene);
  88318. /**
  88319. * Registers the component in a given scene
  88320. */
  88321. register(): void;
  88322. /**
  88323. * Rebuilds the elements related to this component in case of
  88324. * context lost for instance.
  88325. */
  88326. rebuild(): void;
  88327. /**
  88328. * Disposes the component and the associated ressources.
  88329. */
  88330. dispose(): void;
  88331. private _pickSpriteButKeepRay;
  88332. private _pointerMove;
  88333. private _pointerDown;
  88334. private _pointerUp;
  88335. }
  88336. }
  88337. declare module BABYLON {
  88338. /** @hidden */
  88339. export var fogFragmentDeclaration: {
  88340. name: string;
  88341. shader: string;
  88342. };
  88343. }
  88344. declare module BABYLON {
  88345. /** @hidden */
  88346. export var fogFragment: {
  88347. name: string;
  88348. shader: string;
  88349. };
  88350. }
  88351. declare module BABYLON {
  88352. /** @hidden */
  88353. export var spritesPixelShader: {
  88354. name: string;
  88355. shader: string;
  88356. };
  88357. }
  88358. declare module BABYLON {
  88359. /** @hidden */
  88360. export var fogVertexDeclaration: {
  88361. name: string;
  88362. shader: string;
  88363. };
  88364. }
  88365. declare module BABYLON {
  88366. /** @hidden */
  88367. export var spritesVertexShader: {
  88368. name: string;
  88369. shader: string;
  88370. };
  88371. }
  88372. declare module BABYLON {
  88373. /**
  88374. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88375. */
  88376. export interface ISpriteManager extends IDisposable {
  88377. /**
  88378. * Gets manager's name
  88379. */
  88380. name: string;
  88381. /**
  88382. * Restricts the camera to viewing objects with the same layerMask.
  88383. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88384. */
  88385. layerMask: number;
  88386. /**
  88387. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88388. */
  88389. isPickable: boolean;
  88390. /**
  88391. * Gets the hosting scene
  88392. */
  88393. scene: Scene;
  88394. /**
  88395. * Specifies the rendering group id for this mesh (0 by default)
  88396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88397. */
  88398. renderingGroupId: number;
  88399. /**
  88400. * Defines the list of sprites managed by the manager.
  88401. */
  88402. sprites: Array<Sprite>;
  88403. /**
  88404. * Gets or sets the spritesheet texture
  88405. */
  88406. texture: Texture;
  88407. /** Defines the default width of a cell in the spritesheet */
  88408. cellWidth: number;
  88409. /** Defines the default height of a cell in the spritesheet */
  88410. cellHeight: number;
  88411. /**
  88412. * Tests the intersection of a sprite with a specific ray.
  88413. * @param ray The ray we are sending to test the collision
  88414. * @param camera The camera space we are sending rays in
  88415. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88416. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88417. * @returns picking info or null.
  88418. */
  88419. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88420. /**
  88421. * Intersects the sprites with a ray
  88422. * @param ray defines the ray to intersect with
  88423. * @param camera defines the current active camera
  88424. * @param predicate defines a predicate used to select candidate sprites
  88425. * @returns null if no hit or a PickingInfo array
  88426. */
  88427. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88428. /**
  88429. * Renders the list of sprites on screen.
  88430. */
  88431. render(): void;
  88432. }
  88433. /**
  88434. * Class used to manage multiple sprites on the same spritesheet
  88435. * @see http://doc.babylonjs.com/babylon101/sprites
  88436. */
  88437. export class SpriteManager implements ISpriteManager {
  88438. /** defines the manager's name */
  88439. name: string;
  88440. /** Define the Url to load snippets */
  88441. static SnippetUrl: string;
  88442. /** Snippet ID if the manager was created from the snippet server */
  88443. snippetId: string;
  88444. /** Gets the list of sprites */
  88445. sprites: Sprite[];
  88446. /** Gets or sets the rendering group id (0 by default) */
  88447. renderingGroupId: number;
  88448. /** Gets or sets camera layer mask */
  88449. layerMask: number;
  88450. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88451. fogEnabled: boolean;
  88452. /** Gets or sets a boolean indicating if the sprites are pickable */
  88453. isPickable: boolean;
  88454. /** Defines the default width of a cell in the spritesheet */
  88455. cellWidth: number;
  88456. /** Defines the default height of a cell in the spritesheet */
  88457. cellHeight: number;
  88458. /** Associative array from JSON sprite data file */
  88459. private _cellData;
  88460. /** Array of sprite names from JSON sprite data file */
  88461. private _spriteMap;
  88462. /** True when packed cell data from JSON file is ready*/
  88463. private _packedAndReady;
  88464. private _textureContent;
  88465. /**
  88466. * An event triggered when the manager is disposed.
  88467. */
  88468. onDisposeObservable: Observable<SpriteManager>;
  88469. private _onDisposeObserver;
  88470. /**
  88471. * Callback called when the manager is disposed
  88472. */
  88473. set onDispose(callback: () => void);
  88474. private _capacity;
  88475. private _fromPacked;
  88476. private _spriteTexture;
  88477. private _epsilon;
  88478. private _scene;
  88479. private _vertexData;
  88480. private _buffer;
  88481. private _vertexBuffers;
  88482. private _indexBuffer;
  88483. private _effectBase;
  88484. private _effectFog;
  88485. /**
  88486. * Gets or sets the unique id of the sprite
  88487. */
  88488. uniqueId: number;
  88489. /**
  88490. * Gets the array of sprites
  88491. */
  88492. get children(): Sprite[];
  88493. /**
  88494. * Gets the hosting scene
  88495. */
  88496. get scene(): Scene;
  88497. /**
  88498. * Gets the capacity of the manager
  88499. */
  88500. get capacity(): number;
  88501. /**
  88502. * Gets or sets the spritesheet texture
  88503. */
  88504. get texture(): Texture;
  88505. set texture(value: Texture);
  88506. private _blendMode;
  88507. /**
  88508. * Blend mode use to render the particle, it can be any of
  88509. * the static Constants.ALPHA_x properties provided in this class.
  88510. * Default value is Constants.ALPHA_COMBINE
  88511. */
  88512. get blendMode(): number;
  88513. set blendMode(blendMode: number);
  88514. /** Disables writing to the depth buffer when rendering the sprites.
  88515. * It can be handy to disable depth writing when using textures without alpha channel
  88516. * and setting some specific blend modes.
  88517. */
  88518. disableDepthWrite: boolean;
  88519. /**
  88520. * Creates a new sprite manager
  88521. * @param name defines the manager's name
  88522. * @param imgUrl defines the sprite sheet url
  88523. * @param capacity defines the maximum allowed number of sprites
  88524. * @param cellSize defines the size of a sprite cell
  88525. * @param scene defines the hosting scene
  88526. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88527. * @param samplingMode defines the smapling mode to use with spritesheet
  88528. * @param fromPacked set to false; do not alter
  88529. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88530. */
  88531. constructor(
  88532. /** defines the manager's name */
  88533. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88534. /**
  88535. * Returns the string "SpriteManager"
  88536. * @returns "SpriteManager"
  88537. */
  88538. getClassName(): string;
  88539. private _makePacked;
  88540. private _appendSpriteVertex;
  88541. private _checkTextureAlpha;
  88542. /**
  88543. * Intersects the sprites with a ray
  88544. * @param ray defines the ray to intersect with
  88545. * @param camera defines the current active camera
  88546. * @param predicate defines a predicate used to select candidate sprites
  88547. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88548. * @returns null if no hit or a PickingInfo
  88549. */
  88550. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88551. /**
  88552. * Intersects the sprites with a ray
  88553. * @param ray defines the ray to intersect with
  88554. * @param camera defines the current active camera
  88555. * @param predicate defines a predicate used to select candidate sprites
  88556. * @returns null if no hit or a PickingInfo array
  88557. */
  88558. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88559. /**
  88560. * Render all child sprites
  88561. */
  88562. render(): void;
  88563. /**
  88564. * Release associated resources
  88565. */
  88566. dispose(): void;
  88567. /**
  88568. * Serializes the sprite manager to a JSON object
  88569. * @param serializeTexture defines if the texture must be serialized as well
  88570. * @returns the JSON object
  88571. */
  88572. serialize(serializeTexture?: boolean): any;
  88573. /**
  88574. * Parses a JSON object to create a new sprite manager.
  88575. * @param parsedManager The JSON object to parse
  88576. * @param scene The scene to create the sprite managerin
  88577. * @param rootUrl The root url to use to load external dependencies like texture
  88578. * @returns the new sprite manager
  88579. */
  88580. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88581. /**
  88582. * Creates a sprite manager from a snippet saved in a remote file
  88583. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88584. * @param url defines the url to load from
  88585. * @param scene defines the hosting scene
  88586. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88587. * @returns a promise that will resolve to the new sprite manager
  88588. */
  88589. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88590. /**
  88591. * Creates a sprite manager from a snippet saved by the sprite editor
  88592. * @param snippetId defines the snippet to load
  88593. * @param scene defines the hosting scene
  88594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88595. * @returns a promise that will resolve to the new sprite manager
  88596. */
  88597. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88598. }
  88599. }
  88600. declare module BABYLON {
  88601. /** Interface used by value gradients (color, factor, ...) */
  88602. export interface IValueGradient {
  88603. /**
  88604. * Gets or sets the gradient value (between 0 and 1)
  88605. */
  88606. gradient: number;
  88607. }
  88608. /** Class used to store color4 gradient */
  88609. export class ColorGradient implements IValueGradient {
  88610. /**
  88611. * Gets or sets the gradient value (between 0 and 1)
  88612. */
  88613. gradient: number;
  88614. /**
  88615. * Gets or sets first associated color
  88616. */
  88617. color1: Color4;
  88618. /**
  88619. * Gets or sets second associated color
  88620. */
  88621. color2?: Color4 | undefined;
  88622. /**
  88623. * Creates a new color4 gradient
  88624. * @param gradient gets or sets the gradient value (between 0 and 1)
  88625. * @param color1 gets or sets first associated color
  88626. * @param color2 gets or sets first second color
  88627. */
  88628. constructor(
  88629. /**
  88630. * Gets or sets the gradient value (between 0 and 1)
  88631. */
  88632. gradient: number,
  88633. /**
  88634. * Gets or sets first associated color
  88635. */
  88636. color1: Color4,
  88637. /**
  88638. * Gets or sets second associated color
  88639. */
  88640. color2?: Color4 | undefined);
  88641. /**
  88642. * Will get a color picked randomly between color1 and color2.
  88643. * If color2 is undefined then color1 will be used
  88644. * @param result defines the target Color4 to store the result in
  88645. */
  88646. getColorToRef(result: Color4): void;
  88647. }
  88648. /** Class used to store color 3 gradient */
  88649. export class Color3Gradient implements IValueGradient {
  88650. /**
  88651. * Gets or sets the gradient value (between 0 and 1)
  88652. */
  88653. gradient: number;
  88654. /**
  88655. * Gets or sets the associated color
  88656. */
  88657. color: Color3;
  88658. /**
  88659. * Creates a new color3 gradient
  88660. * @param gradient gets or sets the gradient value (between 0 and 1)
  88661. * @param color gets or sets associated color
  88662. */
  88663. constructor(
  88664. /**
  88665. * Gets or sets the gradient value (between 0 and 1)
  88666. */
  88667. gradient: number,
  88668. /**
  88669. * Gets or sets the associated color
  88670. */
  88671. color: Color3);
  88672. }
  88673. /** Class used to store factor gradient */
  88674. export class FactorGradient implements IValueGradient {
  88675. /**
  88676. * Gets or sets the gradient value (between 0 and 1)
  88677. */
  88678. gradient: number;
  88679. /**
  88680. * Gets or sets first associated factor
  88681. */
  88682. factor1: number;
  88683. /**
  88684. * Gets or sets second associated factor
  88685. */
  88686. factor2?: number | undefined;
  88687. /**
  88688. * Creates a new factor gradient
  88689. * @param gradient gets or sets the gradient value (between 0 and 1)
  88690. * @param factor1 gets or sets first associated factor
  88691. * @param factor2 gets or sets second associated factor
  88692. */
  88693. constructor(
  88694. /**
  88695. * Gets or sets the gradient value (between 0 and 1)
  88696. */
  88697. gradient: number,
  88698. /**
  88699. * Gets or sets first associated factor
  88700. */
  88701. factor1: number,
  88702. /**
  88703. * Gets or sets second associated factor
  88704. */
  88705. factor2?: number | undefined);
  88706. /**
  88707. * Will get a number picked randomly between factor1 and factor2.
  88708. * If factor2 is undefined then factor1 will be used
  88709. * @returns the picked number
  88710. */
  88711. getFactor(): number;
  88712. }
  88713. /**
  88714. * Helper used to simplify some generic gradient tasks
  88715. */
  88716. export class GradientHelper {
  88717. /**
  88718. * Gets the current gradient from an array of IValueGradient
  88719. * @param ratio defines the current ratio to get
  88720. * @param gradients defines the array of IValueGradient
  88721. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88722. */
  88723. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88724. }
  88725. }
  88726. declare module BABYLON {
  88727. interface ThinEngine {
  88728. /**
  88729. * Creates a dynamic texture
  88730. * @param width defines the width of the texture
  88731. * @param height defines the height of the texture
  88732. * @param generateMipMaps defines if the engine should generate the mip levels
  88733. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88734. * @returns the dynamic texture inside an InternalTexture
  88735. */
  88736. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88737. /**
  88738. * Update the content of a dynamic texture
  88739. * @param texture defines the texture to update
  88740. * @param canvas defines the canvas containing the source
  88741. * @param invertY defines if data must be stored with Y axis inverted
  88742. * @param premulAlpha defines if alpha is stored as premultiplied
  88743. * @param format defines the format of the data
  88744. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88745. */
  88746. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88747. }
  88748. }
  88749. declare module BABYLON {
  88750. /**
  88751. * Helper class used to generate a canvas to manipulate images
  88752. */
  88753. export class CanvasGenerator {
  88754. /**
  88755. * Create a new canvas (or offscreen canvas depending on the context)
  88756. * @param width defines the expected width
  88757. * @param height defines the expected height
  88758. * @return a new canvas or offscreen canvas
  88759. */
  88760. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88761. }
  88762. }
  88763. declare module BABYLON {
  88764. /**
  88765. * A class extending Texture allowing drawing on a texture
  88766. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88767. */
  88768. export class DynamicTexture extends Texture {
  88769. private _generateMipMaps;
  88770. private _canvas;
  88771. private _context;
  88772. /**
  88773. * Creates a DynamicTexture
  88774. * @param name defines the name of the texture
  88775. * @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
  88776. * @param scene defines the scene where you want the texture
  88777. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88778. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88779. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88780. */
  88781. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88782. /**
  88783. * Get the current class name of the texture useful for serialization or dynamic coding.
  88784. * @returns "DynamicTexture"
  88785. */
  88786. getClassName(): string;
  88787. /**
  88788. * Gets the current state of canRescale
  88789. */
  88790. get canRescale(): boolean;
  88791. private _recreate;
  88792. /**
  88793. * Scales the texture
  88794. * @param ratio the scale factor to apply to both width and height
  88795. */
  88796. scale(ratio: number): void;
  88797. /**
  88798. * Resizes the texture
  88799. * @param width the new width
  88800. * @param height the new height
  88801. */
  88802. scaleTo(width: number, height: number): void;
  88803. /**
  88804. * Gets the context of the canvas used by the texture
  88805. * @returns the canvas context of the dynamic texture
  88806. */
  88807. getContext(): CanvasRenderingContext2D;
  88808. /**
  88809. * Clears the texture
  88810. */
  88811. clear(): void;
  88812. /**
  88813. * Updates the texture
  88814. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88815. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88816. */
  88817. update(invertY?: boolean, premulAlpha?: boolean): void;
  88818. /**
  88819. * Draws text onto the texture
  88820. * @param text defines the text to be drawn
  88821. * @param x defines the placement of the text from the left
  88822. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88823. * @param font defines the font to be used with font-style, font-size, font-name
  88824. * @param color defines the color used for the text
  88825. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88826. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88827. * @param update defines whether texture is immediately update (default is true)
  88828. */
  88829. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  88830. /**
  88831. * Clones the texture
  88832. * @returns the clone of the texture.
  88833. */
  88834. clone(): DynamicTexture;
  88835. /**
  88836. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  88837. * @returns a serialized dynamic texture object
  88838. */
  88839. serialize(): any;
  88840. /** @hidden */
  88841. _rebuild(): void;
  88842. }
  88843. }
  88844. declare module BABYLON {
  88845. interface ThinEngine {
  88846. /**
  88847. * Creates a raw texture
  88848. * @param data defines the data to store in the texture
  88849. * @param width defines the width of the texture
  88850. * @param height defines the height of the texture
  88851. * @param format defines the format of the data
  88852. * @param generateMipMaps defines if the engine should generate the mip levels
  88853. * @param invertY defines if data must be stored with Y axis inverted
  88854. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88855. * @param compression defines the compression used (null by default)
  88856. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88857. * @returns the raw texture inside an InternalTexture
  88858. */
  88859. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88860. /**
  88861. * Update a raw texture
  88862. * @param texture defines the texture to update
  88863. * @param data defines the data to store in the texture
  88864. * @param format defines the format of the data
  88865. * @param invertY defines if data must be stored with Y axis inverted
  88866. */
  88867. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88868. /**
  88869. * Update a raw texture
  88870. * @param texture defines the texture to update
  88871. * @param data defines the data to store in the texture
  88872. * @param format defines the format of the data
  88873. * @param invertY defines if data must be stored with Y axis inverted
  88874. * @param compression defines the compression used (null by default)
  88875. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88876. */
  88877. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88878. /**
  88879. * Creates a new raw cube texture
  88880. * @param data defines the array of data to use to create each face
  88881. * @param size defines the size of the textures
  88882. * @param format defines the format of the data
  88883. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88884. * @param generateMipMaps defines if the engine should generate the mip levels
  88885. * @param invertY defines if data must be stored with Y axis inverted
  88886. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88887. * @param compression defines the compression used (null by default)
  88888. * @returns the cube texture as an InternalTexture
  88889. */
  88890. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88891. /**
  88892. * Update a raw cube texture
  88893. * @param texture defines the texture to udpdate
  88894. * @param data defines the data to store
  88895. * @param format defines the data format
  88896. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88897. * @param invertY defines if data must be stored with Y axis inverted
  88898. */
  88899. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88900. /**
  88901. * Update a raw cube texture
  88902. * @param texture defines the texture to udpdate
  88903. * @param data defines the data to store
  88904. * @param format defines the data format
  88905. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88906. * @param invertY defines if data must be stored with Y axis inverted
  88907. * @param compression defines the compression used (null by default)
  88908. */
  88909. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88910. /**
  88911. * Update a raw cube texture
  88912. * @param texture defines the texture to udpdate
  88913. * @param data defines the data to store
  88914. * @param format defines the data format
  88915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88916. * @param invertY defines if data must be stored with Y axis inverted
  88917. * @param compression defines the compression used (null by default)
  88918. * @param level defines which level of the texture to update
  88919. */
  88920. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88921. /**
  88922. * Creates a new raw cube texture from a specified url
  88923. * @param url defines the url where the data is located
  88924. * @param scene defines the current scene
  88925. * @param size defines the size of the textures
  88926. * @param format defines the format of the data
  88927. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88928. * @param noMipmap defines if the engine should avoid generating the mip levels
  88929. * @param callback defines a callback used to extract texture data from loaded data
  88930. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88931. * @param onLoad defines a callback called when texture is loaded
  88932. * @param onError defines a callback called if there is an error
  88933. * @returns the cube texture as an InternalTexture
  88934. */
  88935. 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;
  88936. /**
  88937. * Creates a new raw cube texture from a specified url
  88938. * @param url defines the url where the data is located
  88939. * @param scene defines the current scene
  88940. * @param size defines the size of the textures
  88941. * @param format defines the format of the data
  88942. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88943. * @param noMipmap defines if the engine should avoid generating the mip levels
  88944. * @param callback defines a callback used to extract texture data from loaded data
  88945. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88946. * @param onLoad defines a callback called when texture is loaded
  88947. * @param onError defines a callback called if there is an error
  88948. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88949. * @param invertY defines if data must be stored with Y axis inverted
  88950. * @returns the cube texture as an InternalTexture
  88951. */
  88952. 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;
  88953. /**
  88954. * Creates a new raw 3D texture
  88955. * @param data defines the data used to create the texture
  88956. * @param width defines the width of the texture
  88957. * @param height defines the height of the texture
  88958. * @param depth defines the depth of the texture
  88959. * @param format defines the format of the texture
  88960. * @param generateMipMaps defines if the engine must generate mip levels
  88961. * @param invertY defines if data must be stored with Y axis inverted
  88962. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88963. * @param compression defines the compressed used (can be null)
  88964. * @param textureType defines the compressed used (can be null)
  88965. * @returns a new raw 3D texture (stored in an InternalTexture)
  88966. */
  88967. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  88968. /**
  88969. * Update a raw 3D texture
  88970. * @param texture defines the texture to update
  88971. * @param data defines the data to store
  88972. * @param format defines the data format
  88973. * @param invertY defines if data must be stored with Y axis inverted
  88974. */
  88975. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88976. /**
  88977. * Update a raw 3D texture
  88978. * @param texture defines the texture to update
  88979. * @param data defines the data to store
  88980. * @param format defines the data format
  88981. * @param invertY defines if data must be stored with Y axis inverted
  88982. * @param compression defines the used compression (can be null)
  88983. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88984. */
  88985. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  88986. /**
  88987. * Creates a new raw 2D array texture
  88988. * @param data defines the data used to create the texture
  88989. * @param width defines the width of the texture
  88990. * @param height defines the height of the texture
  88991. * @param depth defines the number of layers of the texture
  88992. * @param format defines the format of the texture
  88993. * @param generateMipMaps defines if the engine must generate mip levels
  88994. * @param invertY defines if data must be stored with Y axis inverted
  88995. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88996. * @param compression defines the compressed used (can be null)
  88997. * @param textureType defines the compressed used (can be null)
  88998. * @returns a new raw 2D array texture (stored in an InternalTexture)
  88999. */
  89000. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89001. /**
  89002. * Update a raw 2D array texture
  89003. * @param texture defines the texture to update
  89004. * @param data defines the data to store
  89005. * @param format defines the data format
  89006. * @param invertY defines if data must be stored with Y axis inverted
  89007. */
  89008. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89009. /**
  89010. * Update a raw 2D array texture
  89011. * @param texture defines the texture to update
  89012. * @param data defines the data to store
  89013. * @param format defines the data format
  89014. * @param invertY defines if data must be stored with Y axis inverted
  89015. * @param compression defines the used compression (can be null)
  89016. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89017. */
  89018. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89019. }
  89020. }
  89021. declare module BABYLON {
  89022. /**
  89023. * Raw texture can help creating a texture directly from an array of data.
  89024. * This can be super useful if you either get the data from an uncompressed source or
  89025. * if you wish to create your texture pixel by pixel.
  89026. */
  89027. export class RawTexture extends Texture {
  89028. /**
  89029. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89030. */
  89031. format: number;
  89032. /**
  89033. * Instantiates a new RawTexture.
  89034. * Raw texture can help creating a texture directly from an array of data.
  89035. * This can be super useful if you either get the data from an uncompressed source or
  89036. * if you wish to create your texture pixel by pixel.
  89037. * @param data define the array of data to use to create the texture
  89038. * @param width define the width of the texture
  89039. * @param height define the height of the texture
  89040. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89041. * @param scene define the scene the texture belongs to
  89042. * @param generateMipMaps define whether mip maps should be generated or not
  89043. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89044. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89045. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89046. */
  89047. constructor(data: ArrayBufferView, width: number, height: number,
  89048. /**
  89049. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89050. */
  89051. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89052. /**
  89053. * Updates the texture underlying data.
  89054. * @param data Define the new data of the texture
  89055. */
  89056. update(data: ArrayBufferView): void;
  89057. /**
  89058. * Creates a luminance texture from some data.
  89059. * @param data Define the texture data
  89060. * @param width Define the width of the texture
  89061. * @param height Define the height of the texture
  89062. * @param scene Define the scene the texture belongs to
  89063. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89064. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89065. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89066. * @returns the luminance texture
  89067. */
  89068. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89069. /**
  89070. * Creates a luminance alpha texture from some data.
  89071. * @param data Define the texture data
  89072. * @param width Define the width of the texture
  89073. * @param height Define the height of the texture
  89074. * @param scene Define the scene the texture belongs to
  89075. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89076. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89077. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89078. * @returns the luminance alpha texture
  89079. */
  89080. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89081. /**
  89082. * Creates an alpha texture from some data.
  89083. * @param data Define the texture data
  89084. * @param width Define the width of the texture
  89085. * @param height Define the height of the texture
  89086. * @param scene Define the scene the texture belongs to
  89087. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89088. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89089. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89090. * @returns the alpha texture
  89091. */
  89092. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89093. /**
  89094. * Creates a RGB texture from some data.
  89095. * @param data Define the texture data
  89096. * @param width Define the width of the texture
  89097. * @param height Define the height of the texture
  89098. * @param scene Define the scene the texture belongs to
  89099. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89100. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89101. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89102. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89103. * @returns the RGB alpha texture
  89104. */
  89105. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89106. /**
  89107. * Creates a RGBA texture from some data.
  89108. * @param data Define the texture data
  89109. * @param width Define the width of the texture
  89110. * @param height Define the height of the texture
  89111. * @param scene Define the scene the texture belongs to
  89112. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89113. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89114. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89115. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89116. * @returns the RGBA texture
  89117. */
  89118. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89119. /**
  89120. * Creates a R texture from some data.
  89121. * @param data Define the texture data
  89122. * @param width Define the width of the texture
  89123. * @param height Define the height of the texture
  89124. * @param scene Define the scene the texture belongs to
  89125. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89126. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89127. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89128. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89129. * @returns the R texture
  89130. */
  89131. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89132. }
  89133. }
  89134. declare module BABYLON {
  89135. interface AbstractScene {
  89136. /**
  89137. * The list of procedural textures added to the scene
  89138. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89139. */
  89140. proceduralTextures: Array<ProceduralTexture>;
  89141. }
  89142. /**
  89143. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89144. * in a given scene.
  89145. */
  89146. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89147. /**
  89148. * The component name helpfull to identify the component in the list of scene components.
  89149. */
  89150. readonly name: string;
  89151. /**
  89152. * The scene the component belongs to.
  89153. */
  89154. scene: Scene;
  89155. /**
  89156. * Creates a new instance of the component for the given scene
  89157. * @param scene Defines the scene to register the component in
  89158. */
  89159. constructor(scene: Scene);
  89160. /**
  89161. * Registers the component in a given scene
  89162. */
  89163. register(): void;
  89164. /**
  89165. * Rebuilds the elements related to this component in case of
  89166. * context lost for instance.
  89167. */
  89168. rebuild(): void;
  89169. /**
  89170. * Disposes the component and the associated ressources.
  89171. */
  89172. dispose(): void;
  89173. private _beforeClear;
  89174. }
  89175. }
  89176. declare module BABYLON {
  89177. interface ThinEngine {
  89178. /**
  89179. * Creates a new render target cube texture
  89180. * @param size defines the size of the texture
  89181. * @param options defines the options used to create the texture
  89182. * @returns a new render target cube texture stored in an InternalTexture
  89183. */
  89184. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89185. }
  89186. }
  89187. declare module BABYLON {
  89188. /** @hidden */
  89189. export var proceduralVertexShader: {
  89190. name: string;
  89191. shader: string;
  89192. };
  89193. }
  89194. declare module BABYLON {
  89195. /**
  89196. * 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.
  89197. * This is the base class of any Procedural texture and contains most of the shareable code.
  89198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89199. */
  89200. export class ProceduralTexture extends Texture {
  89201. isCube: boolean;
  89202. /**
  89203. * Define if the texture is enabled or not (disabled texture will not render)
  89204. */
  89205. isEnabled: boolean;
  89206. /**
  89207. * Define if the texture must be cleared before rendering (default is true)
  89208. */
  89209. autoClear: boolean;
  89210. /**
  89211. * Callback called when the texture is generated
  89212. */
  89213. onGenerated: () => void;
  89214. /**
  89215. * Event raised when the texture is generated
  89216. */
  89217. onGeneratedObservable: Observable<ProceduralTexture>;
  89218. /** @hidden */
  89219. _generateMipMaps: boolean;
  89220. /** @hidden **/
  89221. _effect: Effect;
  89222. /** @hidden */
  89223. _textures: {
  89224. [key: string]: Texture;
  89225. };
  89226. /** @hidden */
  89227. protected _fallbackTexture: Nullable<Texture>;
  89228. private _size;
  89229. private _currentRefreshId;
  89230. private _frameId;
  89231. private _refreshRate;
  89232. private _vertexBuffers;
  89233. private _indexBuffer;
  89234. private _uniforms;
  89235. private _samplers;
  89236. private _fragment;
  89237. private _floats;
  89238. private _ints;
  89239. private _floatsArrays;
  89240. private _colors3;
  89241. private _colors4;
  89242. private _vectors2;
  89243. private _vectors3;
  89244. private _matrices;
  89245. private _fallbackTextureUsed;
  89246. private _fullEngine;
  89247. private _cachedDefines;
  89248. private _contentUpdateId;
  89249. private _contentData;
  89250. /**
  89251. * Instantiates a new procedural texture.
  89252. * 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.
  89253. * This is the base class of any Procedural texture and contains most of the shareable code.
  89254. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89255. * @param name Define the name of the texture
  89256. * @param size Define the size of the texture to create
  89257. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89258. * @param scene Define the scene the texture belongs to
  89259. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89260. * @param generateMipMaps Define if the texture should creates mip maps or not
  89261. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89262. */
  89263. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89264. /**
  89265. * The effect that is created when initializing the post process.
  89266. * @returns The created effect corresponding the the postprocess.
  89267. */
  89268. getEffect(): Effect;
  89269. /**
  89270. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89271. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89272. */
  89273. getContent(): Nullable<ArrayBufferView>;
  89274. private _createIndexBuffer;
  89275. /** @hidden */
  89276. _rebuild(): void;
  89277. /**
  89278. * Resets the texture in order to recreate its associated resources.
  89279. * This can be called in case of context loss
  89280. */
  89281. reset(): void;
  89282. protected _getDefines(): string;
  89283. /**
  89284. * Is the texture ready to be used ? (rendered at least once)
  89285. * @returns true if ready, otherwise, false.
  89286. */
  89287. isReady(): boolean;
  89288. /**
  89289. * Resets the refresh counter of the texture and start bak from scratch.
  89290. * Could be useful to regenerate the texture if it is setup to render only once.
  89291. */
  89292. resetRefreshCounter(): void;
  89293. /**
  89294. * Set the fragment shader to use in order to render the texture.
  89295. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89296. */
  89297. setFragment(fragment: any): void;
  89298. /**
  89299. * Define the refresh rate of the texture or the rendering frequency.
  89300. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89301. */
  89302. get refreshRate(): number;
  89303. set refreshRate(value: number);
  89304. /** @hidden */
  89305. _shouldRender(): boolean;
  89306. /**
  89307. * Get the size the texture is rendering at.
  89308. * @returns the size (texture is always squared)
  89309. */
  89310. getRenderSize(): number;
  89311. /**
  89312. * Resize the texture to new value.
  89313. * @param size Define the new size the texture should have
  89314. * @param generateMipMaps Define whether the new texture should create mip maps
  89315. */
  89316. resize(size: number, generateMipMaps: boolean): void;
  89317. private _checkUniform;
  89318. /**
  89319. * Set a texture in the shader program used to render.
  89320. * @param name Define the name of the uniform samplers as defined in the shader
  89321. * @param texture Define the texture to bind to this sampler
  89322. * @return the texture itself allowing "fluent" like uniform updates
  89323. */
  89324. setTexture(name: string, texture: Texture): ProceduralTexture;
  89325. /**
  89326. * Set a float in the shader.
  89327. * @param name Define the name of the uniform as defined in the shader
  89328. * @param value Define the value to give to the uniform
  89329. * @return the texture itself allowing "fluent" like uniform updates
  89330. */
  89331. setFloat(name: string, value: number): ProceduralTexture;
  89332. /**
  89333. * Set a int in the shader.
  89334. * @param name Define the name of the uniform as defined in the shader
  89335. * @param value Define the value to give to the uniform
  89336. * @return the texture itself allowing "fluent" like uniform updates
  89337. */
  89338. setInt(name: string, value: number): ProceduralTexture;
  89339. /**
  89340. * Set an array of floats in the shader.
  89341. * @param name Define the name of the uniform as defined in the shader
  89342. * @param value Define the value to give to the uniform
  89343. * @return the texture itself allowing "fluent" like uniform updates
  89344. */
  89345. setFloats(name: string, value: number[]): ProceduralTexture;
  89346. /**
  89347. * Set a vec3 in the shader from a Color3.
  89348. * @param name Define the name of the uniform as defined in the shader
  89349. * @param value Define the value to give to the uniform
  89350. * @return the texture itself allowing "fluent" like uniform updates
  89351. */
  89352. setColor3(name: string, value: Color3): ProceduralTexture;
  89353. /**
  89354. * Set a vec4 in the shader from a Color4.
  89355. * @param name Define the name of the uniform as defined in the shader
  89356. * @param value Define the value to give to the uniform
  89357. * @return the texture itself allowing "fluent" like uniform updates
  89358. */
  89359. setColor4(name: string, value: Color4): ProceduralTexture;
  89360. /**
  89361. * Set a vec2 in the shader from a Vector2.
  89362. * @param name Define the name of the uniform as defined in the shader
  89363. * @param value Define the value to give to the uniform
  89364. * @return the texture itself allowing "fluent" like uniform updates
  89365. */
  89366. setVector2(name: string, value: Vector2): ProceduralTexture;
  89367. /**
  89368. * Set a vec3 in the shader from a Vector3.
  89369. * @param name Define the name of the uniform as defined in the shader
  89370. * @param value Define the value to give to the uniform
  89371. * @return the texture itself allowing "fluent" like uniform updates
  89372. */
  89373. setVector3(name: string, value: Vector3): ProceduralTexture;
  89374. /**
  89375. * Set a mat4 in the shader from a MAtrix.
  89376. * @param name Define the name of the uniform as defined in the shader
  89377. * @param value Define the value to give to the uniform
  89378. * @return the texture itself allowing "fluent" like uniform updates
  89379. */
  89380. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89381. /**
  89382. * Render the texture to its associated render target.
  89383. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89384. */
  89385. render(useCameraPostProcess?: boolean): void;
  89386. /**
  89387. * Clone the texture.
  89388. * @returns the cloned texture
  89389. */
  89390. clone(): ProceduralTexture;
  89391. /**
  89392. * Dispose the texture and release its asoociated resources.
  89393. */
  89394. dispose(): void;
  89395. }
  89396. }
  89397. declare module BABYLON {
  89398. /**
  89399. * This represents the base class for particle system in Babylon.
  89400. * 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.
  89401. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89402. * @example https://doc.babylonjs.com/babylon101/particles
  89403. */
  89404. export class BaseParticleSystem {
  89405. /**
  89406. * Source color is added to the destination color without alpha affecting the result
  89407. */
  89408. static BLENDMODE_ONEONE: number;
  89409. /**
  89410. * Blend current color and particle color using particle’s alpha
  89411. */
  89412. static BLENDMODE_STANDARD: number;
  89413. /**
  89414. * Add current color and particle color multiplied by particle’s alpha
  89415. */
  89416. static BLENDMODE_ADD: number;
  89417. /**
  89418. * Multiply current color with particle color
  89419. */
  89420. static BLENDMODE_MULTIPLY: number;
  89421. /**
  89422. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89423. */
  89424. static BLENDMODE_MULTIPLYADD: number;
  89425. /**
  89426. * List of animations used by the particle system.
  89427. */
  89428. animations: Animation[];
  89429. /**
  89430. * Gets or sets the unique id of the particle system
  89431. */
  89432. uniqueId: number;
  89433. /**
  89434. * The id of the Particle system.
  89435. */
  89436. id: string;
  89437. /**
  89438. * The friendly name of the Particle system.
  89439. */
  89440. name: string;
  89441. /**
  89442. * Snippet ID if the particle system was created from the snippet server
  89443. */
  89444. snippetId: string;
  89445. /**
  89446. * The rendering group used by the Particle system to chose when to render.
  89447. */
  89448. renderingGroupId: number;
  89449. /**
  89450. * The emitter represents the Mesh or position we are attaching the particle system to.
  89451. */
  89452. emitter: Nullable<AbstractMesh | Vector3>;
  89453. /**
  89454. * The maximum number of particles to emit per frame
  89455. */
  89456. emitRate: number;
  89457. /**
  89458. * If you want to launch only a few particles at once, that can be done, as well.
  89459. */
  89460. manualEmitCount: number;
  89461. /**
  89462. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89463. */
  89464. updateSpeed: number;
  89465. /**
  89466. * The amount of time the particle system is running (depends of the overall update speed).
  89467. */
  89468. targetStopDuration: number;
  89469. /**
  89470. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89471. */
  89472. disposeOnStop: boolean;
  89473. /**
  89474. * Minimum power of emitting particles.
  89475. */
  89476. minEmitPower: number;
  89477. /**
  89478. * Maximum power of emitting particles.
  89479. */
  89480. maxEmitPower: number;
  89481. /**
  89482. * Minimum life time of emitting particles.
  89483. */
  89484. minLifeTime: number;
  89485. /**
  89486. * Maximum life time of emitting particles.
  89487. */
  89488. maxLifeTime: number;
  89489. /**
  89490. * Minimum Size of emitting particles.
  89491. */
  89492. minSize: number;
  89493. /**
  89494. * Maximum Size of emitting particles.
  89495. */
  89496. maxSize: number;
  89497. /**
  89498. * Minimum scale of emitting particles on X axis.
  89499. */
  89500. minScaleX: number;
  89501. /**
  89502. * Maximum scale of emitting particles on X axis.
  89503. */
  89504. maxScaleX: number;
  89505. /**
  89506. * Minimum scale of emitting particles on Y axis.
  89507. */
  89508. minScaleY: number;
  89509. /**
  89510. * Maximum scale of emitting particles on Y axis.
  89511. */
  89512. maxScaleY: number;
  89513. /**
  89514. * Gets or sets the minimal initial rotation in radians.
  89515. */
  89516. minInitialRotation: number;
  89517. /**
  89518. * Gets or sets the maximal initial rotation in radians.
  89519. */
  89520. maxInitialRotation: number;
  89521. /**
  89522. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89523. */
  89524. minAngularSpeed: number;
  89525. /**
  89526. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89527. */
  89528. maxAngularSpeed: number;
  89529. /**
  89530. * The texture used to render each particle. (this can be a spritesheet)
  89531. */
  89532. particleTexture: Nullable<Texture>;
  89533. /**
  89534. * The layer mask we are rendering the particles through.
  89535. */
  89536. layerMask: number;
  89537. /**
  89538. * This can help using your own shader to render the particle system.
  89539. * The according effect will be created
  89540. */
  89541. customShader: any;
  89542. /**
  89543. * By default particle system starts as soon as they are created. This prevents the
  89544. * automatic start to happen and let you decide when to start emitting particles.
  89545. */
  89546. preventAutoStart: boolean;
  89547. private _noiseTexture;
  89548. /**
  89549. * Gets or sets a texture used to add random noise to particle positions
  89550. */
  89551. get noiseTexture(): Nullable<ProceduralTexture>;
  89552. set noiseTexture(value: Nullable<ProceduralTexture>);
  89553. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89554. noiseStrength: Vector3;
  89555. /**
  89556. * Callback triggered when the particle animation is ending.
  89557. */
  89558. onAnimationEnd: Nullable<() => void>;
  89559. /**
  89560. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89561. */
  89562. blendMode: number;
  89563. /**
  89564. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89565. * to override the particles.
  89566. */
  89567. forceDepthWrite: boolean;
  89568. /** 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 */
  89569. preWarmCycles: number;
  89570. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89571. preWarmStepOffset: number;
  89572. /**
  89573. * 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)
  89574. */
  89575. spriteCellChangeSpeed: number;
  89576. /**
  89577. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89578. */
  89579. startSpriteCellID: number;
  89580. /**
  89581. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89582. */
  89583. endSpriteCellID: number;
  89584. /**
  89585. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89586. */
  89587. spriteCellWidth: number;
  89588. /**
  89589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89590. */
  89591. spriteCellHeight: number;
  89592. /**
  89593. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89594. */
  89595. spriteRandomStartCell: boolean;
  89596. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89597. translationPivot: Vector2;
  89598. /** @hidden */
  89599. protected _isAnimationSheetEnabled: boolean;
  89600. /**
  89601. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89602. */
  89603. beginAnimationOnStart: boolean;
  89604. /**
  89605. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89606. */
  89607. beginAnimationFrom: number;
  89608. /**
  89609. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89610. */
  89611. beginAnimationTo: number;
  89612. /**
  89613. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89614. */
  89615. beginAnimationLoop: boolean;
  89616. /**
  89617. * Gets or sets a world offset applied to all particles
  89618. */
  89619. worldOffset: Vector3;
  89620. /**
  89621. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89622. */
  89623. get isAnimationSheetEnabled(): boolean;
  89624. set isAnimationSheetEnabled(value: boolean);
  89625. /**
  89626. * Get hosting scene
  89627. * @returns the scene
  89628. */
  89629. getScene(): Scene;
  89630. /**
  89631. * You can use gravity if you want to give an orientation to your particles.
  89632. */
  89633. gravity: Vector3;
  89634. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89635. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89636. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89637. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89638. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89639. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89640. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89641. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89642. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89643. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89644. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89645. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89646. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89647. /**
  89648. * Defines the delay in milliseconds before starting the system (0 by default)
  89649. */
  89650. startDelay: number;
  89651. /**
  89652. * Gets the current list of drag gradients.
  89653. * You must use addDragGradient and removeDragGradient to udpate this list
  89654. * @returns the list of drag gradients
  89655. */
  89656. getDragGradients(): Nullable<Array<FactorGradient>>;
  89657. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89658. limitVelocityDamping: number;
  89659. /**
  89660. * Gets the current list of limit velocity gradients.
  89661. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89662. * @returns the list of limit velocity gradients
  89663. */
  89664. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89665. /**
  89666. * Gets the current list of color gradients.
  89667. * You must use addColorGradient and removeColorGradient to udpate this list
  89668. * @returns the list of color gradients
  89669. */
  89670. getColorGradients(): Nullable<Array<ColorGradient>>;
  89671. /**
  89672. * Gets the current list of size gradients.
  89673. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89674. * @returns the list of size gradients
  89675. */
  89676. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89677. /**
  89678. * Gets the current list of color remap gradients.
  89679. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89680. * @returns the list of color remap gradients
  89681. */
  89682. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89683. /**
  89684. * Gets the current list of alpha remap gradients.
  89685. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89686. * @returns the list of alpha remap gradients
  89687. */
  89688. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89689. /**
  89690. * Gets the current list of life time gradients.
  89691. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89692. * @returns the list of life time gradients
  89693. */
  89694. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89695. /**
  89696. * Gets the current list of angular speed gradients.
  89697. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89698. * @returns the list of angular speed gradients
  89699. */
  89700. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89701. /**
  89702. * Gets the current list of velocity gradients.
  89703. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89704. * @returns the list of velocity gradients
  89705. */
  89706. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89707. /**
  89708. * Gets the current list of start size gradients.
  89709. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89710. * @returns the list of start size gradients
  89711. */
  89712. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89713. /**
  89714. * Gets the current list of emit rate gradients.
  89715. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89716. * @returns the list of emit rate gradients
  89717. */
  89718. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89719. /**
  89720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89721. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89722. */
  89723. get direction1(): Vector3;
  89724. set direction1(value: Vector3);
  89725. /**
  89726. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89727. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89728. */
  89729. get direction2(): Vector3;
  89730. set direction2(value: Vector3);
  89731. /**
  89732. * 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.
  89733. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89734. */
  89735. get minEmitBox(): Vector3;
  89736. set minEmitBox(value: Vector3);
  89737. /**
  89738. * 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.
  89739. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89740. */
  89741. get maxEmitBox(): Vector3;
  89742. set maxEmitBox(value: Vector3);
  89743. /**
  89744. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89745. */
  89746. color1: Color4;
  89747. /**
  89748. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89749. */
  89750. color2: Color4;
  89751. /**
  89752. * Color the particle will have at the end of its lifetime
  89753. */
  89754. colorDead: Color4;
  89755. /**
  89756. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89757. */
  89758. textureMask: Color4;
  89759. /**
  89760. * The particle emitter type defines the emitter used by the particle system.
  89761. * It can be for example box, sphere, or cone...
  89762. */
  89763. particleEmitterType: IParticleEmitterType;
  89764. /** @hidden */
  89765. _isSubEmitter: boolean;
  89766. /**
  89767. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89768. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89769. */
  89770. billboardMode: number;
  89771. protected _isBillboardBased: boolean;
  89772. /**
  89773. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89774. */
  89775. get isBillboardBased(): boolean;
  89776. set isBillboardBased(value: boolean);
  89777. /**
  89778. * The scene the particle system belongs to.
  89779. */
  89780. protected _scene: Scene;
  89781. /**
  89782. * Local cache of defines for image processing.
  89783. */
  89784. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89785. /**
  89786. * Default configuration related to image processing available in the standard Material.
  89787. */
  89788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89789. /**
  89790. * Gets the image processing configuration used either in this material.
  89791. */
  89792. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89793. /**
  89794. * Sets the Default image processing configuration used either in the this material.
  89795. *
  89796. * If sets to null, the scene one is in use.
  89797. */
  89798. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89799. /**
  89800. * Attaches a new image processing configuration to the Standard Material.
  89801. * @param configuration
  89802. */
  89803. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89804. /** @hidden */
  89805. protected _reset(): void;
  89806. /** @hidden */
  89807. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89808. /**
  89809. * Instantiates a particle system.
  89810. * 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.
  89811. * @param name The name of the particle system
  89812. */
  89813. constructor(name: string);
  89814. /**
  89815. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89816. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89817. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89818. * @returns the emitter
  89819. */
  89820. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89821. /**
  89822. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89823. * @param radius The radius of the hemisphere to emit from
  89824. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89825. * @returns the emitter
  89826. */
  89827. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89828. /**
  89829. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89830. * @param radius The radius of the sphere to emit from
  89831. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89832. * @returns the emitter
  89833. */
  89834. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89835. /**
  89836. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89837. * @param radius The radius of the sphere to emit from
  89838. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89839. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89840. * @returns the emitter
  89841. */
  89842. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89843. /**
  89844. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89845. * @param radius The radius of the emission cylinder
  89846. * @param height The height of the emission cylinder
  89847. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89848. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89849. * @returns the emitter
  89850. */
  89851. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89852. /**
  89853. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89854. * @param radius The radius of the cylinder to emit from
  89855. * @param height The height of the emission cylinder
  89856. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89857. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89858. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89859. * @returns the emitter
  89860. */
  89861. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89862. /**
  89863. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89864. * @param radius The radius of the cone to emit from
  89865. * @param angle The base angle of the cone
  89866. * @returns the emitter
  89867. */
  89868. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89869. /**
  89870. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89871. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89872. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89873. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89874. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89875. * @returns the emitter
  89876. */
  89877. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89878. }
  89879. }
  89880. declare module BABYLON {
  89881. /**
  89882. * Type of sub emitter
  89883. */
  89884. export enum SubEmitterType {
  89885. /**
  89886. * Attached to the particle over it's lifetime
  89887. */
  89888. ATTACHED = 0,
  89889. /**
  89890. * Created when the particle dies
  89891. */
  89892. END = 1
  89893. }
  89894. /**
  89895. * Sub emitter class used to emit particles from an existing particle
  89896. */
  89897. export class SubEmitter {
  89898. /**
  89899. * the particle system to be used by the sub emitter
  89900. */
  89901. particleSystem: ParticleSystem;
  89902. /**
  89903. * Type of the submitter (Default: END)
  89904. */
  89905. type: SubEmitterType;
  89906. /**
  89907. * 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)
  89908. * Note: This only is supported when using an emitter of type Mesh
  89909. */
  89910. inheritDirection: boolean;
  89911. /**
  89912. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89913. */
  89914. inheritedVelocityAmount: number;
  89915. /**
  89916. * Creates a sub emitter
  89917. * @param particleSystem the particle system to be used by the sub emitter
  89918. */
  89919. constructor(
  89920. /**
  89921. * the particle system to be used by the sub emitter
  89922. */
  89923. particleSystem: ParticleSystem);
  89924. /**
  89925. * Clones the sub emitter
  89926. * @returns the cloned sub emitter
  89927. */
  89928. clone(): SubEmitter;
  89929. /**
  89930. * Serialize current object to a JSON object
  89931. * @returns the serialized object
  89932. */
  89933. serialize(): any;
  89934. /** @hidden */
  89935. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89936. /**
  89937. * Creates a new SubEmitter from a serialized JSON version
  89938. * @param serializationObject defines the JSON object to read from
  89939. * @param scene defines the hosting scene
  89940. * @param rootUrl defines the rootUrl for data loading
  89941. * @returns a new SubEmitter
  89942. */
  89943. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  89944. /** Release associated resources */
  89945. dispose(): void;
  89946. }
  89947. }
  89948. declare module BABYLON {
  89949. /** @hidden */
  89950. export var imageProcessingDeclaration: {
  89951. name: string;
  89952. shader: string;
  89953. };
  89954. }
  89955. declare module BABYLON {
  89956. /** @hidden */
  89957. export var imageProcessingFunctions: {
  89958. name: string;
  89959. shader: string;
  89960. };
  89961. }
  89962. declare module BABYLON {
  89963. /** @hidden */
  89964. export var particlesPixelShader: {
  89965. name: string;
  89966. shader: string;
  89967. };
  89968. }
  89969. declare module BABYLON {
  89970. /** @hidden */
  89971. export var particlesVertexShader: {
  89972. name: string;
  89973. shader: string;
  89974. };
  89975. }
  89976. declare module BABYLON {
  89977. /**
  89978. * This represents a particle system in Babylon.
  89979. * 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.
  89980. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89981. * @example https://doc.babylonjs.com/babylon101/particles
  89982. */
  89983. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  89984. /**
  89985. * Billboard mode will only apply to Y axis
  89986. */
  89987. static readonly BILLBOARDMODE_Y: number;
  89988. /**
  89989. * Billboard mode will apply to all axes
  89990. */
  89991. static readonly BILLBOARDMODE_ALL: number;
  89992. /**
  89993. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  89994. */
  89995. static readonly BILLBOARDMODE_STRETCHED: number;
  89996. /**
  89997. * This function can be defined to provide custom update for active particles.
  89998. * This function will be called instead of regular update (age, position, color, etc.).
  89999. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90000. */
  90001. updateFunction: (particles: Particle[]) => void;
  90002. private _emitterWorldMatrix;
  90003. /**
  90004. * This function can be defined to specify initial direction for every new particle.
  90005. * It by default use the emitterType defined function
  90006. */
  90007. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90008. /**
  90009. * This function can be defined to specify initial position for every new particle.
  90010. * It by default use the emitterType defined function
  90011. */
  90012. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90013. /**
  90014. * @hidden
  90015. */
  90016. _inheritedVelocityOffset: Vector3;
  90017. /**
  90018. * An event triggered when the system is disposed
  90019. */
  90020. onDisposeObservable: Observable<IParticleSystem>;
  90021. private _onDisposeObserver;
  90022. /**
  90023. * Sets a callback that will be triggered when the system is disposed
  90024. */
  90025. set onDispose(callback: () => void);
  90026. private _particles;
  90027. private _epsilon;
  90028. private _capacity;
  90029. private _stockParticles;
  90030. private _newPartsExcess;
  90031. private _vertexData;
  90032. private _vertexBuffer;
  90033. private _vertexBuffers;
  90034. private _spriteBuffer;
  90035. private _indexBuffer;
  90036. private _effect;
  90037. private _customEffect;
  90038. private _cachedDefines;
  90039. private _scaledColorStep;
  90040. private _colorDiff;
  90041. private _scaledDirection;
  90042. private _scaledGravity;
  90043. private _currentRenderId;
  90044. private _alive;
  90045. private _useInstancing;
  90046. private _started;
  90047. private _stopped;
  90048. private _actualFrame;
  90049. private _scaledUpdateSpeed;
  90050. private _vertexBufferSize;
  90051. /** @hidden */
  90052. _currentEmitRateGradient: Nullable<FactorGradient>;
  90053. /** @hidden */
  90054. _currentEmitRate1: number;
  90055. /** @hidden */
  90056. _currentEmitRate2: number;
  90057. /** @hidden */
  90058. _currentStartSizeGradient: Nullable<FactorGradient>;
  90059. /** @hidden */
  90060. _currentStartSize1: number;
  90061. /** @hidden */
  90062. _currentStartSize2: number;
  90063. private readonly _rawTextureWidth;
  90064. private _rampGradientsTexture;
  90065. private _useRampGradients;
  90066. /** Gets or sets a boolean indicating that ramp gradients must be used
  90067. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90068. */
  90069. get useRampGradients(): boolean;
  90070. set useRampGradients(value: boolean);
  90071. /**
  90072. * 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.
  90073. * 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: [])
  90074. */
  90075. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90076. private _subEmitters;
  90077. /**
  90078. * @hidden
  90079. * If the particle systems emitter should be disposed when the particle system is disposed
  90080. */
  90081. _disposeEmitterOnDispose: boolean;
  90082. /**
  90083. * The current active Sub-systems, this property is used by the root particle system only.
  90084. */
  90085. activeSubSystems: Array<ParticleSystem>;
  90086. /**
  90087. * Specifies if the particles are updated in emitter local space or world space
  90088. */
  90089. isLocal: boolean;
  90090. private _rootParticleSystem;
  90091. /**
  90092. * Gets the current list of active particles
  90093. */
  90094. get particles(): Particle[];
  90095. /**
  90096. * Gets the number of particles active at the same time.
  90097. * @returns The number of active particles.
  90098. */
  90099. getActiveCount(): number;
  90100. /**
  90101. * Returns the string "ParticleSystem"
  90102. * @returns a string containing the class name
  90103. */
  90104. getClassName(): string;
  90105. /**
  90106. * Gets a boolean indicating that the system is stopping
  90107. * @returns true if the system is currently stopping
  90108. */
  90109. isStopping(): boolean;
  90110. /**
  90111. * Gets the custom effect used to render the particles
  90112. * @param blendMode Blend mode for which the effect should be retrieved
  90113. * @returns The effect
  90114. */
  90115. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90116. /**
  90117. * Sets the custom effect used to render the particles
  90118. * @param effect The effect to set
  90119. * @param blendMode Blend mode for which the effect should be set
  90120. */
  90121. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90122. /** @hidden */
  90123. private _onBeforeDrawParticlesObservable;
  90124. /**
  90125. * Observable that will be called just before the particles are drawn
  90126. */
  90127. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90128. /**
  90129. * Gets the name of the particle vertex shader
  90130. */
  90131. get vertexShaderName(): string;
  90132. /**
  90133. * Instantiates a particle system.
  90134. * 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.
  90135. * @param name The name of the particle system
  90136. * @param capacity The max number of particles alive at the same time
  90137. * @param scene The scene the particle system belongs to
  90138. * @param customEffect a custom effect used to change the way particles are rendered by default
  90139. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90140. * @param epsilon Offset used to render the particles
  90141. */
  90142. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90143. private _addFactorGradient;
  90144. private _removeFactorGradient;
  90145. /**
  90146. * Adds a new life time gradient
  90147. * @param gradient defines the gradient to use (between 0 and 1)
  90148. * @param factor defines the life time factor to affect to the specified gradient
  90149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90150. * @returns the current particle system
  90151. */
  90152. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90153. /**
  90154. * Remove a specific life time gradient
  90155. * @param gradient defines the gradient to remove
  90156. * @returns the current particle system
  90157. */
  90158. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90159. /**
  90160. * Adds a new size gradient
  90161. * @param gradient defines the gradient to use (between 0 and 1)
  90162. * @param factor defines the size factor to affect to the specified gradient
  90163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90164. * @returns the current particle system
  90165. */
  90166. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90167. /**
  90168. * Remove a specific size gradient
  90169. * @param gradient defines the gradient to remove
  90170. * @returns the current particle system
  90171. */
  90172. removeSizeGradient(gradient: number): IParticleSystem;
  90173. /**
  90174. * Adds a new color remap gradient
  90175. * @param gradient defines the gradient to use (between 0 and 1)
  90176. * @param min defines the color remap minimal range
  90177. * @param max defines the color remap maximal range
  90178. * @returns the current particle system
  90179. */
  90180. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90181. /**
  90182. * Remove a specific color remap gradient
  90183. * @param gradient defines the gradient to remove
  90184. * @returns the current particle system
  90185. */
  90186. removeColorRemapGradient(gradient: number): IParticleSystem;
  90187. /**
  90188. * Adds a new alpha remap gradient
  90189. * @param gradient defines the gradient to use (between 0 and 1)
  90190. * @param min defines the alpha remap minimal range
  90191. * @param max defines the alpha remap maximal range
  90192. * @returns the current particle system
  90193. */
  90194. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90195. /**
  90196. * Remove a specific alpha remap gradient
  90197. * @param gradient defines the gradient to remove
  90198. * @returns the current particle system
  90199. */
  90200. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90201. /**
  90202. * Adds a new angular speed gradient
  90203. * @param gradient defines the gradient to use (between 0 and 1)
  90204. * @param factor defines the angular speed to affect to the specified gradient
  90205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90206. * @returns the current particle system
  90207. */
  90208. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90209. /**
  90210. * Remove a specific angular speed gradient
  90211. * @param gradient defines the gradient to remove
  90212. * @returns the current particle system
  90213. */
  90214. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90215. /**
  90216. * Adds a new velocity gradient
  90217. * @param gradient defines the gradient to use (between 0 and 1)
  90218. * @param factor defines the velocity to affect to the specified gradient
  90219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90220. * @returns the current particle system
  90221. */
  90222. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90223. /**
  90224. * Remove a specific velocity gradient
  90225. * @param gradient defines the gradient to remove
  90226. * @returns the current particle system
  90227. */
  90228. removeVelocityGradient(gradient: number): IParticleSystem;
  90229. /**
  90230. * Adds a new limit velocity gradient
  90231. * @param gradient defines the gradient to use (between 0 and 1)
  90232. * @param factor defines the limit velocity value to affect to the specified gradient
  90233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90234. * @returns the current particle system
  90235. */
  90236. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90237. /**
  90238. * Remove a specific limit velocity gradient
  90239. * @param gradient defines the gradient to remove
  90240. * @returns the current particle system
  90241. */
  90242. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90243. /**
  90244. * Adds a new drag gradient
  90245. * @param gradient defines the gradient to use (between 0 and 1)
  90246. * @param factor defines the drag value to affect to the specified gradient
  90247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90248. * @returns the current particle system
  90249. */
  90250. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90251. /**
  90252. * Remove a specific drag gradient
  90253. * @param gradient defines the gradient to remove
  90254. * @returns the current particle system
  90255. */
  90256. removeDragGradient(gradient: number): IParticleSystem;
  90257. /**
  90258. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90259. * @param gradient defines the gradient to use (between 0 and 1)
  90260. * @param factor defines the emit rate value to affect to the specified gradient
  90261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90262. * @returns the current particle system
  90263. */
  90264. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90265. /**
  90266. * Remove a specific emit rate gradient
  90267. * @param gradient defines the gradient to remove
  90268. * @returns the current particle system
  90269. */
  90270. removeEmitRateGradient(gradient: number): IParticleSystem;
  90271. /**
  90272. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90273. * @param gradient defines the gradient to use (between 0 and 1)
  90274. * @param factor defines the start size value to affect to the specified gradient
  90275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90276. * @returns the current particle system
  90277. */
  90278. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90279. /**
  90280. * Remove a specific start size gradient
  90281. * @param gradient defines the gradient to remove
  90282. * @returns the current particle system
  90283. */
  90284. removeStartSizeGradient(gradient: number): IParticleSystem;
  90285. private _createRampGradientTexture;
  90286. /**
  90287. * Gets the current list of ramp gradients.
  90288. * You must use addRampGradient and removeRampGradient to udpate this list
  90289. * @returns the list of ramp gradients
  90290. */
  90291. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90292. /** Force the system to rebuild all gradients that need to be resync */
  90293. forceRefreshGradients(): void;
  90294. private _syncRampGradientTexture;
  90295. /**
  90296. * Adds a new ramp gradient used to remap particle colors
  90297. * @param gradient defines the gradient to use (between 0 and 1)
  90298. * @param color defines the color to affect to the specified gradient
  90299. * @returns the current particle system
  90300. */
  90301. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90302. /**
  90303. * Remove a specific ramp gradient
  90304. * @param gradient defines the gradient to remove
  90305. * @returns the current particle system
  90306. */
  90307. removeRampGradient(gradient: number): ParticleSystem;
  90308. /**
  90309. * Adds a new color gradient
  90310. * @param gradient defines the gradient to use (between 0 and 1)
  90311. * @param color1 defines the color to affect to the specified gradient
  90312. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90313. * @returns this particle system
  90314. */
  90315. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90316. /**
  90317. * Remove a specific color gradient
  90318. * @param gradient defines the gradient to remove
  90319. * @returns this particle system
  90320. */
  90321. removeColorGradient(gradient: number): IParticleSystem;
  90322. private _fetchR;
  90323. protected _reset(): void;
  90324. private _resetEffect;
  90325. private _createVertexBuffers;
  90326. private _createIndexBuffer;
  90327. /**
  90328. * Gets the maximum number of particles active at the same time.
  90329. * @returns The max number of active particles.
  90330. */
  90331. getCapacity(): number;
  90332. /**
  90333. * Gets whether there are still active particles in the system.
  90334. * @returns True if it is alive, otherwise false.
  90335. */
  90336. isAlive(): boolean;
  90337. /**
  90338. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90339. * @returns True if it has been started, otherwise false.
  90340. */
  90341. isStarted(): boolean;
  90342. private _prepareSubEmitterInternalArray;
  90343. /**
  90344. * Starts the particle system and begins to emit
  90345. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90346. */
  90347. start(delay?: number): void;
  90348. /**
  90349. * Stops the particle system.
  90350. * @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.
  90351. */
  90352. stop(stopSubEmitters?: boolean): void;
  90353. /**
  90354. * Remove all active particles
  90355. */
  90356. reset(): void;
  90357. /**
  90358. * @hidden (for internal use only)
  90359. */
  90360. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90361. /**
  90362. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90363. * Its lifetime will start back at 0.
  90364. */
  90365. recycleParticle: (particle: Particle) => void;
  90366. private _stopSubEmitters;
  90367. private _createParticle;
  90368. private _removeFromRoot;
  90369. private _emitFromParticle;
  90370. private _update;
  90371. /** @hidden */
  90372. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90373. /** @hidden */
  90374. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90375. /**
  90376. * Fill the defines array according to the current settings of the particle system
  90377. * @param defines Array to be updated
  90378. * @param blendMode blend mode to take into account when updating the array
  90379. */
  90380. fillDefines(defines: Array<string>, blendMode: number): void;
  90381. /**
  90382. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90383. * @param uniforms Uniforms array to fill
  90384. * @param attributes Attributes array to fill
  90385. * @param samplers Samplers array to fill
  90386. */
  90387. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90388. /** @hidden */
  90389. private _getEffect;
  90390. /**
  90391. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90392. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90393. */
  90394. animate(preWarmOnly?: boolean): void;
  90395. private _appendParticleVertices;
  90396. /**
  90397. * Rebuilds the particle system.
  90398. */
  90399. rebuild(): void;
  90400. /**
  90401. * Is this system ready to be used/rendered
  90402. * @return true if the system is ready
  90403. */
  90404. isReady(): boolean;
  90405. private _render;
  90406. /**
  90407. * Renders the particle system in its current state.
  90408. * @returns the current number of particles
  90409. */
  90410. render(): number;
  90411. /**
  90412. * Disposes the particle system and free the associated resources
  90413. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90414. */
  90415. dispose(disposeTexture?: boolean): void;
  90416. /**
  90417. * Clones the particle system.
  90418. * @param name The name of the cloned object
  90419. * @param newEmitter The new emitter to use
  90420. * @returns the cloned particle system
  90421. */
  90422. clone(name: string, newEmitter: any): ParticleSystem;
  90423. /**
  90424. * Serializes the particle system to a JSON object
  90425. * @param serializeTexture defines if the texture must be serialized as well
  90426. * @returns the JSON object
  90427. */
  90428. serialize(serializeTexture?: boolean): any;
  90429. /** @hidden */
  90430. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90431. /** @hidden */
  90432. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90433. /**
  90434. * Parses a JSON object to create a particle system.
  90435. * @param parsedParticleSystem The JSON object to parse
  90436. * @param scene The scene to create the particle system in
  90437. * @param rootUrl The root url to use to load external dependencies like texture
  90438. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90439. * @returns the Parsed particle system
  90440. */
  90441. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90442. }
  90443. }
  90444. declare module BABYLON {
  90445. /**
  90446. * A particle represents one of the element emitted by a particle system.
  90447. * This is mainly define by its coordinates, direction, velocity and age.
  90448. */
  90449. export class Particle {
  90450. /**
  90451. * The particle system the particle belongs to.
  90452. */
  90453. particleSystem: ParticleSystem;
  90454. private static _Count;
  90455. /**
  90456. * Unique ID of the particle
  90457. */
  90458. id: number;
  90459. /**
  90460. * The world position of the particle in the scene.
  90461. */
  90462. position: Vector3;
  90463. /**
  90464. * The world direction of the particle in the scene.
  90465. */
  90466. direction: Vector3;
  90467. /**
  90468. * The color of the particle.
  90469. */
  90470. color: Color4;
  90471. /**
  90472. * The color change of the particle per step.
  90473. */
  90474. colorStep: Color4;
  90475. /**
  90476. * Defines how long will the life of the particle be.
  90477. */
  90478. lifeTime: number;
  90479. /**
  90480. * The current age of the particle.
  90481. */
  90482. age: number;
  90483. /**
  90484. * The current size of the particle.
  90485. */
  90486. size: number;
  90487. /**
  90488. * The current scale of the particle.
  90489. */
  90490. scale: Vector2;
  90491. /**
  90492. * The current angle of the particle.
  90493. */
  90494. angle: number;
  90495. /**
  90496. * Defines how fast is the angle changing.
  90497. */
  90498. angularSpeed: number;
  90499. /**
  90500. * Defines the cell index used by the particle to be rendered from a sprite.
  90501. */
  90502. cellIndex: number;
  90503. /**
  90504. * The information required to support color remapping
  90505. */
  90506. remapData: Vector4;
  90507. /** @hidden */
  90508. _randomCellOffset?: number;
  90509. /** @hidden */
  90510. _initialDirection: Nullable<Vector3>;
  90511. /** @hidden */
  90512. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90513. /** @hidden */
  90514. _initialStartSpriteCellID: number;
  90515. /** @hidden */
  90516. _initialEndSpriteCellID: number;
  90517. /** @hidden */
  90518. _currentColorGradient: Nullable<ColorGradient>;
  90519. /** @hidden */
  90520. _currentColor1: Color4;
  90521. /** @hidden */
  90522. _currentColor2: Color4;
  90523. /** @hidden */
  90524. _currentSizeGradient: Nullable<FactorGradient>;
  90525. /** @hidden */
  90526. _currentSize1: number;
  90527. /** @hidden */
  90528. _currentSize2: number;
  90529. /** @hidden */
  90530. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90531. /** @hidden */
  90532. _currentAngularSpeed1: number;
  90533. /** @hidden */
  90534. _currentAngularSpeed2: number;
  90535. /** @hidden */
  90536. _currentVelocityGradient: Nullable<FactorGradient>;
  90537. /** @hidden */
  90538. _currentVelocity1: number;
  90539. /** @hidden */
  90540. _currentVelocity2: number;
  90541. /** @hidden */
  90542. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90543. /** @hidden */
  90544. _currentLimitVelocity1: number;
  90545. /** @hidden */
  90546. _currentLimitVelocity2: number;
  90547. /** @hidden */
  90548. _currentDragGradient: Nullable<FactorGradient>;
  90549. /** @hidden */
  90550. _currentDrag1: number;
  90551. /** @hidden */
  90552. _currentDrag2: number;
  90553. /** @hidden */
  90554. _randomNoiseCoordinates1: Vector3;
  90555. /** @hidden */
  90556. _randomNoiseCoordinates2: Vector3;
  90557. /** @hidden */
  90558. _localPosition?: Vector3;
  90559. /**
  90560. * Creates a new instance Particle
  90561. * @param particleSystem the particle system the particle belongs to
  90562. */
  90563. constructor(
  90564. /**
  90565. * The particle system the particle belongs to.
  90566. */
  90567. particleSystem: ParticleSystem);
  90568. private updateCellInfoFromSystem;
  90569. /**
  90570. * Defines how the sprite cell index is updated for the particle
  90571. */
  90572. updateCellIndex(): void;
  90573. /** @hidden */
  90574. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90575. /** @hidden */
  90576. _inheritParticleInfoToSubEmitters(): void;
  90577. /** @hidden */
  90578. _reset(): void;
  90579. /**
  90580. * Copy the properties of particle to another one.
  90581. * @param other the particle to copy the information to.
  90582. */
  90583. copyTo(other: Particle): void;
  90584. }
  90585. }
  90586. declare module BABYLON {
  90587. /**
  90588. * Particle emitter represents a volume emitting particles.
  90589. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90590. */
  90591. export interface IParticleEmitterType {
  90592. /**
  90593. * Called by the particle System when the direction is computed for the created particle.
  90594. * @param worldMatrix is the world matrix of the particle system
  90595. * @param directionToUpdate is the direction vector to update with the result
  90596. * @param particle is the particle we are computed the direction for
  90597. * @param isLocal defines if the direction should be set in local space
  90598. */
  90599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90600. /**
  90601. * Called by the particle System when the position is computed for the created particle.
  90602. * @param worldMatrix is the world matrix of the particle system
  90603. * @param positionToUpdate is the position vector to update with the result
  90604. * @param particle is the particle we are computed the position for
  90605. * @param isLocal defines if the position should be set in local space
  90606. */
  90607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90608. /**
  90609. * Clones the current emitter and returns a copy of it
  90610. * @returns the new emitter
  90611. */
  90612. clone(): IParticleEmitterType;
  90613. /**
  90614. * Called by the GPUParticleSystem to setup the update shader
  90615. * @param effect defines the update shader
  90616. */
  90617. applyToShader(effect: Effect): void;
  90618. /**
  90619. * Returns a string to use to update the GPU particles update shader
  90620. * @returns the effect defines string
  90621. */
  90622. getEffectDefines(): string;
  90623. /**
  90624. * Returns a string representing the class name
  90625. * @returns a string containing the class name
  90626. */
  90627. getClassName(): string;
  90628. /**
  90629. * Serializes the particle system to a JSON object.
  90630. * @returns the JSON object
  90631. */
  90632. serialize(): any;
  90633. /**
  90634. * Parse properties from a JSON object
  90635. * @param serializationObject defines the JSON object
  90636. * @param scene defines the hosting scene
  90637. */
  90638. parse(serializationObject: any, scene: Scene): void;
  90639. }
  90640. }
  90641. declare module BABYLON {
  90642. /**
  90643. * Particle emitter emitting particles from the inside of a box.
  90644. * It emits the particles randomly between 2 given directions.
  90645. */
  90646. export class BoxParticleEmitter implements IParticleEmitterType {
  90647. /**
  90648. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90649. */
  90650. direction1: Vector3;
  90651. /**
  90652. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90653. */
  90654. direction2: Vector3;
  90655. /**
  90656. * 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.
  90657. */
  90658. minEmitBox: Vector3;
  90659. /**
  90660. * 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.
  90661. */
  90662. maxEmitBox: Vector3;
  90663. /**
  90664. * Creates a new instance BoxParticleEmitter
  90665. */
  90666. constructor();
  90667. /**
  90668. * Called by the particle System when the direction is computed for the created particle.
  90669. * @param worldMatrix is the world matrix of the particle system
  90670. * @param directionToUpdate is the direction vector to update with the result
  90671. * @param particle is the particle we are computed the direction for
  90672. * @param isLocal defines if the direction should be set in local space
  90673. */
  90674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90675. /**
  90676. * Called by the particle System when the position is computed for the created particle.
  90677. * @param worldMatrix is the world matrix of the particle system
  90678. * @param positionToUpdate is the position vector to update with the result
  90679. * @param particle is the particle we are computed the position for
  90680. * @param isLocal defines if the position should be set in local space
  90681. */
  90682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90683. /**
  90684. * Clones the current emitter and returns a copy of it
  90685. * @returns the new emitter
  90686. */
  90687. clone(): BoxParticleEmitter;
  90688. /**
  90689. * Called by the GPUParticleSystem to setup the update shader
  90690. * @param effect defines the update shader
  90691. */
  90692. applyToShader(effect: Effect): void;
  90693. /**
  90694. * Returns a string to use to update the GPU particles update shader
  90695. * @returns a string containng the defines string
  90696. */
  90697. getEffectDefines(): string;
  90698. /**
  90699. * Returns the string "BoxParticleEmitter"
  90700. * @returns a string containing the class name
  90701. */
  90702. getClassName(): string;
  90703. /**
  90704. * Serializes the particle system to a JSON object.
  90705. * @returns the JSON object
  90706. */
  90707. serialize(): any;
  90708. /**
  90709. * Parse properties from a JSON object
  90710. * @param serializationObject defines the JSON object
  90711. */
  90712. parse(serializationObject: any): void;
  90713. }
  90714. }
  90715. declare module BABYLON {
  90716. /**
  90717. * Particle emitter emitting particles from the inside of a cone.
  90718. * It emits the particles alongside the cone volume from the base to the particle.
  90719. * The emission direction might be randomized.
  90720. */
  90721. export class ConeParticleEmitter implements IParticleEmitterType {
  90722. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90723. directionRandomizer: number;
  90724. private _radius;
  90725. private _angle;
  90726. private _height;
  90727. /**
  90728. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90729. */
  90730. radiusRange: number;
  90731. /**
  90732. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90733. */
  90734. heightRange: number;
  90735. /**
  90736. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90737. */
  90738. emitFromSpawnPointOnly: boolean;
  90739. /**
  90740. * Gets or sets the radius of the emission cone
  90741. */
  90742. get radius(): number;
  90743. set radius(value: number);
  90744. /**
  90745. * Gets or sets the angle of the emission cone
  90746. */
  90747. get angle(): number;
  90748. set angle(value: number);
  90749. private _buildHeight;
  90750. /**
  90751. * Creates a new instance ConeParticleEmitter
  90752. * @param radius the radius of the emission cone (1 by default)
  90753. * @param angle the cone base angle (PI by default)
  90754. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90755. */
  90756. constructor(radius?: number, angle?: number,
  90757. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90758. directionRandomizer?: number);
  90759. /**
  90760. * Called by the particle System when the direction is computed for the created particle.
  90761. * @param worldMatrix is the world matrix of the particle system
  90762. * @param directionToUpdate is the direction vector to update with the result
  90763. * @param particle is the particle we are computed the direction for
  90764. * @param isLocal defines if the direction should be set in local space
  90765. */
  90766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90767. /**
  90768. * Called by the particle System when the position is computed for the created particle.
  90769. * @param worldMatrix is the world matrix of the particle system
  90770. * @param positionToUpdate is the position vector to update with the result
  90771. * @param particle is the particle we are computed the position for
  90772. * @param isLocal defines if the position should be set in local space
  90773. */
  90774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90775. /**
  90776. * Clones the current emitter and returns a copy of it
  90777. * @returns the new emitter
  90778. */
  90779. clone(): ConeParticleEmitter;
  90780. /**
  90781. * Called by the GPUParticleSystem to setup the update shader
  90782. * @param effect defines the update shader
  90783. */
  90784. applyToShader(effect: Effect): void;
  90785. /**
  90786. * Returns a string to use to update the GPU particles update shader
  90787. * @returns a string containng the defines string
  90788. */
  90789. getEffectDefines(): string;
  90790. /**
  90791. * Returns the string "ConeParticleEmitter"
  90792. * @returns a string containing the class name
  90793. */
  90794. getClassName(): string;
  90795. /**
  90796. * Serializes the particle system to a JSON object.
  90797. * @returns the JSON object
  90798. */
  90799. serialize(): any;
  90800. /**
  90801. * Parse properties from a JSON object
  90802. * @param serializationObject defines the JSON object
  90803. */
  90804. parse(serializationObject: any): void;
  90805. }
  90806. }
  90807. declare module BABYLON {
  90808. /**
  90809. * Particle emitter emitting particles from the inside of a cylinder.
  90810. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90811. */
  90812. export class CylinderParticleEmitter implements IParticleEmitterType {
  90813. /**
  90814. * The radius of the emission cylinder.
  90815. */
  90816. radius: number;
  90817. /**
  90818. * The height of the emission cylinder.
  90819. */
  90820. height: number;
  90821. /**
  90822. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90823. */
  90824. radiusRange: number;
  90825. /**
  90826. * How much to randomize the particle direction [0-1].
  90827. */
  90828. directionRandomizer: number;
  90829. /**
  90830. * Creates a new instance CylinderParticleEmitter
  90831. * @param radius the radius of the emission cylinder (1 by default)
  90832. * @param height the height of the emission cylinder (1 by default)
  90833. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90834. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90835. */
  90836. constructor(
  90837. /**
  90838. * The radius of the emission cylinder.
  90839. */
  90840. radius?: number,
  90841. /**
  90842. * The height of the emission cylinder.
  90843. */
  90844. height?: number,
  90845. /**
  90846. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90847. */
  90848. radiusRange?: number,
  90849. /**
  90850. * How much to randomize the particle direction [0-1].
  90851. */
  90852. directionRandomizer?: number);
  90853. /**
  90854. * Called by the particle System when the direction is computed for the created particle.
  90855. * @param worldMatrix is the world matrix of the particle system
  90856. * @param directionToUpdate is the direction vector to update with the result
  90857. * @param particle is the particle we are computed the direction for
  90858. * @param isLocal defines if the direction should be set in local space
  90859. */
  90860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90861. /**
  90862. * Called by the particle System when the position is computed for the created particle.
  90863. * @param worldMatrix is the world matrix of the particle system
  90864. * @param positionToUpdate is the position vector to update with the result
  90865. * @param particle is the particle we are computed the position for
  90866. * @param isLocal defines if the position should be set in local space
  90867. */
  90868. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90869. /**
  90870. * Clones the current emitter and returns a copy of it
  90871. * @returns the new emitter
  90872. */
  90873. clone(): CylinderParticleEmitter;
  90874. /**
  90875. * Called by the GPUParticleSystem to setup the update shader
  90876. * @param effect defines the update shader
  90877. */
  90878. applyToShader(effect: Effect): void;
  90879. /**
  90880. * Returns a string to use to update the GPU particles update shader
  90881. * @returns a string containng the defines string
  90882. */
  90883. getEffectDefines(): string;
  90884. /**
  90885. * Returns the string "CylinderParticleEmitter"
  90886. * @returns a string containing the class name
  90887. */
  90888. getClassName(): string;
  90889. /**
  90890. * Serializes the particle system to a JSON object.
  90891. * @returns the JSON object
  90892. */
  90893. serialize(): any;
  90894. /**
  90895. * Parse properties from a JSON object
  90896. * @param serializationObject defines the JSON object
  90897. */
  90898. parse(serializationObject: any): void;
  90899. }
  90900. /**
  90901. * Particle emitter emitting particles from the inside of a cylinder.
  90902. * It emits the particles randomly between two vectors.
  90903. */
  90904. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90905. /**
  90906. * The min limit of the emission direction.
  90907. */
  90908. direction1: Vector3;
  90909. /**
  90910. * The max limit of the emission direction.
  90911. */
  90912. direction2: Vector3;
  90913. /**
  90914. * Creates a new instance CylinderDirectedParticleEmitter
  90915. * @param radius the radius of the emission cylinder (1 by default)
  90916. * @param height the height of the emission cylinder (1 by default)
  90917. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90918. * @param direction1 the min limit of the emission direction (up vector by default)
  90919. * @param direction2 the max limit of the emission direction (up vector by default)
  90920. */
  90921. constructor(radius?: number, height?: number, radiusRange?: number,
  90922. /**
  90923. * The min limit of the emission direction.
  90924. */
  90925. direction1?: Vector3,
  90926. /**
  90927. * The max limit of the emission direction.
  90928. */
  90929. direction2?: Vector3);
  90930. /**
  90931. * Called by the particle System when the direction is computed for the created particle.
  90932. * @param worldMatrix is the world matrix of the particle system
  90933. * @param directionToUpdate is the direction vector to update with the result
  90934. * @param particle is the particle we are computed the direction for
  90935. */
  90936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90937. /**
  90938. * Clones the current emitter and returns a copy of it
  90939. * @returns the new emitter
  90940. */
  90941. clone(): CylinderDirectedParticleEmitter;
  90942. /**
  90943. * Called by the GPUParticleSystem to setup the update shader
  90944. * @param effect defines the update shader
  90945. */
  90946. applyToShader(effect: Effect): void;
  90947. /**
  90948. * Returns a string to use to update the GPU particles update shader
  90949. * @returns a string containng the defines string
  90950. */
  90951. getEffectDefines(): string;
  90952. /**
  90953. * Returns the string "CylinderDirectedParticleEmitter"
  90954. * @returns a string containing the class name
  90955. */
  90956. getClassName(): string;
  90957. /**
  90958. * Serializes the particle system to a JSON object.
  90959. * @returns the JSON object
  90960. */
  90961. serialize(): any;
  90962. /**
  90963. * Parse properties from a JSON object
  90964. * @param serializationObject defines the JSON object
  90965. */
  90966. parse(serializationObject: any): void;
  90967. }
  90968. }
  90969. declare module BABYLON {
  90970. /**
  90971. * Particle emitter emitting particles from the inside of a hemisphere.
  90972. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  90973. */
  90974. export class HemisphericParticleEmitter implements IParticleEmitterType {
  90975. /**
  90976. * The radius of the emission hemisphere.
  90977. */
  90978. radius: number;
  90979. /**
  90980. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90981. */
  90982. radiusRange: number;
  90983. /**
  90984. * How much to randomize the particle direction [0-1].
  90985. */
  90986. directionRandomizer: number;
  90987. /**
  90988. * Creates a new instance HemisphericParticleEmitter
  90989. * @param radius the radius of the emission hemisphere (1 by default)
  90990. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90991. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90992. */
  90993. constructor(
  90994. /**
  90995. * The radius of the emission hemisphere.
  90996. */
  90997. radius?: number,
  90998. /**
  90999. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91000. */
  91001. radiusRange?: number,
  91002. /**
  91003. * How much to randomize the particle direction [0-1].
  91004. */
  91005. directionRandomizer?: number);
  91006. /**
  91007. * Called by the particle System when the direction is computed for the created particle.
  91008. * @param worldMatrix is the world matrix of the particle system
  91009. * @param directionToUpdate is the direction vector to update with the result
  91010. * @param particle is the particle we are computed the direction for
  91011. * @param isLocal defines if the direction should be set in local space
  91012. */
  91013. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91014. /**
  91015. * Called by the particle System when the position is computed for the created particle.
  91016. * @param worldMatrix is the world matrix of the particle system
  91017. * @param positionToUpdate is the position vector to update with the result
  91018. * @param particle is the particle we are computed the position for
  91019. * @param isLocal defines if the position should be set in local space
  91020. */
  91021. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91022. /**
  91023. * Clones the current emitter and returns a copy of it
  91024. * @returns the new emitter
  91025. */
  91026. clone(): HemisphericParticleEmitter;
  91027. /**
  91028. * Called by the GPUParticleSystem to setup the update shader
  91029. * @param effect defines the update shader
  91030. */
  91031. applyToShader(effect: Effect): void;
  91032. /**
  91033. * Returns a string to use to update the GPU particles update shader
  91034. * @returns a string containng the defines string
  91035. */
  91036. getEffectDefines(): string;
  91037. /**
  91038. * Returns the string "HemisphericParticleEmitter"
  91039. * @returns a string containing the class name
  91040. */
  91041. getClassName(): string;
  91042. /**
  91043. * Serializes the particle system to a JSON object.
  91044. * @returns the JSON object
  91045. */
  91046. serialize(): any;
  91047. /**
  91048. * Parse properties from a JSON object
  91049. * @param serializationObject defines the JSON object
  91050. */
  91051. parse(serializationObject: any): void;
  91052. }
  91053. }
  91054. declare module BABYLON {
  91055. /**
  91056. * Particle emitter emitting particles from a point.
  91057. * It emits the particles randomly between 2 given directions.
  91058. */
  91059. export class PointParticleEmitter implements IParticleEmitterType {
  91060. /**
  91061. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91062. */
  91063. direction1: Vector3;
  91064. /**
  91065. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91066. */
  91067. direction2: Vector3;
  91068. /**
  91069. * Creates a new instance PointParticleEmitter
  91070. */
  91071. constructor();
  91072. /**
  91073. * Called by the particle System when the direction is computed for the created particle.
  91074. * @param worldMatrix is the world matrix of the particle system
  91075. * @param directionToUpdate is the direction vector to update with the result
  91076. * @param particle is the particle we are computed the direction for
  91077. * @param isLocal defines if the direction should be set in local space
  91078. */
  91079. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91080. /**
  91081. * Called by the particle System when the position is computed for the created particle.
  91082. * @param worldMatrix is the world matrix of the particle system
  91083. * @param positionToUpdate is the position vector to update with the result
  91084. * @param particle is the particle we are computed the position for
  91085. * @param isLocal defines if the position should be set in local space
  91086. */
  91087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91088. /**
  91089. * Clones the current emitter and returns a copy of it
  91090. * @returns the new emitter
  91091. */
  91092. clone(): PointParticleEmitter;
  91093. /**
  91094. * Called by the GPUParticleSystem to setup the update shader
  91095. * @param effect defines the update shader
  91096. */
  91097. applyToShader(effect: Effect): void;
  91098. /**
  91099. * Returns a string to use to update the GPU particles update shader
  91100. * @returns a string containng the defines string
  91101. */
  91102. getEffectDefines(): string;
  91103. /**
  91104. * Returns the string "PointParticleEmitter"
  91105. * @returns a string containing the class name
  91106. */
  91107. getClassName(): string;
  91108. /**
  91109. * Serializes the particle system to a JSON object.
  91110. * @returns the JSON object
  91111. */
  91112. serialize(): any;
  91113. /**
  91114. * Parse properties from a JSON object
  91115. * @param serializationObject defines the JSON object
  91116. */
  91117. parse(serializationObject: any): void;
  91118. }
  91119. }
  91120. declare module BABYLON {
  91121. /**
  91122. * Particle emitter emitting particles from the inside of a sphere.
  91123. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91124. */
  91125. export class SphereParticleEmitter implements IParticleEmitterType {
  91126. /**
  91127. * The radius of the emission sphere.
  91128. */
  91129. radius: number;
  91130. /**
  91131. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91132. */
  91133. radiusRange: number;
  91134. /**
  91135. * How much to randomize the particle direction [0-1].
  91136. */
  91137. directionRandomizer: number;
  91138. /**
  91139. * Creates a new instance SphereParticleEmitter
  91140. * @param radius the radius of the emission sphere (1 by default)
  91141. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91142. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91143. */
  91144. constructor(
  91145. /**
  91146. * The radius of the emission sphere.
  91147. */
  91148. radius?: number,
  91149. /**
  91150. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91151. */
  91152. radiusRange?: number,
  91153. /**
  91154. * How much to randomize the particle direction [0-1].
  91155. */
  91156. directionRandomizer?: number);
  91157. /**
  91158. * Called by the particle System when the direction is computed for the created particle.
  91159. * @param worldMatrix is the world matrix of the particle system
  91160. * @param directionToUpdate is the direction vector to update with the result
  91161. * @param particle is the particle we are computed the direction for
  91162. * @param isLocal defines if the direction should be set in local space
  91163. */
  91164. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91165. /**
  91166. * Called by the particle System when the position is computed for the created particle.
  91167. * @param worldMatrix is the world matrix of the particle system
  91168. * @param positionToUpdate is the position vector to update with the result
  91169. * @param particle is the particle we are computed the position for
  91170. * @param isLocal defines if the position should be set in local space
  91171. */
  91172. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91173. /**
  91174. * Clones the current emitter and returns a copy of it
  91175. * @returns the new emitter
  91176. */
  91177. clone(): SphereParticleEmitter;
  91178. /**
  91179. * Called by the GPUParticleSystem to setup the update shader
  91180. * @param effect defines the update shader
  91181. */
  91182. applyToShader(effect: Effect): void;
  91183. /**
  91184. * Returns a string to use to update the GPU particles update shader
  91185. * @returns a string containng the defines string
  91186. */
  91187. getEffectDefines(): string;
  91188. /**
  91189. * Returns the string "SphereParticleEmitter"
  91190. * @returns a string containing the class name
  91191. */
  91192. getClassName(): string;
  91193. /**
  91194. * Serializes the particle system to a JSON object.
  91195. * @returns the JSON object
  91196. */
  91197. serialize(): any;
  91198. /**
  91199. * Parse properties from a JSON object
  91200. * @param serializationObject defines the JSON object
  91201. */
  91202. parse(serializationObject: any): void;
  91203. }
  91204. /**
  91205. * Particle emitter emitting particles from the inside of a sphere.
  91206. * It emits the particles randomly between two vectors.
  91207. */
  91208. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91209. /**
  91210. * The min limit of the emission direction.
  91211. */
  91212. direction1: Vector3;
  91213. /**
  91214. * The max limit of the emission direction.
  91215. */
  91216. direction2: Vector3;
  91217. /**
  91218. * Creates a new instance SphereDirectedParticleEmitter
  91219. * @param radius the radius of the emission sphere (1 by default)
  91220. * @param direction1 the min limit of the emission direction (up vector by default)
  91221. * @param direction2 the max limit of the emission direction (up vector by default)
  91222. */
  91223. constructor(radius?: number,
  91224. /**
  91225. * The min limit of the emission direction.
  91226. */
  91227. direction1?: Vector3,
  91228. /**
  91229. * The max limit of the emission direction.
  91230. */
  91231. direction2?: Vector3);
  91232. /**
  91233. * Called by the particle System when the direction is computed for the created particle.
  91234. * @param worldMatrix is the world matrix of the particle system
  91235. * @param directionToUpdate is the direction vector to update with the result
  91236. * @param particle is the particle we are computed the direction for
  91237. */
  91238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91239. /**
  91240. * Clones the current emitter and returns a copy of it
  91241. * @returns the new emitter
  91242. */
  91243. clone(): SphereDirectedParticleEmitter;
  91244. /**
  91245. * Called by the GPUParticleSystem to setup the update shader
  91246. * @param effect defines the update shader
  91247. */
  91248. applyToShader(effect: Effect): void;
  91249. /**
  91250. * Returns a string to use to update the GPU particles update shader
  91251. * @returns a string containng the defines string
  91252. */
  91253. getEffectDefines(): string;
  91254. /**
  91255. * Returns the string "SphereDirectedParticleEmitter"
  91256. * @returns a string containing the class name
  91257. */
  91258. getClassName(): string;
  91259. /**
  91260. * Serializes the particle system to a JSON object.
  91261. * @returns the JSON object
  91262. */
  91263. serialize(): any;
  91264. /**
  91265. * Parse properties from a JSON object
  91266. * @param serializationObject defines the JSON object
  91267. */
  91268. parse(serializationObject: any): void;
  91269. }
  91270. }
  91271. declare module BABYLON {
  91272. /**
  91273. * Particle emitter emitting particles from a custom list of positions.
  91274. */
  91275. export class CustomParticleEmitter implements IParticleEmitterType {
  91276. /**
  91277. * Gets or sets the position generator that will create the inital position of each particle.
  91278. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91279. */
  91280. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91281. /**
  91282. * Gets or sets the destination generator that will create the final destination of each particle.
  91283. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91284. */
  91285. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91286. /**
  91287. * Creates a new instance CustomParticleEmitter
  91288. */
  91289. constructor();
  91290. /**
  91291. * Called by the particle System when the direction is computed for the created particle.
  91292. * @param worldMatrix is the world matrix of the particle system
  91293. * @param directionToUpdate is the direction vector to update with the result
  91294. * @param particle is the particle we are computed the direction for
  91295. * @param isLocal defines if the direction should be set in local space
  91296. */
  91297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91298. /**
  91299. * Called by the particle System when the position is computed for the created particle.
  91300. * @param worldMatrix is the world matrix of the particle system
  91301. * @param positionToUpdate is the position vector to update with the result
  91302. * @param particle is the particle we are computed the position for
  91303. * @param isLocal defines if the position should be set in local space
  91304. */
  91305. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91306. /**
  91307. * Clones the current emitter and returns a copy of it
  91308. * @returns the new emitter
  91309. */
  91310. clone(): CustomParticleEmitter;
  91311. /**
  91312. * Called by the GPUParticleSystem to setup the update shader
  91313. * @param effect defines the update shader
  91314. */
  91315. applyToShader(effect: Effect): void;
  91316. /**
  91317. * Returns a string to use to update the GPU particles update shader
  91318. * @returns a string containng the defines string
  91319. */
  91320. getEffectDefines(): string;
  91321. /**
  91322. * Returns the string "PointParticleEmitter"
  91323. * @returns a string containing the class name
  91324. */
  91325. getClassName(): string;
  91326. /**
  91327. * Serializes the particle system to a JSON object.
  91328. * @returns the JSON object
  91329. */
  91330. serialize(): any;
  91331. /**
  91332. * Parse properties from a JSON object
  91333. * @param serializationObject defines the JSON object
  91334. */
  91335. parse(serializationObject: any): void;
  91336. }
  91337. }
  91338. declare module BABYLON {
  91339. /**
  91340. * Particle emitter emitting particles from the inside of a box.
  91341. * It emits the particles randomly between 2 given directions.
  91342. */
  91343. export class MeshParticleEmitter implements IParticleEmitterType {
  91344. private _indices;
  91345. private _positions;
  91346. private _normals;
  91347. private _storedNormal;
  91348. private _mesh;
  91349. /**
  91350. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91351. */
  91352. direction1: Vector3;
  91353. /**
  91354. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91355. */
  91356. direction2: Vector3;
  91357. /**
  91358. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91359. */
  91360. useMeshNormalsForDirection: boolean;
  91361. /** Defines the mesh to use as source */
  91362. get mesh(): Nullable<AbstractMesh>;
  91363. set mesh(value: Nullable<AbstractMesh>);
  91364. /**
  91365. * Creates a new instance MeshParticleEmitter
  91366. * @param mesh defines the mesh to use as source
  91367. */
  91368. constructor(mesh?: Nullable<AbstractMesh>);
  91369. /**
  91370. * Called by the particle System when the direction is computed for the created particle.
  91371. * @param worldMatrix is the world matrix of the particle system
  91372. * @param directionToUpdate is the direction vector to update with the result
  91373. * @param particle is the particle we are computed the direction for
  91374. * @param isLocal defines if the direction should be set in local space
  91375. */
  91376. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91377. /**
  91378. * Called by the particle System when the position is computed for the created particle.
  91379. * @param worldMatrix is the world matrix of the particle system
  91380. * @param positionToUpdate is the position vector to update with the result
  91381. * @param particle is the particle we are computed the position for
  91382. * @param isLocal defines if the position should be set in local space
  91383. */
  91384. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91385. /**
  91386. * Clones the current emitter and returns a copy of it
  91387. * @returns the new emitter
  91388. */
  91389. clone(): MeshParticleEmitter;
  91390. /**
  91391. * Called by the GPUParticleSystem to setup the update shader
  91392. * @param effect defines the update shader
  91393. */
  91394. applyToShader(effect: Effect): void;
  91395. /**
  91396. * Returns a string to use to update the GPU particles update shader
  91397. * @returns a string containng the defines string
  91398. */
  91399. getEffectDefines(): string;
  91400. /**
  91401. * Returns the string "BoxParticleEmitter"
  91402. * @returns a string containing the class name
  91403. */
  91404. getClassName(): string;
  91405. /**
  91406. * Serializes the particle system to a JSON object.
  91407. * @returns the JSON object
  91408. */
  91409. serialize(): any;
  91410. /**
  91411. * Parse properties from a JSON object
  91412. * @param serializationObject defines the JSON object
  91413. * @param scene defines the hosting scene
  91414. */
  91415. parse(serializationObject: any, scene: Scene): void;
  91416. }
  91417. }
  91418. declare module BABYLON {
  91419. /**
  91420. * Interface representing a particle system in Babylon.js.
  91421. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91422. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91423. */
  91424. export interface IParticleSystem {
  91425. /**
  91426. * List of animations used by the particle system.
  91427. */
  91428. animations: Animation[];
  91429. /**
  91430. * The id of the Particle system.
  91431. */
  91432. id: string;
  91433. /**
  91434. * The name of the Particle system.
  91435. */
  91436. name: string;
  91437. /**
  91438. * The emitter represents the Mesh or position we are attaching the particle system to.
  91439. */
  91440. emitter: Nullable<AbstractMesh | Vector3>;
  91441. /**
  91442. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91443. */
  91444. isBillboardBased: boolean;
  91445. /**
  91446. * The rendering group used by the Particle system to chose when to render.
  91447. */
  91448. renderingGroupId: number;
  91449. /**
  91450. * The layer mask we are rendering the particles through.
  91451. */
  91452. layerMask: number;
  91453. /**
  91454. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91455. */
  91456. updateSpeed: number;
  91457. /**
  91458. * The amount of time the particle system is running (depends of the overall update speed).
  91459. */
  91460. targetStopDuration: number;
  91461. /**
  91462. * The texture used to render each particle. (this can be a spritesheet)
  91463. */
  91464. particleTexture: Nullable<Texture>;
  91465. /**
  91466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91467. */
  91468. blendMode: number;
  91469. /**
  91470. * Minimum life time of emitting particles.
  91471. */
  91472. minLifeTime: number;
  91473. /**
  91474. * Maximum life time of emitting particles.
  91475. */
  91476. maxLifeTime: number;
  91477. /**
  91478. * Minimum Size of emitting particles.
  91479. */
  91480. minSize: number;
  91481. /**
  91482. * Maximum Size of emitting particles.
  91483. */
  91484. maxSize: number;
  91485. /**
  91486. * Minimum scale of emitting particles on X axis.
  91487. */
  91488. minScaleX: number;
  91489. /**
  91490. * Maximum scale of emitting particles on X axis.
  91491. */
  91492. maxScaleX: number;
  91493. /**
  91494. * Minimum scale of emitting particles on Y axis.
  91495. */
  91496. minScaleY: number;
  91497. /**
  91498. * Maximum scale of emitting particles on Y axis.
  91499. */
  91500. maxScaleY: number;
  91501. /**
  91502. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91503. */
  91504. color1: Color4;
  91505. /**
  91506. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91507. */
  91508. color2: Color4;
  91509. /**
  91510. * Color the particle will have at the end of its lifetime.
  91511. */
  91512. colorDead: Color4;
  91513. /**
  91514. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91515. */
  91516. emitRate: number;
  91517. /**
  91518. * You can use gravity if you want to give an orientation to your particles.
  91519. */
  91520. gravity: Vector3;
  91521. /**
  91522. * Minimum power of emitting particles.
  91523. */
  91524. minEmitPower: number;
  91525. /**
  91526. * Maximum power of emitting particles.
  91527. */
  91528. maxEmitPower: number;
  91529. /**
  91530. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91531. */
  91532. minAngularSpeed: number;
  91533. /**
  91534. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91535. */
  91536. maxAngularSpeed: number;
  91537. /**
  91538. * Gets or sets the minimal initial rotation in radians.
  91539. */
  91540. minInitialRotation: number;
  91541. /**
  91542. * Gets or sets the maximal initial rotation in radians.
  91543. */
  91544. maxInitialRotation: number;
  91545. /**
  91546. * The particle emitter type defines the emitter used by the particle system.
  91547. * It can be for example box, sphere, or cone...
  91548. */
  91549. particleEmitterType: Nullable<IParticleEmitterType>;
  91550. /**
  91551. * Defines the delay in milliseconds before starting the system (0 by default)
  91552. */
  91553. startDelay: number;
  91554. /**
  91555. * 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
  91556. */
  91557. preWarmCycles: number;
  91558. /**
  91559. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91560. */
  91561. preWarmStepOffset: number;
  91562. /**
  91563. * 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)
  91564. */
  91565. spriteCellChangeSpeed: number;
  91566. /**
  91567. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91568. */
  91569. startSpriteCellID: number;
  91570. /**
  91571. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91572. */
  91573. endSpriteCellID: number;
  91574. /**
  91575. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91576. */
  91577. spriteCellWidth: number;
  91578. /**
  91579. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91580. */
  91581. spriteCellHeight: number;
  91582. /**
  91583. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91584. */
  91585. spriteRandomStartCell: boolean;
  91586. /**
  91587. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91588. */
  91589. isAnimationSheetEnabled: boolean;
  91590. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91591. translationPivot: Vector2;
  91592. /**
  91593. * Gets or sets a texture used to add random noise to particle positions
  91594. */
  91595. noiseTexture: Nullable<BaseTexture>;
  91596. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91597. noiseStrength: Vector3;
  91598. /**
  91599. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91600. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91601. */
  91602. billboardMode: number;
  91603. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91604. limitVelocityDamping: number;
  91605. /**
  91606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91607. */
  91608. beginAnimationOnStart: boolean;
  91609. /**
  91610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91611. */
  91612. beginAnimationFrom: number;
  91613. /**
  91614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91615. */
  91616. beginAnimationTo: number;
  91617. /**
  91618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91619. */
  91620. beginAnimationLoop: boolean;
  91621. /**
  91622. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91623. */
  91624. disposeOnStop: boolean;
  91625. /**
  91626. * Specifies if the particles are updated in emitter local space or world space
  91627. */
  91628. isLocal: boolean;
  91629. /** Snippet ID if the particle system was created from the snippet server */
  91630. snippetId: string;
  91631. /**
  91632. * Gets the maximum number of particles active at the same time.
  91633. * @returns The max number of active particles.
  91634. */
  91635. getCapacity(): number;
  91636. /**
  91637. * Gets the number of particles active at the same time.
  91638. * @returns The number of active particles.
  91639. */
  91640. getActiveCount(): number;
  91641. /**
  91642. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91643. * @returns True if it has been started, otherwise false.
  91644. */
  91645. isStarted(): boolean;
  91646. /**
  91647. * Animates the particle system for this frame.
  91648. */
  91649. animate(): void;
  91650. /**
  91651. * Renders the particle system in its current state.
  91652. * @returns the current number of particles
  91653. */
  91654. render(): number;
  91655. /**
  91656. * Dispose the particle system and frees its associated resources.
  91657. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91658. */
  91659. dispose(disposeTexture?: boolean): void;
  91660. /**
  91661. * An event triggered when the system is disposed
  91662. */
  91663. onDisposeObservable: Observable<IParticleSystem>;
  91664. /**
  91665. * Clones the particle system.
  91666. * @param name The name of the cloned object
  91667. * @param newEmitter The new emitter to use
  91668. * @returns the cloned particle system
  91669. */
  91670. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91671. /**
  91672. * Serializes the particle system to a JSON object
  91673. * @param serializeTexture defines if the texture must be serialized as well
  91674. * @returns the JSON object
  91675. */
  91676. serialize(serializeTexture: boolean): any;
  91677. /**
  91678. * Rebuild the particle system
  91679. */
  91680. rebuild(): void;
  91681. /** Force the system to rebuild all gradients that need to be resync */
  91682. forceRefreshGradients(): void;
  91683. /**
  91684. * Starts the particle system and begins to emit
  91685. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91686. */
  91687. start(delay?: number): void;
  91688. /**
  91689. * Stops the particle system.
  91690. */
  91691. stop(): void;
  91692. /**
  91693. * Remove all active particles
  91694. */
  91695. reset(): void;
  91696. /**
  91697. * Gets a boolean indicating that the system is stopping
  91698. * @returns true if the system is currently stopping
  91699. */
  91700. isStopping(): boolean;
  91701. /**
  91702. * Is this system ready to be used/rendered
  91703. * @return true if the system is ready
  91704. */
  91705. isReady(): boolean;
  91706. /**
  91707. * Returns the string "ParticleSystem"
  91708. * @returns a string containing the class name
  91709. */
  91710. getClassName(): string;
  91711. /**
  91712. * Gets the custom effect used to render the particles
  91713. * @param blendMode Blend mode for which the effect should be retrieved
  91714. * @returns The effect
  91715. */
  91716. getCustomEffect(blendMode: number): Nullable<Effect>;
  91717. /**
  91718. * Sets the custom effect used to render the particles
  91719. * @param effect The effect to set
  91720. * @param blendMode Blend mode for which the effect should be set
  91721. */
  91722. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91723. /**
  91724. * Fill the defines array according to the current settings of the particle system
  91725. * @param defines Array to be updated
  91726. * @param blendMode blend mode to take into account when updating the array
  91727. */
  91728. fillDefines(defines: Array<string>, blendMode: number): void;
  91729. /**
  91730. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91731. * @param uniforms Uniforms array to fill
  91732. * @param attributes Attributes array to fill
  91733. * @param samplers Samplers array to fill
  91734. */
  91735. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91736. /**
  91737. * Observable that will be called just before the particles are drawn
  91738. */
  91739. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91740. /**
  91741. * Gets the name of the particle vertex shader
  91742. */
  91743. vertexShaderName: string;
  91744. /**
  91745. * Adds a new color gradient
  91746. * @param gradient defines the gradient to use (between 0 and 1)
  91747. * @param color1 defines the color to affect to the specified gradient
  91748. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91749. * @returns the current particle system
  91750. */
  91751. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91752. /**
  91753. * Remove a specific color gradient
  91754. * @param gradient defines the gradient to remove
  91755. * @returns the current particle system
  91756. */
  91757. removeColorGradient(gradient: number): IParticleSystem;
  91758. /**
  91759. * Adds a new size gradient
  91760. * @param gradient defines the gradient to use (between 0 and 1)
  91761. * @param factor defines the size factor to affect to the specified gradient
  91762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91763. * @returns the current particle system
  91764. */
  91765. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91766. /**
  91767. * Remove a specific size gradient
  91768. * @param gradient defines the gradient to remove
  91769. * @returns the current particle system
  91770. */
  91771. removeSizeGradient(gradient: number): IParticleSystem;
  91772. /**
  91773. * Gets the current list of color gradients.
  91774. * You must use addColorGradient and removeColorGradient to udpate this list
  91775. * @returns the list of color gradients
  91776. */
  91777. getColorGradients(): Nullable<Array<ColorGradient>>;
  91778. /**
  91779. * Gets the current list of size gradients.
  91780. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91781. * @returns the list of size gradients
  91782. */
  91783. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91784. /**
  91785. * Gets the current list of angular speed gradients.
  91786. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91787. * @returns the list of angular speed gradients
  91788. */
  91789. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91790. /**
  91791. * Adds a new angular speed gradient
  91792. * @param gradient defines the gradient to use (between 0 and 1)
  91793. * @param factor defines the angular speed to affect to the specified gradient
  91794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91795. * @returns the current particle system
  91796. */
  91797. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91798. /**
  91799. * Remove a specific angular speed gradient
  91800. * @param gradient defines the gradient to remove
  91801. * @returns the current particle system
  91802. */
  91803. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91804. /**
  91805. * Gets the current list of velocity gradients.
  91806. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91807. * @returns the list of velocity gradients
  91808. */
  91809. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91810. /**
  91811. * Adds a new velocity gradient
  91812. * @param gradient defines the gradient to use (between 0 and 1)
  91813. * @param factor defines the velocity to affect to the specified gradient
  91814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91815. * @returns the current particle system
  91816. */
  91817. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91818. /**
  91819. * Remove a specific velocity gradient
  91820. * @param gradient defines the gradient to remove
  91821. * @returns the current particle system
  91822. */
  91823. removeVelocityGradient(gradient: number): IParticleSystem;
  91824. /**
  91825. * Gets the current list of limit velocity gradients.
  91826. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91827. * @returns the list of limit velocity gradients
  91828. */
  91829. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91830. /**
  91831. * Adds a new limit velocity gradient
  91832. * @param gradient defines the gradient to use (between 0 and 1)
  91833. * @param factor defines the limit velocity to affect to the specified gradient
  91834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91835. * @returns the current particle system
  91836. */
  91837. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91838. /**
  91839. * Remove a specific limit velocity gradient
  91840. * @param gradient defines the gradient to remove
  91841. * @returns the current particle system
  91842. */
  91843. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91844. /**
  91845. * Adds a new drag gradient
  91846. * @param gradient defines the gradient to use (between 0 and 1)
  91847. * @param factor defines the drag to affect to the specified gradient
  91848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91849. * @returns the current particle system
  91850. */
  91851. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91852. /**
  91853. * Remove a specific drag gradient
  91854. * @param gradient defines the gradient to remove
  91855. * @returns the current particle system
  91856. */
  91857. removeDragGradient(gradient: number): IParticleSystem;
  91858. /**
  91859. * Gets the current list of drag gradients.
  91860. * You must use addDragGradient and removeDragGradient to udpate this list
  91861. * @returns the list of drag gradients
  91862. */
  91863. getDragGradients(): Nullable<Array<FactorGradient>>;
  91864. /**
  91865. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91866. * @param gradient defines the gradient to use (between 0 and 1)
  91867. * @param factor defines the emit rate to affect to the specified gradient
  91868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91869. * @returns the current particle system
  91870. */
  91871. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91872. /**
  91873. * Remove a specific emit rate gradient
  91874. * @param gradient defines the gradient to remove
  91875. * @returns the current particle system
  91876. */
  91877. removeEmitRateGradient(gradient: number): IParticleSystem;
  91878. /**
  91879. * Gets the current list of emit rate gradients.
  91880. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91881. * @returns the list of emit rate gradients
  91882. */
  91883. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91884. /**
  91885. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91886. * @param gradient defines the gradient to use (between 0 and 1)
  91887. * @param factor defines the start size to affect to the specified gradient
  91888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91889. * @returns the current particle system
  91890. */
  91891. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91892. /**
  91893. * Remove a specific start size gradient
  91894. * @param gradient defines the gradient to remove
  91895. * @returns the current particle system
  91896. */
  91897. removeStartSizeGradient(gradient: number): IParticleSystem;
  91898. /**
  91899. * Gets the current list of start size gradients.
  91900. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91901. * @returns the list of start size gradients
  91902. */
  91903. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91904. /**
  91905. * Adds a new life time gradient
  91906. * @param gradient defines the gradient to use (between 0 and 1)
  91907. * @param factor defines the life time factor to affect to the specified gradient
  91908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91909. * @returns the current particle system
  91910. */
  91911. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91912. /**
  91913. * Remove a specific life time gradient
  91914. * @param gradient defines the gradient to remove
  91915. * @returns the current particle system
  91916. */
  91917. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91918. /**
  91919. * Gets the current list of life time gradients.
  91920. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91921. * @returns the list of life time gradients
  91922. */
  91923. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91924. /**
  91925. * Gets the current list of color gradients.
  91926. * You must use addColorGradient and removeColorGradient to udpate this list
  91927. * @returns the list of color gradients
  91928. */
  91929. getColorGradients(): Nullable<Array<ColorGradient>>;
  91930. /**
  91931. * Adds a new ramp gradient used to remap particle colors
  91932. * @param gradient defines the gradient to use (between 0 and 1)
  91933. * @param color defines the color to affect to the specified gradient
  91934. * @returns the current particle system
  91935. */
  91936. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91937. /**
  91938. * Gets the current list of ramp gradients.
  91939. * You must use addRampGradient and removeRampGradient to udpate this list
  91940. * @returns the list of ramp gradients
  91941. */
  91942. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91943. /** Gets or sets a boolean indicating that ramp gradients must be used
  91944. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91945. */
  91946. useRampGradients: boolean;
  91947. /**
  91948. * Adds a new color remap gradient
  91949. * @param gradient defines the gradient to use (between 0 and 1)
  91950. * @param min defines the color remap minimal range
  91951. * @param max defines the color remap maximal range
  91952. * @returns the current particle system
  91953. */
  91954. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91955. /**
  91956. * Gets the current list of color remap gradients.
  91957. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91958. * @returns the list of color remap gradients
  91959. */
  91960. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91961. /**
  91962. * Adds a new alpha remap gradient
  91963. * @param gradient defines the gradient to use (between 0 and 1)
  91964. * @param min defines the alpha remap minimal range
  91965. * @param max defines the alpha remap maximal range
  91966. * @returns the current particle system
  91967. */
  91968. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91969. /**
  91970. * Gets the current list of alpha remap gradients.
  91971. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91972. * @returns the list of alpha remap gradients
  91973. */
  91974. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91975. /**
  91976. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91977. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91978. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91979. * @returns the emitter
  91980. */
  91981. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91982. /**
  91983. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91984. * @param radius The radius of the hemisphere to emit from
  91985. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91986. * @returns the emitter
  91987. */
  91988. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  91989. /**
  91990. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91991. * @param radius The radius of the sphere to emit from
  91992. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91993. * @returns the emitter
  91994. */
  91995. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  91996. /**
  91997. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91998. * @param radius The radius of the sphere to emit from
  91999. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92000. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92001. * @returns the emitter
  92002. */
  92003. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92004. /**
  92005. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92006. * @param radius The radius of the emission cylinder
  92007. * @param height The height of the emission cylinder
  92008. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92009. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92010. * @returns the emitter
  92011. */
  92012. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92013. /**
  92014. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92015. * @param radius The radius of the cylinder to emit from
  92016. * @param height The height of the emission cylinder
  92017. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92018. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92019. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92020. * @returns the emitter
  92021. */
  92022. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92023. /**
  92024. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92025. * @param radius The radius of the cone to emit from
  92026. * @param angle The base angle of the cone
  92027. * @returns the emitter
  92028. */
  92029. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92030. /**
  92031. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92032. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92033. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92034. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92035. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92036. * @returns the emitter
  92037. */
  92038. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92039. /**
  92040. * Get hosting scene
  92041. * @returns the scene
  92042. */
  92043. getScene(): Scene;
  92044. }
  92045. }
  92046. declare module BABYLON {
  92047. /**
  92048. * 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.
  92049. * @see https://doc.babylonjs.com/how_to/transformnode
  92050. */
  92051. export class TransformNode extends Node {
  92052. /**
  92053. * Object will not rotate to face the camera
  92054. */
  92055. static BILLBOARDMODE_NONE: number;
  92056. /**
  92057. * Object will rotate to face the camera but only on the x axis
  92058. */
  92059. static BILLBOARDMODE_X: number;
  92060. /**
  92061. * Object will rotate to face the camera but only on the y axis
  92062. */
  92063. static BILLBOARDMODE_Y: number;
  92064. /**
  92065. * Object will rotate to face the camera but only on the z axis
  92066. */
  92067. static BILLBOARDMODE_Z: number;
  92068. /**
  92069. * Object will rotate to face the camera
  92070. */
  92071. static BILLBOARDMODE_ALL: number;
  92072. /**
  92073. * Object will rotate to face the camera's position instead of orientation
  92074. */
  92075. static BILLBOARDMODE_USE_POSITION: number;
  92076. private _forward;
  92077. private _forwardInverted;
  92078. private _up;
  92079. private _right;
  92080. private _rightInverted;
  92081. private _position;
  92082. private _rotation;
  92083. private _rotationQuaternion;
  92084. protected _scaling: Vector3;
  92085. protected _isDirty: boolean;
  92086. private _transformToBoneReferal;
  92087. private _isAbsoluteSynced;
  92088. private _billboardMode;
  92089. /**
  92090. * Gets or sets the billboard mode. Default is 0.
  92091. *
  92092. * | Value | Type | Description |
  92093. * | --- | --- | --- |
  92094. * | 0 | BILLBOARDMODE_NONE | |
  92095. * | 1 | BILLBOARDMODE_X | |
  92096. * | 2 | BILLBOARDMODE_Y | |
  92097. * | 4 | BILLBOARDMODE_Z | |
  92098. * | 7 | BILLBOARDMODE_ALL | |
  92099. *
  92100. */
  92101. get billboardMode(): number;
  92102. set billboardMode(value: number);
  92103. private _preserveParentRotationForBillboard;
  92104. /**
  92105. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92106. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92107. */
  92108. get preserveParentRotationForBillboard(): boolean;
  92109. set preserveParentRotationForBillboard(value: boolean);
  92110. /**
  92111. * 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
  92112. */
  92113. scalingDeterminant: number;
  92114. private _infiniteDistance;
  92115. /**
  92116. * Gets or sets the distance of the object to max, often used by skybox
  92117. */
  92118. get infiniteDistance(): boolean;
  92119. set infiniteDistance(value: boolean);
  92120. /**
  92121. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92122. * By default the system will update normals to compensate
  92123. */
  92124. ignoreNonUniformScaling: boolean;
  92125. /**
  92126. * 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
  92127. */
  92128. reIntegrateRotationIntoRotationQuaternion: boolean;
  92129. /** @hidden */
  92130. _poseMatrix: Nullable<Matrix>;
  92131. /** @hidden */
  92132. _localMatrix: Matrix;
  92133. private _usePivotMatrix;
  92134. private _absolutePosition;
  92135. private _absoluteScaling;
  92136. private _absoluteRotationQuaternion;
  92137. private _pivotMatrix;
  92138. private _pivotMatrixInverse;
  92139. protected _postMultiplyPivotMatrix: boolean;
  92140. protected _isWorldMatrixFrozen: boolean;
  92141. /** @hidden */
  92142. _indexInSceneTransformNodesArray: number;
  92143. /**
  92144. * An event triggered after the world matrix is updated
  92145. */
  92146. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92147. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92148. /**
  92149. * Gets a string identifying the name of the class
  92150. * @returns "TransformNode" string
  92151. */
  92152. getClassName(): string;
  92153. /**
  92154. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92155. */
  92156. get position(): Vector3;
  92157. set position(newPosition: Vector3);
  92158. /**
  92159. * 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)).
  92160. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92161. */
  92162. get rotation(): Vector3;
  92163. set rotation(newRotation: Vector3);
  92164. /**
  92165. * 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)).
  92166. */
  92167. get scaling(): Vector3;
  92168. set scaling(newScaling: Vector3);
  92169. /**
  92170. * 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).
  92171. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92172. */
  92173. get rotationQuaternion(): Nullable<Quaternion>;
  92174. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92175. /**
  92176. * The forward direction of that transform in world space.
  92177. */
  92178. get forward(): Vector3;
  92179. /**
  92180. * The up direction of that transform in world space.
  92181. */
  92182. get up(): Vector3;
  92183. /**
  92184. * The right direction of that transform in world space.
  92185. */
  92186. get right(): Vector3;
  92187. /**
  92188. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92189. * @param matrix the matrix to copy the pose from
  92190. * @returns this TransformNode.
  92191. */
  92192. updatePoseMatrix(matrix: Matrix): TransformNode;
  92193. /**
  92194. * Returns the mesh Pose matrix.
  92195. * @returns the pose matrix
  92196. */
  92197. getPoseMatrix(): Matrix;
  92198. /** @hidden */
  92199. _isSynchronized(): boolean;
  92200. /** @hidden */
  92201. _initCache(): void;
  92202. /**
  92203. * Flag the transform node as dirty (Forcing it to update everything)
  92204. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92205. * @returns this transform node
  92206. */
  92207. markAsDirty(property: string): TransformNode;
  92208. /**
  92209. * Returns the current mesh absolute position.
  92210. * Returns a Vector3.
  92211. */
  92212. get absolutePosition(): Vector3;
  92213. /**
  92214. * Returns the current mesh absolute scaling.
  92215. * Returns a Vector3.
  92216. */
  92217. get absoluteScaling(): Vector3;
  92218. /**
  92219. * Returns the current mesh absolute rotation.
  92220. * Returns a Quaternion.
  92221. */
  92222. get absoluteRotationQuaternion(): Quaternion;
  92223. /**
  92224. * Sets a new matrix to apply before all other transformation
  92225. * @param matrix defines the transform matrix
  92226. * @returns the current TransformNode
  92227. */
  92228. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92229. /**
  92230. * Sets a new pivot matrix to the current node
  92231. * @param matrix defines the new pivot matrix to use
  92232. * @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
  92233. * @returns the current TransformNode
  92234. */
  92235. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92236. /**
  92237. * Returns the mesh pivot matrix.
  92238. * Default : Identity.
  92239. * @returns the matrix
  92240. */
  92241. getPivotMatrix(): Matrix;
  92242. /**
  92243. * Instantiate (when possible) or clone that node with its hierarchy
  92244. * @param newParent defines the new parent to use for the instance (or clone)
  92245. * @param options defines options to configure how copy is done
  92246. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92247. * @returns an instance (or a clone) of the current node with its hiearchy
  92248. */
  92249. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92250. doNotInstantiate: boolean;
  92251. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92252. /**
  92253. * Prevents the World matrix to be computed any longer
  92254. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92255. * @returns the TransformNode.
  92256. */
  92257. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92258. /**
  92259. * Allows back the World matrix computation.
  92260. * @returns the TransformNode.
  92261. */
  92262. unfreezeWorldMatrix(): this;
  92263. /**
  92264. * True if the World matrix has been frozen.
  92265. */
  92266. get isWorldMatrixFrozen(): boolean;
  92267. /**
  92268. * Retuns the mesh absolute position in the World.
  92269. * @returns a Vector3.
  92270. */
  92271. getAbsolutePosition(): Vector3;
  92272. /**
  92273. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92274. * @param absolutePosition the absolute position to set
  92275. * @returns the TransformNode.
  92276. */
  92277. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92278. /**
  92279. * Sets the mesh position in its local space.
  92280. * @param vector3 the position to set in localspace
  92281. * @returns the TransformNode.
  92282. */
  92283. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92284. /**
  92285. * Returns the mesh position in the local space from the current World matrix values.
  92286. * @returns a new Vector3.
  92287. */
  92288. getPositionExpressedInLocalSpace(): Vector3;
  92289. /**
  92290. * Translates the mesh along the passed Vector3 in its local space.
  92291. * @param vector3 the distance to translate in localspace
  92292. * @returns the TransformNode.
  92293. */
  92294. locallyTranslate(vector3: Vector3): TransformNode;
  92295. private static _lookAtVectorCache;
  92296. /**
  92297. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92298. * @param targetPoint the position (must be in same space as current mesh) to look at
  92299. * @param yawCor optional yaw (y-axis) correction in radians
  92300. * @param pitchCor optional pitch (x-axis) correction in radians
  92301. * @param rollCor optional roll (z-axis) correction in radians
  92302. * @param space the choosen space of the target
  92303. * @returns the TransformNode.
  92304. */
  92305. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92306. /**
  92307. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92308. * This Vector3 is expressed in the World space.
  92309. * @param localAxis axis to rotate
  92310. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92311. */
  92312. getDirection(localAxis: Vector3): Vector3;
  92313. /**
  92314. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92315. * localAxis is expressed in the mesh local space.
  92316. * result is computed in the Wordl space from the mesh World matrix.
  92317. * @param localAxis axis to rotate
  92318. * @param result the resulting transformnode
  92319. * @returns this TransformNode.
  92320. */
  92321. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92322. /**
  92323. * Sets this transform node rotation to the given local axis.
  92324. * @param localAxis the axis in local space
  92325. * @param yawCor optional yaw (y-axis) correction in radians
  92326. * @param pitchCor optional pitch (x-axis) correction in radians
  92327. * @param rollCor optional roll (z-axis) correction in radians
  92328. * @returns this TransformNode
  92329. */
  92330. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92331. /**
  92332. * Sets a new pivot point to the current node
  92333. * @param point defines the new pivot point to use
  92334. * @param space defines if the point is in world or local space (local by default)
  92335. * @returns the current TransformNode
  92336. */
  92337. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92338. /**
  92339. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92340. * @returns the pivot point
  92341. */
  92342. getPivotPoint(): Vector3;
  92343. /**
  92344. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92345. * @param result the vector3 to store the result
  92346. * @returns this TransformNode.
  92347. */
  92348. getPivotPointToRef(result: Vector3): TransformNode;
  92349. /**
  92350. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92351. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92352. */
  92353. getAbsolutePivotPoint(): Vector3;
  92354. /**
  92355. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92356. * @param result vector3 to store the result
  92357. * @returns this TransformNode.
  92358. */
  92359. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92360. /**
  92361. * Defines the passed node as the parent of the current node.
  92362. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92363. * @see https://doc.babylonjs.com/how_to/parenting
  92364. * @param node the node ot set as the parent
  92365. * @returns this TransformNode.
  92366. */
  92367. setParent(node: Nullable<Node>): TransformNode;
  92368. private _nonUniformScaling;
  92369. /**
  92370. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92371. */
  92372. get nonUniformScaling(): boolean;
  92373. /** @hidden */
  92374. _updateNonUniformScalingState(value: boolean): boolean;
  92375. /**
  92376. * Attach the current TransformNode to another TransformNode associated with a bone
  92377. * @param bone Bone affecting the TransformNode
  92378. * @param affectedTransformNode TransformNode associated with the bone
  92379. * @returns this object
  92380. */
  92381. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92382. /**
  92383. * Detach the transform node if its associated with a bone
  92384. * @returns this object
  92385. */
  92386. detachFromBone(): TransformNode;
  92387. private static _rotationAxisCache;
  92388. /**
  92389. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92390. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92391. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92392. * The passed axis is also normalized.
  92393. * @param axis the axis to rotate around
  92394. * @param amount the amount to rotate in radians
  92395. * @param space Space to rotate in (Default: local)
  92396. * @returns the TransformNode.
  92397. */
  92398. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92399. /**
  92400. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92401. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92402. * The passed axis is also normalized. .
  92403. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92404. * @param point the point to rotate around
  92405. * @param axis the axis to rotate around
  92406. * @param amount the amount to rotate in radians
  92407. * @returns the TransformNode
  92408. */
  92409. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92410. /**
  92411. * Translates the mesh along the axis vector for the passed distance in the given space.
  92412. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92413. * @param axis the axis to translate in
  92414. * @param distance the distance to translate
  92415. * @param space Space to rotate in (Default: local)
  92416. * @returns the TransformNode.
  92417. */
  92418. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92419. /**
  92420. * Adds a rotation step to the mesh current rotation.
  92421. * x, y, z are Euler angles expressed in radians.
  92422. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92423. * This means this rotation is made in the mesh local space only.
  92424. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92425. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92426. * ```javascript
  92427. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92428. * ```
  92429. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92430. * 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.
  92431. * @param x Rotation to add
  92432. * @param y Rotation to add
  92433. * @param z Rotation to add
  92434. * @returns the TransformNode.
  92435. */
  92436. addRotation(x: number, y: number, z: number): TransformNode;
  92437. /**
  92438. * @hidden
  92439. */
  92440. protected _getEffectiveParent(): Nullable<Node>;
  92441. /**
  92442. * Computes the world matrix of the node
  92443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92444. * @returns the world matrix
  92445. */
  92446. computeWorldMatrix(force?: boolean): Matrix;
  92447. /**
  92448. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92449. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92450. */
  92451. resetLocalMatrix(independentOfChildren?: boolean): void;
  92452. protected _afterComputeWorldMatrix(): void;
  92453. /**
  92454. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92455. * @param func callback function to add
  92456. *
  92457. * @returns the TransformNode.
  92458. */
  92459. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92460. /**
  92461. * Removes a registered callback function.
  92462. * @param func callback function to remove
  92463. * @returns the TransformNode.
  92464. */
  92465. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92466. /**
  92467. * Gets the position of the current mesh in camera space
  92468. * @param camera defines the camera to use
  92469. * @returns a position
  92470. */
  92471. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92472. /**
  92473. * Returns the distance from the mesh to the active camera
  92474. * @param camera defines the camera to use
  92475. * @returns the distance
  92476. */
  92477. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92478. /**
  92479. * Clone the current transform node
  92480. * @param name Name of the new clone
  92481. * @param newParent New parent for the clone
  92482. * @param doNotCloneChildren Do not clone children hierarchy
  92483. * @returns the new transform node
  92484. */
  92485. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92486. /**
  92487. * Serializes the objects information.
  92488. * @param currentSerializationObject defines the object to serialize in
  92489. * @returns the serialized object
  92490. */
  92491. serialize(currentSerializationObject?: any): any;
  92492. /**
  92493. * Returns a new TransformNode object parsed from the source provided.
  92494. * @param parsedTransformNode is the source.
  92495. * @param scene the scne the object belongs to
  92496. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92497. * @returns a new TransformNode object parsed from the source provided.
  92498. */
  92499. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92500. /**
  92501. * Get all child-transformNodes of this node
  92502. * @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
  92503. * @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
  92504. * @returns an array of TransformNode
  92505. */
  92506. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92507. /**
  92508. * Releases resources associated with this transform node.
  92509. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92510. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92511. */
  92512. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92513. /**
  92514. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92515. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92516. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92517. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92518. * @returns the current mesh
  92519. */
  92520. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92521. private _syncAbsoluteScalingAndRotation;
  92522. }
  92523. }
  92524. declare module BABYLON {
  92525. /**
  92526. * Class used to override all child animations of a given target
  92527. */
  92528. export class AnimationPropertiesOverride {
  92529. /**
  92530. * Gets or sets a value indicating if animation blending must be used
  92531. */
  92532. enableBlending: boolean;
  92533. /**
  92534. * Gets or sets the blending speed to use when enableBlending is true
  92535. */
  92536. blendingSpeed: number;
  92537. /**
  92538. * Gets or sets the default loop mode to use
  92539. */
  92540. loopMode: number;
  92541. }
  92542. }
  92543. declare module BABYLON {
  92544. /**
  92545. * Class used to store bone information
  92546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92547. */
  92548. export class Bone extends Node {
  92549. /**
  92550. * defines the bone name
  92551. */
  92552. name: string;
  92553. private static _tmpVecs;
  92554. private static _tmpQuat;
  92555. private static _tmpMats;
  92556. /**
  92557. * Gets the list of child bones
  92558. */
  92559. children: Bone[];
  92560. /** Gets the animations associated with this bone */
  92561. animations: Animation[];
  92562. /**
  92563. * Gets or sets bone length
  92564. */
  92565. length: number;
  92566. /**
  92567. * @hidden Internal only
  92568. * Set this value to map this bone to a different index in the transform matrices
  92569. * Set this value to -1 to exclude the bone from the transform matrices
  92570. */
  92571. _index: Nullable<number>;
  92572. private _skeleton;
  92573. private _localMatrix;
  92574. private _restPose;
  92575. private _baseMatrix;
  92576. private _absoluteTransform;
  92577. private _invertedAbsoluteTransform;
  92578. private _parent;
  92579. private _scalingDeterminant;
  92580. private _worldTransform;
  92581. private _localScaling;
  92582. private _localRotation;
  92583. private _localPosition;
  92584. private _needToDecompose;
  92585. private _needToCompose;
  92586. /** @hidden */
  92587. _linkedTransformNode: Nullable<TransformNode>;
  92588. /** @hidden */
  92589. _waitingTransformNodeId: Nullable<string>;
  92590. /** @hidden */
  92591. get _matrix(): Matrix;
  92592. /** @hidden */
  92593. set _matrix(value: Matrix);
  92594. /**
  92595. * Create a new bone
  92596. * @param name defines the bone name
  92597. * @param skeleton defines the parent skeleton
  92598. * @param parentBone defines the parent (can be null if the bone is the root)
  92599. * @param localMatrix defines the local matrix
  92600. * @param restPose defines the rest pose matrix
  92601. * @param baseMatrix defines the base matrix
  92602. * @param index defines index of the bone in the hiearchy
  92603. */
  92604. constructor(
  92605. /**
  92606. * defines the bone name
  92607. */
  92608. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92609. /**
  92610. * Gets the current object class name.
  92611. * @return the class name
  92612. */
  92613. getClassName(): string;
  92614. /**
  92615. * Gets the parent skeleton
  92616. * @returns a skeleton
  92617. */
  92618. getSkeleton(): Skeleton;
  92619. /**
  92620. * Gets parent bone
  92621. * @returns a bone or null if the bone is the root of the bone hierarchy
  92622. */
  92623. getParent(): Nullable<Bone>;
  92624. /**
  92625. * Returns an array containing the root bones
  92626. * @returns an array containing the root bones
  92627. */
  92628. getChildren(): Array<Bone>;
  92629. /**
  92630. * Gets the node index in matrix array generated for rendering
  92631. * @returns the node index
  92632. */
  92633. getIndex(): number;
  92634. /**
  92635. * Sets the parent bone
  92636. * @param parent defines the parent (can be null if the bone is the root)
  92637. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92638. */
  92639. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92640. /**
  92641. * Gets the local matrix
  92642. * @returns a matrix
  92643. */
  92644. getLocalMatrix(): Matrix;
  92645. /**
  92646. * Gets the base matrix (initial matrix which remains unchanged)
  92647. * @returns a matrix
  92648. */
  92649. getBaseMatrix(): Matrix;
  92650. /**
  92651. * Gets the rest pose matrix
  92652. * @returns a matrix
  92653. */
  92654. getRestPose(): Matrix;
  92655. /**
  92656. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92657. */
  92658. getWorldMatrix(): Matrix;
  92659. /**
  92660. * Sets the local matrix to rest pose matrix
  92661. */
  92662. returnToRest(): void;
  92663. /**
  92664. * Gets the inverse of the absolute transform matrix.
  92665. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92666. * @returns a matrix
  92667. */
  92668. getInvertedAbsoluteTransform(): Matrix;
  92669. /**
  92670. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92671. * @returns a matrix
  92672. */
  92673. getAbsoluteTransform(): Matrix;
  92674. /**
  92675. * Links with the given transform node.
  92676. * The local matrix of this bone is copied from the transform node every frame.
  92677. * @param transformNode defines the transform node to link to
  92678. */
  92679. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92680. /**
  92681. * Gets the node used to drive the bone's transformation
  92682. * @returns a transform node or null
  92683. */
  92684. getTransformNode(): Nullable<TransformNode>;
  92685. /** Gets or sets current position (in local space) */
  92686. get position(): Vector3;
  92687. set position(newPosition: Vector3);
  92688. /** Gets or sets current rotation (in local space) */
  92689. get rotation(): Vector3;
  92690. set rotation(newRotation: Vector3);
  92691. /** Gets or sets current rotation quaternion (in local space) */
  92692. get rotationQuaternion(): Quaternion;
  92693. set rotationQuaternion(newRotation: Quaternion);
  92694. /** Gets or sets current scaling (in local space) */
  92695. get scaling(): Vector3;
  92696. set scaling(newScaling: Vector3);
  92697. /**
  92698. * Gets the animation properties override
  92699. */
  92700. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92701. private _decompose;
  92702. private _compose;
  92703. /**
  92704. * Update the base and local matrices
  92705. * @param matrix defines the new base or local matrix
  92706. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92707. * @param updateLocalMatrix defines if the local matrix should be updated
  92708. */
  92709. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92710. /** @hidden */
  92711. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92712. /**
  92713. * Flag the bone as dirty (Forcing it to update everything)
  92714. */
  92715. markAsDirty(): void;
  92716. /** @hidden */
  92717. _markAsDirtyAndCompose(): void;
  92718. private _markAsDirtyAndDecompose;
  92719. /**
  92720. * Translate the bone in local or world space
  92721. * @param vec The amount to translate the bone
  92722. * @param space The space that the translation is in
  92723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92724. */
  92725. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92726. /**
  92727. * Set the postion of the bone in local or world space
  92728. * @param position The position to set the bone
  92729. * @param space The space that the position is in
  92730. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92731. */
  92732. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92733. /**
  92734. * Set the absolute position of the bone (world space)
  92735. * @param position The position to set the bone
  92736. * @param mesh The mesh that this bone is attached to
  92737. */
  92738. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92739. /**
  92740. * Scale the bone on the x, y and z axes (in local space)
  92741. * @param x The amount to scale the bone on the x axis
  92742. * @param y The amount to scale the bone on the y axis
  92743. * @param z The amount to scale the bone on the z axis
  92744. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92745. */
  92746. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92747. /**
  92748. * Set the bone scaling in local space
  92749. * @param scale defines the scaling vector
  92750. */
  92751. setScale(scale: Vector3): void;
  92752. /**
  92753. * Gets the current scaling in local space
  92754. * @returns the current scaling vector
  92755. */
  92756. getScale(): Vector3;
  92757. /**
  92758. * Gets the current scaling in local space and stores it in a target vector
  92759. * @param result defines the target vector
  92760. */
  92761. getScaleToRef(result: Vector3): void;
  92762. /**
  92763. * Set the yaw, pitch, and roll of the bone in local or world space
  92764. * @param yaw The rotation of the bone on the y axis
  92765. * @param pitch The rotation of the bone on the x axis
  92766. * @param roll The rotation of the bone on the z axis
  92767. * @param space The space that the axes of rotation are in
  92768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92769. */
  92770. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92771. /**
  92772. * Add a rotation to the bone on an axis in local or world space
  92773. * @param axis The axis to rotate the bone on
  92774. * @param amount The amount to rotate the bone
  92775. * @param space The space that the axis is in
  92776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92777. */
  92778. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92779. /**
  92780. * Set the rotation of the bone to a particular axis angle in local or world space
  92781. * @param axis The axis to rotate the bone on
  92782. * @param angle The angle that the bone should be rotated to
  92783. * @param space The space that the axis is in
  92784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92785. */
  92786. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92787. /**
  92788. * Set the euler rotation of the bone in local of world space
  92789. * @param rotation The euler rotation that the bone should be set to
  92790. * @param space The space that the rotation is in
  92791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92792. */
  92793. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92794. /**
  92795. * Set the quaternion rotation of the bone in local of world space
  92796. * @param quat The quaternion rotation that the bone should be set to
  92797. * @param space The space that the rotation is in
  92798. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92799. */
  92800. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92801. /**
  92802. * Set the rotation matrix of the bone in local of world space
  92803. * @param rotMat The rotation matrix that the bone should be set to
  92804. * @param space The space that the rotation is in
  92805. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92806. */
  92807. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92808. private _rotateWithMatrix;
  92809. private _getNegativeRotationToRef;
  92810. /**
  92811. * Get the position of the bone in local or world space
  92812. * @param space The space that the returned position is in
  92813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92814. * @returns The position of the bone
  92815. */
  92816. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92817. /**
  92818. * Copy the position of the bone to a vector3 in local or world space
  92819. * @param space The space that the returned position is in
  92820. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92821. * @param result The vector3 to copy the position to
  92822. */
  92823. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92824. /**
  92825. * Get the absolute position of the bone (world space)
  92826. * @param mesh The mesh that this bone is attached to
  92827. * @returns The absolute position of the bone
  92828. */
  92829. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92830. /**
  92831. * Copy the absolute position of the bone (world space) to the result param
  92832. * @param mesh The mesh that this bone is attached to
  92833. * @param result The vector3 to copy the absolute position to
  92834. */
  92835. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92836. /**
  92837. * Compute the absolute transforms of this bone and its children
  92838. */
  92839. computeAbsoluteTransforms(): void;
  92840. /**
  92841. * Get the world direction from an axis that is in the local space of the bone
  92842. * @param localAxis The local direction that is used to compute the world direction
  92843. * @param mesh The mesh that this bone is attached to
  92844. * @returns The world direction
  92845. */
  92846. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92847. /**
  92848. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92849. * @param localAxis The local direction that is used to compute the world direction
  92850. * @param mesh The mesh that this bone is attached to
  92851. * @param result The vector3 that the world direction will be copied to
  92852. */
  92853. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92854. /**
  92855. * Get the euler rotation of the bone in local or world space
  92856. * @param space The space that the rotation should be in
  92857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92858. * @returns The euler rotation
  92859. */
  92860. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92861. /**
  92862. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92863. * @param space The space that the rotation should be in
  92864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92865. * @param result The vector3 that the rotation should be copied to
  92866. */
  92867. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92868. /**
  92869. * Get the quaternion rotation of the bone in either local or world space
  92870. * @param space The space that the rotation should be in
  92871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92872. * @returns The quaternion rotation
  92873. */
  92874. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92875. /**
  92876. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92877. * @param space The space that the rotation should be in
  92878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92879. * @param result The quaternion that the rotation should be copied to
  92880. */
  92881. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92882. /**
  92883. * Get the rotation matrix of the bone in local or world space
  92884. * @param space The space that the rotation should be in
  92885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92886. * @returns The rotation matrix
  92887. */
  92888. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92889. /**
  92890. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92891. * @param space The space that the rotation should be in
  92892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92893. * @param result The quaternion that the rotation should be copied to
  92894. */
  92895. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92896. /**
  92897. * Get the world position of a point that is in the local space of the bone
  92898. * @param position The local position
  92899. * @param mesh The mesh that this bone is attached to
  92900. * @returns The world position
  92901. */
  92902. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92903. /**
  92904. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92905. * @param position The local position
  92906. * @param mesh The mesh that this bone is attached to
  92907. * @param result The vector3 that the world position should be copied to
  92908. */
  92909. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92910. /**
  92911. * Get the local position of a point that is in world space
  92912. * @param position The world position
  92913. * @param mesh The mesh that this bone is attached to
  92914. * @returns The local position
  92915. */
  92916. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92917. /**
  92918. * Get the local position of a point that is in world space and copy it to the result param
  92919. * @param position The world position
  92920. * @param mesh The mesh that this bone is attached to
  92921. * @param result The vector3 that the local position should be copied to
  92922. */
  92923. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92924. }
  92925. }
  92926. declare module BABYLON {
  92927. /**
  92928. * Defines a runtime animation
  92929. */
  92930. export class RuntimeAnimation {
  92931. private _events;
  92932. /**
  92933. * The current frame of the runtime animation
  92934. */
  92935. private _currentFrame;
  92936. /**
  92937. * The animation used by the runtime animation
  92938. */
  92939. private _animation;
  92940. /**
  92941. * The target of the runtime animation
  92942. */
  92943. private _target;
  92944. /**
  92945. * The initiating animatable
  92946. */
  92947. private _host;
  92948. /**
  92949. * The original value of the runtime animation
  92950. */
  92951. private _originalValue;
  92952. /**
  92953. * The original blend value of the runtime animation
  92954. */
  92955. private _originalBlendValue;
  92956. /**
  92957. * The offsets cache of the runtime animation
  92958. */
  92959. private _offsetsCache;
  92960. /**
  92961. * The high limits cache of the runtime animation
  92962. */
  92963. private _highLimitsCache;
  92964. /**
  92965. * Specifies if the runtime animation has been stopped
  92966. */
  92967. private _stopped;
  92968. /**
  92969. * The blending factor of the runtime animation
  92970. */
  92971. private _blendingFactor;
  92972. /**
  92973. * The BabylonJS scene
  92974. */
  92975. private _scene;
  92976. /**
  92977. * The current value of the runtime animation
  92978. */
  92979. private _currentValue;
  92980. /** @hidden */
  92981. _animationState: _IAnimationState;
  92982. /**
  92983. * The active target of the runtime animation
  92984. */
  92985. private _activeTargets;
  92986. private _currentActiveTarget;
  92987. private _directTarget;
  92988. /**
  92989. * The target path of the runtime animation
  92990. */
  92991. private _targetPath;
  92992. /**
  92993. * The weight of the runtime animation
  92994. */
  92995. private _weight;
  92996. /**
  92997. * The ratio offset of the runtime animation
  92998. */
  92999. private _ratioOffset;
  93000. /**
  93001. * The previous delay of the runtime animation
  93002. */
  93003. private _previousDelay;
  93004. /**
  93005. * The previous ratio of the runtime animation
  93006. */
  93007. private _previousRatio;
  93008. private _enableBlending;
  93009. private _keys;
  93010. private _minFrame;
  93011. private _maxFrame;
  93012. private _minValue;
  93013. private _maxValue;
  93014. private _targetIsArray;
  93015. /**
  93016. * Gets the current frame of the runtime animation
  93017. */
  93018. get currentFrame(): number;
  93019. /**
  93020. * Gets the weight of the runtime animation
  93021. */
  93022. get weight(): number;
  93023. /**
  93024. * Gets the current value of the runtime animation
  93025. */
  93026. get currentValue(): any;
  93027. /**
  93028. * Gets the target path of the runtime animation
  93029. */
  93030. get targetPath(): string;
  93031. /**
  93032. * Gets the actual target of the runtime animation
  93033. */
  93034. get target(): any;
  93035. /**
  93036. * Gets the additive state of the runtime animation
  93037. */
  93038. get isAdditive(): boolean;
  93039. /** @hidden */
  93040. _onLoop: () => void;
  93041. /**
  93042. * Create a new RuntimeAnimation object
  93043. * @param target defines the target of the animation
  93044. * @param animation defines the source animation object
  93045. * @param scene defines the hosting scene
  93046. * @param host defines the initiating Animatable
  93047. */
  93048. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93049. private _preparePath;
  93050. /**
  93051. * Gets the animation from the runtime animation
  93052. */
  93053. get animation(): Animation;
  93054. /**
  93055. * Resets the runtime animation to the beginning
  93056. * @param restoreOriginal defines whether to restore the target property to the original value
  93057. */
  93058. reset(restoreOriginal?: boolean): void;
  93059. /**
  93060. * Specifies if the runtime animation is stopped
  93061. * @returns Boolean specifying if the runtime animation is stopped
  93062. */
  93063. isStopped(): boolean;
  93064. /**
  93065. * Disposes of the runtime animation
  93066. */
  93067. dispose(): void;
  93068. /**
  93069. * Apply the interpolated value to the target
  93070. * @param currentValue defines the value computed by the animation
  93071. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93072. */
  93073. setValue(currentValue: any, weight: number): void;
  93074. private _getOriginalValues;
  93075. private _setValue;
  93076. /**
  93077. * Gets the loop pmode of the runtime animation
  93078. * @returns Loop Mode
  93079. */
  93080. private _getCorrectLoopMode;
  93081. /**
  93082. * Move the current animation to a given frame
  93083. * @param frame defines the frame to move to
  93084. */
  93085. goToFrame(frame: number): void;
  93086. /**
  93087. * @hidden Internal use only
  93088. */
  93089. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93090. /**
  93091. * Execute the current animation
  93092. * @param delay defines the delay to add to the current frame
  93093. * @param from defines the lower bound of the animation range
  93094. * @param to defines the upper bound of the animation range
  93095. * @param loop defines if the current animation must loop
  93096. * @param speedRatio defines the current speed ratio
  93097. * @param weight defines the weight of the animation (default is -1 so no weight)
  93098. * @param onLoop optional callback called when animation loops
  93099. * @returns a boolean indicating if the animation is running
  93100. */
  93101. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93102. }
  93103. }
  93104. declare module BABYLON {
  93105. /**
  93106. * Class used to store an actual running animation
  93107. */
  93108. export class Animatable {
  93109. /** defines the target object */
  93110. target: any;
  93111. /** defines the starting frame number (default is 0) */
  93112. fromFrame: number;
  93113. /** defines the ending frame number (default is 100) */
  93114. toFrame: number;
  93115. /** defines if the animation must loop (default is false) */
  93116. loopAnimation: boolean;
  93117. /** defines a callback to call when animation ends if it is not looping */
  93118. onAnimationEnd?: (() => void) | null | undefined;
  93119. /** defines a callback to call when animation loops */
  93120. onAnimationLoop?: (() => void) | null | undefined;
  93121. /** defines whether the animation should be evaluated additively */
  93122. isAdditive: boolean;
  93123. private _localDelayOffset;
  93124. private _pausedDelay;
  93125. private _runtimeAnimations;
  93126. private _paused;
  93127. private _scene;
  93128. private _speedRatio;
  93129. private _weight;
  93130. private _syncRoot;
  93131. /**
  93132. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93133. * This will only apply for non looping animation (default is true)
  93134. */
  93135. disposeOnEnd: boolean;
  93136. /**
  93137. * Gets a boolean indicating if the animation has started
  93138. */
  93139. animationStarted: boolean;
  93140. /**
  93141. * Observer raised when the animation ends
  93142. */
  93143. onAnimationEndObservable: Observable<Animatable>;
  93144. /**
  93145. * Observer raised when the animation loops
  93146. */
  93147. onAnimationLoopObservable: Observable<Animatable>;
  93148. /**
  93149. * Gets the root Animatable used to synchronize and normalize animations
  93150. */
  93151. get syncRoot(): Nullable<Animatable>;
  93152. /**
  93153. * Gets the current frame of the first RuntimeAnimation
  93154. * Used to synchronize Animatables
  93155. */
  93156. get masterFrame(): number;
  93157. /**
  93158. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93159. */
  93160. get weight(): number;
  93161. set weight(value: number);
  93162. /**
  93163. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93164. */
  93165. get speedRatio(): number;
  93166. set speedRatio(value: number);
  93167. /**
  93168. * Creates a new Animatable
  93169. * @param scene defines the hosting scene
  93170. * @param target defines the target object
  93171. * @param fromFrame defines the starting frame number (default is 0)
  93172. * @param toFrame defines the ending frame number (default is 100)
  93173. * @param loopAnimation defines if the animation must loop (default is false)
  93174. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93175. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93176. * @param animations defines a group of animation to add to the new Animatable
  93177. * @param onAnimationLoop defines a callback to call when animation loops
  93178. * @param isAdditive defines whether the animation should be evaluated additively
  93179. */
  93180. constructor(scene: Scene,
  93181. /** defines the target object */
  93182. target: any,
  93183. /** defines the starting frame number (default is 0) */
  93184. fromFrame?: number,
  93185. /** defines the ending frame number (default is 100) */
  93186. toFrame?: number,
  93187. /** defines if the animation must loop (default is false) */
  93188. loopAnimation?: boolean, speedRatio?: number,
  93189. /** defines a callback to call when animation ends if it is not looping */
  93190. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93191. /** defines a callback to call when animation loops */
  93192. onAnimationLoop?: (() => void) | null | undefined,
  93193. /** defines whether the animation should be evaluated additively */
  93194. isAdditive?: boolean);
  93195. /**
  93196. * Synchronize and normalize current Animatable with a source Animatable
  93197. * This is useful when using animation weights and when animations are not of the same length
  93198. * @param root defines the root Animatable to synchronize with
  93199. * @returns the current Animatable
  93200. */
  93201. syncWith(root: Animatable): Animatable;
  93202. /**
  93203. * Gets the list of runtime animations
  93204. * @returns an array of RuntimeAnimation
  93205. */
  93206. getAnimations(): RuntimeAnimation[];
  93207. /**
  93208. * Adds more animations to the current animatable
  93209. * @param target defines the target of the animations
  93210. * @param animations defines the new animations to add
  93211. */
  93212. appendAnimations(target: any, animations: Animation[]): void;
  93213. /**
  93214. * Gets the source animation for a specific property
  93215. * @param property defines the propertyu to look for
  93216. * @returns null or the source animation for the given property
  93217. */
  93218. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93219. /**
  93220. * Gets the runtime animation for a specific property
  93221. * @param property defines the propertyu to look for
  93222. * @returns null or the runtime animation for the given property
  93223. */
  93224. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93225. /**
  93226. * Resets the animatable to its original state
  93227. */
  93228. reset(): void;
  93229. /**
  93230. * Allows the animatable to blend with current running animations
  93231. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93232. * @param blendingSpeed defines the blending speed to use
  93233. */
  93234. enableBlending(blendingSpeed: number): void;
  93235. /**
  93236. * Disable animation blending
  93237. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93238. */
  93239. disableBlending(): void;
  93240. /**
  93241. * Jump directly to a given frame
  93242. * @param frame defines the frame to jump to
  93243. */
  93244. goToFrame(frame: number): void;
  93245. /**
  93246. * Pause the animation
  93247. */
  93248. pause(): void;
  93249. /**
  93250. * Restart the animation
  93251. */
  93252. restart(): void;
  93253. private _raiseOnAnimationEnd;
  93254. /**
  93255. * Stop and delete the current animation
  93256. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93257. * @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)
  93258. */
  93259. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93260. /**
  93261. * Wait asynchronously for the animation to end
  93262. * @returns a promise which will be fullfilled when the animation ends
  93263. */
  93264. waitAsync(): Promise<Animatable>;
  93265. /** @hidden */
  93266. _animate(delay: number): boolean;
  93267. }
  93268. interface Scene {
  93269. /** @hidden */
  93270. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93271. /** @hidden */
  93272. _processLateAnimationBindingsForMatrices(holder: {
  93273. totalWeight: number;
  93274. totalAdditiveWeight: number;
  93275. animations: RuntimeAnimation[];
  93276. additiveAnimations: RuntimeAnimation[];
  93277. originalValue: Matrix;
  93278. }): any;
  93279. /** @hidden */
  93280. _processLateAnimationBindingsForQuaternions(holder: {
  93281. totalWeight: number;
  93282. totalAdditiveWeight: number;
  93283. animations: RuntimeAnimation[];
  93284. additiveAnimations: RuntimeAnimation[];
  93285. originalValue: Quaternion;
  93286. }, refQuaternion: Quaternion): Quaternion;
  93287. /** @hidden */
  93288. _processLateAnimationBindings(): void;
  93289. /**
  93290. * Will start the animation sequence of a given target
  93291. * @param target defines the target
  93292. * @param from defines from which frame should animation start
  93293. * @param to defines until which frame should animation run.
  93294. * @param weight defines the weight to apply to the animation (1.0 by default)
  93295. * @param loop defines if the animation loops
  93296. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93297. * @param onAnimationEnd defines the function to be executed when the animation ends
  93298. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93299. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93300. * @param onAnimationLoop defines the callback to call when an animation loops
  93301. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93302. * @returns the animatable object created for this animation
  93303. */
  93304. 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;
  93305. /**
  93306. * Will start the animation sequence of a given target
  93307. * @param target defines the target
  93308. * @param from defines from which frame should animation start
  93309. * @param to defines until which frame should animation run.
  93310. * @param loop defines if the animation loops
  93311. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93312. * @param onAnimationEnd defines the function to be executed when the animation ends
  93313. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93314. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93315. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93316. * @param onAnimationLoop defines the callback to call when an animation loops
  93317. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93318. * @returns the animatable object created for this animation
  93319. */
  93320. 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;
  93321. /**
  93322. * Will start the animation sequence of a given target and its hierarchy
  93323. * @param target defines the target
  93324. * @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.
  93325. * @param from defines from which frame should animation start
  93326. * @param to defines until which frame should animation run.
  93327. * @param loop defines if the animation loops
  93328. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93329. * @param onAnimationEnd defines the function to be executed when the animation ends
  93330. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93331. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93332. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93333. * @param onAnimationLoop defines the callback to call when an animation loops
  93334. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93335. * @returns the list of created animatables
  93336. */
  93337. 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[];
  93338. /**
  93339. * Begin a new animation on a given node
  93340. * @param target defines the target where the animation will take place
  93341. * @param animations defines the list of animations to start
  93342. * @param from defines the initial value
  93343. * @param to defines the final value
  93344. * @param loop defines if you want animation to loop (off by default)
  93345. * @param speedRatio defines the speed ratio to apply to all animations
  93346. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93347. * @param onAnimationLoop defines the callback to call when an animation loops
  93348. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93349. * @returns the list of created animatables
  93350. */
  93351. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93352. /**
  93353. * Begin a new animation on a given node and its hierarchy
  93354. * @param target defines the root node where the animation will take place
  93355. * @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.
  93356. * @param animations defines the list of animations to start
  93357. * @param from defines the initial value
  93358. * @param to defines the final value
  93359. * @param loop defines if you want animation to loop (off by default)
  93360. * @param speedRatio defines the speed ratio to apply to all animations
  93361. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93362. * @param onAnimationLoop defines the callback to call when an animation loops
  93363. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93364. * @returns the list of animatables created for all nodes
  93365. */
  93366. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93367. /**
  93368. * Gets the animatable associated with a specific target
  93369. * @param target defines the target of the animatable
  93370. * @returns the required animatable if found
  93371. */
  93372. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93373. /**
  93374. * Gets all animatables associated with a given target
  93375. * @param target defines the target to look animatables for
  93376. * @returns an array of Animatables
  93377. */
  93378. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93379. /**
  93380. * Stops and removes all animations that have been applied to the scene
  93381. */
  93382. stopAllAnimations(): void;
  93383. /**
  93384. * Gets the current delta time used by animation engine
  93385. */
  93386. deltaTime: number;
  93387. }
  93388. interface Bone {
  93389. /**
  93390. * Copy an animation range from another bone
  93391. * @param source defines the source bone
  93392. * @param rangeName defines the range name to copy
  93393. * @param frameOffset defines the frame offset
  93394. * @param rescaleAsRequired defines if rescaling must be applied if required
  93395. * @param skelDimensionsRatio defines the scaling ratio
  93396. * @returns true if operation was successful
  93397. */
  93398. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93399. }
  93400. }
  93401. declare module BABYLON {
  93402. /**
  93403. * Class used to handle skinning animations
  93404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93405. */
  93406. export class Skeleton implements IAnimatable {
  93407. /** defines the skeleton name */
  93408. name: string;
  93409. /** defines the skeleton Id */
  93410. id: string;
  93411. /**
  93412. * Defines the list of child bones
  93413. */
  93414. bones: Bone[];
  93415. /**
  93416. * Defines an estimate of the dimension of the skeleton at rest
  93417. */
  93418. dimensionsAtRest: Vector3;
  93419. /**
  93420. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93421. */
  93422. needInitialSkinMatrix: boolean;
  93423. /**
  93424. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93425. */
  93426. overrideMesh: Nullable<AbstractMesh>;
  93427. /**
  93428. * Gets the list of animations attached to this skeleton
  93429. */
  93430. animations: Array<Animation>;
  93431. private _scene;
  93432. private _isDirty;
  93433. private _transformMatrices;
  93434. private _transformMatrixTexture;
  93435. private _meshesWithPoseMatrix;
  93436. private _animatables;
  93437. private _identity;
  93438. private _synchronizedWithMesh;
  93439. private _ranges;
  93440. private _lastAbsoluteTransformsUpdateId;
  93441. private _canUseTextureForBones;
  93442. private _uniqueId;
  93443. /** @hidden */
  93444. _numBonesWithLinkedTransformNode: number;
  93445. /** @hidden */
  93446. _hasWaitingData: Nullable<boolean>;
  93447. /**
  93448. * Specifies if the skeleton should be serialized
  93449. */
  93450. doNotSerialize: boolean;
  93451. private _useTextureToStoreBoneMatrices;
  93452. /**
  93453. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93454. * Please note that this option is not available if the hardware does not support it
  93455. */
  93456. get useTextureToStoreBoneMatrices(): boolean;
  93457. set useTextureToStoreBoneMatrices(value: boolean);
  93458. private _animationPropertiesOverride;
  93459. /**
  93460. * Gets or sets the animation properties override
  93461. */
  93462. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93463. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93464. /**
  93465. * List of inspectable custom properties (used by the Inspector)
  93466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93467. */
  93468. inspectableCustomProperties: IInspectable[];
  93469. /**
  93470. * An observable triggered before computing the skeleton's matrices
  93471. */
  93472. onBeforeComputeObservable: Observable<Skeleton>;
  93473. /**
  93474. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93475. */
  93476. get isUsingTextureForMatrices(): boolean;
  93477. /**
  93478. * Gets the unique ID of this skeleton
  93479. */
  93480. get uniqueId(): number;
  93481. /**
  93482. * Creates a new skeleton
  93483. * @param name defines the skeleton name
  93484. * @param id defines the skeleton Id
  93485. * @param scene defines the hosting scene
  93486. */
  93487. constructor(
  93488. /** defines the skeleton name */
  93489. name: string,
  93490. /** defines the skeleton Id */
  93491. id: string, scene: Scene);
  93492. /**
  93493. * Gets the current object class name.
  93494. * @return the class name
  93495. */
  93496. getClassName(): string;
  93497. /**
  93498. * Returns an array containing the root bones
  93499. * @returns an array containing the root bones
  93500. */
  93501. getChildren(): Array<Bone>;
  93502. /**
  93503. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93504. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93505. * @returns a Float32Array containing matrices data
  93506. */
  93507. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93508. /**
  93509. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93510. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93511. * @returns a raw texture containing the data
  93512. */
  93513. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93514. /**
  93515. * Gets the current hosting scene
  93516. * @returns a scene object
  93517. */
  93518. getScene(): Scene;
  93519. /**
  93520. * Gets a string representing the current skeleton data
  93521. * @param fullDetails defines a boolean indicating if we want a verbose version
  93522. * @returns a string representing the current skeleton data
  93523. */
  93524. toString(fullDetails?: boolean): string;
  93525. /**
  93526. * Get bone's index searching by name
  93527. * @param name defines bone's name to search for
  93528. * @return the indice of the bone. Returns -1 if not found
  93529. */
  93530. getBoneIndexByName(name: string): number;
  93531. /**
  93532. * Creater a new animation range
  93533. * @param name defines the name of the range
  93534. * @param from defines the start key
  93535. * @param to defines the end key
  93536. */
  93537. createAnimationRange(name: string, from: number, to: number): void;
  93538. /**
  93539. * Delete a specific animation range
  93540. * @param name defines the name of the range
  93541. * @param deleteFrames defines if frames must be removed as well
  93542. */
  93543. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93544. /**
  93545. * Gets a specific animation range
  93546. * @param name defines the name of the range to look for
  93547. * @returns the requested animation range or null if not found
  93548. */
  93549. getAnimationRange(name: string): Nullable<AnimationRange>;
  93550. /**
  93551. * Gets the list of all animation ranges defined on this skeleton
  93552. * @returns an array
  93553. */
  93554. getAnimationRanges(): Nullable<AnimationRange>[];
  93555. /**
  93556. * Copy animation range from a source skeleton.
  93557. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93558. * @param source defines the source skeleton
  93559. * @param name defines the name of the range to copy
  93560. * @param rescaleAsRequired defines if rescaling must be applied if required
  93561. * @returns true if operation was successful
  93562. */
  93563. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93564. /**
  93565. * Forces the skeleton to go to rest pose
  93566. */
  93567. returnToRest(): void;
  93568. private _getHighestAnimationFrame;
  93569. /**
  93570. * Begin a specific animation range
  93571. * @param name defines the name of the range to start
  93572. * @param loop defines if looping must be turned on (false by default)
  93573. * @param speedRatio defines the speed ratio to apply (1 by default)
  93574. * @param onAnimationEnd defines a callback which will be called when animation will end
  93575. * @returns a new animatable
  93576. */
  93577. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93578. /**
  93579. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93580. * @param skeleton defines the Skeleton containing the animation range to convert
  93581. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93582. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93583. * @returns the original skeleton
  93584. */
  93585. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93586. /** @hidden */
  93587. _markAsDirty(): void;
  93588. /** @hidden */
  93589. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93590. /** @hidden */
  93591. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93592. private _computeTransformMatrices;
  93593. /**
  93594. * Build all resources required to render a skeleton
  93595. */
  93596. prepare(): void;
  93597. /**
  93598. * Gets the list of animatables currently running for this skeleton
  93599. * @returns an array of animatables
  93600. */
  93601. getAnimatables(): IAnimatable[];
  93602. /**
  93603. * Clone the current skeleton
  93604. * @param name defines the name of the new skeleton
  93605. * @param id defines the id of the new skeleton
  93606. * @returns the new skeleton
  93607. */
  93608. clone(name: string, id?: string): Skeleton;
  93609. /**
  93610. * Enable animation blending for this skeleton
  93611. * @param blendingSpeed defines the blending speed to apply
  93612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93613. */
  93614. enableBlending(blendingSpeed?: number): void;
  93615. /**
  93616. * Releases all resources associated with the current skeleton
  93617. */
  93618. dispose(): void;
  93619. /**
  93620. * Serialize the skeleton in a JSON object
  93621. * @returns a JSON object
  93622. */
  93623. serialize(): any;
  93624. /**
  93625. * Creates a new skeleton from serialized data
  93626. * @param parsedSkeleton defines the serialized data
  93627. * @param scene defines the hosting scene
  93628. * @returns a new skeleton
  93629. */
  93630. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93631. /**
  93632. * Compute all node absolute transforms
  93633. * @param forceUpdate defines if computation must be done even if cache is up to date
  93634. */
  93635. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93636. /**
  93637. * Gets the root pose matrix
  93638. * @returns a matrix
  93639. */
  93640. getPoseMatrix(): Nullable<Matrix>;
  93641. /**
  93642. * Sorts bones per internal index
  93643. */
  93644. sortBones(): void;
  93645. private _sortBones;
  93646. }
  93647. }
  93648. declare module BABYLON {
  93649. /**
  93650. * Creates an instance based on a source mesh.
  93651. */
  93652. export class InstancedMesh extends AbstractMesh {
  93653. private _sourceMesh;
  93654. private _currentLOD;
  93655. /** @hidden */
  93656. _indexInSourceMeshInstanceArray: number;
  93657. constructor(name: string, source: Mesh);
  93658. /**
  93659. * Returns the string "InstancedMesh".
  93660. */
  93661. getClassName(): string;
  93662. /** Gets the list of lights affecting that mesh */
  93663. get lightSources(): Light[];
  93664. _resyncLightSources(): void;
  93665. _resyncLightSource(light: Light): void;
  93666. _removeLightSource(light: Light, dispose: boolean): void;
  93667. /**
  93668. * If the source mesh receives shadows
  93669. */
  93670. get receiveShadows(): boolean;
  93671. /**
  93672. * The material of the source mesh
  93673. */
  93674. get material(): Nullable<Material>;
  93675. /**
  93676. * Visibility of the source mesh
  93677. */
  93678. get visibility(): number;
  93679. /**
  93680. * Skeleton of the source mesh
  93681. */
  93682. get skeleton(): Nullable<Skeleton>;
  93683. /**
  93684. * Rendering ground id of the source mesh
  93685. */
  93686. get renderingGroupId(): number;
  93687. set renderingGroupId(value: number);
  93688. /**
  93689. * Returns the total number of vertices (integer).
  93690. */
  93691. getTotalVertices(): number;
  93692. /**
  93693. * Returns a positive integer : the total number of indices in this mesh geometry.
  93694. * @returns the numner of indices or zero if the mesh has no geometry.
  93695. */
  93696. getTotalIndices(): number;
  93697. /**
  93698. * The source mesh of the instance
  93699. */
  93700. get sourceMesh(): Mesh;
  93701. /**
  93702. * Creates a new InstancedMesh object from the mesh model.
  93703. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93704. * @param name defines the name of the new instance
  93705. * @returns a new InstancedMesh
  93706. */
  93707. createInstance(name: string): InstancedMesh;
  93708. /**
  93709. * Is this node ready to be used/rendered
  93710. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93711. * @return {boolean} is it ready
  93712. */
  93713. isReady(completeCheck?: boolean): boolean;
  93714. /**
  93715. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93716. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93717. * @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.
  93718. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93719. */
  93720. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93721. /**
  93722. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93723. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93724. * The `data` are either a numeric array either a Float32Array.
  93725. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93726. * 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).
  93727. * Note that a new underlying VertexBuffer object is created each call.
  93728. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93729. *
  93730. * Possible `kind` values :
  93731. * - VertexBuffer.PositionKind
  93732. * - VertexBuffer.UVKind
  93733. * - VertexBuffer.UV2Kind
  93734. * - VertexBuffer.UV3Kind
  93735. * - VertexBuffer.UV4Kind
  93736. * - VertexBuffer.UV5Kind
  93737. * - VertexBuffer.UV6Kind
  93738. * - VertexBuffer.ColorKind
  93739. * - VertexBuffer.MatricesIndicesKind
  93740. * - VertexBuffer.MatricesIndicesExtraKind
  93741. * - VertexBuffer.MatricesWeightsKind
  93742. * - VertexBuffer.MatricesWeightsExtraKind
  93743. *
  93744. * Returns the Mesh.
  93745. */
  93746. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93747. /**
  93748. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93749. * If the mesh has no geometry, it is simply returned as it is.
  93750. * The `data` are either a numeric array either a Float32Array.
  93751. * No new underlying VertexBuffer object is created.
  93752. * 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.
  93753. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93754. *
  93755. * Possible `kind` values :
  93756. * - VertexBuffer.PositionKind
  93757. * - VertexBuffer.UVKind
  93758. * - VertexBuffer.UV2Kind
  93759. * - VertexBuffer.UV3Kind
  93760. * - VertexBuffer.UV4Kind
  93761. * - VertexBuffer.UV5Kind
  93762. * - VertexBuffer.UV6Kind
  93763. * - VertexBuffer.ColorKind
  93764. * - VertexBuffer.MatricesIndicesKind
  93765. * - VertexBuffer.MatricesIndicesExtraKind
  93766. * - VertexBuffer.MatricesWeightsKind
  93767. * - VertexBuffer.MatricesWeightsExtraKind
  93768. *
  93769. * Returns the Mesh.
  93770. */
  93771. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93772. /**
  93773. * Sets the mesh indices.
  93774. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93775. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93776. * This method creates a new index buffer each call.
  93777. * Returns the Mesh.
  93778. */
  93779. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93780. /**
  93781. * Boolean : True if the mesh owns the requested kind of data.
  93782. */
  93783. isVerticesDataPresent(kind: string): boolean;
  93784. /**
  93785. * Returns an array of indices (IndicesArray).
  93786. */
  93787. getIndices(): Nullable<IndicesArray>;
  93788. get _positions(): Nullable<Vector3[]>;
  93789. /**
  93790. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93791. * This means the mesh underlying bounding box and sphere are recomputed.
  93792. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93793. * @returns the current mesh
  93794. */
  93795. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93796. /** @hidden */
  93797. _preActivate(): InstancedMesh;
  93798. /** @hidden */
  93799. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93800. /** @hidden */
  93801. _postActivate(): void;
  93802. getWorldMatrix(): Matrix;
  93803. get isAnInstance(): boolean;
  93804. /**
  93805. * Returns the current associated LOD AbstractMesh.
  93806. */
  93807. getLOD(camera: Camera): AbstractMesh;
  93808. /** @hidden */
  93809. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93810. /** @hidden */
  93811. _syncSubMeshes(): InstancedMesh;
  93812. /** @hidden */
  93813. _generatePointsArray(): boolean;
  93814. /**
  93815. * Creates a new InstancedMesh from the current mesh.
  93816. * - name (string) : the cloned mesh name
  93817. * - newParent (optional Node) : the optional Node to parent the clone to.
  93818. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93819. *
  93820. * Returns the clone.
  93821. */
  93822. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93823. /**
  93824. * Disposes the InstancedMesh.
  93825. * Returns nothing.
  93826. */
  93827. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93828. }
  93829. interface Mesh {
  93830. /**
  93831. * Register a custom buffer that will be instanced
  93832. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93833. * @param kind defines the buffer kind
  93834. * @param stride defines the stride in floats
  93835. */
  93836. registerInstancedBuffer(kind: string, stride: number): void;
  93837. /**
  93838. * true to use the edge renderer for all instances of this mesh
  93839. */
  93840. edgesShareWithInstances: boolean;
  93841. /** @hidden */
  93842. _userInstancedBuffersStorage: {
  93843. data: {
  93844. [key: string]: Float32Array;
  93845. };
  93846. sizes: {
  93847. [key: string]: number;
  93848. };
  93849. vertexBuffers: {
  93850. [key: string]: Nullable<VertexBuffer>;
  93851. };
  93852. strides: {
  93853. [key: string]: number;
  93854. };
  93855. };
  93856. }
  93857. interface AbstractMesh {
  93858. /**
  93859. * Object used to store instanced buffers defined by user
  93860. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93861. */
  93862. instancedBuffers: {
  93863. [key: string]: any;
  93864. };
  93865. }
  93866. }
  93867. declare module BABYLON {
  93868. /**
  93869. * Defines the options associated with the creation of a shader material.
  93870. */
  93871. export interface IShaderMaterialOptions {
  93872. /**
  93873. * Does the material work in alpha blend mode
  93874. */
  93875. needAlphaBlending: boolean;
  93876. /**
  93877. * Does the material work in alpha test mode
  93878. */
  93879. needAlphaTesting: boolean;
  93880. /**
  93881. * The list of attribute names used in the shader
  93882. */
  93883. attributes: string[];
  93884. /**
  93885. * The list of unifrom names used in the shader
  93886. */
  93887. uniforms: string[];
  93888. /**
  93889. * The list of UBO names used in the shader
  93890. */
  93891. uniformBuffers: string[];
  93892. /**
  93893. * The list of sampler names used in the shader
  93894. */
  93895. samplers: string[];
  93896. /**
  93897. * The list of defines used in the shader
  93898. */
  93899. defines: string[];
  93900. }
  93901. /**
  93902. * 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.
  93903. *
  93904. * This returned material effects how the mesh will look based on the code in the shaders.
  93905. *
  93906. * @see http://doc.babylonjs.com/how_to/shader_material
  93907. */
  93908. export class ShaderMaterial extends Material {
  93909. private _shaderPath;
  93910. private _options;
  93911. private _textures;
  93912. private _textureArrays;
  93913. private _floats;
  93914. private _ints;
  93915. private _floatsArrays;
  93916. private _colors3;
  93917. private _colors3Arrays;
  93918. private _colors4;
  93919. private _colors4Arrays;
  93920. private _vectors2;
  93921. private _vectors3;
  93922. private _vectors4;
  93923. private _matrices;
  93924. private _matrixArrays;
  93925. private _matrices3x3;
  93926. private _matrices2x2;
  93927. private _vectors2Arrays;
  93928. private _vectors3Arrays;
  93929. private _vectors4Arrays;
  93930. private _cachedWorldViewMatrix;
  93931. private _cachedWorldViewProjectionMatrix;
  93932. private _renderId;
  93933. private _multiview;
  93934. private _cachedDefines;
  93935. /** Define the Url to load snippets */
  93936. static SnippetUrl: string;
  93937. /** Snippet ID if the material was created from the snippet server */
  93938. snippetId: string;
  93939. /**
  93940. * Instantiate a new shader material.
  93941. * 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.
  93942. * This returned material effects how the mesh will look based on the code in the shaders.
  93943. * @see http://doc.babylonjs.com/how_to/shader_material
  93944. * @param name Define the name of the material in the scene
  93945. * @param scene Define the scene the material belongs to
  93946. * @param shaderPath Defines the route to the shader code in one of three ways:
  93947. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  93948. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  93949. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  93950. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  93951. * @param options Define the options used to create the shader
  93952. */
  93953. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  93954. /**
  93955. * Gets the shader path used to define the shader code
  93956. * It can be modified to trigger a new compilation
  93957. */
  93958. get shaderPath(): any;
  93959. /**
  93960. * Sets the shader path used to define the shader code
  93961. * It can be modified to trigger a new compilation
  93962. */
  93963. set shaderPath(shaderPath: any);
  93964. /**
  93965. * Gets the options used to compile the shader.
  93966. * They can be modified to trigger a new compilation
  93967. */
  93968. get options(): IShaderMaterialOptions;
  93969. /**
  93970. * Gets the current class name of the material e.g. "ShaderMaterial"
  93971. * Mainly use in serialization.
  93972. * @returns the class name
  93973. */
  93974. getClassName(): string;
  93975. /**
  93976. * Specifies if the material will require alpha blending
  93977. * @returns a boolean specifying if alpha blending is needed
  93978. */
  93979. needAlphaBlending(): boolean;
  93980. /**
  93981. * Specifies if this material should be rendered in alpha test mode
  93982. * @returns a boolean specifying if an alpha test is needed.
  93983. */
  93984. needAlphaTesting(): boolean;
  93985. private _checkUniform;
  93986. /**
  93987. * Set a texture in the shader.
  93988. * @param name Define the name of the uniform samplers as defined in the shader
  93989. * @param texture Define the texture to bind to this sampler
  93990. * @return the material itself allowing "fluent" like uniform updates
  93991. */
  93992. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  93993. /**
  93994. * Set a texture array in the shader.
  93995. * @param name Define the name of the uniform sampler array as defined in the shader
  93996. * @param textures Define the list of textures to bind to this sampler
  93997. * @return the material itself allowing "fluent" like uniform updates
  93998. */
  93999. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94000. /**
  94001. * Set a float in the shader.
  94002. * @param name Define the name of the uniform as defined in the shader
  94003. * @param value Define the value to give to the uniform
  94004. * @return the material itself allowing "fluent" like uniform updates
  94005. */
  94006. setFloat(name: string, value: number): ShaderMaterial;
  94007. /**
  94008. * Set a int in the shader.
  94009. * @param name Define the name of the uniform as defined in the shader
  94010. * @param value Define the value to give to the uniform
  94011. * @return the material itself allowing "fluent" like uniform updates
  94012. */
  94013. setInt(name: string, value: number): ShaderMaterial;
  94014. /**
  94015. * Set an array of floats in the shader.
  94016. * @param name Define the name of the uniform as defined in the shader
  94017. * @param value Define the value to give to the uniform
  94018. * @return the material itself allowing "fluent" like uniform updates
  94019. */
  94020. setFloats(name: string, value: number[]): ShaderMaterial;
  94021. /**
  94022. * Set a vec3 in the shader from a Color3.
  94023. * @param name Define the name of the uniform as defined in the shader
  94024. * @param value Define the value to give to the uniform
  94025. * @return the material itself allowing "fluent" like uniform updates
  94026. */
  94027. setColor3(name: string, value: Color3): ShaderMaterial;
  94028. /**
  94029. * Set a vec3 array in the shader from a Color3 array.
  94030. * @param name Define the name of the uniform as defined in the shader
  94031. * @param value Define the value to give to the uniform
  94032. * @return the material itself allowing "fluent" like uniform updates
  94033. */
  94034. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94035. /**
  94036. * Set a vec4 in the shader from a Color4.
  94037. * @param name Define the name of the uniform as defined in the shader
  94038. * @param value Define the value to give to the uniform
  94039. * @return the material itself allowing "fluent" like uniform updates
  94040. */
  94041. setColor4(name: string, value: Color4): ShaderMaterial;
  94042. /**
  94043. * Set a vec4 array in the shader from a Color4 array.
  94044. * @param name Define the name of the uniform as defined in the shader
  94045. * @param value Define the value to give to the uniform
  94046. * @return the material itself allowing "fluent" like uniform updates
  94047. */
  94048. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94049. /**
  94050. * Set a vec2 in the shader from a Vector2.
  94051. * @param name Define the name of the uniform as defined in the shader
  94052. * @param value Define the value to give to the uniform
  94053. * @return the material itself allowing "fluent" like uniform updates
  94054. */
  94055. setVector2(name: string, value: Vector2): ShaderMaterial;
  94056. /**
  94057. * Set a vec3 in the shader from a Vector3.
  94058. * @param name Define the name of the uniform as defined in the shader
  94059. * @param value Define the value to give to the uniform
  94060. * @return the material itself allowing "fluent" like uniform updates
  94061. */
  94062. setVector3(name: string, value: Vector3): ShaderMaterial;
  94063. /**
  94064. * Set a vec4 in the shader from a Vector4.
  94065. * @param name Define the name of the uniform as defined in the shader
  94066. * @param value Define the value to give to the uniform
  94067. * @return the material itself allowing "fluent" like uniform updates
  94068. */
  94069. setVector4(name: string, value: Vector4): ShaderMaterial;
  94070. /**
  94071. * Set a mat4 in the shader from a Matrix.
  94072. * @param name Define the name of the uniform as defined in the shader
  94073. * @param value Define the value to give to the uniform
  94074. * @return the material itself allowing "fluent" like uniform updates
  94075. */
  94076. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94077. /**
  94078. * Set a float32Array in the shader from a matrix array.
  94079. * @param name Define the name of the uniform as defined in the shader
  94080. * @param value Define the value to give to the uniform
  94081. * @return the material itself allowing "fluent" like uniform updates
  94082. */
  94083. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94084. /**
  94085. * Set a mat3 in the shader from a Float32Array.
  94086. * @param name Define the name of the uniform as defined in the shader
  94087. * @param value Define the value to give to the uniform
  94088. * @return the material itself allowing "fluent" like uniform updates
  94089. */
  94090. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94091. /**
  94092. * Set a mat2 in the shader from a Float32Array.
  94093. * @param name Define the name of the uniform as defined in the shader
  94094. * @param value Define the value to give to the uniform
  94095. * @return the material itself allowing "fluent" like uniform updates
  94096. */
  94097. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94098. /**
  94099. * Set a vec2 array in the shader from a number array.
  94100. * @param name Define the name of the uniform as defined in the shader
  94101. * @param value Define the value to give to the uniform
  94102. * @return the material itself allowing "fluent" like uniform updates
  94103. */
  94104. setArray2(name: string, value: number[]): ShaderMaterial;
  94105. /**
  94106. * Set a vec3 array in the shader from a number array.
  94107. * @param name Define the name of the uniform as defined in the shader
  94108. * @param value Define the value to give to the uniform
  94109. * @return the material itself allowing "fluent" like uniform updates
  94110. */
  94111. setArray3(name: string, value: number[]): ShaderMaterial;
  94112. /**
  94113. * Set a vec4 array in the shader from a number array.
  94114. * @param name Define the name of the uniform as defined in the shader
  94115. * @param value Define the value to give to the uniform
  94116. * @return the material itself allowing "fluent" like uniform updates
  94117. */
  94118. setArray4(name: string, value: number[]): ShaderMaterial;
  94119. private _checkCache;
  94120. /**
  94121. * Specifies that the submesh is ready to be used
  94122. * @param mesh defines the mesh to check
  94123. * @param subMesh defines which submesh to check
  94124. * @param useInstances specifies that instances should be used
  94125. * @returns a boolean indicating that the submesh is ready or not
  94126. */
  94127. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94128. /**
  94129. * Checks if the material is ready to render the requested mesh
  94130. * @param mesh Define the mesh to render
  94131. * @param useInstances Define whether or not the material is used with instances
  94132. * @returns true if ready, otherwise false
  94133. */
  94134. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94135. /**
  94136. * Binds the world matrix to the material
  94137. * @param world defines the world transformation matrix
  94138. * @param effectOverride - If provided, use this effect instead of internal effect
  94139. */
  94140. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94141. /**
  94142. * Binds the submesh to this material by preparing the effect and shader to draw
  94143. * @param world defines the world transformation matrix
  94144. * @param mesh defines the mesh containing the submesh
  94145. * @param subMesh defines the submesh to bind the material to
  94146. */
  94147. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94148. /**
  94149. * Binds the material to the mesh
  94150. * @param world defines the world transformation matrix
  94151. * @param mesh defines the mesh to bind the material to
  94152. * @param effectOverride - If provided, use this effect instead of internal effect
  94153. */
  94154. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94155. protected _afterBind(mesh?: Mesh): void;
  94156. /**
  94157. * Gets the active textures from the material
  94158. * @returns an array of textures
  94159. */
  94160. getActiveTextures(): BaseTexture[];
  94161. /**
  94162. * Specifies if the material uses a texture
  94163. * @param texture defines the texture to check against the material
  94164. * @returns a boolean specifying if the material uses the texture
  94165. */
  94166. hasTexture(texture: BaseTexture): boolean;
  94167. /**
  94168. * Makes a duplicate of the material, and gives it a new name
  94169. * @param name defines the new name for the duplicated material
  94170. * @returns the cloned material
  94171. */
  94172. clone(name: string): ShaderMaterial;
  94173. /**
  94174. * Disposes the material
  94175. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94176. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94177. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94178. */
  94179. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94180. /**
  94181. * Serializes this material in a JSON representation
  94182. * @returns the serialized material object
  94183. */
  94184. serialize(): any;
  94185. /**
  94186. * Creates a shader material from parsed shader material data
  94187. * @param source defines the JSON represnetation of the material
  94188. * @param scene defines the hosting scene
  94189. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94190. * @returns a new material
  94191. */
  94192. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94193. /**
  94194. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94195. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94196. * @param url defines the url to load from
  94197. * @param scene defines the hosting scene
  94198. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94199. * @returns a promise that will resolve to the new ShaderMaterial
  94200. */
  94201. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94202. /**
  94203. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94204. * @param snippetId defines the snippet to load
  94205. * @param scene defines the hosting scene
  94206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94207. * @returns a promise that will resolve to the new ShaderMaterial
  94208. */
  94209. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94210. }
  94211. }
  94212. declare module BABYLON {
  94213. /** @hidden */
  94214. export var colorPixelShader: {
  94215. name: string;
  94216. shader: string;
  94217. };
  94218. }
  94219. declare module BABYLON {
  94220. /** @hidden */
  94221. export var colorVertexShader: {
  94222. name: string;
  94223. shader: string;
  94224. };
  94225. }
  94226. declare module BABYLON {
  94227. /**
  94228. * Line mesh
  94229. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94230. */
  94231. export class LinesMesh extends Mesh {
  94232. /**
  94233. * If vertex color should be applied to the mesh
  94234. */
  94235. readonly useVertexColor?: boolean | undefined;
  94236. /**
  94237. * If vertex alpha should be applied to the mesh
  94238. */
  94239. readonly useVertexAlpha?: boolean | undefined;
  94240. /**
  94241. * Color of the line (Default: White)
  94242. */
  94243. color: Color3;
  94244. /**
  94245. * Alpha of the line (Default: 1)
  94246. */
  94247. alpha: number;
  94248. /**
  94249. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94250. * This margin is expressed in world space coordinates, so its value may vary.
  94251. * Default value is 0.1
  94252. */
  94253. intersectionThreshold: number;
  94254. private _colorShader;
  94255. private color4;
  94256. /**
  94257. * Creates a new LinesMesh
  94258. * @param name defines the name
  94259. * @param scene defines the hosting scene
  94260. * @param parent defines the parent mesh if any
  94261. * @param source defines the optional source LinesMesh used to clone data from
  94262. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94263. * When false, achieved by calling a clone(), also passing False.
  94264. * This will make creation of children, recursive.
  94265. * @param useVertexColor defines if this LinesMesh supports vertex color
  94266. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94267. */
  94268. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94269. /**
  94270. * If vertex color should be applied to the mesh
  94271. */
  94272. useVertexColor?: boolean | undefined,
  94273. /**
  94274. * If vertex alpha should be applied to the mesh
  94275. */
  94276. useVertexAlpha?: boolean | undefined);
  94277. private _addClipPlaneDefine;
  94278. private _removeClipPlaneDefine;
  94279. isReady(): boolean;
  94280. /**
  94281. * Returns the string "LineMesh"
  94282. */
  94283. getClassName(): string;
  94284. /**
  94285. * @hidden
  94286. */
  94287. get material(): Material;
  94288. /**
  94289. * @hidden
  94290. */
  94291. set material(value: Material);
  94292. /**
  94293. * @hidden
  94294. */
  94295. get checkCollisions(): boolean;
  94296. /** @hidden */
  94297. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94298. /** @hidden */
  94299. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94300. /**
  94301. * Disposes of the line mesh
  94302. * @param doNotRecurse If children should be disposed
  94303. */
  94304. dispose(doNotRecurse?: boolean): void;
  94305. /**
  94306. * Returns a new LineMesh object cloned from the current one.
  94307. */
  94308. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94309. /**
  94310. * Creates a new InstancedLinesMesh object from the mesh model.
  94311. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94312. * @param name defines the name of the new instance
  94313. * @returns a new InstancedLinesMesh
  94314. */
  94315. createInstance(name: string): InstancedLinesMesh;
  94316. }
  94317. /**
  94318. * Creates an instance based on a source LinesMesh
  94319. */
  94320. export class InstancedLinesMesh extends InstancedMesh {
  94321. /**
  94322. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94323. * This margin is expressed in world space coordinates, so its value may vary.
  94324. * Initilized with the intersectionThreshold value of the source LinesMesh
  94325. */
  94326. intersectionThreshold: number;
  94327. constructor(name: string, source: LinesMesh);
  94328. /**
  94329. * Returns the string "InstancedLinesMesh".
  94330. */
  94331. getClassName(): string;
  94332. }
  94333. }
  94334. declare module BABYLON {
  94335. /** @hidden */
  94336. export var linePixelShader: {
  94337. name: string;
  94338. shader: string;
  94339. };
  94340. }
  94341. declare module BABYLON {
  94342. /** @hidden */
  94343. export var lineVertexShader: {
  94344. name: string;
  94345. shader: string;
  94346. };
  94347. }
  94348. declare module BABYLON {
  94349. interface Scene {
  94350. /** @hidden */
  94351. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94352. }
  94353. interface AbstractMesh {
  94354. /**
  94355. * Gets the edgesRenderer associated with the mesh
  94356. */
  94357. edgesRenderer: Nullable<EdgesRenderer>;
  94358. }
  94359. interface LinesMesh {
  94360. /**
  94361. * Enables the edge rendering mode on the mesh.
  94362. * This mode makes the mesh edges visible
  94363. * @param epsilon defines the maximal distance between two angles to detect a face
  94364. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94365. * @returns the currentAbstractMesh
  94366. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94367. */
  94368. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94369. }
  94370. interface InstancedLinesMesh {
  94371. /**
  94372. * Enables the edge rendering mode on the mesh.
  94373. * This mode makes the mesh edges visible
  94374. * @param epsilon defines the maximal distance between two angles to detect a face
  94375. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94376. * @returns the current InstancedLinesMesh
  94377. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94378. */
  94379. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94380. }
  94381. /**
  94382. * Defines the minimum contract an Edges renderer should follow.
  94383. */
  94384. export interface IEdgesRenderer extends IDisposable {
  94385. /**
  94386. * Gets or sets a boolean indicating if the edgesRenderer is active
  94387. */
  94388. isEnabled: boolean;
  94389. /**
  94390. * Renders the edges of the attached mesh,
  94391. */
  94392. render(): void;
  94393. /**
  94394. * Checks wether or not the edges renderer is ready to render.
  94395. * @return true if ready, otherwise false.
  94396. */
  94397. isReady(): boolean;
  94398. /**
  94399. * List of instances to render in case the source mesh has instances
  94400. */
  94401. customInstances: SmartArray<Matrix>;
  94402. }
  94403. /**
  94404. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94405. */
  94406. export class EdgesRenderer implements IEdgesRenderer {
  94407. /**
  94408. * Define the size of the edges with an orthographic camera
  94409. */
  94410. edgesWidthScalerForOrthographic: number;
  94411. /**
  94412. * Define the size of the edges with a perspective camera
  94413. */
  94414. edgesWidthScalerForPerspective: number;
  94415. protected _source: AbstractMesh;
  94416. protected _linesPositions: number[];
  94417. protected _linesNormals: number[];
  94418. protected _linesIndices: number[];
  94419. protected _epsilon: number;
  94420. protected _indicesCount: number;
  94421. protected _lineShader: ShaderMaterial;
  94422. protected _ib: DataBuffer;
  94423. protected _buffers: {
  94424. [key: string]: Nullable<VertexBuffer>;
  94425. };
  94426. protected _buffersForInstances: {
  94427. [key: string]: Nullable<VertexBuffer>;
  94428. };
  94429. protected _checkVerticesInsteadOfIndices: boolean;
  94430. private _meshRebuildObserver;
  94431. private _meshDisposeObserver;
  94432. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94433. isEnabled: boolean;
  94434. /**
  94435. * List of instances to render in case the source mesh has instances
  94436. */
  94437. customInstances: SmartArray<Matrix>;
  94438. private static GetShader;
  94439. /**
  94440. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94441. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94442. * @param source Mesh used to create edges
  94443. * @param epsilon sum of angles in adjacency to check for edge
  94444. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94445. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94446. */
  94447. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94448. protected _prepareRessources(): void;
  94449. /** @hidden */
  94450. _rebuild(): void;
  94451. /**
  94452. * Releases the required resources for the edges renderer
  94453. */
  94454. dispose(): void;
  94455. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94456. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94457. /**
  94458. * Checks if the pair of p0 and p1 is en edge
  94459. * @param faceIndex
  94460. * @param edge
  94461. * @param faceNormals
  94462. * @param p0
  94463. * @param p1
  94464. * @private
  94465. */
  94466. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94467. /**
  94468. * push line into the position, normal and index buffer
  94469. * @protected
  94470. */
  94471. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94472. /**
  94473. * Generates lines edges from adjacencjes
  94474. * @private
  94475. */
  94476. _generateEdgesLines(): void;
  94477. /**
  94478. * Checks wether or not the edges renderer is ready to render.
  94479. * @return true if ready, otherwise false.
  94480. */
  94481. isReady(): boolean;
  94482. /**
  94483. * Renders the edges of the attached mesh,
  94484. */
  94485. render(): void;
  94486. }
  94487. /**
  94488. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94489. */
  94490. export class LineEdgesRenderer extends EdgesRenderer {
  94491. /**
  94492. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94493. * @param source LineMesh used to generate edges
  94494. * @param epsilon not important (specified angle for edge detection)
  94495. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94496. */
  94497. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94498. /**
  94499. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94500. */
  94501. _generateEdgesLines(): void;
  94502. }
  94503. }
  94504. declare module BABYLON {
  94505. /**
  94506. * This represents the object necessary to create a rendering group.
  94507. * This is exclusively used and created by the rendering manager.
  94508. * To modify the behavior, you use the available helpers in your scene or meshes.
  94509. * @hidden
  94510. */
  94511. export class RenderingGroup {
  94512. index: number;
  94513. private static _zeroVector;
  94514. private _scene;
  94515. private _opaqueSubMeshes;
  94516. private _transparentSubMeshes;
  94517. private _alphaTestSubMeshes;
  94518. private _depthOnlySubMeshes;
  94519. private _particleSystems;
  94520. private _spriteManagers;
  94521. private _opaqueSortCompareFn;
  94522. private _alphaTestSortCompareFn;
  94523. private _transparentSortCompareFn;
  94524. private _renderOpaque;
  94525. private _renderAlphaTest;
  94526. private _renderTransparent;
  94527. /** @hidden */
  94528. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94529. onBeforeTransparentRendering: () => void;
  94530. /**
  94531. * Set the opaque sort comparison function.
  94532. * If null the sub meshes will be render in the order they were created
  94533. */
  94534. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94535. /**
  94536. * Set the alpha test sort comparison function.
  94537. * If null the sub meshes will be render in the order they were created
  94538. */
  94539. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94540. /**
  94541. * Set the transparent sort comparison function.
  94542. * If null the sub meshes will be render in the order they were created
  94543. */
  94544. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94545. /**
  94546. * Creates a new rendering group.
  94547. * @param index The rendering group index
  94548. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94549. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94550. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94551. */
  94552. 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>);
  94553. /**
  94554. * Render all the sub meshes contained in the group.
  94555. * @param customRenderFunction Used to override the default render behaviour of the group.
  94556. * @returns true if rendered some submeshes.
  94557. */
  94558. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94559. /**
  94560. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94561. * @param subMeshes The submeshes to render
  94562. */
  94563. private renderOpaqueSorted;
  94564. /**
  94565. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94566. * @param subMeshes The submeshes to render
  94567. */
  94568. private renderAlphaTestSorted;
  94569. /**
  94570. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94571. * @param subMeshes The submeshes to render
  94572. */
  94573. private renderTransparentSorted;
  94574. /**
  94575. * Renders the submeshes in a specified order.
  94576. * @param subMeshes The submeshes to sort before render
  94577. * @param sortCompareFn The comparison function use to sort
  94578. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94579. * @param transparent Specifies to activate blending if true
  94580. */
  94581. private static renderSorted;
  94582. /**
  94583. * Renders the submeshes in the order they were dispatched (no sort applied).
  94584. * @param subMeshes The submeshes to render
  94585. */
  94586. private static renderUnsorted;
  94587. /**
  94588. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94589. * are rendered back to front if in the same alpha index.
  94590. *
  94591. * @param a The first submesh
  94592. * @param b The second submesh
  94593. * @returns The result of the comparison
  94594. */
  94595. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94596. /**
  94597. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94598. * are rendered back to front.
  94599. *
  94600. * @param a The first submesh
  94601. * @param b The second submesh
  94602. * @returns The result of the comparison
  94603. */
  94604. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94605. /**
  94606. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94607. * are rendered front to back (prevent overdraw).
  94608. *
  94609. * @param a The first submesh
  94610. * @param b The second submesh
  94611. * @returns The result of the comparison
  94612. */
  94613. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94614. /**
  94615. * Resets the different lists of submeshes to prepare a new frame.
  94616. */
  94617. prepare(): void;
  94618. dispose(): void;
  94619. /**
  94620. * Inserts the submesh in its correct queue depending on its material.
  94621. * @param subMesh The submesh to dispatch
  94622. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94623. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94624. */
  94625. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94626. dispatchSprites(spriteManager: ISpriteManager): void;
  94627. dispatchParticles(particleSystem: IParticleSystem): void;
  94628. private _renderParticles;
  94629. private _renderSprites;
  94630. }
  94631. }
  94632. declare module BABYLON {
  94633. /**
  94634. * Interface describing the different options available in the rendering manager
  94635. * regarding Auto Clear between groups.
  94636. */
  94637. export interface IRenderingManagerAutoClearSetup {
  94638. /**
  94639. * Defines whether or not autoclear is enable.
  94640. */
  94641. autoClear: boolean;
  94642. /**
  94643. * Defines whether or not to autoclear the depth buffer.
  94644. */
  94645. depth: boolean;
  94646. /**
  94647. * Defines whether or not to autoclear the stencil buffer.
  94648. */
  94649. stencil: boolean;
  94650. }
  94651. /**
  94652. * This class is used by the onRenderingGroupObservable
  94653. */
  94654. export class RenderingGroupInfo {
  94655. /**
  94656. * The Scene that being rendered
  94657. */
  94658. scene: Scene;
  94659. /**
  94660. * The camera currently used for the rendering pass
  94661. */
  94662. camera: Nullable<Camera>;
  94663. /**
  94664. * The ID of the renderingGroup being processed
  94665. */
  94666. renderingGroupId: number;
  94667. }
  94668. /**
  94669. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94670. * It is enable to manage the different groups as well as the different necessary sort functions.
  94671. * This should not be used directly aside of the few static configurations
  94672. */
  94673. export class RenderingManager {
  94674. /**
  94675. * The max id used for rendering groups (not included)
  94676. */
  94677. static MAX_RENDERINGGROUPS: number;
  94678. /**
  94679. * The min id used for rendering groups (included)
  94680. */
  94681. static MIN_RENDERINGGROUPS: number;
  94682. /**
  94683. * Used to globally prevent autoclearing scenes.
  94684. */
  94685. static AUTOCLEAR: boolean;
  94686. /**
  94687. * @hidden
  94688. */
  94689. _useSceneAutoClearSetup: boolean;
  94690. private _scene;
  94691. private _renderingGroups;
  94692. private _depthStencilBufferAlreadyCleaned;
  94693. private _autoClearDepthStencil;
  94694. private _customOpaqueSortCompareFn;
  94695. private _customAlphaTestSortCompareFn;
  94696. private _customTransparentSortCompareFn;
  94697. private _renderingGroupInfo;
  94698. /**
  94699. * Instantiates a new rendering group for a particular scene
  94700. * @param scene Defines the scene the groups belongs to
  94701. */
  94702. constructor(scene: Scene);
  94703. private _clearDepthStencilBuffer;
  94704. /**
  94705. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94706. * @hidden
  94707. */
  94708. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94709. /**
  94710. * Resets the different information of the group to prepare a new frame
  94711. * @hidden
  94712. */
  94713. reset(): void;
  94714. /**
  94715. * Dispose and release the group and its associated resources.
  94716. * @hidden
  94717. */
  94718. dispose(): void;
  94719. /**
  94720. * Clear the info related to rendering groups preventing retention points during dispose.
  94721. */
  94722. freeRenderingGroups(): void;
  94723. private _prepareRenderingGroup;
  94724. /**
  94725. * Add a sprite manager to the rendering manager in order to render it this frame.
  94726. * @param spriteManager Define the sprite manager to render
  94727. */
  94728. dispatchSprites(spriteManager: ISpriteManager): void;
  94729. /**
  94730. * Add a particle system to the rendering manager in order to render it this frame.
  94731. * @param particleSystem Define the particle system to render
  94732. */
  94733. dispatchParticles(particleSystem: IParticleSystem): void;
  94734. /**
  94735. * Add a submesh to the manager in order to render it this frame
  94736. * @param subMesh The submesh to dispatch
  94737. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94738. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94739. */
  94740. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94741. /**
  94742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94743. * This allowed control for front to back rendering or reversly depending of the special needs.
  94744. *
  94745. * @param renderingGroupId The rendering group id corresponding to its index
  94746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94749. */
  94750. 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;
  94751. /**
  94752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94753. *
  94754. * @param renderingGroupId The rendering group id corresponding to its index
  94755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94756. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94757. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94758. */
  94759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94760. /**
  94761. * Gets the current auto clear configuration for one rendering group of the rendering
  94762. * manager.
  94763. * @param index the rendering group index to get the information for
  94764. * @returns The auto clear setup for the requested rendering group
  94765. */
  94766. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94767. }
  94768. }
  94769. declare module BABYLON {
  94770. /**
  94771. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94772. */
  94773. export interface ICustomShaderOptions {
  94774. /**
  94775. * Gets or sets the custom shader name to use
  94776. */
  94777. shaderName: string;
  94778. /**
  94779. * The list of attribute names used in the shader
  94780. */
  94781. attributes?: string[];
  94782. /**
  94783. * The list of unifrom names used in the shader
  94784. */
  94785. uniforms?: string[];
  94786. /**
  94787. * The list of sampler names used in the shader
  94788. */
  94789. samplers?: string[];
  94790. /**
  94791. * The list of defines used in the shader
  94792. */
  94793. defines?: string[];
  94794. }
  94795. /**
  94796. * Interface to implement to create a shadow generator compatible with BJS.
  94797. */
  94798. export interface IShadowGenerator {
  94799. /**
  94800. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94801. * @returns The render target texture if present otherwise, null
  94802. */
  94803. getShadowMap(): Nullable<RenderTargetTexture>;
  94804. /**
  94805. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94806. * @param subMesh The submesh we want to render in the shadow map
  94807. * @param useInstances Defines wether will draw in the map using instances
  94808. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94809. * @returns true if ready otherwise, false
  94810. */
  94811. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94812. /**
  94813. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94814. * @param defines Defines of the material we want to update
  94815. * @param lightIndex Index of the light in the enabled light list of the material
  94816. */
  94817. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94818. /**
  94819. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94820. * defined in the generator but impacting the effect).
  94821. * It implies the unifroms available on the materials are the standard BJS ones.
  94822. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94823. * @param effect The effect we are binfing the information for
  94824. */
  94825. bindShadowLight(lightIndex: string, effect: Effect): void;
  94826. /**
  94827. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94828. * (eq to shadow prjection matrix * light transform matrix)
  94829. * @returns The transform matrix used to create the shadow map
  94830. */
  94831. getTransformMatrix(): Matrix;
  94832. /**
  94833. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94834. * Cube and 2D textures for instance.
  94835. */
  94836. recreateShadowMap(): void;
  94837. /**
  94838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94839. * @param onCompiled Callback triggered at the and of the effects compilation
  94840. * @param options Sets of optional options forcing the compilation with different modes
  94841. */
  94842. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94843. useInstances: boolean;
  94844. }>): void;
  94845. /**
  94846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94847. * @param options Sets of optional options forcing the compilation with different modes
  94848. * @returns A promise that resolves when the compilation completes
  94849. */
  94850. forceCompilationAsync(options?: Partial<{
  94851. useInstances: boolean;
  94852. }>): Promise<void>;
  94853. /**
  94854. * Serializes the shadow generator setup to a json object.
  94855. * @returns The serialized JSON object
  94856. */
  94857. serialize(): any;
  94858. /**
  94859. * Disposes the Shadow map and related Textures and effects.
  94860. */
  94861. dispose(): void;
  94862. }
  94863. /**
  94864. * Default implementation IShadowGenerator.
  94865. * This is the main object responsible of generating shadows in the framework.
  94866. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94867. */
  94868. export class ShadowGenerator implements IShadowGenerator {
  94869. /**
  94870. * Name of the shadow generator class
  94871. */
  94872. static CLASSNAME: string;
  94873. /**
  94874. * Shadow generator mode None: no filtering applied.
  94875. */
  94876. static readonly FILTER_NONE: number;
  94877. /**
  94878. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94879. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94880. */
  94881. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94882. /**
  94883. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94884. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94885. */
  94886. static readonly FILTER_POISSONSAMPLING: number;
  94887. /**
  94888. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94889. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94890. */
  94891. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94892. /**
  94893. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94894. * edge artifacts on steep falloff.
  94895. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94896. */
  94897. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94898. /**
  94899. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94900. * edge artifacts on steep falloff.
  94901. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94902. */
  94903. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94904. /**
  94905. * Shadow generator mode PCF: Percentage Closer Filtering
  94906. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94907. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94908. */
  94909. static readonly FILTER_PCF: number;
  94910. /**
  94911. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94912. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94913. * Contact Hardening
  94914. */
  94915. static readonly FILTER_PCSS: number;
  94916. /**
  94917. * Reserved for PCF and PCSS
  94918. * Highest Quality.
  94919. *
  94920. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94921. *
  94922. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94923. */
  94924. static readonly QUALITY_HIGH: number;
  94925. /**
  94926. * Reserved for PCF and PCSS
  94927. * Good tradeoff for quality/perf cross devices
  94928. *
  94929. * Execute PCF on a 3*3 kernel.
  94930. *
  94931. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94932. */
  94933. static readonly QUALITY_MEDIUM: number;
  94934. /**
  94935. * Reserved for PCF and PCSS
  94936. * The lowest quality but the fastest.
  94937. *
  94938. * Execute PCF on a 1*1 kernel.
  94939. *
  94940. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  94941. */
  94942. static readonly QUALITY_LOW: number;
  94943. /** Gets or sets the custom shader name to use */
  94944. customShaderOptions: ICustomShaderOptions;
  94945. /**
  94946. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  94947. */
  94948. onBeforeShadowMapRenderObservable: Observable<Effect>;
  94949. /**
  94950. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  94951. */
  94952. onAfterShadowMapRenderObservable: Observable<Effect>;
  94953. /**
  94954. * Observable triggered before a mesh is rendered in the shadow map.
  94955. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  94956. */
  94957. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  94958. /**
  94959. * Observable triggered after a mesh is rendered in the shadow map.
  94960. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  94961. */
  94962. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  94963. protected _bias: number;
  94964. /**
  94965. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  94966. */
  94967. get bias(): number;
  94968. /**
  94969. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  94970. */
  94971. set bias(bias: number);
  94972. protected _normalBias: number;
  94973. /**
  94974. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94975. */
  94976. get normalBias(): number;
  94977. /**
  94978. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  94979. */
  94980. set normalBias(normalBias: number);
  94981. protected _blurBoxOffset: number;
  94982. /**
  94983. * Gets the blur box offset: offset applied during the blur pass.
  94984. * Only useful if useKernelBlur = false
  94985. */
  94986. get blurBoxOffset(): number;
  94987. /**
  94988. * Sets the blur box offset: offset applied during the blur pass.
  94989. * Only useful if useKernelBlur = false
  94990. */
  94991. set blurBoxOffset(value: number);
  94992. protected _blurScale: number;
  94993. /**
  94994. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  94995. * 2 means half of the size.
  94996. */
  94997. get blurScale(): number;
  94998. /**
  94999. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95000. * 2 means half of the size.
  95001. */
  95002. set blurScale(value: number);
  95003. protected _blurKernel: number;
  95004. /**
  95005. * Gets the blur kernel: kernel size of the blur pass.
  95006. * Only useful if useKernelBlur = true
  95007. */
  95008. get blurKernel(): number;
  95009. /**
  95010. * Sets the blur kernel: kernel size of the blur pass.
  95011. * Only useful if useKernelBlur = true
  95012. */
  95013. set blurKernel(value: number);
  95014. protected _useKernelBlur: boolean;
  95015. /**
  95016. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95017. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95018. */
  95019. get useKernelBlur(): boolean;
  95020. /**
  95021. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95022. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95023. */
  95024. set useKernelBlur(value: boolean);
  95025. protected _depthScale: number;
  95026. /**
  95027. * Gets the depth scale used in ESM mode.
  95028. */
  95029. get depthScale(): number;
  95030. /**
  95031. * Sets the depth scale used in ESM mode.
  95032. * This can override the scale stored on the light.
  95033. */
  95034. set depthScale(value: number);
  95035. protected _validateFilter(filter: number): number;
  95036. protected _filter: number;
  95037. /**
  95038. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95039. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95040. */
  95041. get filter(): number;
  95042. /**
  95043. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95044. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95045. */
  95046. set filter(value: number);
  95047. /**
  95048. * Gets if the current filter is set to Poisson Sampling.
  95049. */
  95050. get usePoissonSampling(): boolean;
  95051. /**
  95052. * Sets the current filter to Poisson Sampling.
  95053. */
  95054. set usePoissonSampling(value: boolean);
  95055. /**
  95056. * Gets if the current filter is set to ESM.
  95057. */
  95058. get useExponentialShadowMap(): boolean;
  95059. /**
  95060. * Sets the current filter is to ESM.
  95061. */
  95062. set useExponentialShadowMap(value: boolean);
  95063. /**
  95064. * Gets if the current filter is set to filtered ESM.
  95065. */
  95066. get useBlurExponentialShadowMap(): boolean;
  95067. /**
  95068. * Gets if the current filter is set to filtered ESM.
  95069. */
  95070. set useBlurExponentialShadowMap(value: boolean);
  95071. /**
  95072. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95073. * exponential to prevent steep falloff artifacts).
  95074. */
  95075. get useCloseExponentialShadowMap(): boolean;
  95076. /**
  95077. * Sets the current filter to "close ESM" (using the inverse of the
  95078. * exponential to prevent steep falloff artifacts).
  95079. */
  95080. set useCloseExponentialShadowMap(value: boolean);
  95081. /**
  95082. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95083. * exponential to prevent steep falloff artifacts).
  95084. */
  95085. get useBlurCloseExponentialShadowMap(): boolean;
  95086. /**
  95087. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95088. * exponential to prevent steep falloff artifacts).
  95089. */
  95090. set useBlurCloseExponentialShadowMap(value: boolean);
  95091. /**
  95092. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95093. */
  95094. get usePercentageCloserFiltering(): boolean;
  95095. /**
  95096. * Sets the current filter to "PCF" (percentage closer filtering).
  95097. */
  95098. set usePercentageCloserFiltering(value: boolean);
  95099. protected _filteringQuality: number;
  95100. /**
  95101. * Gets the PCF or PCSS Quality.
  95102. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95103. */
  95104. get filteringQuality(): number;
  95105. /**
  95106. * Sets the PCF or PCSS Quality.
  95107. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95108. */
  95109. set filteringQuality(filteringQuality: number);
  95110. /**
  95111. * Gets if the current filter is set to "PCSS" (contact hardening).
  95112. */
  95113. get useContactHardeningShadow(): boolean;
  95114. /**
  95115. * Sets the current filter to "PCSS" (contact hardening).
  95116. */
  95117. set useContactHardeningShadow(value: boolean);
  95118. protected _contactHardeningLightSizeUVRatio: number;
  95119. /**
  95120. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95121. * Using a ratio helps keeping shape stability independently of the map size.
  95122. *
  95123. * It does not account for the light projection as it was having too much
  95124. * instability during the light setup or during light position changes.
  95125. *
  95126. * Only valid if useContactHardeningShadow is true.
  95127. */
  95128. get contactHardeningLightSizeUVRatio(): number;
  95129. /**
  95130. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95131. * Using a ratio helps keeping shape stability independently of the map size.
  95132. *
  95133. * It does not account for the light projection as it was having too much
  95134. * instability during the light setup or during light position changes.
  95135. *
  95136. * Only valid if useContactHardeningShadow is true.
  95137. */
  95138. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95139. protected _darkness: number;
  95140. /** Gets or sets the actual darkness of a shadow */
  95141. get darkness(): number;
  95142. set darkness(value: number);
  95143. /**
  95144. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95145. * 0 means strongest and 1 would means no shadow.
  95146. * @returns the darkness.
  95147. */
  95148. getDarkness(): number;
  95149. /**
  95150. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95151. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95152. * @returns the shadow generator allowing fluent coding.
  95153. */
  95154. setDarkness(darkness: number): ShadowGenerator;
  95155. protected _transparencyShadow: boolean;
  95156. /** Gets or sets the ability to have transparent shadow */
  95157. get transparencyShadow(): boolean;
  95158. set transparencyShadow(value: boolean);
  95159. /**
  95160. * Sets the ability to have transparent shadow (boolean).
  95161. * @param transparent True if transparent else False
  95162. * @returns the shadow generator allowing fluent coding
  95163. */
  95164. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95165. /**
  95166. * Enables or disables shadows with varying strength based on the transparency
  95167. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95168. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95169. * mesh.visibility * alphaTexture.a
  95170. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95171. */
  95172. enableSoftTransparentShadow: boolean;
  95173. protected _shadowMap: Nullable<RenderTargetTexture>;
  95174. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95175. /**
  95176. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95177. * @returns The render target texture if present otherwise, null
  95178. */
  95179. getShadowMap(): Nullable<RenderTargetTexture>;
  95180. /**
  95181. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95182. * @returns The render target texture if the shadow map is present otherwise, null
  95183. */
  95184. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95185. /**
  95186. * Gets the class name of that object
  95187. * @returns "ShadowGenerator"
  95188. */
  95189. getClassName(): string;
  95190. /**
  95191. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95192. * @param mesh Mesh to add
  95193. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95194. * @returns the Shadow Generator itself
  95195. */
  95196. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95197. /**
  95198. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95199. * @param mesh Mesh to remove
  95200. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95201. * @returns the Shadow Generator itself
  95202. */
  95203. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95204. /**
  95205. * Controls the extent to which the shadows fade out at the edge of the frustum
  95206. */
  95207. frustumEdgeFalloff: number;
  95208. protected _light: IShadowLight;
  95209. /**
  95210. * Returns the associated light object.
  95211. * @returns the light generating the shadow
  95212. */
  95213. getLight(): IShadowLight;
  95214. /**
  95215. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95216. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95217. * It might on the other hand introduce peter panning.
  95218. */
  95219. forceBackFacesOnly: boolean;
  95220. protected _scene: Scene;
  95221. protected _lightDirection: Vector3;
  95222. protected _effect: Effect;
  95223. protected _viewMatrix: Matrix;
  95224. protected _projectionMatrix: Matrix;
  95225. protected _transformMatrix: Matrix;
  95226. protected _cachedPosition: Vector3;
  95227. protected _cachedDirection: Vector3;
  95228. protected _cachedDefines: string;
  95229. protected _currentRenderID: number;
  95230. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95231. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95232. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95233. protected _blurPostProcesses: PostProcess[];
  95234. protected _mapSize: number;
  95235. protected _currentFaceIndex: number;
  95236. protected _currentFaceIndexCache: number;
  95237. protected _textureType: number;
  95238. protected _defaultTextureMatrix: Matrix;
  95239. protected _storedUniqueId: Nullable<number>;
  95240. /** @hidden */
  95241. static _SceneComponentInitialization: (scene: Scene) => void;
  95242. /**
  95243. * Creates a ShadowGenerator object.
  95244. * A ShadowGenerator is the required tool to use the shadows.
  95245. * Each light casting shadows needs to use its own ShadowGenerator.
  95246. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95247. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95248. * @param light The light object generating the shadows.
  95249. * @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.
  95250. */
  95251. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95252. protected _initializeGenerator(): void;
  95253. protected _createTargetRenderTexture(): void;
  95254. protected _initializeShadowMap(): void;
  95255. protected _initializeBlurRTTAndPostProcesses(): void;
  95256. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95257. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95258. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95259. protected _applyFilterValues(): void;
  95260. /**
  95261. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95262. * @param onCompiled Callback triggered at the and of the effects compilation
  95263. * @param options Sets of optional options forcing the compilation with different modes
  95264. */
  95265. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95266. useInstances: boolean;
  95267. }>): void;
  95268. /**
  95269. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95270. * @param options Sets of optional options forcing the compilation with different modes
  95271. * @returns A promise that resolves when the compilation completes
  95272. */
  95273. forceCompilationAsync(options?: Partial<{
  95274. useInstances: boolean;
  95275. }>): Promise<void>;
  95276. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95277. private _prepareShadowDefines;
  95278. /**
  95279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95280. * @param subMesh The submesh we want to render in the shadow map
  95281. * @param useInstances Defines wether will draw in the map using instances
  95282. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95283. * @returns true if ready otherwise, false
  95284. */
  95285. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95286. /**
  95287. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95288. * @param defines Defines of the material we want to update
  95289. * @param lightIndex Index of the light in the enabled light list of the material
  95290. */
  95291. prepareDefines(defines: any, lightIndex: number): void;
  95292. /**
  95293. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95294. * defined in the generator but impacting the effect).
  95295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95296. * @param effect The effect we are binfing the information for
  95297. */
  95298. bindShadowLight(lightIndex: string, effect: Effect): void;
  95299. /**
  95300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95301. * (eq to shadow prjection matrix * light transform matrix)
  95302. * @returns The transform matrix used to create the shadow map
  95303. */
  95304. getTransformMatrix(): Matrix;
  95305. /**
  95306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95307. * Cube and 2D textures for instance.
  95308. */
  95309. recreateShadowMap(): void;
  95310. protected _disposeBlurPostProcesses(): void;
  95311. protected _disposeRTTandPostProcesses(): void;
  95312. /**
  95313. * Disposes the ShadowGenerator.
  95314. * Returns nothing.
  95315. */
  95316. dispose(): void;
  95317. /**
  95318. * Serializes the shadow generator setup to a json object.
  95319. * @returns The serialized JSON object
  95320. */
  95321. serialize(): any;
  95322. /**
  95323. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95324. * @param parsedShadowGenerator The JSON object to parse
  95325. * @param scene The scene to create the shadow map for
  95326. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95327. * @returns The parsed shadow generator
  95328. */
  95329. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95330. }
  95331. }
  95332. declare module BABYLON {
  95333. /**
  95334. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95335. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95336. * 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.
  95337. */
  95338. export abstract class Light extends Node {
  95339. /**
  95340. * Falloff Default: light is falling off following the material specification:
  95341. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95342. */
  95343. static readonly FALLOFF_DEFAULT: number;
  95344. /**
  95345. * Falloff Physical: light is falling off following the inverse squared distance law.
  95346. */
  95347. static readonly FALLOFF_PHYSICAL: number;
  95348. /**
  95349. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95350. * to enhance interoperability with other engines.
  95351. */
  95352. static readonly FALLOFF_GLTF: number;
  95353. /**
  95354. * Falloff Standard: light is falling off like in the standard material
  95355. * to enhance interoperability with other materials.
  95356. */
  95357. static readonly FALLOFF_STANDARD: number;
  95358. /**
  95359. * If every light affecting the material is in this lightmapMode,
  95360. * material.lightmapTexture adds or multiplies
  95361. * (depends on material.useLightmapAsShadowmap)
  95362. * after every other light calculations.
  95363. */
  95364. static readonly LIGHTMAP_DEFAULT: number;
  95365. /**
  95366. * material.lightmapTexture as only diffuse lighting from this light
  95367. * adds only specular lighting from this light
  95368. * adds dynamic shadows
  95369. */
  95370. static readonly LIGHTMAP_SPECULAR: number;
  95371. /**
  95372. * material.lightmapTexture as only lighting
  95373. * no light calculation from this light
  95374. * only adds dynamic shadows from this light
  95375. */
  95376. static readonly LIGHTMAP_SHADOWSONLY: number;
  95377. /**
  95378. * Each light type uses the default quantity according to its type:
  95379. * point/spot lights use luminous intensity
  95380. * directional lights use illuminance
  95381. */
  95382. static readonly INTENSITYMODE_AUTOMATIC: number;
  95383. /**
  95384. * lumen (lm)
  95385. */
  95386. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95387. /**
  95388. * candela (lm/sr)
  95389. */
  95390. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95391. /**
  95392. * lux (lm/m^2)
  95393. */
  95394. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95395. /**
  95396. * nit (cd/m^2)
  95397. */
  95398. static readonly INTENSITYMODE_LUMINANCE: number;
  95399. /**
  95400. * Light type const id of the point light.
  95401. */
  95402. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95403. /**
  95404. * Light type const id of the directional light.
  95405. */
  95406. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95407. /**
  95408. * Light type const id of the spot light.
  95409. */
  95410. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95411. /**
  95412. * Light type const id of the hemispheric light.
  95413. */
  95414. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95415. /**
  95416. * Diffuse gives the basic color to an object.
  95417. */
  95418. diffuse: Color3;
  95419. /**
  95420. * Specular produces a highlight color on an object.
  95421. * Note: This is note affecting PBR materials.
  95422. */
  95423. specular: Color3;
  95424. /**
  95425. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95426. * falling off base on range or angle.
  95427. * This can be set to any values in Light.FALLOFF_x.
  95428. *
  95429. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95430. * other types of materials.
  95431. */
  95432. falloffType: number;
  95433. /**
  95434. * Strength of the light.
  95435. * Note: By default it is define in the framework own unit.
  95436. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95437. */
  95438. intensity: number;
  95439. private _range;
  95440. protected _inverseSquaredRange: number;
  95441. /**
  95442. * Defines how far from the source the light is impacting in scene units.
  95443. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95444. */
  95445. get range(): number;
  95446. /**
  95447. * Defines how far from the source the light is impacting in scene units.
  95448. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95449. */
  95450. set range(value: number);
  95451. /**
  95452. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95453. * of light.
  95454. */
  95455. private _photometricScale;
  95456. private _intensityMode;
  95457. /**
  95458. * Gets the photometric scale used to interpret the intensity.
  95459. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95460. */
  95461. get intensityMode(): number;
  95462. /**
  95463. * Sets the photometric scale used to interpret the intensity.
  95464. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95465. */
  95466. set intensityMode(value: number);
  95467. private _radius;
  95468. /**
  95469. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95470. */
  95471. get radius(): number;
  95472. /**
  95473. * sets the light radius used by PBR Materials to simulate soft area lights.
  95474. */
  95475. set radius(value: number);
  95476. private _renderPriority;
  95477. /**
  95478. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95479. * exceeding the number allowed of the materials.
  95480. */
  95481. renderPriority: number;
  95482. private _shadowEnabled;
  95483. /**
  95484. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95485. * the current shadow generator.
  95486. */
  95487. get shadowEnabled(): boolean;
  95488. /**
  95489. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95490. * the current shadow generator.
  95491. */
  95492. set shadowEnabled(value: boolean);
  95493. private _includedOnlyMeshes;
  95494. /**
  95495. * Gets the only meshes impacted by this light.
  95496. */
  95497. get includedOnlyMeshes(): AbstractMesh[];
  95498. /**
  95499. * Sets the only meshes impacted by this light.
  95500. */
  95501. set includedOnlyMeshes(value: AbstractMesh[]);
  95502. private _excludedMeshes;
  95503. /**
  95504. * Gets the meshes not impacted by this light.
  95505. */
  95506. get excludedMeshes(): AbstractMesh[];
  95507. /**
  95508. * Sets the meshes not impacted by this light.
  95509. */
  95510. set excludedMeshes(value: AbstractMesh[]);
  95511. private _excludeWithLayerMask;
  95512. /**
  95513. * Gets the layer id use to find what meshes are not impacted by the light.
  95514. * Inactive if 0
  95515. */
  95516. get excludeWithLayerMask(): number;
  95517. /**
  95518. * Sets the layer id use to find what meshes are not impacted by the light.
  95519. * Inactive if 0
  95520. */
  95521. set excludeWithLayerMask(value: number);
  95522. private _includeOnlyWithLayerMask;
  95523. /**
  95524. * Gets the layer id use to find what meshes are impacted by the light.
  95525. * Inactive if 0
  95526. */
  95527. get includeOnlyWithLayerMask(): number;
  95528. /**
  95529. * Sets the layer id use to find what meshes are impacted by the light.
  95530. * Inactive if 0
  95531. */
  95532. set includeOnlyWithLayerMask(value: number);
  95533. private _lightmapMode;
  95534. /**
  95535. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95536. */
  95537. get lightmapMode(): number;
  95538. /**
  95539. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95540. */
  95541. set lightmapMode(value: number);
  95542. /**
  95543. * Shadow generator associted to the light.
  95544. * @hidden Internal use only.
  95545. */
  95546. _shadowGenerator: Nullable<IShadowGenerator>;
  95547. /**
  95548. * @hidden Internal use only.
  95549. */
  95550. _excludedMeshesIds: string[];
  95551. /**
  95552. * @hidden Internal use only.
  95553. */
  95554. _includedOnlyMeshesIds: string[];
  95555. /**
  95556. * The current light unifom buffer.
  95557. * @hidden Internal use only.
  95558. */
  95559. _uniformBuffer: UniformBuffer;
  95560. /** @hidden */
  95561. _renderId: number;
  95562. /**
  95563. * Creates a Light object in the scene.
  95564. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95565. * @param name The firendly name of the light
  95566. * @param scene The scene the light belongs too
  95567. */
  95568. constructor(name: string, scene: Scene);
  95569. protected abstract _buildUniformLayout(): void;
  95570. /**
  95571. * Sets the passed Effect "effect" with the Light information.
  95572. * @param effect The effect to update
  95573. * @param lightIndex The index of the light in the effect to update
  95574. * @returns The light
  95575. */
  95576. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95577. /**
  95578. * Sets the passed Effect "effect" with the Light textures.
  95579. * @param effect The effect to update
  95580. * @param lightIndex The index of the light in the effect to update
  95581. * @returns The light
  95582. */
  95583. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95584. /**
  95585. * Binds the lights information from the scene to the effect for the given mesh.
  95586. * @param lightIndex Light index
  95587. * @param scene The scene where the light belongs to
  95588. * @param effect The effect we are binding the data to
  95589. * @param useSpecular Defines if specular is supported
  95590. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95591. */
  95592. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95593. /**
  95594. * Sets the passed Effect "effect" with the Light information.
  95595. * @param effect The effect to update
  95596. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95597. * @returns The light
  95598. */
  95599. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95600. /**
  95601. * Returns the string "Light".
  95602. * @returns the class name
  95603. */
  95604. getClassName(): string;
  95605. /** @hidden */
  95606. readonly _isLight: boolean;
  95607. /**
  95608. * Converts the light information to a readable string for debug purpose.
  95609. * @param fullDetails Supports for multiple levels of logging within scene loading
  95610. * @returns the human readable light info
  95611. */
  95612. toString(fullDetails?: boolean): string;
  95613. /** @hidden */
  95614. protected _syncParentEnabledState(): void;
  95615. /**
  95616. * Set the enabled state of this node.
  95617. * @param value - the new enabled state
  95618. */
  95619. setEnabled(value: boolean): void;
  95620. /**
  95621. * Returns the Light associated shadow generator if any.
  95622. * @return the associated shadow generator.
  95623. */
  95624. getShadowGenerator(): Nullable<IShadowGenerator>;
  95625. /**
  95626. * Returns a Vector3, the absolute light position in the World.
  95627. * @returns the world space position of the light
  95628. */
  95629. getAbsolutePosition(): Vector3;
  95630. /**
  95631. * Specifies if the light will affect the passed mesh.
  95632. * @param mesh The mesh to test against the light
  95633. * @return true the mesh is affected otherwise, false.
  95634. */
  95635. canAffectMesh(mesh: AbstractMesh): boolean;
  95636. /**
  95637. * Sort function to order lights for rendering.
  95638. * @param a First Light object to compare to second.
  95639. * @param b Second Light object to compare first.
  95640. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95641. */
  95642. static CompareLightsPriority(a: Light, b: Light): number;
  95643. /**
  95644. * Releases resources associated with this node.
  95645. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95646. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95647. */
  95648. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95649. /**
  95650. * Returns the light type ID (integer).
  95651. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95652. */
  95653. getTypeID(): number;
  95654. /**
  95655. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95656. * @returns the scaled intensity in intensity mode unit
  95657. */
  95658. getScaledIntensity(): number;
  95659. /**
  95660. * Returns a new Light object, named "name", from the current one.
  95661. * @param name The name of the cloned light
  95662. * @param newParent The parent of this light, if it has one
  95663. * @returns the new created light
  95664. */
  95665. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95666. /**
  95667. * Serializes the current light into a Serialization object.
  95668. * @returns the serialized object.
  95669. */
  95670. serialize(): any;
  95671. /**
  95672. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95673. * This new light is named "name" and added to the passed scene.
  95674. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95675. * @param name The friendly name of the light
  95676. * @param scene The scene the new light will belong to
  95677. * @returns the constructor function
  95678. */
  95679. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95680. /**
  95681. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95682. * @param parsedLight The JSON representation of the light
  95683. * @param scene The scene to create the parsed light in
  95684. * @returns the created light after parsing
  95685. */
  95686. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95687. private _hookArrayForExcluded;
  95688. private _hookArrayForIncludedOnly;
  95689. private _resyncMeshes;
  95690. /**
  95691. * Forces the meshes to update their light related information in their rendering used effects
  95692. * @hidden Internal Use Only
  95693. */
  95694. _markMeshesAsLightDirty(): void;
  95695. /**
  95696. * Recomputes the cached photometric scale if needed.
  95697. */
  95698. private _computePhotometricScale;
  95699. /**
  95700. * Returns the Photometric Scale according to the light type and intensity mode.
  95701. */
  95702. private _getPhotometricScale;
  95703. /**
  95704. * Reorder the light in the scene according to their defined priority.
  95705. * @hidden Internal Use Only
  95706. */
  95707. _reorderLightsInScene(): void;
  95708. /**
  95709. * Prepares the list of defines specific to the light type.
  95710. * @param defines the list of defines
  95711. * @param lightIndex defines the index of the light for the effect
  95712. */
  95713. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95714. }
  95715. }
  95716. declare module BABYLON {
  95717. /**
  95718. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95719. * This is the base of the follow, arc rotate cameras and Free camera
  95720. * @see http://doc.babylonjs.com/features/cameras
  95721. */
  95722. export class TargetCamera extends Camera {
  95723. private static _RigCamTransformMatrix;
  95724. private static _TargetTransformMatrix;
  95725. private static _TargetFocalPoint;
  95726. /**
  95727. * Define the current direction the camera is moving to
  95728. */
  95729. cameraDirection: Vector3;
  95730. /**
  95731. * Define the current rotation the camera is rotating to
  95732. */
  95733. cameraRotation: Vector2;
  95734. /**
  95735. * When set, the up vector of the camera will be updated by the rotation of the camera
  95736. */
  95737. updateUpVectorFromRotation: boolean;
  95738. private _tmpQuaternion;
  95739. /**
  95740. * Define the current rotation of the camera
  95741. */
  95742. rotation: Vector3;
  95743. /**
  95744. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95745. */
  95746. rotationQuaternion: Quaternion;
  95747. /**
  95748. * Define the current speed of the camera
  95749. */
  95750. speed: number;
  95751. /**
  95752. * Add constraint to the camera to prevent it to move freely in all directions and
  95753. * around all axis.
  95754. */
  95755. noRotationConstraint: boolean;
  95756. /**
  95757. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95758. * panning
  95759. */
  95760. invertRotation: boolean;
  95761. /**
  95762. * Speed multiplier for inverse camera panning
  95763. */
  95764. inverseRotationSpeed: number;
  95765. /**
  95766. * Define the current target of the camera as an object or a position.
  95767. */
  95768. lockedTarget: any;
  95769. /** @hidden */
  95770. _currentTarget: Vector3;
  95771. /** @hidden */
  95772. _initialFocalDistance: number;
  95773. /** @hidden */
  95774. _viewMatrix: Matrix;
  95775. /** @hidden */
  95776. _camMatrix: Matrix;
  95777. /** @hidden */
  95778. _cameraTransformMatrix: Matrix;
  95779. /** @hidden */
  95780. _cameraRotationMatrix: Matrix;
  95781. /** @hidden */
  95782. _referencePoint: Vector3;
  95783. /** @hidden */
  95784. _transformedReferencePoint: Vector3;
  95785. protected _globalCurrentTarget: Vector3;
  95786. protected _globalCurrentUpVector: Vector3;
  95787. /** @hidden */
  95788. _reset: () => void;
  95789. private _defaultUp;
  95790. /**
  95791. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95792. * This is the base of the follow, arc rotate cameras and Free camera
  95793. * @see http://doc.babylonjs.com/features/cameras
  95794. * @param name Defines the name of the camera in the scene
  95795. * @param position Defines the start position of the camera in the scene
  95796. * @param scene Defines the scene the camera belongs to
  95797. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95798. */
  95799. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95800. /**
  95801. * Gets the position in front of the camera at a given distance.
  95802. * @param distance The distance from the camera we want the position to be
  95803. * @returns the position
  95804. */
  95805. getFrontPosition(distance: number): Vector3;
  95806. /** @hidden */
  95807. _getLockedTargetPosition(): Nullable<Vector3>;
  95808. private _storedPosition;
  95809. private _storedRotation;
  95810. private _storedRotationQuaternion;
  95811. /**
  95812. * Store current camera state of the camera (fov, position, rotation, etc..)
  95813. * @returns the camera
  95814. */
  95815. storeState(): Camera;
  95816. /**
  95817. * Restored camera state. You must call storeState() first
  95818. * @returns whether it was successful or not
  95819. * @hidden
  95820. */
  95821. _restoreStateValues(): boolean;
  95822. /** @hidden */
  95823. _initCache(): void;
  95824. /** @hidden */
  95825. _updateCache(ignoreParentClass?: boolean): void;
  95826. /** @hidden */
  95827. _isSynchronizedViewMatrix(): boolean;
  95828. /** @hidden */
  95829. _computeLocalCameraSpeed(): number;
  95830. /**
  95831. * Defines the target the camera should look at.
  95832. * @param target Defines the new target as a Vector or a mesh
  95833. */
  95834. setTarget(target: Vector3): void;
  95835. /**
  95836. * Return the current target position of the camera. This value is expressed in local space.
  95837. * @returns the target position
  95838. */
  95839. getTarget(): Vector3;
  95840. /** @hidden */
  95841. _decideIfNeedsToMove(): boolean;
  95842. /** @hidden */
  95843. _updatePosition(): void;
  95844. /** @hidden */
  95845. _checkInputs(): void;
  95846. protected _updateCameraRotationMatrix(): void;
  95847. /**
  95848. * 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)
  95849. * @returns the current camera
  95850. */
  95851. private _rotateUpVectorWithCameraRotationMatrix;
  95852. private _cachedRotationZ;
  95853. private _cachedQuaternionRotationZ;
  95854. /** @hidden */
  95855. _getViewMatrix(): Matrix;
  95856. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95857. /**
  95858. * @hidden
  95859. */
  95860. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95861. /**
  95862. * @hidden
  95863. */
  95864. _updateRigCameras(): void;
  95865. private _getRigCamPositionAndTarget;
  95866. /**
  95867. * Gets the current object class name.
  95868. * @return the class name
  95869. */
  95870. getClassName(): string;
  95871. }
  95872. }
  95873. declare module BABYLON {
  95874. /**
  95875. * Gather the list of keyboard event types as constants.
  95876. */
  95877. export class KeyboardEventTypes {
  95878. /**
  95879. * The keydown event is fired when a key becomes active (pressed).
  95880. */
  95881. static readonly KEYDOWN: number;
  95882. /**
  95883. * The keyup event is fired when a key has been released.
  95884. */
  95885. static readonly KEYUP: number;
  95886. }
  95887. /**
  95888. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95889. */
  95890. export class KeyboardInfo {
  95891. /**
  95892. * Defines the type of event (KeyboardEventTypes)
  95893. */
  95894. type: number;
  95895. /**
  95896. * Defines the related dom event
  95897. */
  95898. event: KeyboardEvent;
  95899. /**
  95900. * Instantiates a new keyboard info.
  95901. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95902. * @param type Defines the type of event (KeyboardEventTypes)
  95903. * @param event Defines the related dom event
  95904. */
  95905. constructor(
  95906. /**
  95907. * Defines the type of event (KeyboardEventTypes)
  95908. */
  95909. type: number,
  95910. /**
  95911. * Defines the related dom event
  95912. */
  95913. event: KeyboardEvent);
  95914. }
  95915. /**
  95916. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95917. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95918. */
  95919. export class KeyboardInfoPre extends KeyboardInfo {
  95920. /**
  95921. * Defines the type of event (KeyboardEventTypes)
  95922. */
  95923. type: number;
  95924. /**
  95925. * Defines the related dom event
  95926. */
  95927. event: KeyboardEvent;
  95928. /**
  95929. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95930. */
  95931. skipOnPointerObservable: boolean;
  95932. /**
  95933. * Instantiates a new keyboard pre info.
  95934. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95935. * @param type Defines the type of event (KeyboardEventTypes)
  95936. * @param event Defines the related dom event
  95937. */
  95938. constructor(
  95939. /**
  95940. * Defines the type of event (KeyboardEventTypes)
  95941. */
  95942. type: number,
  95943. /**
  95944. * Defines the related dom event
  95945. */
  95946. event: KeyboardEvent);
  95947. }
  95948. }
  95949. declare module BABYLON {
  95950. /**
  95951. * Manage the keyboard inputs to control the movement of a free camera.
  95952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95953. */
  95954. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  95955. /**
  95956. * Defines the camera the input is attached to.
  95957. */
  95958. camera: FreeCamera;
  95959. /**
  95960. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  95961. */
  95962. keysUp: number[];
  95963. /**
  95964. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  95965. */
  95966. keysUpward: number[];
  95967. /**
  95968. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  95969. */
  95970. keysDown: number[];
  95971. /**
  95972. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  95973. */
  95974. keysDownward: number[];
  95975. /**
  95976. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  95977. */
  95978. keysLeft: number[];
  95979. /**
  95980. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  95981. */
  95982. keysRight: number[];
  95983. private _keys;
  95984. private _onCanvasBlurObserver;
  95985. private _onKeyboardObserver;
  95986. private _engine;
  95987. private _scene;
  95988. /**
  95989. * Attach the input controls to a specific dom element to get the input from.
  95990. * @param element Defines the element the controls should be listened from
  95991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95992. */
  95993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95994. /**
  95995. * Detach the current controls from the specified dom element.
  95996. * @param element Defines the element to stop listening the inputs from
  95997. */
  95998. detachControl(element: Nullable<HTMLElement>): void;
  95999. /**
  96000. * Update the current camera state depending on the inputs that have been used this frame.
  96001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96002. */
  96003. checkInputs(): void;
  96004. /**
  96005. * Gets the class name of the current intput.
  96006. * @returns the class name
  96007. */
  96008. getClassName(): string;
  96009. /** @hidden */
  96010. _onLostFocus(): void;
  96011. /**
  96012. * Get the friendly name associated with the input class.
  96013. * @returns the input friendly name
  96014. */
  96015. getSimpleName(): string;
  96016. }
  96017. }
  96018. declare module BABYLON {
  96019. /**
  96020. * Gather the list of pointer event types as constants.
  96021. */
  96022. export class PointerEventTypes {
  96023. /**
  96024. * 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.
  96025. */
  96026. static readonly POINTERDOWN: number;
  96027. /**
  96028. * The pointerup event is fired when a pointer is no longer active.
  96029. */
  96030. static readonly POINTERUP: number;
  96031. /**
  96032. * The pointermove event is fired when a pointer changes coordinates.
  96033. */
  96034. static readonly POINTERMOVE: number;
  96035. /**
  96036. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96037. */
  96038. static readonly POINTERWHEEL: number;
  96039. /**
  96040. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96041. */
  96042. static readonly POINTERPICK: number;
  96043. /**
  96044. * The pointertap event is fired when a the object has been touched and released without drag.
  96045. */
  96046. static readonly POINTERTAP: number;
  96047. /**
  96048. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96049. */
  96050. static readonly POINTERDOUBLETAP: number;
  96051. }
  96052. /**
  96053. * Base class of pointer info types.
  96054. */
  96055. export class PointerInfoBase {
  96056. /**
  96057. * Defines the type of event (PointerEventTypes)
  96058. */
  96059. type: number;
  96060. /**
  96061. * Defines the related dom event
  96062. */
  96063. event: PointerEvent | MouseWheelEvent;
  96064. /**
  96065. * Instantiates the base class of pointers info.
  96066. * @param type Defines the type of event (PointerEventTypes)
  96067. * @param event Defines the related dom event
  96068. */
  96069. constructor(
  96070. /**
  96071. * Defines the type of event (PointerEventTypes)
  96072. */
  96073. type: number,
  96074. /**
  96075. * Defines the related dom event
  96076. */
  96077. event: PointerEvent | MouseWheelEvent);
  96078. }
  96079. /**
  96080. * This class is used to store pointer related info for the onPrePointerObservable event.
  96081. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96082. */
  96083. export class PointerInfoPre extends PointerInfoBase {
  96084. /**
  96085. * Ray from a pointer if availible (eg. 6dof controller)
  96086. */
  96087. ray: Nullable<Ray>;
  96088. /**
  96089. * Defines the local position of the pointer on the canvas.
  96090. */
  96091. localPosition: Vector2;
  96092. /**
  96093. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96094. */
  96095. skipOnPointerObservable: boolean;
  96096. /**
  96097. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96098. * @param type Defines the type of event (PointerEventTypes)
  96099. * @param event Defines the related dom event
  96100. * @param localX Defines the local x coordinates of the pointer when the event occured
  96101. * @param localY Defines the local y coordinates of the pointer when the event occured
  96102. */
  96103. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96104. }
  96105. /**
  96106. * This type contains all the data related to a pointer event in Babylon.js.
  96107. * 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.
  96108. */
  96109. export class PointerInfo extends PointerInfoBase {
  96110. /**
  96111. * Defines the picking info associated to the info (if any)\
  96112. */
  96113. pickInfo: Nullable<PickingInfo>;
  96114. /**
  96115. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96116. * @param type Defines the type of event (PointerEventTypes)
  96117. * @param event Defines the related dom event
  96118. * @param pickInfo Defines the picking info associated to the info (if any)\
  96119. */
  96120. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96121. /**
  96122. * Defines the picking info associated to the info (if any)\
  96123. */
  96124. pickInfo: Nullable<PickingInfo>);
  96125. }
  96126. /**
  96127. * Data relating to a touch event on the screen.
  96128. */
  96129. export interface PointerTouch {
  96130. /**
  96131. * X coordinate of touch.
  96132. */
  96133. x: number;
  96134. /**
  96135. * Y coordinate of touch.
  96136. */
  96137. y: number;
  96138. /**
  96139. * Id of touch. Unique for each finger.
  96140. */
  96141. pointerId: number;
  96142. /**
  96143. * Event type passed from DOM.
  96144. */
  96145. type: any;
  96146. }
  96147. }
  96148. declare module BABYLON {
  96149. /**
  96150. * Manage the mouse inputs to control the movement of a free camera.
  96151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96152. */
  96153. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96154. /**
  96155. * Define if touch is enabled in the mouse input
  96156. */
  96157. touchEnabled: boolean;
  96158. /**
  96159. * Defines the camera the input is attached to.
  96160. */
  96161. camera: FreeCamera;
  96162. /**
  96163. * Defines the buttons associated with the input to handle camera move.
  96164. */
  96165. buttons: number[];
  96166. /**
  96167. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96168. */
  96169. angularSensibility: number;
  96170. private _pointerInput;
  96171. private _onMouseMove;
  96172. private _observer;
  96173. private previousPosition;
  96174. /**
  96175. * Observable for when a pointer move event occurs containing the move offset
  96176. */
  96177. onPointerMovedObservable: Observable<{
  96178. offsetX: number;
  96179. offsetY: number;
  96180. }>;
  96181. /**
  96182. * @hidden
  96183. * If the camera should be rotated automatically based on pointer movement
  96184. */
  96185. _allowCameraRotation: boolean;
  96186. /**
  96187. * Manage the mouse inputs to control the movement of a free camera.
  96188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96189. * @param touchEnabled Defines if touch is enabled or not
  96190. */
  96191. constructor(
  96192. /**
  96193. * Define if touch is enabled in the mouse input
  96194. */
  96195. touchEnabled?: boolean);
  96196. /**
  96197. * Attach the input controls to a specific dom element to get the input from.
  96198. * @param element Defines the element the controls should be listened from
  96199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96200. */
  96201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96202. /**
  96203. * Called on JS contextmenu event.
  96204. * Override this method to provide functionality.
  96205. */
  96206. protected onContextMenu(evt: PointerEvent): void;
  96207. /**
  96208. * Detach the current controls from the specified dom element.
  96209. * @param element Defines the element to stop listening the inputs from
  96210. */
  96211. detachControl(element: Nullable<HTMLElement>): void;
  96212. /**
  96213. * Gets the class name of the current intput.
  96214. * @returns the class name
  96215. */
  96216. getClassName(): string;
  96217. /**
  96218. * Get the friendly name associated with the input class.
  96219. * @returns the input friendly name
  96220. */
  96221. getSimpleName(): string;
  96222. }
  96223. }
  96224. declare module BABYLON {
  96225. /**
  96226. * Manage the touch inputs to control the movement of a free camera.
  96227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96228. */
  96229. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96230. /**
  96231. * Defines the camera the input is attached to.
  96232. */
  96233. camera: FreeCamera;
  96234. /**
  96235. * Defines the touch sensibility for rotation.
  96236. * The higher the faster.
  96237. */
  96238. touchAngularSensibility: number;
  96239. /**
  96240. * Defines the touch sensibility for move.
  96241. * The higher the faster.
  96242. */
  96243. touchMoveSensibility: number;
  96244. private _offsetX;
  96245. private _offsetY;
  96246. private _pointerPressed;
  96247. private _pointerInput;
  96248. private _observer;
  96249. private _onLostFocus;
  96250. /**
  96251. * Attach the input controls to a specific dom element to get the input from.
  96252. * @param element Defines the element the controls should be listened from
  96253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96254. */
  96255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96256. /**
  96257. * Detach the current controls from the specified dom element.
  96258. * @param element Defines the element to stop listening the inputs from
  96259. */
  96260. detachControl(element: Nullable<HTMLElement>): void;
  96261. /**
  96262. * Update the current camera state depending on the inputs that have been used this frame.
  96263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96264. */
  96265. checkInputs(): void;
  96266. /**
  96267. * Gets the class name of the current intput.
  96268. * @returns the class name
  96269. */
  96270. getClassName(): string;
  96271. /**
  96272. * Get the friendly name associated with the input class.
  96273. * @returns the input friendly name
  96274. */
  96275. getSimpleName(): string;
  96276. }
  96277. }
  96278. declare module BABYLON {
  96279. /**
  96280. * Default Inputs manager for the FreeCamera.
  96281. * It groups all the default supported inputs for ease of use.
  96282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96283. */
  96284. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96285. /**
  96286. * @hidden
  96287. */
  96288. _mouseInput: Nullable<FreeCameraMouseInput>;
  96289. /**
  96290. * Instantiates a new FreeCameraInputsManager.
  96291. * @param camera Defines the camera the inputs belong to
  96292. */
  96293. constructor(camera: FreeCamera);
  96294. /**
  96295. * Add keyboard input support to the input manager.
  96296. * @returns the current input manager
  96297. */
  96298. addKeyboard(): FreeCameraInputsManager;
  96299. /**
  96300. * Add mouse input support to the input manager.
  96301. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96302. * @returns the current input manager
  96303. */
  96304. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96305. /**
  96306. * Removes the mouse input support from the manager
  96307. * @returns the current input manager
  96308. */
  96309. removeMouse(): FreeCameraInputsManager;
  96310. /**
  96311. * Add touch input support to the input manager.
  96312. * @returns the current input manager
  96313. */
  96314. addTouch(): FreeCameraInputsManager;
  96315. /**
  96316. * Remove all attached input methods from a camera
  96317. */
  96318. clear(): void;
  96319. }
  96320. }
  96321. declare module BABYLON {
  96322. /**
  96323. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96324. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96326. */
  96327. export class FreeCamera extends TargetCamera {
  96328. /**
  96329. * Define the collision ellipsoid of the camera.
  96330. * This is helpful to simulate a camera body like the player body around the camera
  96331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96332. */
  96333. ellipsoid: Vector3;
  96334. /**
  96335. * Define an offset for the position of the ellipsoid around the camera.
  96336. * This can be helpful to determine the center of the body near the gravity center of the body
  96337. * instead of its head.
  96338. */
  96339. ellipsoidOffset: Vector3;
  96340. /**
  96341. * Enable or disable collisions of the camera with the rest of the scene objects.
  96342. */
  96343. checkCollisions: boolean;
  96344. /**
  96345. * Enable or disable gravity on the camera.
  96346. */
  96347. applyGravity: boolean;
  96348. /**
  96349. * Define the input manager associated to the camera.
  96350. */
  96351. inputs: FreeCameraInputsManager;
  96352. /**
  96353. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96354. * Higher values reduce sensitivity.
  96355. */
  96356. get angularSensibility(): number;
  96357. /**
  96358. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96359. * Higher values reduce sensitivity.
  96360. */
  96361. set angularSensibility(value: number);
  96362. /**
  96363. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96364. */
  96365. get keysUp(): number[];
  96366. set keysUp(value: number[]);
  96367. /**
  96368. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96369. */
  96370. get keysUpward(): number[];
  96371. set keysUpward(value: number[]);
  96372. /**
  96373. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96374. */
  96375. get keysDown(): number[];
  96376. set keysDown(value: number[]);
  96377. /**
  96378. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96379. */
  96380. get keysDownward(): number[];
  96381. set keysDownward(value: number[]);
  96382. /**
  96383. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96384. */
  96385. get keysLeft(): number[];
  96386. set keysLeft(value: number[]);
  96387. /**
  96388. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96389. */
  96390. get keysRight(): number[];
  96391. set keysRight(value: number[]);
  96392. /**
  96393. * Event raised when the camera collide with a mesh in the scene.
  96394. */
  96395. onCollide: (collidedMesh: AbstractMesh) => void;
  96396. private _collider;
  96397. private _needMoveForGravity;
  96398. private _oldPosition;
  96399. private _diffPosition;
  96400. private _newPosition;
  96401. /** @hidden */
  96402. _localDirection: Vector3;
  96403. /** @hidden */
  96404. _transformedDirection: Vector3;
  96405. /**
  96406. * Instantiates a Free Camera.
  96407. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96408. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96410. * @param name Define the name of the camera in the scene
  96411. * @param position Define the start position of the camera in the scene
  96412. * @param scene Define the scene the camera belongs to
  96413. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96414. */
  96415. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96416. /**
  96417. * Attached controls to the current camera.
  96418. * @param element Defines the element the controls should be listened from
  96419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96420. */
  96421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96422. /**
  96423. * Detach the current controls from the camera.
  96424. * The camera will stop reacting to inputs.
  96425. * @param element Defines the element to stop listening the inputs from
  96426. */
  96427. detachControl(element: HTMLElement): void;
  96428. private _collisionMask;
  96429. /**
  96430. * Define a collision mask to limit the list of object the camera can collide with
  96431. */
  96432. get collisionMask(): number;
  96433. set collisionMask(mask: number);
  96434. /** @hidden */
  96435. _collideWithWorld(displacement: Vector3): void;
  96436. private _onCollisionPositionChange;
  96437. /** @hidden */
  96438. _checkInputs(): void;
  96439. /** @hidden */
  96440. _decideIfNeedsToMove(): boolean;
  96441. /** @hidden */
  96442. _updatePosition(): void;
  96443. /**
  96444. * Destroy the camera and release the current resources hold by it.
  96445. */
  96446. dispose(): void;
  96447. /**
  96448. * Gets the current object class name.
  96449. * @return the class name
  96450. */
  96451. getClassName(): string;
  96452. }
  96453. }
  96454. declare module BABYLON {
  96455. /**
  96456. * Represents a gamepad control stick position
  96457. */
  96458. export class StickValues {
  96459. /**
  96460. * The x component of the control stick
  96461. */
  96462. x: number;
  96463. /**
  96464. * The y component of the control stick
  96465. */
  96466. y: number;
  96467. /**
  96468. * Initializes the gamepad x and y control stick values
  96469. * @param x The x component of the gamepad control stick value
  96470. * @param y The y component of the gamepad control stick value
  96471. */
  96472. constructor(
  96473. /**
  96474. * The x component of the control stick
  96475. */
  96476. x: number,
  96477. /**
  96478. * The y component of the control stick
  96479. */
  96480. y: number);
  96481. }
  96482. /**
  96483. * An interface which manages callbacks for gamepad button changes
  96484. */
  96485. export interface GamepadButtonChanges {
  96486. /**
  96487. * Called when a gamepad has been changed
  96488. */
  96489. changed: boolean;
  96490. /**
  96491. * Called when a gamepad press event has been triggered
  96492. */
  96493. pressChanged: boolean;
  96494. /**
  96495. * Called when a touch event has been triggered
  96496. */
  96497. touchChanged: boolean;
  96498. /**
  96499. * Called when a value has changed
  96500. */
  96501. valueChanged: boolean;
  96502. }
  96503. /**
  96504. * Represents a gamepad
  96505. */
  96506. export class Gamepad {
  96507. /**
  96508. * The id of the gamepad
  96509. */
  96510. id: string;
  96511. /**
  96512. * The index of the gamepad
  96513. */
  96514. index: number;
  96515. /**
  96516. * The browser gamepad
  96517. */
  96518. browserGamepad: any;
  96519. /**
  96520. * Specifies what type of gamepad this represents
  96521. */
  96522. type: number;
  96523. private _leftStick;
  96524. private _rightStick;
  96525. /** @hidden */
  96526. _isConnected: boolean;
  96527. private _leftStickAxisX;
  96528. private _leftStickAxisY;
  96529. private _rightStickAxisX;
  96530. private _rightStickAxisY;
  96531. /**
  96532. * Triggered when the left control stick has been changed
  96533. */
  96534. private _onleftstickchanged;
  96535. /**
  96536. * Triggered when the right control stick has been changed
  96537. */
  96538. private _onrightstickchanged;
  96539. /**
  96540. * Represents a gamepad controller
  96541. */
  96542. static GAMEPAD: number;
  96543. /**
  96544. * Represents a generic controller
  96545. */
  96546. static GENERIC: number;
  96547. /**
  96548. * Represents an XBox controller
  96549. */
  96550. static XBOX: number;
  96551. /**
  96552. * Represents a pose-enabled controller
  96553. */
  96554. static POSE_ENABLED: number;
  96555. /**
  96556. * Represents an Dual Shock controller
  96557. */
  96558. static DUALSHOCK: number;
  96559. /**
  96560. * Specifies whether the left control stick should be Y-inverted
  96561. */
  96562. protected _invertLeftStickY: boolean;
  96563. /**
  96564. * Specifies if the gamepad has been connected
  96565. */
  96566. get isConnected(): boolean;
  96567. /**
  96568. * Initializes the gamepad
  96569. * @param id The id of the gamepad
  96570. * @param index The index of the gamepad
  96571. * @param browserGamepad The browser gamepad
  96572. * @param leftStickX The x component of the left joystick
  96573. * @param leftStickY The y component of the left joystick
  96574. * @param rightStickX The x component of the right joystick
  96575. * @param rightStickY The y component of the right joystick
  96576. */
  96577. constructor(
  96578. /**
  96579. * The id of the gamepad
  96580. */
  96581. id: string,
  96582. /**
  96583. * The index of the gamepad
  96584. */
  96585. index: number,
  96586. /**
  96587. * The browser gamepad
  96588. */
  96589. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96590. /**
  96591. * Callback triggered when the left joystick has changed
  96592. * @param callback
  96593. */
  96594. onleftstickchanged(callback: (values: StickValues) => void): void;
  96595. /**
  96596. * Callback triggered when the right joystick has changed
  96597. * @param callback
  96598. */
  96599. onrightstickchanged(callback: (values: StickValues) => void): void;
  96600. /**
  96601. * Gets the left joystick
  96602. */
  96603. get leftStick(): StickValues;
  96604. /**
  96605. * Sets the left joystick values
  96606. */
  96607. set leftStick(newValues: StickValues);
  96608. /**
  96609. * Gets the right joystick
  96610. */
  96611. get rightStick(): StickValues;
  96612. /**
  96613. * Sets the right joystick value
  96614. */
  96615. set rightStick(newValues: StickValues);
  96616. /**
  96617. * Updates the gamepad joystick positions
  96618. */
  96619. update(): void;
  96620. /**
  96621. * Disposes the gamepad
  96622. */
  96623. dispose(): void;
  96624. }
  96625. /**
  96626. * Represents a generic gamepad
  96627. */
  96628. export class GenericPad extends Gamepad {
  96629. private _buttons;
  96630. private _onbuttondown;
  96631. private _onbuttonup;
  96632. /**
  96633. * Observable triggered when a button has been pressed
  96634. */
  96635. onButtonDownObservable: Observable<number>;
  96636. /**
  96637. * Observable triggered when a button has been released
  96638. */
  96639. onButtonUpObservable: Observable<number>;
  96640. /**
  96641. * Callback triggered when a button has been pressed
  96642. * @param callback Called when a button has been pressed
  96643. */
  96644. onbuttondown(callback: (buttonPressed: number) => void): void;
  96645. /**
  96646. * Callback triggered when a button has been released
  96647. * @param callback Called when a button has been released
  96648. */
  96649. onbuttonup(callback: (buttonReleased: number) => void): void;
  96650. /**
  96651. * Initializes the generic gamepad
  96652. * @param id The id of the generic gamepad
  96653. * @param index The index of the generic gamepad
  96654. * @param browserGamepad The browser gamepad
  96655. */
  96656. constructor(id: string, index: number, browserGamepad: any);
  96657. private _setButtonValue;
  96658. /**
  96659. * Updates the generic gamepad
  96660. */
  96661. update(): void;
  96662. /**
  96663. * Disposes the generic gamepad
  96664. */
  96665. dispose(): void;
  96666. }
  96667. }
  96668. declare module BABYLON {
  96669. /**
  96670. * Defines the types of pose enabled controllers that are supported
  96671. */
  96672. export enum PoseEnabledControllerType {
  96673. /**
  96674. * HTC Vive
  96675. */
  96676. VIVE = 0,
  96677. /**
  96678. * Oculus Rift
  96679. */
  96680. OCULUS = 1,
  96681. /**
  96682. * Windows mixed reality
  96683. */
  96684. WINDOWS = 2,
  96685. /**
  96686. * Samsung gear VR
  96687. */
  96688. GEAR_VR = 3,
  96689. /**
  96690. * Google Daydream
  96691. */
  96692. DAYDREAM = 4,
  96693. /**
  96694. * Generic
  96695. */
  96696. GENERIC = 5
  96697. }
  96698. /**
  96699. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96700. */
  96701. export interface MutableGamepadButton {
  96702. /**
  96703. * Value of the button/trigger
  96704. */
  96705. value: number;
  96706. /**
  96707. * If the button/trigger is currently touched
  96708. */
  96709. touched: boolean;
  96710. /**
  96711. * If the button/trigger is currently pressed
  96712. */
  96713. pressed: boolean;
  96714. }
  96715. /**
  96716. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96717. * @hidden
  96718. */
  96719. export interface ExtendedGamepadButton extends GamepadButton {
  96720. /**
  96721. * If the button/trigger is currently pressed
  96722. */
  96723. readonly pressed: boolean;
  96724. /**
  96725. * If the button/trigger is currently touched
  96726. */
  96727. readonly touched: boolean;
  96728. /**
  96729. * Value of the button/trigger
  96730. */
  96731. readonly value: number;
  96732. }
  96733. /** @hidden */
  96734. export interface _GamePadFactory {
  96735. /**
  96736. * Returns whether or not the current gamepad can be created for this type of controller.
  96737. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96738. * @returns true if it can be created, otherwise false
  96739. */
  96740. canCreate(gamepadInfo: any): boolean;
  96741. /**
  96742. * Creates a new instance of the Gamepad.
  96743. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96744. * @returns the new gamepad instance
  96745. */
  96746. create(gamepadInfo: any): Gamepad;
  96747. }
  96748. /**
  96749. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96750. */
  96751. export class PoseEnabledControllerHelper {
  96752. /** @hidden */
  96753. static _ControllerFactories: _GamePadFactory[];
  96754. /** @hidden */
  96755. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96756. /**
  96757. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96758. * @param vrGamepad the gamepad to initialized
  96759. * @returns a vr controller of the type the gamepad identified as
  96760. */
  96761. static InitiateController(vrGamepad: any): Gamepad;
  96762. }
  96763. /**
  96764. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96765. */
  96766. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96767. /**
  96768. * If the controller is used in a webXR session
  96769. */
  96770. isXR: boolean;
  96771. private _deviceRoomPosition;
  96772. private _deviceRoomRotationQuaternion;
  96773. /**
  96774. * The device position in babylon space
  96775. */
  96776. devicePosition: Vector3;
  96777. /**
  96778. * The device rotation in babylon space
  96779. */
  96780. deviceRotationQuaternion: Quaternion;
  96781. /**
  96782. * The scale factor of the device in babylon space
  96783. */
  96784. deviceScaleFactor: number;
  96785. /**
  96786. * (Likely devicePosition should be used instead) The device position in its room space
  96787. */
  96788. position: Vector3;
  96789. /**
  96790. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96791. */
  96792. rotationQuaternion: Quaternion;
  96793. /**
  96794. * The type of controller (Eg. Windows mixed reality)
  96795. */
  96796. controllerType: PoseEnabledControllerType;
  96797. protected _calculatedPosition: Vector3;
  96798. private _calculatedRotation;
  96799. /**
  96800. * The raw pose from the device
  96801. */
  96802. rawPose: DevicePose;
  96803. private _trackPosition;
  96804. private _maxRotationDistFromHeadset;
  96805. private _draggedRoomRotation;
  96806. /**
  96807. * @hidden
  96808. */
  96809. _disableTrackPosition(fixedPosition: Vector3): void;
  96810. /**
  96811. * Internal, the mesh attached to the controller
  96812. * @hidden
  96813. */
  96814. _mesh: Nullable<AbstractMesh>;
  96815. private _poseControlledCamera;
  96816. private _leftHandSystemQuaternion;
  96817. /**
  96818. * Internal, matrix used to convert room space to babylon space
  96819. * @hidden
  96820. */
  96821. _deviceToWorld: Matrix;
  96822. /**
  96823. * Node to be used when casting a ray from the controller
  96824. * @hidden
  96825. */
  96826. _pointingPoseNode: Nullable<TransformNode>;
  96827. /**
  96828. * Name of the child mesh that can be used to cast a ray from the controller
  96829. */
  96830. static readonly POINTING_POSE: string;
  96831. /**
  96832. * Creates a new PoseEnabledController from a gamepad
  96833. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96834. */
  96835. constructor(browserGamepad: any);
  96836. private _workingMatrix;
  96837. /**
  96838. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96839. */
  96840. update(): void;
  96841. /**
  96842. * Updates only the pose device and mesh without doing any button event checking
  96843. */
  96844. protected _updatePoseAndMesh(): void;
  96845. /**
  96846. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96847. * @param poseData raw pose fromthe device
  96848. */
  96849. updateFromDevice(poseData: DevicePose): void;
  96850. /**
  96851. * @hidden
  96852. */
  96853. _meshAttachedObservable: Observable<AbstractMesh>;
  96854. /**
  96855. * Attaches a mesh to the controller
  96856. * @param mesh the mesh to be attached
  96857. */
  96858. attachToMesh(mesh: AbstractMesh): void;
  96859. /**
  96860. * Attaches the controllers mesh to a camera
  96861. * @param camera the camera the mesh should be attached to
  96862. */
  96863. attachToPoseControlledCamera(camera: TargetCamera): void;
  96864. /**
  96865. * Disposes of the controller
  96866. */
  96867. dispose(): void;
  96868. /**
  96869. * The mesh that is attached to the controller
  96870. */
  96871. get mesh(): Nullable<AbstractMesh>;
  96872. /**
  96873. * Gets the ray of the controller in the direction the controller is pointing
  96874. * @param length the length the resulting ray should be
  96875. * @returns a ray in the direction the controller is pointing
  96876. */
  96877. getForwardRay(length?: number): Ray;
  96878. }
  96879. }
  96880. declare module BABYLON {
  96881. /**
  96882. * Defines the WebVRController object that represents controllers tracked in 3D space
  96883. */
  96884. export abstract class WebVRController extends PoseEnabledController {
  96885. /**
  96886. * Internal, the default controller model for the controller
  96887. */
  96888. protected _defaultModel: Nullable<AbstractMesh>;
  96889. /**
  96890. * Fired when the trigger state has changed
  96891. */
  96892. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96893. /**
  96894. * Fired when the main button state has changed
  96895. */
  96896. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96897. /**
  96898. * Fired when the secondary button state has changed
  96899. */
  96900. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96901. /**
  96902. * Fired when the pad state has changed
  96903. */
  96904. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96905. /**
  96906. * Fired when controllers stick values have changed
  96907. */
  96908. onPadValuesChangedObservable: Observable<StickValues>;
  96909. /**
  96910. * Array of button availible on the controller
  96911. */
  96912. protected _buttons: Array<MutableGamepadButton>;
  96913. private _onButtonStateChange;
  96914. /**
  96915. * Fired when a controller button's state has changed
  96916. * @param callback the callback containing the button that was modified
  96917. */
  96918. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96919. /**
  96920. * X and Y axis corresponding to the controllers joystick
  96921. */
  96922. pad: StickValues;
  96923. /**
  96924. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96925. */
  96926. hand: string;
  96927. /**
  96928. * The default controller model for the controller
  96929. */
  96930. get defaultModel(): Nullable<AbstractMesh>;
  96931. /**
  96932. * Creates a new WebVRController from a gamepad
  96933. * @param vrGamepad the gamepad that the WebVRController should be created from
  96934. */
  96935. constructor(vrGamepad: any);
  96936. /**
  96937. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  96938. */
  96939. update(): void;
  96940. /**
  96941. * Function to be called when a button is modified
  96942. */
  96943. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96944. /**
  96945. * Loads a mesh and attaches it to the controller
  96946. * @param scene the scene the mesh should be added to
  96947. * @param meshLoaded callback for when the mesh has been loaded
  96948. */
  96949. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96950. private _setButtonValue;
  96951. private _changes;
  96952. private _checkChanges;
  96953. /**
  96954. * Disposes of th webVRCOntroller
  96955. */
  96956. dispose(): void;
  96957. }
  96958. }
  96959. declare module BABYLON {
  96960. /**
  96961. * The HemisphericLight simulates the ambient environment light,
  96962. * so the passed direction is the light reflection direction, not the incoming direction.
  96963. */
  96964. export class HemisphericLight extends Light {
  96965. /**
  96966. * The groundColor is the light in the opposite direction to the one specified during creation.
  96967. * 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.
  96968. */
  96969. groundColor: Color3;
  96970. /**
  96971. * The light reflection direction, not the incoming direction.
  96972. */
  96973. direction: Vector3;
  96974. /**
  96975. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  96976. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  96977. * The HemisphericLight can't cast shadows.
  96978. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96979. * @param name The friendly name of the light
  96980. * @param direction The direction of the light reflection
  96981. * @param scene The scene the light belongs to
  96982. */
  96983. constructor(name: string, direction: Vector3, scene: Scene);
  96984. protected _buildUniformLayout(): void;
  96985. /**
  96986. * Returns the string "HemisphericLight".
  96987. * @return The class name
  96988. */
  96989. getClassName(): string;
  96990. /**
  96991. * Sets the HemisphericLight direction towards the passed target (Vector3).
  96992. * Returns the updated direction.
  96993. * @param target The target the direction should point to
  96994. * @return The computed direction
  96995. */
  96996. setDirectionToTarget(target: Vector3): Vector3;
  96997. /**
  96998. * Returns the shadow generator associated to the light.
  96999. * @returns Always null for hemispheric lights because it does not support shadows.
  97000. */
  97001. getShadowGenerator(): Nullable<IShadowGenerator>;
  97002. /**
  97003. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97004. * @param effect The effect to update
  97005. * @param lightIndex The index of the light in the effect to update
  97006. * @returns The hemispheric light
  97007. */
  97008. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97009. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97010. /**
  97011. * Computes the world matrix of the node
  97012. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97013. * @param useWasUpdatedFlag defines a reserved property
  97014. * @returns the world matrix
  97015. */
  97016. computeWorldMatrix(): Matrix;
  97017. /**
  97018. * Returns the integer 3.
  97019. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97020. */
  97021. getTypeID(): number;
  97022. /**
  97023. * Prepares the list of defines specific to the light type.
  97024. * @param defines the list of defines
  97025. * @param lightIndex defines the index of the light for the effect
  97026. */
  97027. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97028. }
  97029. }
  97030. declare module BABYLON {
  97031. /** @hidden */
  97032. export var vrMultiviewToSingleviewPixelShader: {
  97033. name: string;
  97034. shader: string;
  97035. };
  97036. }
  97037. declare module BABYLON {
  97038. /**
  97039. * Renders to multiple views with a single draw call
  97040. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97041. */
  97042. export class MultiviewRenderTarget extends RenderTargetTexture {
  97043. /**
  97044. * Creates a multiview render target
  97045. * @param scene scene used with the render target
  97046. * @param size the size of the render target (used for each view)
  97047. */
  97048. constructor(scene: Scene, size?: number | {
  97049. width: number;
  97050. height: number;
  97051. } | {
  97052. ratio: number;
  97053. });
  97054. /**
  97055. * @hidden
  97056. * @param faceIndex the face index, if its a cube texture
  97057. */
  97058. _bindFrameBuffer(faceIndex?: number): void;
  97059. /**
  97060. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97061. * @returns the view count
  97062. */
  97063. getViewCount(): number;
  97064. }
  97065. }
  97066. declare module BABYLON {
  97067. interface Engine {
  97068. /**
  97069. * Creates a new multiview render target
  97070. * @param width defines the width of the texture
  97071. * @param height defines the height of the texture
  97072. * @returns the created multiview texture
  97073. */
  97074. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97075. /**
  97076. * Binds a multiview framebuffer to be drawn to
  97077. * @param multiviewTexture texture to bind
  97078. */
  97079. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97080. }
  97081. interface Camera {
  97082. /**
  97083. * @hidden
  97084. * 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)
  97085. */
  97086. _useMultiviewToSingleView: boolean;
  97087. /**
  97088. * @hidden
  97089. * 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)
  97090. */
  97091. _multiviewTexture: Nullable<RenderTargetTexture>;
  97092. /**
  97093. * @hidden
  97094. * ensures the multiview texture of the camera exists and has the specified width/height
  97095. * @param width height to set on the multiview texture
  97096. * @param height width to set on the multiview texture
  97097. */
  97098. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97099. }
  97100. interface Scene {
  97101. /** @hidden */
  97102. _transformMatrixR: Matrix;
  97103. /** @hidden */
  97104. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97105. /** @hidden */
  97106. _createMultiviewUbo(): void;
  97107. /** @hidden */
  97108. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97109. /** @hidden */
  97110. _renderMultiviewToSingleView(camera: Camera): void;
  97111. }
  97112. }
  97113. declare module BABYLON {
  97114. /**
  97115. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97116. * This will not be used for webXR as it supports displaying texture arrays directly
  97117. */
  97118. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97119. /**
  97120. * Initializes a VRMultiviewToSingleview
  97121. * @param name name of the post process
  97122. * @param camera camera to be applied to
  97123. * @param scaleFactor scaling factor to the size of the output texture
  97124. */
  97125. constructor(name: string, camera: Camera, scaleFactor: number);
  97126. }
  97127. }
  97128. declare module BABYLON {
  97129. /**
  97130. * Interface used to define additional presentation attributes
  97131. */
  97132. export interface IVRPresentationAttributes {
  97133. /**
  97134. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97135. */
  97136. highRefreshRate: boolean;
  97137. /**
  97138. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97139. */
  97140. foveationLevel: number;
  97141. }
  97142. interface Engine {
  97143. /** @hidden */
  97144. _vrDisplay: any;
  97145. /** @hidden */
  97146. _vrSupported: boolean;
  97147. /** @hidden */
  97148. _oldSize: Size;
  97149. /** @hidden */
  97150. _oldHardwareScaleFactor: number;
  97151. /** @hidden */
  97152. _vrExclusivePointerMode: boolean;
  97153. /** @hidden */
  97154. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97155. /** @hidden */
  97156. _onVRDisplayPointerRestricted: () => void;
  97157. /** @hidden */
  97158. _onVRDisplayPointerUnrestricted: () => void;
  97159. /** @hidden */
  97160. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97161. /** @hidden */
  97162. _onVrDisplayDisconnect: Nullable<() => void>;
  97163. /** @hidden */
  97164. _onVrDisplayPresentChange: Nullable<() => void>;
  97165. /**
  97166. * Observable signaled when VR display mode changes
  97167. */
  97168. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97169. /**
  97170. * Observable signaled when VR request present is complete
  97171. */
  97172. onVRRequestPresentComplete: Observable<boolean>;
  97173. /**
  97174. * Observable signaled when VR request present starts
  97175. */
  97176. onVRRequestPresentStart: Observable<Engine>;
  97177. /**
  97178. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97179. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97180. */
  97181. isInVRExclusivePointerMode: boolean;
  97182. /**
  97183. * Gets a boolean indicating if a webVR device was detected
  97184. * @returns true if a webVR device was detected
  97185. */
  97186. isVRDevicePresent(): boolean;
  97187. /**
  97188. * Gets the current webVR device
  97189. * @returns the current webVR device (or null)
  97190. */
  97191. getVRDevice(): any;
  97192. /**
  97193. * Initializes a webVR display and starts listening to display change events
  97194. * The onVRDisplayChangedObservable will be notified upon these changes
  97195. * @returns A promise containing a VRDisplay and if vr is supported
  97196. */
  97197. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97198. /** @hidden */
  97199. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97200. /**
  97201. * Gets or sets the presentation attributes used to configure VR rendering
  97202. */
  97203. vrPresentationAttributes?: IVRPresentationAttributes;
  97204. /**
  97205. * Call this function to switch to webVR mode
  97206. * Will do nothing if webVR is not supported or if there is no webVR device
  97207. * @param options the webvr options provided to the camera. mainly used for multiview
  97208. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97209. */
  97210. enableVR(options: WebVROptions): void;
  97211. /** @hidden */
  97212. _onVRFullScreenTriggered(): void;
  97213. }
  97214. }
  97215. declare module BABYLON {
  97216. /**
  97217. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97218. * IMPORTANT!! The data is right-hand data.
  97219. * @export
  97220. * @interface DevicePose
  97221. */
  97222. export interface DevicePose {
  97223. /**
  97224. * The position of the device, values in array are [x,y,z].
  97225. */
  97226. readonly position: Nullable<Float32Array>;
  97227. /**
  97228. * The linearVelocity of the device, values in array are [x,y,z].
  97229. */
  97230. readonly linearVelocity: Nullable<Float32Array>;
  97231. /**
  97232. * The linearAcceleration of the device, values in array are [x,y,z].
  97233. */
  97234. readonly linearAcceleration: Nullable<Float32Array>;
  97235. /**
  97236. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97237. */
  97238. readonly orientation: Nullable<Float32Array>;
  97239. /**
  97240. * The angularVelocity of the device, values in array are [x,y,z].
  97241. */
  97242. readonly angularVelocity: Nullable<Float32Array>;
  97243. /**
  97244. * The angularAcceleration of the device, values in array are [x,y,z].
  97245. */
  97246. readonly angularAcceleration: Nullable<Float32Array>;
  97247. }
  97248. /**
  97249. * Interface representing a pose controlled object in Babylon.
  97250. * A pose controlled object has both regular pose values as well as pose values
  97251. * from an external device such as a VR head mounted display
  97252. */
  97253. export interface PoseControlled {
  97254. /**
  97255. * The position of the object in babylon space.
  97256. */
  97257. position: Vector3;
  97258. /**
  97259. * The rotation quaternion of the object in babylon space.
  97260. */
  97261. rotationQuaternion: Quaternion;
  97262. /**
  97263. * The position of the device in babylon space.
  97264. */
  97265. devicePosition?: Vector3;
  97266. /**
  97267. * The rotation quaternion of the device in babylon space.
  97268. */
  97269. deviceRotationQuaternion: Quaternion;
  97270. /**
  97271. * The raw pose coming from the device.
  97272. */
  97273. rawPose: Nullable<DevicePose>;
  97274. /**
  97275. * The scale of the device to be used when translating from device space to babylon space.
  97276. */
  97277. deviceScaleFactor: number;
  97278. /**
  97279. * Updates the poseControlled values based on the input device pose.
  97280. * @param poseData the pose data to update the object with
  97281. */
  97282. updateFromDevice(poseData: DevicePose): void;
  97283. }
  97284. /**
  97285. * Set of options to customize the webVRCamera
  97286. */
  97287. export interface WebVROptions {
  97288. /**
  97289. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97290. */
  97291. trackPosition?: boolean;
  97292. /**
  97293. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97294. */
  97295. positionScale?: number;
  97296. /**
  97297. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97298. */
  97299. displayName?: string;
  97300. /**
  97301. * Should the native controller meshes be initialized. (default: true)
  97302. */
  97303. controllerMeshes?: boolean;
  97304. /**
  97305. * Creating a default HemiLight only on controllers. (default: true)
  97306. */
  97307. defaultLightingOnControllers?: boolean;
  97308. /**
  97309. * If you don't want to use the default VR button of the helper. (default: false)
  97310. */
  97311. useCustomVRButton?: boolean;
  97312. /**
  97313. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97314. */
  97315. customVRButton?: HTMLButtonElement;
  97316. /**
  97317. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97318. */
  97319. rayLength?: number;
  97320. /**
  97321. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97322. */
  97323. defaultHeight?: number;
  97324. /**
  97325. * If multiview should be used if availible (default: false)
  97326. */
  97327. useMultiview?: boolean;
  97328. }
  97329. /**
  97330. * This represents a WebVR camera.
  97331. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97332. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97333. */
  97334. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97335. private webVROptions;
  97336. /**
  97337. * @hidden
  97338. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97339. */
  97340. _vrDevice: any;
  97341. /**
  97342. * The rawPose of the vrDevice.
  97343. */
  97344. rawPose: Nullable<DevicePose>;
  97345. private _onVREnabled;
  97346. private _specsVersion;
  97347. private _attached;
  97348. private _frameData;
  97349. protected _descendants: Array<Node>;
  97350. private _deviceRoomPosition;
  97351. /** @hidden */
  97352. _deviceRoomRotationQuaternion: Quaternion;
  97353. private _standingMatrix;
  97354. /**
  97355. * Represents device position in babylon space.
  97356. */
  97357. devicePosition: Vector3;
  97358. /**
  97359. * Represents device rotation in babylon space.
  97360. */
  97361. deviceRotationQuaternion: Quaternion;
  97362. /**
  97363. * The scale of the device to be used when translating from device space to babylon space.
  97364. */
  97365. deviceScaleFactor: number;
  97366. private _deviceToWorld;
  97367. private _worldToDevice;
  97368. /**
  97369. * References to the webVR controllers for the vrDevice.
  97370. */
  97371. controllers: Array<WebVRController>;
  97372. /**
  97373. * Emits an event when a controller is attached.
  97374. */
  97375. onControllersAttachedObservable: Observable<WebVRController[]>;
  97376. /**
  97377. * Emits an event when a controller's mesh has been loaded;
  97378. */
  97379. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97380. /**
  97381. * Emits an event when the HMD's pose has been updated.
  97382. */
  97383. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97384. private _poseSet;
  97385. /**
  97386. * If the rig cameras be used as parent instead of this camera.
  97387. */
  97388. rigParenting: boolean;
  97389. private _lightOnControllers;
  97390. private _defaultHeight?;
  97391. /**
  97392. * Instantiates a WebVRFreeCamera.
  97393. * @param name The name of the WebVRFreeCamera
  97394. * @param position The starting anchor position for the camera
  97395. * @param scene The scene the camera belongs to
  97396. * @param webVROptions a set of customizable options for the webVRCamera
  97397. */
  97398. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97399. /**
  97400. * Gets the device distance from the ground in meters.
  97401. * @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.
  97402. */
  97403. deviceDistanceToRoomGround(): number;
  97404. /**
  97405. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97406. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97407. */
  97408. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97409. /**
  97410. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97411. * @returns A promise with a boolean set to if the standing matrix is supported.
  97412. */
  97413. useStandingMatrixAsync(): Promise<boolean>;
  97414. /**
  97415. * Disposes the camera
  97416. */
  97417. dispose(): void;
  97418. /**
  97419. * Gets a vrController by name.
  97420. * @param name The name of the controller to retreive
  97421. * @returns the controller matching the name specified or null if not found
  97422. */
  97423. getControllerByName(name: string): Nullable<WebVRController>;
  97424. private _leftController;
  97425. /**
  97426. * The controller corresponding to the users left hand.
  97427. */
  97428. get leftController(): Nullable<WebVRController>;
  97429. private _rightController;
  97430. /**
  97431. * The controller corresponding to the users right hand.
  97432. */
  97433. get rightController(): Nullable<WebVRController>;
  97434. /**
  97435. * Casts a ray forward from the vrCamera's gaze.
  97436. * @param length Length of the ray (default: 100)
  97437. * @returns the ray corresponding to the gaze
  97438. */
  97439. getForwardRay(length?: number): Ray;
  97440. /**
  97441. * @hidden
  97442. * Updates the camera based on device's frame data
  97443. */
  97444. _checkInputs(): void;
  97445. /**
  97446. * Updates the poseControlled values based on the input device pose.
  97447. * @param poseData Pose coming from the device
  97448. */
  97449. updateFromDevice(poseData: DevicePose): void;
  97450. private _htmlElementAttached;
  97451. private _detachIfAttached;
  97452. /**
  97453. * WebVR's attach control will start broadcasting frames to the device.
  97454. * Note that in certain browsers (chrome for example) this function must be called
  97455. * within a user-interaction callback. Example:
  97456. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97457. *
  97458. * @param element html element to attach the vrDevice to
  97459. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97460. */
  97461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97462. /**
  97463. * Detaches the camera from the html element and disables VR
  97464. *
  97465. * @param element html element to detach from
  97466. */
  97467. detachControl(element: HTMLElement): void;
  97468. /**
  97469. * @returns the name of this class
  97470. */
  97471. getClassName(): string;
  97472. /**
  97473. * Calls resetPose on the vrDisplay
  97474. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97475. */
  97476. resetToCurrentRotation(): void;
  97477. /**
  97478. * @hidden
  97479. * Updates the rig cameras (left and right eye)
  97480. */
  97481. _updateRigCameras(): void;
  97482. private _workingVector;
  97483. private _oneVector;
  97484. private _workingMatrix;
  97485. private updateCacheCalled;
  97486. private _correctPositionIfNotTrackPosition;
  97487. /**
  97488. * @hidden
  97489. * Updates the cached values of the camera
  97490. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97491. */
  97492. _updateCache(ignoreParentClass?: boolean): void;
  97493. /**
  97494. * @hidden
  97495. * Get current device position in babylon world
  97496. */
  97497. _computeDevicePosition(): void;
  97498. /**
  97499. * Updates the current device position and rotation in the babylon world
  97500. */
  97501. update(): void;
  97502. /**
  97503. * @hidden
  97504. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97505. * @returns an identity matrix
  97506. */
  97507. _getViewMatrix(): Matrix;
  97508. private _tmpMatrix;
  97509. /**
  97510. * This function is called by the two RIG cameras.
  97511. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97512. * @hidden
  97513. */
  97514. _getWebVRViewMatrix(): Matrix;
  97515. /** @hidden */
  97516. _getWebVRProjectionMatrix(): Matrix;
  97517. private _onGamepadConnectedObserver;
  97518. private _onGamepadDisconnectedObserver;
  97519. private _updateCacheWhenTrackingDisabledObserver;
  97520. /**
  97521. * Initializes the controllers and their meshes
  97522. */
  97523. initControllers(): void;
  97524. }
  97525. }
  97526. declare module BABYLON {
  97527. /**
  97528. * "Static Class" containing the most commonly used helper while dealing with material for
  97529. * rendering purpose.
  97530. *
  97531. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97532. *
  97533. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97534. */
  97535. export class MaterialHelper {
  97536. /**
  97537. * Bind the current view position to an effect.
  97538. * @param effect The effect to be bound
  97539. * @param scene The scene the eyes position is used from
  97540. * @param variableName name of the shader variable that will hold the eye position
  97541. */
  97542. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97543. /**
  97544. * Helps preparing the defines values about the UVs in used in the effect.
  97545. * UVs are shared as much as we can accross channels in the shaders.
  97546. * @param texture The texture we are preparing the UVs for
  97547. * @param defines The defines to update
  97548. * @param key The channel key "diffuse", "specular"... used in the shader
  97549. */
  97550. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97551. /**
  97552. * Binds a texture matrix value to its corrsponding uniform
  97553. * @param texture The texture to bind the matrix for
  97554. * @param uniformBuffer The uniform buffer receivin the data
  97555. * @param key The channel key "diffuse", "specular"... used in the shader
  97556. */
  97557. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97558. /**
  97559. * Gets the current status of the fog (should it be enabled?)
  97560. * @param mesh defines the mesh to evaluate for fog support
  97561. * @param scene defines the hosting scene
  97562. * @returns true if fog must be enabled
  97563. */
  97564. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97565. /**
  97566. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97567. * @param mesh defines the current mesh
  97568. * @param scene defines the current scene
  97569. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97570. * @param pointsCloud defines if point cloud rendering has to be turned on
  97571. * @param fogEnabled defines if fog has to be turned on
  97572. * @param alphaTest defines if alpha testing has to be turned on
  97573. * @param defines defines the current list of defines
  97574. */
  97575. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97576. /**
  97577. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97578. * @param scene defines the current scene
  97579. * @param engine defines the current engine
  97580. * @param defines specifies the list of active defines
  97581. * @param useInstances defines if instances have to be turned on
  97582. * @param useClipPlane defines if clip plane have to be turned on
  97583. * @param useInstances defines if instances have to be turned on
  97584. * @param useThinInstances defines if thin instances have to be turned on
  97585. */
  97586. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97587. /**
  97588. * Prepares the defines for bones
  97589. * @param mesh The mesh containing the geometry data we will draw
  97590. * @param defines The defines to update
  97591. */
  97592. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97593. /**
  97594. * Prepares the defines for morph targets
  97595. * @param mesh The mesh containing the geometry data we will draw
  97596. * @param defines The defines to update
  97597. */
  97598. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97599. /**
  97600. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97601. * @param mesh The mesh containing the geometry data we will draw
  97602. * @param defines The defines to update
  97603. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97604. * @param useBones Precise whether bones should be used or not (override mesh info)
  97605. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97606. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97607. * @returns false if defines are considered not dirty and have not been checked
  97608. */
  97609. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97610. /**
  97611. * Prepares the defines related to multiview
  97612. * @param scene The scene we are intending to draw
  97613. * @param defines The defines to update
  97614. */
  97615. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97616. /**
  97617. * Prepares the defines related to the light information passed in parameter
  97618. * @param scene The scene we are intending to draw
  97619. * @param mesh The mesh the effect is compiling for
  97620. * @param light The light the effect is compiling for
  97621. * @param lightIndex The index of the light
  97622. * @param defines The defines to update
  97623. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97624. * @param state Defines the current state regarding what is needed (normals, etc...)
  97625. */
  97626. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97627. needNormals: boolean;
  97628. needRebuild: boolean;
  97629. shadowEnabled: boolean;
  97630. specularEnabled: boolean;
  97631. lightmapMode: boolean;
  97632. }): void;
  97633. /**
  97634. * Prepares the defines related to the light information passed in parameter
  97635. * @param scene The scene we are intending to draw
  97636. * @param mesh The mesh the effect is compiling for
  97637. * @param defines The defines to update
  97638. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97639. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97640. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97641. * @returns true if normals will be required for the rest of the effect
  97642. */
  97643. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97644. /**
  97645. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97646. * @param lightIndex defines the light index
  97647. * @param uniformsList The uniform list
  97648. * @param samplersList The sampler list
  97649. * @param projectedLightTexture defines if projected texture must be used
  97650. * @param uniformBuffersList defines an optional list of uniform buffers
  97651. */
  97652. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97653. /**
  97654. * Prepares the uniforms and samplers list to be used in the effect
  97655. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97656. * @param samplersList The sampler list
  97657. * @param defines The defines helping in the list generation
  97658. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97659. */
  97660. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97661. /**
  97662. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97663. * @param defines The defines to update while falling back
  97664. * @param fallbacks The authorized effect fallbacks
  97665. * @param maxSimultaneousLights The maximum number of lights allowed
  97666. * @param rank the current rank of the Effect
  97667. * @returns The newly affected rank
  97668. */
  97669. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97670. private static _TmpMorphInfluencers;
  97671. /**
  97672. * Prepares the list of attributes required for morph targets according to the effect defines.
  97673. * @param attribs The current list of supported attribs
  97674. * @param mesh The mesh to prepare the morph targets attributes for
  97675. * @param influencers The number of influencers
  97676. */
  97677. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97678. /**
  97679. * Prepares the list of attributes required for morph targets according to the effect defines.
  97680. * @param attribs The current list of supported attribs
  97681. * @param mesh The mesh to prepare the morph targets attributes for
  97682. * @param defines The current Defines of the effect
  97683. */
  97684. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97685. /**
  97686. * Prepares the list of attributes required for bones according to the effect defines.
  97687. * @param attribs The current list of supported attribs
  97688. * @param mesh The mesh to prepare the bones attributes for
  97689. * @param defines The current Defines of the effect
  97690. * @param fallbacks The current efffect fallback strategy
  97691. */
  97692. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97693. /**
  97694. * Check and prepare the list of attributes required for instances according to the effect defines.
  97695. * @param attribs The current list of supported attribs
  97696. * @param defines The current MaterialDefines of the effect
  97697. */
  97698. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97699. /**
  97700. * Add the list of attributes required for instances to the attribs array.
  97701. * @param attribs The current list of supported attribs
  97702. */
  97703. static PushAttributesForInstances(attribs: string[]): void;
  97704. /**
  97705. * Binds the light information to the effect.
  97706. * @param light The light containing the generator
  97707. * @param effect The effect we are binding the data to
  97708. * @param lightIndex The light index in the effect used to render
  97709. */
  97710. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97711. /**
  97712. * Binds the lights information from the scene to the effect for the given mesh.
  97713. * @param light Light to bind
  97714. * @param lightIndex Light index
  97715. * @param scene The scene where the light belongs to
  97716. * @param effect The effect we are binding the data to
  97717. * @param useSpecular Defines if specular is supported
  97718. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97719. */
  97720. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97721. /**
  97722. * Binds the lights information from the scene to the effect for the given mesh.
  97723. * @param scene The scene the lights belongs to
  97724. * @param mesh The mesh we are binding the information to render
  97725. * @param effect The effect we are binding the data to
  97726. * @param defines The generated defines for the effect
  97727. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97728. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97729. */
  97730. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97731. private static _tempFogColor;
  97732. /**
  97733. * Binds the fog information from the scene to the effect for the given mesh.
  97734. * @param scene The scene the lights belongs to
  97735. * @param mesh The mesh we are binding the information to render
  97736. * @param effect The effect we are binding the data to
  97737. * @param linearSpace Defines if the fog effect is applied in linear space
  97738. */
  97739. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97740. /**
  97741. * Binds the bones information from the mesh to the effect.
  97742. * @param mesh The mesh we are binding the information to render
  97743. * @param effect The effect we are binding the data to
  97744. */
  97745. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97746. /**
  97747. * Binds the morph targets information from the mesh to the effect.
  97748. * @param abstractMesh The mesh we are binding the information to render
  97749. * @param effect The effect we are binding the data to
  97750. */
  97751. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97752. /**
  97753. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97754. * @param defines The generated defines used in the effect
  97755. * @param effect The effect we are binding the data to
  97756. * @param scene The scene we are willing to render with logarithmic scale for
  97757. */
  97758. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97759. /**
  97760. * Binds the clip plane information from the scene to the effect.
  97761. * @param scene The scene the clip plane information are extracted from
  97762. * @param effect The effect we are binding the data to
  97763. */
  97764. static BindClipPlane(effect: Effect, scene: Scene): void;
  97765. }
  97766. }
  97767. declare module BABYLON {
  97768. /**
  97769. * Block used to expose an input value
  97770. */
  97771. export class InputBlock extends NodeMaterialBlock {
  97772. private _mode;
  97773. private _associatedVariableName;
  97774. private _storedValue;
  97775. private _valueCallback;
  97776. private _type;
  97777. private _animationType;
  97778. /** Gets or set a value used to limit the range of float values */
  97779. min: number;
  97780. /** Gets or set a value used to limit the range of float values */
  97781. max: number;
  97782. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97783. isBoolean: boolean;
  97784. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97785. matrixMode: number;
  97786. /** @hidden */
  97787. _systemValue: Nullable<NodeMaterialSystemValues>;
  97788. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97789. visibleInInspector: boolean;
  97790. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97791. isConstant: boolean;
  97792. /** Gets or sets the group to use to display this block in the Inspector */
  97793. groupInInspector: string;
  97794. /** Gets an observable raised when the value is changed */
  97795. onValueChangedObservable: Observable<InputBlock>;
  97796. /**
  97797. * Gets or sets the connection point type (default is float)
  97798. */
  97799. get type(): NodeMaterialBlockConnectionPointTypes;
  97800. /**
  97801. * Creates a new InputBlock
  97802. * @param name defines the block name
  97803. * @param target defines the target of that block (Vertex by default)
  97804. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97805. */
  97806. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97807. /**
  97808. * Gets the output component
  97809. */
  97810. get output(): NodeMaterialConnectionPoint;
  97811. /**
  97812. * Set the source of this connection point to a vertex attribute
  97813. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97814. * @returns the current connection point
  97815. */
  97816. setAsAttribute(attributeName?: string): InputBlock;
  97817. /**
  97818. * Set the source of this connection point to a system value
  97819. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97820. * @returns the current connection point
  97821. */
  97822. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97823. /**
  97824. * Gets or sets the value of that point.
  97825. * Please note that this value will be ignored if valueCallback is defined
  97826. */
  97827. get value(): any;
  97828. set value(value: any);
  97829. /**
  97830. * Gets or sets a callback used to get the value of that point.
  97831. * Please note that setting this value will force the connection point to ignore the value property
  97832. */
  97833. get valueCallback(): () => any;
  97834. set valueCallback(value: () => any);
  97835. /**
  97836. * Gets or sets the associated variable name in the shader
  97837. */
  97838. get associatedVariableName(): string;
  97839. set associatedVariableName(value: string);
  97840. /** Gets or sets the type of animation applied to the input */
  97841. get animationType(): AnimatedInputBlockTypes;
  97842. set animationType(value: AnimatedInputBlockTypes);
  97843. /**
  97844. * Gets a boolean indicating that this connection point not defined yet
  97845. */
  97846. get isUndefined(): boolean;
  97847. /**
  97848. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97849. * In this case the connection point name must be the name of the uniform to use.
  97850. * Can only be set on inputs
  97851. */
  97852. get isUniform(): boolean;
  97853. set isUniform(value: boolean);
  97854. /**
  97855. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97856. * In this case the connection point name must be the name of the attribute to use
  97857. * Can only be set on inputs
  97858. */
  97859. get isAttribute(): boolean;
  97860. set isAttribute(value: boolean);
  97861. /**
  97862. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97863. * Can only be set on exit points
  97864. */
  97865. get isVarying(): boolean;
  97866. set isVarying(value: boolean);
  97867. /**
  97868. * Gets a boolean indicating that the current connection point is a system value
  97869. */
  97870. get isSystemValue(): boolean;
  97871. /**
  97872. * Gets or sets the current well known value or null if not defined as a system value
  97873. */
  97874. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97875. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97876. /**
  97877. * Gets the current class name
  97878. * @returns the class name
  97879. */
  97880. getClassName(): string;
  97881. /**
  97882. * Animate the input if animationType !== None
  97883. * @param scene defines the rendering scene
  97884. */
  97885. animate(scene: Scene): void;
  97886. private _emitDefine;
  97887. initialize(state: NodeMaterialBuildState): void;
  97888. /**
  97889. * Set the input block to its default value (based on its type)
  97890. */
  97891. setDefaultValue(): void;
  97892. private _emitConstant;
  97893. /** @hidden */
  97894. get _noContextSwitch(): boolean;
  97895. private _emit;
  97896. /** @hidden */
  97897. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97898. /** @hidden */
  97899. _transmit(effect: Effect, scene: Scene): void;
  97900. protected _buildBlock(state: NodeMaterialBuildState): void;
  97901. protected _dumpPropertiesCode(): string;
  97902. dispose(): void;
  97903. serialize(): any;
  97904. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97905. }
  97906. }
  97907. declare module BABYLON {
  97908. /**
  97909. * Enum used to define the compatibility state between two connection points
  97910. */
  97911. export enum NodeMaterialConnectionPointCompatibilityStates {
  97912. /** Points are compatibles */
  97913. Compatible = 0,
  97914. /** Points are incompatible because of their types */
  97915. TypeIncompatible = 1,
  97916. /** Points are incompatible because of their targets (vertex vs fragment) */
  97917. TargetIncompatible = 2
  97918. }
  97919. /**
  97920. * Defines the direction of a connection point
  97921. */
  97922. export enum NodeMaterialConnectionPointDirection {
  97923. /** Input */
  97924. Input = 0,
  97925. /** Output */
  97926. Output = 1
  97927. }
  97928. /**
  97929. * Defines a connection point for a block
  97930. */
  97931. export class NodeMaterialConnectionPoint {
  97932. /** @hidden */
  97933. _ownerBlock: NodeMaterialBlock;
  97934. /** @hidden */
  97935. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  97936. private _endpoints;
  97937. private _associatedVariableName;
  97938. private _direction;
  97939. /** @hidden */
  97940. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97941. /** @hidden */
  97942. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  97943. private _type;
  97944. /** @hidden */
  97945. _enforceAssociatedVariableName: boolean;
  97946. /** Gets the direction of the point */
  97947. get direction(): NodeMaterialConnectionPointDirection;
  97948. /** Indicates that this connection point needs dual validation before being connected to another point */
  97949. needDualDirectionValidation: boolean;
  97950. /**
  97951. * Gets or sets the additional types supported by this connection point
  97952. */
  97953. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97954. /**
  97955. * Gets or sets the additional types excluded by this connection point
  97956. */
  97957. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  97958. /**
  97959. * Observable triggered when this point is connected
  97960. */
  97961. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  97962. /**
  97963. * Gets or sets the associated variable name in the shader
  97964. */
  97965. get associatedVariableName(): string;
  97966. set associatedVariableName(value: string);
  97967. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  97968. get innerType(): NodeMaterialBlockConnectionPointTypes;
  97969. /**
  97970. * Gets or sets the connection point type (default is float)
  97971. */
  97972. get type(): NodeMaterialBlockConnectionPointTypes;
  97973. set type(value: NodeMaterialBlockConnectionPointTypes);
  97974. /**
  97975. * Gets or sets the connection point name
  97976. */
  97977. name: string;
  97978. /**
  97979. * Gets or sets the connection point name
  97980. */
  97981. displayName: string;
  97982. /**
  97983. * Gets or sets a boolean indicating that this connection point can be omitted
  97984. */
  97985. isOptional: boolean;
  97986. /**
  97987. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  97988. */
  97989. define: string;
  97990. /** @hidden */
  97991. _prioritizeVertex: boolean;
  97992. private _target;
  97993. /** Gets or sets the target of that connection point */
  97994. get target(): NodeMaterialBlockTargets;
  97995. set target(value: NodeMaterialBlockTargets);
  97996. /**
  97997. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  97998. */
  97999. get isConnected(): boolean;
  98000. /**
  98001. * Gets a boolean indicating that the current point is connected to an input block
  98002. */
  98003. get isConnectedToInputBlock(): boolean;
  98004. /**
  98005. * Gets a the connected input block (if any)
  98006. */
  98007. get connectInputBlock(): Nullable<InputBlock>;
  98008. /** Get the other side of the connection (if any) */
  98009. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98010. /** Get the block that owns this connection point */
  98011. get ownerBlock(): NodeMaterialBlock;
  98012. /** Get the block connected on the other side of this connection (if any) */
  98013. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98014. /** Get the block connected on the endpoints of this connection (if any) */
  98015. get connectedBlocks(): Array<NodeMaterialBlock>;
  98016. /** Gets the list of connected endpoints */
  98017. get endpoints(): NodeMaterialConnectionPoint[];
  98018. /** Gets a boolean indicating if that output point is connected to at least one input */
  98019. get hasEndpoints(): boolean;
  98020. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98021. get isConnectedInVertexShader(): boolean;
  98022. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98023. get isConnectedInFragmentShader(): boolean;
  98024. /**
  98025. * Creates a block suitable to be used as an input for this input point.
  98026. * If null is returned, a block based on the point type will be created.
  98027. * @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
  98028. */
  98029. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98030. /**
  98031. * Creates a new connection point
  98032. * @param name defines the connection point name
  98033. * @param ownerBlock defines the block hosting this connection point
  98034. * @param direction defines the direction of the connection point
  98035. */
  98036. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98037. /**
  98038. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98039. * @returns the class name
  98040. */
  98041. getClassName(): string;
  98042. /**
  98043. * Gets a boolean indicating if the current point can be connected to another point
  98044. * @param connectionPoint defines the other connection point
  98045. * @returns a boolean
  98046. */
  98047. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98048. /**
  98049. * Gets a number indicating if the current point can be connected to another point
  98050. * @param connectionPoint defines the other connection point
  98051. * @returns a number defining the compatibility state
  98052. */
  98053. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98054. /**
  98055. * Connect this point to another connection point
  98056. * @param connectionPoint defines the other connection point
  98057. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98058. * @returns the current connection point
  98059. */
  98060. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98061. /**
  98062. * Disconnect this point from one of his endpoint
  98063. * @param endpoint defines the other connection point
  98064. * @returns the current connection point
  98065. */
  98066. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98067. /**
  98068. * Serializes this point in a JSON representation
  98069. * @param isInput defines if the connection point is an input (default is true)
  98070. * @returns the serialized point object
  98071. */
  98072. serialize(isInput?: boolean): any;
  98073. /**
  98074. * Release resources
  98075. */
  98076. dispose(): void;
  98077. }
  98078. }
  98079. declare module BABYLON {
  98080. /**
  98081. * Enum used to define the material modes
  98082. */
  98083. export enum NodeMaterialModes {
  98084. /** Regular material */
  98085. Material = 0,
  98086. /** For post process */
  98087. PostProcess = 1,
  98088. /** For particle system */
  98089. Particle = 2
  98090. }
  98091. }
  98092. declare module BABYLON {
  98093. /**
  98094. * Block used to read a texture from a sampler
  98095. */
  98096. export class TextureBlock extends NodeMaterialBlock {
  98097. private _defineName;
  98098. private _linearDefineName;
  98099. private _gammaDefineName;
  98100. private _tempTextureRead;
  98101. private _samplerName;
  98102. private _transformedUVName;
  98103. private _textureTransformName;
  98104. private _textureInfoName;
  98105. private _mainUVName;
  98106. private _mainUVDefineName;
  98107. private _fragmentOnly;
  98108. /**
  98109. * Gets or sets the texture associated with the node
  98110. */
  98111. texture: Nullable<Texture>;
  98112. /**
  98113. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98114. */
  98115. convertToGammaSpace: boolean;
  98116. /**
  98117. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98118. */
  98119. convertToLinearSpace: boolean;
  98120. /**
  98121. * Create a new TextureBlock
  98122. * @param name defines the block name
  98123. */
  98124. constructor(name: string, fragmentOnly?: boolean);
  98125. /**
  98126. * Gets the current class name
  98127. * @returns the class name
  98128. */
  98129. getClassName(): string;
  98130. /**
  98131. * Gets the uv input component
  98132. */
  98133. get uv(): NodeMaterialConnectionPoint;
  98134. /**
  98135. * Gets the rgba output component
  98136. */
  98137. get rgba(): NodeMaterialConnectionPoint;
  98138. /**
  98139. * Gets the rgb output component
  98140. */
  98141. get rgb(): NodeMaterialConnectionPoint;
  98142. /**
  98143. * Gets the r output component
  98144. */
  98145. get r(): NodeMaterialConnectionPoint;
  98146. /**
  98147. * Gets the g output component
  98148. */
  98149. get g(): NodeMaterialConnectionPoint;
  98150. /**
  98151. * Gets the b output component
  98152. */
  98153. get b(): NodeMaterialConnectionPoint;
  98154. /**
  98155. * Gets the a output component
  98156. */
  98157. get a(): NodeMaterialConnectionPoint;
  98158. get target(): NodeMaterialBlockTargets;
  98159. autoConfigure(material: NodeMaterial): void;
  98160. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98162. isReady(): boolean;
  98163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98164. private get _isMixed();
  98165. private _injectVertexCode;
  98166. private _writeTextureRead;
  98167. private _writeOutput;
  98168. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98169. protected _dumpPropertiesCode(): string;
  98170. serialize(): any;
  98171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98172. }
  98173. }
  98174. declare module BABYLON {
  98175. /** @hidden */
  98176. export var reflectionFunction: {
  98177. name: string;
  98178. shader: string;
  98179. };
  98180. }
  98181. declare module BABYLON {
  98182. /**
  98183. * Base block used to read a reflection texture from a sampler
  98184. */
  98185. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98186. /** @hidden */
  98187. _define3DName: string;
  98188. /** @hidden */
  98189. _defineCubicName: string;
  98190. /** @hidden */
  98191. _defineExplicitName: string;
  98192. /** @hidden */
  98193. _defineProjectionName: string;
  98194. /** @hidden */
  98195. _defineLocalCubicName: string;
  98196. /** @hidden */
  98197. _defineSphericalName: string;
  98198. /** @hidden */
  98199. _definePlanarName: string;
  98200. /** @hidden */
  98201. _defineEquirectangularName: string;
  98202. /** @hidden */
  98203. _defineMirroredEquirectangularFixedName: string;
  98204. /** @hidden */
  98205. _defineEquirectangularFixedName: string;
  98206. /** @hidden */
  98207. _defineSkyboxName: string;
  98208. /** @hidden */
  98209. _defineOppositeZ: string;
  98210. /** @hidden */
  98211. _cubeSamplerName: string;
  98212. /** @hidden */
  98213. _2DSamplerName: string;
  98214. protected _positionUVWName: string;
  98215. protected _directionWName: string;
  98216. protected _reflectionVectorName: string;
  98217. /** @hidden */
  98218. _reflectionCoordsName: string;
  98219. /** @hidden */
  98220. _reflectionMatrixName: string;
  98221. protected _reflectionColorName: string;
  98222. /**
  98223. * Gets or sets the texture associated with the node
  98224. */
  98225. texture: Nullable<BaseTexture>;
  98226. /**
  98227. * Create a new ReflectionTextureBaseBlock
  98228. * @param name defines the block name
  98229. */
  98230. constructor(name: string);
  98231. /**
  98232. * Gets the current class name
  98233. * @returns the class name
  98234. */
  98235. getClassName(): string;
  98236. /**
  98237. * Gets the world position input component
  98238. */
  98239. abstract get position(): NodeMaterialConnectionPoint;
  98240. /**
  98241. * Gets the world position input component
  98242. */
  98243. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98244. /**
  98245. * Gets the world normal input component
  98246. */
  98247. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98248. /**
  98249. * Gets the world input component
  98250. */
  98251. abstract get world(): NodeMaterialConnectionPoint;
  98252. /**
  98253. * Gets the camera (or eye) position component
  98254. */
  98255. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98256. /**
  98257. * Gets the view input component
  98258. */
  98259. abstract get view(): NodeMaterialConnectionPoint;
  98260. protected _getTexture(): Nullable<BaseTexture>;
  98261. autoConfigure(material: NodeMaterial): void;
  98262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98263. isReady(): boolean;
  98264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98265. /**
  98266. * Gets the code to inject in the vertex shader
  98267. * @param state current state of the node material building
  98268. * @returns the shader code
  98269. */
  98270. handleVertexSide(state: NodeMaterialBuildState): string;
  98271. /**
  98272. * Handles the inits for the fragment code path
  98273. * @param state node material build state
  98274. */
  98275. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98276. /**
  98277. * Generates the reflection coords code for the fragment code path
  98278. * @param worldNormalVarName name of the world normal variable
  98279. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98280. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98281. * @returns the shader code
  98282. */
  98283. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98284. /**
  98285. * Generates the reflection color code for the fragment code path
  98286. * @param lodVarName name of the lod variable
  98287. * @param swizzleLookupTexture swizzle to use for the final color variable
  98288. * @returns the shader code
  98289. */
  98290. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98291. /**
  98292. * Generates the code corresponding to the connected output points
  98293. * @param state node material build state
  98294. * @param varName name of the variable to output
  98295. * @returns the shader code
  98296. */
  98297. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98298. protected _buildBlock(state: NodeMaterialBuildState): this;
  98299. protected _dumpPropertiesCode(): string;
  98300. serialize(): any;
  98301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98302. }
  98303. }
  98304. declare module BABYLON {
  98305. /**
  98306. * Defines a connection point to be used for points with a custom object type
  98307. */
  98308. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98309. private _blockType;
  98310. private _blockName;
  98311. private _nameForCheking?;
  98312. /**
  98313. * Creates a new connection point
  98314. * @param name defines the connection point name
  98315. * @param ownerBlock defines the block hosting this connection point
  98316. * @param direction defines the direction of the connection point
  98317. */
  98318. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98319. /**
  98320. * Gets a number indicating if the current point can be connected to another point
  98321. * @param connectionPoint defines the other connection point
  98322. * @returns a number defining the compatibility state
  98323. */
  98324. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98325. /**
  98326. * Creates a block suitable to be used as an input for this input point.
  98327. * If null is returned, a block based on the point type will be created.
  98328. * @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
  98329. */
  98330. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98331. }
  98332. }
  98333. declare module BABYLON {
  98334. /**
  98335. * Enum defining the type of properties that can be edited in the property pages in the NME
  98336. */
  98337. export enum PropertyTypeForEdition {
  98338. /** property is a boolean */
  98339. Boolean = 0,
  98340. /** property is a float */
  98341. Float = 1,
  98342. /** property is a Vector2 */
  98343. Vector2 = 2,
  98344. /** property is a list of values */
  98345. List = 3
  98346. }
  98347. /**
  98348. * Interface that defines an option in a variable of type list
  98349. */
  98350. export interface IEditablePropertyListOption {
  98351. /** label of the option */
  98352. "label": string;
  98353. /** value of the option */
  98354. "value": number;
  98355. }
  98356. /**
  98357. * Interface that defines the options available for an editable property
  98358. */
  98359. export interface IEditablePropertyOption {
  98360. /** min value */
  98361. "min"?: number;
  98362. /** max value */
  98363. "max"?: number;
  98364. /** notifiers: indicates which actions to take when the property is changed */
  98365. "notifiers"?: {
  98366. /** the material should be rebuilt */
  98367. "rebuild"?: boolean;
  98368. /** the preview should be updated */
  98369. "update"?: boolean;
  98370. };
  98371. /** list of the options for a variable of type list */
  98372. "options"?: IEditablePropertyListOption[];
  98373. }
  98374. /**
  98375. * Interface that describes an editable property
  98376. */
  98377. export interface IPropertyDescriptionForEdition {
  98378. /** name of the property */
  98379. "propertyName": string;
  98380. /** display name of the property */
  98381. "displayName": string;
  98382. /** type of the property */
  98383. "type": PropertyTypeForEdition;
  98384. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98385. "groupName": string;
  98386. /** options for the property */
  98387. "options": IEditablePropertyOption;
  98388. }
  98389. /**
  98390. * Decorator that flags a property in a node material block as being editable
  98391. */
  98392. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98393. }
  98394. declare module BABYLON {
  98395. /**
  98396. * Block used to implement the refraction part of the sub surface module of the PBR material
  98397. */
  98398. export class RefractionBlock extends NodeMaterialBlock {
  98399. /** @hidden */
  98400. _define3DName: string;
  98401. /** @hidden */
  98402. _refractionMatrixName: string;
  98403. /** @hidden */
  98404. _defineLODRefractionAlpha: string;
  98405. /** @hidden */
  98406. _defineLinearSpecularRefraction: string;
  98407. /** @hidden */
  98408. _defineOppositeZ: string;
  98409. /** @hidden */
  98410. _cubeSamplerName: string;
  98411. /** @hidden */
  98412. _2DSamplerName: string;
  98413. /** @hidden */
  98414. _vRefractionMicrosurfaceInfosName: string;
  98415. /** @hidden */
  98416. _vRefractionInfosName: string;
  98417. private _scene;
  98418. /**
  98419. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98420. * Materials half opaque for instance using refraction could benefit from this control.
  98421. */
  98422. linkRefractionWithTransparency: boolean;
  98423. /**
  98424. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98425. */
  98426. invertRefractionY: boolean;
  98427. /**
  98428. * Gets or sets the texture associated with the node
  98429. */
  98430. texture: Nullable<BaseTexture>;
  98431. /**
  98432. * Create a new RefractionBlock
  98433. * @param name defines the block name
  98434. */
  98435. constructor(name: string);
  98436. /**
  98437. * Gets the current class name
  98438. * @returns the class name
  98439. */
  98440. getClassName(): string;
  98441. /**
  98442. * Gets the intensity input component
  98443. */
  98444. get intensity(): NodeMaterialConnectionPoint;
  98445. /**
  98446. * Gets the index of refraction input component
  98447. */
  98448. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98449. /**
  98450. * Gets the tint at distance input component
  98451. */
  98452. get tintAtDistance(): NodeMaterialConnectionPoint;
  98453. /**
  98454. * Gets the view input component
  98455. */
  98456. get view(): NodeMaterialConnectionPoint;
  98457. /**
  98458. * Gets the refraction object output component
  98459. */
  98460. get refraction(): NodeMaterialConnectionPoint;
  98461. /**
  98462. * Returns true if the block has a texture
  98463. */
  98464. get hasTexture(): boolean;
  98465. protected _getTexture(): Nullable<BaseTexture>;
  98466. autoConfigure(material: NodeMaterial): void;
  98467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98468. isReady(): boolean;
  98469. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98470. /**
  98471. * Gets the main code of the block (fragment side)
  98472. * @param state current state of the node material building
  98473. * @returns the shader code
  98474. */
  98475. getCode(state: NodeMaterialBuildState): string;
  98476. protected _buildBlock(state: NodeMaterialBuildState): this;
  98477. protected _dumpPropertiesCode(): string;
  98478. serialize(): any;
  98479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98480. }
  98481. }
  98482. declare module BABYLON {
  98483. /**
  98484. * Base block used as input for post process
  98485. */
  98486. export class CurrentScreenBlock extends NodeMaterialBlock {
  98487. private _samplerName;
  98488. private _linearDefineName;
  98489. private _gammaDefineName;
  98490. private _mainUVName;
  98491. private _tempTextureRead;
  98492. /**
  98493. * Gets or sets the texture associated with the node
  98494. */
  98495. texture: Nullable<BaseTexture>;
  98496. /**
  98497. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98498. */
  98499. convertToGammaSpace: boolean;
  98500. /**
  98501. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98502. */
  98503. convertToLinearSpace: boolean;
  98504. /**
  98505. * Create a new CurrentScreenBlock
  98506. * @param name defines the block name
  98507. */
  98508. constructor(name: string);
  98509. /**
  98510. * Gets the current class name
  98511. * @returns the class name
  98512. */
  98513. getClassName(): string;
  98514. /**
  98515. * Gets the uv input component
  98516. */
  98517. get uv(): NodeMaterialConnectionPoint;
  98518. /**
  98519. * Gets the rgba output component
  98520. */
  98521. get rgba(): NodeMaterialConnectionPoint;
  98522. /**
  98523. * Gets the rgb output component
  98524. */
  98525. get rgb(): NodeMaterialConnectionPoint;
  98526. /**
  98527. * Gets the r output component
  98528. */
  98529. get r(): NodeMaterialConnectionPoint;
  98530. /**
  98531. * Gets the g output component
  98532. */
  98533. get g(): NodeMaterialConnectionPoint;
  98534. /**
  98535. * Gets the b output component
  98536. */
  98537. get b(): NodeMaterialConnectionPoint;
  98538. /**
  98539. * Gets the a output component
  98540. */
  98541. get a(): NodeMaterialConnectionPoint;
  98542. /**
  98543. * Initialize the block and prepare the context for build
  98544. * @param state defines the state that will be used for the build
  98545. */
  98546. initialize(state: NodeMaterialBuildState): void;
  98547. get target(): NodeMaterialBlockTargets;
  98548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98549. isReady(): boolean;
  98550. private _injectVertexCode;
  98551. private _writeTextureRead;
  98552. private _writeOutput;
  98553. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98554. serialize(): any;
  98555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98556. }
  98557. }
  98558. declare module BABYLON {
  98559. /**
  98560. * Base block used for the particle texture
  98561. */
  98562. export class ParticleTextureBlock extends NodeMaterialBlock {
  98563. private _samplerName;
  98564. private _linearDefineName;
  98565. private _gammaDefineName;
  98566. private _tempTextureRead;
  98567. /**
  98568. * Gets or sets the texture associated with the node
  98569. */
  98570. texture: Nullable<BaseTexture>;
  98571. /**
  98572. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98573. */
  98574. convertToGammaSpace: boolean;
  98575. /**
  98576. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98577. */
  98578. convertToLinearSpace: boolean;
  98579. /**
  98580. * Create a new ParticleTextureBlock
  98581. * @param name defines the block name
  98582. */
  98583. constructor(name: string);
  98584. /**
  98585. * Gets the current class name
  98586. * @returns the class name
  98587. */
  98588. getClassName(): string;
  98589. /**
  98590. * Gets the uv input component
  98591. */
  98592. get uv(): NodeMaterialConnectionPoint;
  98593. /**
  98594. * Gets the rgba output component
  98595. */
  98596. get rgba(): NodeMaterialConnectionPoint;
  98597. /**
  98598. * Gets the rgb output component
  98599. */
  98600. get rgb(): NodeMaterialConnectionPoint;
  98601. /**
  98602. * Gets the r output component
  98603. */
  98604. get r(): NodeMaterialConnectionPoint;
  98605. /**
  98606. * Gets the g output component
  98607. */
  98608. get g(): NodeMaterialConnectionPoint;
  98609. /**
  98610. * Gets the b output component
  98611. */
  98612. get b(): NodeMaterialConnectionPoint;
  98613. /**
  98614. * Gets the a output component
  98615. */
  98616. get a(): NodeMaterialConnectionPoint;
  98617. /**
  98618. * Initialize the block and prepare the context for build
  98619. * @param state defines the state that will be used for the build
  98620. */
  98621. initialize(state: NodeMaterialBuildState): void;
  98622. autoConfigure(material: NodeMaterial): void;
  98623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98624. isReady(): boolean;
  98625. private _writeOutput;
  98626. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98627. serialize(): any;
  98628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98629. }
  98630. }
  98631. declare module BABYLON {
  98632. /**
  98633. * Class used to store shared data between 2 NodeMaterialBuildState
  98634. */
  98635. export class NodeMaterialBuildStateSharedData {
  98636. /**
  98637. * Gets the list of emitted varyings
  98638. */
  98639. temps: string[];
  98640. /**
  98641. * Gets the list of emitted varyings
  98642. */
  98643. varyings: string[];
  98644. /**
  98645. * Gets the varying declaration string
  98646. */
  98647. varyingDeclaration: string;
  98648. /**
  98649. * Input blocks
  98650. */
  98651. inputBlocks: InputBlock[];
  98652. /**
  98653. * Input blocks
  98654. */
  98655. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98656. /**
  98657. * Bindable blocks (Blocks that need to set data to the effect)
  98658. */
  98659. bindableBlocks: NodeMaterialBlock[];
  98660. /**
  98661. * List of blocks that can provide a compilation fallback
  98662. */
  98663. blocksWithFallbacks: NodeMaterialBlock[];
  98664. /**
  98665. * List of blocks that can provide a define update
  98666. */
  98667. blocksWithDefines: NodeMaterialBlock[];
  98668. /**
  98669. * List of blocks that can provide a repeatable content
  98670. */
  98671. repeatableContentBlocks: NodeMaterialBlock[];
  98672. /**
  98673. * List of blocks that can provide a dynamic list of uniforms
  98674. */
  98675. dynamicUniformBlocks: NodeMaterialBlock[];
  98676. /**
  98677. * List of blocks that can block the isReady function for the material
  98678. */
  98679. blockingBlocks: NodeMaterialBlock[];
  98680. /**
  98681. * Gets the list of animated inputs
  98682. */
  98683. animatedInputs: InputBlock[];
  98684. /**
  98685. * Build Id used to avoid multiple recompilations
  98686. */
  98687. buildId: number;
  98688. /** List of emitted variables */
  98689. variableNames: {
  98690. [key: string]: number;
  98691. };
  98692. /** List of emitted defines */
  98693. defineNames: {
  98694. [key: string]: number;
  98695. };
  98696. /** Should emit comments? */
  98697. emitComments: boolean;
  98698. /** Emit build activity */
  98699. verbose: boolean;
  98700. /** Gets or sets the hosting scene */
  98701. scene: Scene;
  98702. /**
  98703. * Gets the compilation hints emitted at compilation time
  98704. */
  98705. hints: {
  98706. needWorldViewMatrix: boolean;
  98707. needWorldViewProjectionMatrix: boolean;
  98708. needAlphaBlending: boolean;
  98709. needAlphaTesting: boolean;
  98710. };
  98711. /**
  98712. * List of compilation checks
  98713. */
  98714. checks: {
  98715. emitVertex: boolean;
  98716. emitFragment: boolean;
  98717. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98718. };
  98719. /**
  98720. * Is vertex program allowed to be empty?
  98721. */
  98722. allowEmptyVertexProgram: boolean;
  98723. /** Creates a new shared data */
  98724. constructor();
  98725. /**
  98726. * Emits console errors and exceptions if there is a failing check
  98727. */
  98728. emitErrors(): void;
  98729. }
  98730. }
  98731. declare module BABYLON {
  98732. /**
  98733. * Class used to store node based material build state
  98734. */
  98735. export class NodeMaterialBuildState {
  98736. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98737. supportUniformBuffers: boolean;
  98738. /**
  98739. * Gets the list of emitted attributes
  98740. */
  98741. attributes: string[];
  98742. /**
  98743. * Gets the list of emitted uniforms
  98744. */
  98745. uniforms: string[];
  98746. /**
  98747. * Gets the list of emitted constants
  98748. */
  98749. constants: string[];
  98750. /**
  98751. * Gets the list of emitted samplers
  98752. */
  98753. samplers: string[];
  98754. /**
  98755. * Gets the list of emitted functions
  98756. */
  98757. functions: {
  98758. [key: string]: string;
  98759. };
  98760. /**
  98761. * Gets the list of emitted extensions
  98762. */
  98763. extensions: {
  98764. [key: string]: string;
  98765. };
  98766. /**
  98767. * Gets the target of the compilation state
  98768. */
  98769. target: NodeMaterialBlockTargets;
  98770. /**
  98771. * Gets the list of emitted counters
  98772. */
  98773. counters: {
  98774. [key: string]: number;
  98775. };
  98776. /**
  98777. * Shared data between multiple NodeMaterialBuildState instances
  98778. */
  98779. sharedData: NodeMaterialBuildStateSharedData;
  98780. /** @hidden */
  98781. _vertexState: NodeMaterialBuildState;
  98782. /** @hidden */
  98783. _attributeDeclaration: string;
  98784. /** @hidden */
  98785. _uniformDeclaration: string;
  98786. /** @hidden */
  98787. _constantDeclaration: string;
  98788. /** @hidden */
  98789. _samplerDeclaration: string;
  98790. /** @hidden */
  98791. _varyingTransfer: string;
  98792. /** @hidden */
  98793. _injectAtEnd: string;
  98794. private _repeatableContentAnchorIndex;
  98795. /** @hidden */
  98796. _builtCompilationString: string;
  98797. /**
  98798. * Gets the emitted compilation strings
  98799. */
  98800. compilationString: string;
  98801. /**
  98802. * Finalize the compilation strings
  98803. * @param state defines the current compilation state
  98804. */
  98805. finalize(state: NodeMaterialBuildState): void;
  98806. /** @hidden */
  98807. get _repeatableContentAnchor(): string;
  98808. /** @hidden */
  98809. _getFreeVariableName(prefix: string): string;
  98810. /** @hidden */
  98811. _getFreeDefineName(prefix: string): string;
  98812. /** @hidden */
  98813. _excludeVariableName(name: string): void;
  98814. /** @hidden */
  98815. _emit2DSampler(name: string): void;
  98816. /** @hidden */
  98817. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98818. /** @hidden */
  98819. _emitExtension(name: string, extension: string, define?: string): void;
  98820. /** @hidden */
  98821. _emitFunction(name: string, code: string, comments: string): void;
  98822. /** @hidden */
  98823. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98824. replaceStrings?: {
  98825. search: RegExp;
  98826. replace: string;
  98827. }[];
  98828. repeatKey?: string;
  98829. }): string;
  98830. /** @hidden */
  98831. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98832. repeatKey?: string;
  98833. removeAttributes?: boolean;
  98834. removeUniforms?: boolean;
  98835. removeVaryings?: boolean;
  98836. removeIfDef?: boolean;
  98837. replaceStrings?: {
  98838. search: RegExp;
  98839. replace: string;
  98840. }[];
  98841. }, storeKey?: string): void;
  98842. /** @hidden */
  98843. _registerTempVariable(name: string): boolean;
  98844. /** @hidden */
  98845. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98846. /** @hidden */
  98847. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98848. /** @hidden */
  98849. _emitFloat(value: number): string;
  98850. }
  98851. }
  98852. declare module BABYLON {
  98853. /**
  98854. * Helper class used to generate session unique ID
  98855. */
  98856. export class UniqueIdGenerator {
  98857. private static _UniqueIdCounter;
  98858. /**
  98859. * Gets an unique (relatively to the current scene) Id
  98860. */
  98861. static get UniqueId(): number;
  98862. }
  98863. }
  98864. declare module BABYLON {
  98865. /**
  98866. * Defines a block that can be used inside a node based material
  98867. */
  98868. export class NodeMaterialBlock {
  98869. private _buildId;
  98870. private _buildTarget;
  98871. private _target;
  98872. private _isFinalMerger;
  98873. private _isInput;
  98874. protected _isUnique: boolean;
  98875. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98876. inputsAreExclusive: boolean;
  98877. /** @hidden */
  98878. _codeVariableName: string;
  98879. /** @hidden */
  98880. _inputs: NodeMaterialConnectionPoint[];
  98881. /** @hidden */
  98882. _outputs: NodeMaterialConnectionPoint[];
  98883. /** @hidden */
  98884. _preparationId: number;
  98885. /**
  98886. * Gets or sets the name of the block
  98887. */
  98888. name: string;
  98889. /**
  98890. * Gets or sets the unique id of the node
  98891. */
  98892. uniqueId: number;
  98893. /**
  98894. * Gets or sets the comments associated with this block
  98895. */
  98896. comments: string;
  98897. /**
  98898. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98899. */
  98900. get isUnique(): boolean;
  98901. /**
  98902. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98903. */
  98904. get isFinalMerger(): boolean;
  98905. /**
  98906. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98907. */
  98908. get isInput(): boolean;
  98909. /**
  98910. * Gets or sets the build Id
  98911. */
  98912. get buildId(): number;
  98913. set buildId(value: number);
  98914. /**
  98915. * Gets or sets the target of the block
  98916. */
  98917. get target(): NodeMaterialBlockTargets;
  98918. set target(value: NodeMaterialBlockTargets);
  98919. /**
  98920. * Gets the list of input points
  98921. */
  98922. get inputs(): NodeMaterialConnectionPoint[];
  98923. /** Gets the list of output points */
  98924. get outputs(): NodeMaterialConnectionPoint[];
  98925. /**
  98926. * Find an input by its name
  98927. * @param name defines the name of the input to look for
  98928. * @returns the input or null if not found
  98929. */
  98930. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98931. /**
  98932. * Find an output by its name
  98933. * @param name defines the name of the outputto look for
  98934. * @returns the output or null if not found
  98935. */
  98936. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  98937. /**
  98938. * Creates a new NodeMaterialBlock
  98939. * @param name defines the block name
  98940. * @param target defines the target of that block (Vertex by default)
  98941. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  98942. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  98943. */
  98944. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  98945. /**
  98946. * Initialize the block and prepare the context for build
  98947. * @param state defines the state that will be used for the build
  98948. */
  98949. initialize(state: NodeMaterialBuildState): void;
  98950. /**
  98951. * Bind data to effect. Will only be called for blocks with isBindable === true
  98952. * @param effect defines the effect to bind data to
  98953. * @param nodeMaterial defines the hosting NodeMaterial
  98954. * @param mesh defines the mesh that will be rendered
  98955. * @param subMesh defines the submesh that will be rendered
  98956. */
  98957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98958. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  98959. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  98960. protected _writeFloat(value: number): string;
  98961. /**
  98962. * Gets the current class name e.g. "NodeMaterialBlock"
  98963. * @returns the class name
  98964. */
  98965. getClassName(): string;
  98966. /**
  98967. * Register a new input. Must be called inside a block constructor
  98968. * @param name defines the connection point name
  98969. * @param type defines the connection point type
  98970. * @param isOptional defines a boolean indicating that this input can be omitted
  98971. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98972. * @param point an already created connection point. If not provided, create a new one
  98973. * @returns the current block
  98974. */
  98975. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98976. /**
  98977. * Register a new output. Must be called inside a block constructor
  98978. * @param name defines the connection point name
  98979. * @param type defines the connection point type
  98980. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  98981. * @param point an already created connection point. If not provided, create a new one
  98982. * @returns the current block
  98983. */
  98984. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  98985. /**
  98986. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  98987. * @param forOutput defines an optional connection point to check compatibility with
  98988. * @returns the first available input or null
  98989. */
  98990. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  98991. /**
  98992. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  98993. * @param forBlock defines an optional block to check compatibility with
  98994. * @returns the first available input or null
  98995. */
  98996. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  98997. /**
  98998. * Gets the sibling of the given output
  98999. * @param current defines the current output
  99000. * @returns the next output in the list or null
  99001. */
  99002. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99003. /**
  99004. * Connect current block with another block
  99005. * @param other defines the block to connect with
  99006. * @param options define the various options to help pick the right connections
  99007. * @returns the current block
  99008. */
  99009. connectTo(other: NodeMaterialBlock, options?: {
  99010. input?: string;
  99011. output?: string;
  99012. outputSwizzle?: string;
  99013. }): this | undefined;
  99014. protected _buildBlock(state: NodeMaterialBuildState): void;
  99015. /**
  99016. * Add uniforms, samplers and uniform buffers at compilation time
  99017. * @param state defines the state to update
  99018. * @param nodeMaterial defines the node material requesting the update
  99019. * @param defines defines the material defines to update
  99020. * @param uniformBuffers defines the list of uniform buffer names
  99021. */
  99022. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99023. /**
  99024. * Add potential fallbacks if shader compilation fails
  99025. * @param mesh defines the mesh to be rendered
  99026. * @param fallbacks defines the current prioritized list of fallbacks
  99027. */
  99028. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99029. /**
  99030. * Initialize defines for shader compilation
  99031. * @param mesh defines the mesh to be rendered
  99032. * @param nodeMaterial defines the node material requesting the update
  99033. * @param defines defines the material defines to update
  99034. * @param useInstances specifies that instances should be used
  99035. */
  99036. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99037. /**
  99038. * Update defines for shader compilation
  99039. * @param mesh defines the mesh to be rendered
  99040. * @param nodeMaterial defines the node material requesting the update
  99041. * @param defines defines the material defines to update
  99042. * @param useInstances specifies that instances should be used
  99043. * @param subMesh defines which submesh to render
  99044. */
  99045. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99046. /**
  99047. * Lets the block try to connect some inputs automatically
  99048. * @param material defines the hosting NodeMaterial
  99049. */
  99050. autoConfigure(material: NodeMaterial): void;
  99051. /**
  99052. * Function called when a block is declared as repeatable content generator
  99053. * @param vertexShaderState defines the current compilation state for the vertex shader
  99054. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99055. * @param mesh defines the mesh to be rendered
  99056. * @param defines defines the material defines to update
  99057. */
  99058. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99059. /**
  99060. * Checks if the block is ready
  99061. * @param mesh defines the mesh to be rendered
  99062. * @param nodeMaterial defines the node material requesting the update
  99063. * @param defines defines the material defines to update
  99064. * @param useInstances specifies that instances should be used
  99065. * @returns true if the block is ready
  99066. */
  99067. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99068. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99069. private _processBuild;
  99070. /**
  99071. * Compile the current node and generate the shader code
  99072. * @param state defines the current compilation state (uniforms, samplers, current string)
  99073. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99074. * @returns true if already built
  99075. */
  99076. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99077. protected _inputRename(name: string): string;
  99078. protected _outputRename(name: string): string;
  99079. protected _dumpPropertiesCode(): string;
  99080. /** @hidden */
  99081. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99082. /** @hidden */
  99083. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99084. /**
  99085. * Clone the current block to a new identical block
  99086. * @param scene defines the hosting scene
  99087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99088. * @returns a copy of the current block
  99089. */
  99090. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99091. /**
  99092. * Serializes this block in a JSON representation
  99093. * @returns the serialized block object
  99094. */
  99095. serialize(): any;
  99096. /** @hidden */
  99097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99098. private _deserializePortDisplayNames;
  99099. /**
  99100. * Release resources
  99101. */
  99102. dispose(): void;
  99103. }
  99104. }
  99105. declare module BABYLON {
  99106. /**
  99107. * Base class of materials working in push mode in babylon JS
  99108. * @hidden
  99109. */
  99110. export class PushMaterial extends Material {
  99111. protected _activeEffect: Effect;
  99112. protected _normalMatrix: Matrix;
  99113. constructor(name: string, scene: Scene);
  99114. getEffect(): Effect;
  99115. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99116. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99117. /**
  99118. * Binds the given world matrix to the active effect
  99119. *
  99120. * @param world the matrix to bind
  99121. */
  99122. bindOnlyWorldMatrix(world: Matrix): void;
  99123. /**
  99124. * Binds the given normal matrix to the active effect
  99125. *
  99126. * @param normalMatrix the matrix to bind
  99127. */
  99128. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99129. bind(world: Matrix, mesh?: Mesh): void;
  99130. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99131. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99132. }
  99133. }
  99134. declare module BABYLON {
  99135. /**
  99136. * Root class for all node material optimizers
  99137. */
  99138. export class NodeMaterialOptimizer {
  99139. /**
  99140. * Function used to optimize a NodeMaterial graph
  99141. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99142. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99143. */
  99144. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99145. }
  99146. }
  99147. declare module BABYLON {
  99148. /**
  99149. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99150. */
  99151. export class TransformBlock extends NodeMaterialBlock {
  99152. /**
  99153. * Defines the value to use to complement W value to transform it to a Vector4
  99154. */
  99155. complementW: number;
  99156. /**
  99157. * Defines the value to use to complement z value to transform it to a Vector4
  99158. */
  99159. complementZ: number;
  99160. /**
  99161. * Creates a new TransformBlock
  99162. * @param name defines the block name
  99163. */
  99164. constructor(name: string);
  99165. /**
  99166. * Gets the current class name
  99167. * @returns the class name
  99168. */
  99169. getClassName(): string;
  99170. /**
  99171. * Gets the vector input
  99172. */
  99173. get vector(): NodeMaterialConnectionPoint;
  99174. /**
  99175. * Gets the output component
  99176. */
  99177. get output(): NodeMaterialConnectionPoint;
  99178. /**
  99179. * Gets the xyz output component
  99180. */
  99181. get xyz(): NodeMaterialConnectionPoint;
  99182. /**
  99183. * Gets the matrix transform input
  99184. */
  99185. get transform(): NodeMaterialConnectionPoint;
  99186. protected _buildBlock(state: NodeMaterialBuildState): this;
  99187. /**
  99188. * Update defines for shader compilation
  99189. * @param mesh defines the mesh to be rendered
  99190. * @param nodeMaterial defines the node material requesting the update
  99191. * @param defines defines the material defines to update
  99192. * @param useInstances specifies that instances should be used
  99193. * @param subMesh defines which submesh to render
  99194. */
  99195. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99196. serialize(): any;
  99197. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99198. protected _dumpPropertiesCode(): string;
  99199. }
  99200. }
  99201. declare module BABYLON {
  99202. /**
  99203. * Block used to output the vertex position
  99204. */
  99205. export class VertexOutputBlock extends NodeMaterialBlock {
  99206. /**
  99207. * Creates a new VertexOutputBlock
  99208. * @param name defines the block name
  99209. */
  99210. constructor(name: string);
  99211. /**
  99212. * Gets the current class name
  99213. * @returns the class name
  99214. */
  99215. getClassName(): string;
  99216. /**
  99217. * Gets the vector input component
  99218. */
  99219. get vector(): NodeMaterialConnectionPoint;
  99220. protected _buildBlock(state: NodeMaterialBuildState): this;
  99221. }
  99222. }
  99223. declare module BABYLON {
  99224. /**
  99225. * Block used to output the final color
  99226. */
  99227. export class FragmentOutputBlock extends NodeMaterialBlock {
  99228. /**
  99229. * Create a new FragmentOutputBlock
  99230. * @param name defines the block name
  99231. */
  99232. constructor(name: string);
  99233. /**
  99234. * Gets the current class name
  99235. * @returns the class name
  99236. */
  99237. getClassName(): string;
  99238. /**
  99239. * Gets the rgba input component
  99240. */
  99241. get rgba(): NodeMaterialConnectionPoint;
  99242. /**
  99243. * Gets the rgb input component
  99244. */
  99245. get rgb(): NodeMaterialConnectionPoint;
  99246. /**
  99247. * Gets the a input component
  99248. */
  99249. get a(): NodeMaterialConnectionPoint;
  99250. protected _buildBlock(state: NodeMaterialBuildState): this;
  99251. }
  99252. }
  99253. declare module BABYLON {
  99254. /**
  99255. * Block used for the particle ramp gradient section
  99256. */
  99257. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99258. /**
  99259. * Create a new ParticleRampGradientBlock
  99260. * @param name defines the block name
  99261. */
  99262. constructor(name: string);
  99263. /**
  99264. * Gets the current class name
  99265. * @returns the class name
  99266. */
  99267. getClassName(): string;
  99268. /**
  99269. * Gets the color input component
  99270. */
  99271. get color(): NodeMaterialConnectionPoint;
  99272. /**
  99273. * Gets the rampColor output component
  99274. */
  99275. get rampColor(): NodeMaterialConnectionPoint;
  99276. /**
  99277. * Initialize the block and prepare the context for build
  99278. * @param state defines the state that will be used for the build
  99279. */
  99280. initialize(state: NodeMaterialBuildState): void;
  99281. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99282. }
  99283. }
  99284. declare module BABYLON {
  99285. /**
  99286. * Block used for the particle blend multiply section
  99287. */
  99288. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99289. /**
  99290. * Create a new ParticleBlendMultiplyBlock
  99291. * @param name defines the block name
  99292. */
  99293. constructor(name: string);
  99294. /**
  99295. * Gets the current class name
  99296. * @returns the class name
  99297. */
  99298. getClassName(): string;
  99299. /**
  99300. * Gets the color input component
  99301. */
  99302. get color(): NodeMaterialConnectionPoint;
  99303. /**
  99304. * Gets the alphaTexture input component
  99305. */
  99306. get alphaTexture(): NodeMaterialConnectionPoint;
  99307. /**
  99308. * Gets the alphaColor input component
  99309. */
  99310. get alphaColor(): NodeMaterialConnectionPoint;
  99311. /**
  99312. * Gets the blendColor output component
  99313. */
  99314. get blendColor(): NodeMaterialConnectionPoint;
  99315. /**
  99316. * Initialize the block and prepare the context for build
  99317. * @param state defines the state that will be used for the build
  99318. */
  99319. initialize(state: NodeMaterialBuildState): void;
  99320. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99321. }
  99322. }
  99323. declare module BABYLON {
  99324. /**
  99325. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99326. */
  99327. export class VectorMergerBlock extends NodeMaterialBlock {
  99328. /**
  99329. * Create a new VectorMergerBlock
  99330. * @param name defines the block name
  99331. */
  99332. constructor(name: string);
  99333. /**
  99334. * Gets the current class name
  99335. * @returns the class name
  99336. */
  99337. getClassName(): string;
  99338. /**
  99339. * Gets the xyz component (input)
  99340. */
  99341. get xyzIn(): NodeMaterialConnectionPoint;
  99342. /**
  99343. * Gets the xy component (input)
  99344. */
  99345. get xyIn(): NodeMaterialConnectionPoint;
  99346. /**
  99347. * Gets the x component (input)
  99348. */
  99349. get x(): NodeMaterialConnectionPoint;
  99350. /**
  99351. * Gets the y component (input)
  99352. */
  99353. get y(): NodeMaterialConnectionPoint;
  99354. /**
  99355. * Gets the z component (input)
  99356. */
  99357. get z(): NodeMaterialConnectionPoint;
  99358. /**
  99359. * Gets the w component (input)
  99360. */
  99361. get w(): NodeMaterialConnectionPoint;
  99362. /**
  99363. * Gets the xyzw component (output)
  99364. */
  99365. get xyzw(): NodeMaterialConnectionPoint;
  99366. /**
  99367. * Gets the xyz component (output)
  99368. */
  99369. get xyzOut(): NodeMaterialConnectionPoint;
  99370. /**
  99371. * Gets the xy component (output)
  99372. */
  99373. get xyOut(): NodeMaterialConnectionPoint;
  99374. /**
  99375. * Gets the xy component (output)
  99376. * @deprecated Please use xyOut instead.
  99377. */
  99378. get xy(): NodeMaterialConnectionPoint;
  99379. /**
  99380. * Gets the xyz component (output)
  99381. * @deprecated Please use xyzOut instead.
  99382. */
  99383. get xyz(): NodeMaterialConnectionPoint;
  99384. protected _buildBlock(state: NodeMaterialBuildState): this;
  99385. }
  99386. }
  99387. declare module BABYLON {
  99388. /**
  99389. * Block used to remap a float from a range to a new one
  99390. */
  99391. export class RemapBlock extends NodeMaterialBlock {
  99392. /**
  99393. * Gets or sets the source range
  99394. */
  99395. sourceRange: Vector2;
  99396. /**
  99397. * Gets or sets the target range
  99398. */
  99399. targetRange: Vector2;
  99400. /**
  99401. * Creates a new RemapBlock
  99402. * @param name defines the block name
  99403. */
  99404. constructor(name: string);
  99405. /**
  99406. * Gets the current class name
  99407. * @returns the class name
  99408. */
  99409. getClassName(): string;
  99410. /**
  99411. * Gets the input component
  99412. */
  99413. get input(): NodeMaterialConnectionPoint;
  99414. /**
  99415. * Gets the source min input component
  99416. */
  99417. get sourceMin(): NodeMaterialConnectionPoint;
  99418. /**
  99419. * Gets the source max input component
  99420. */
  99421. get sourceMax(): NodeMaterialConnectionPoint;
  99422. /**
  99423. * Gets the target min input component
  99424. */
  99425. get targetMin(): NodeMaterialConnectionPoint;
  99426. /**
  99427. * Gets the target max input component
  99428. */
  99429. get targetMax(): NodeMaterialConnectionPoint;
  99430. /**
  99431. * Gets the output component
  99432. */
  99433. get output(): NodeMaterialConnectionPoint;
  99434. protected _buildBlock(state: NodeMaterialBuildState): this;
  99435. protected _dumpPropertiesCode(): string;
  99436. serialize(): any;
  99437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * Block used to multiply 2 values
  99443. */
  99444. export class MultiplyBlock extends NodeMaterialBlock {
  99445. /**
  99446. * Creates a new MultiplyBlock
  99447. * @param name defines the block name
  99448. */
  99449. constructor(name: string);
  99450. /**
  99451. * Gets the current class name
  99452. * @returns the class name
  99453. */
  99454. getClassName(): string;
  99455. /**
  99456. * Gets the left operand input component
  99457. */
  99458. get left(): NodeMaterialConnectionPoint;
  99459. /**
  99460. * Gets the right operand input component
  99461. */
  99462. get right(): NodeMaterialConnectionPoint;
  99463. /**
  99464. * Gets the output component
  99465. */
  99466. get output(): NodeMaterialConnectionPoint;
  99467. protected _buildBlock(state: NodeMaterialBuildState): this;
  99468. }
  99469. }
  99470. declare module BABYLON {
  99471. /**
  99472. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99473. */
  99474. export class ColorSplitterBlock extends NodeMaterialBlock {
  99475. /**
  99476. * Create a new ColorSplitterBlock
  99477. * @param name defines the block name
  99478. */
  99479. constructor(name: string);
  99480. /**
  99481. * Gets the current class name
  99482. * @returns the class name
  99483. */
  99484. getClassName(): string;
  99485. /**
  99486. * Gets the rgba component (input)
  99487. */
  99488. get rgba(): NodeMaterialConnectionPoint;
  99489. /**
  99490. * Gets the rgb component (input)
  99491. */
  99492. get rgbIn(): NodeMaterialConnectionPoint;
  99493. /**
  99494. * Gets the rgb component (output)
  99495. */
  99496. get rgbOut(): NodeMaterialConnectionPoint;
  99497. /**
  99498. * Gets the r component (output)
  99499. */
  99500. get r(): NodeMaterialConnectionPoint;
  99501. /**
  99502. * Gets the g component (output)
  99503. */
  99504. get g(): NodeMaterialConnectionPoint;
  99505. /**
  99506. * Gets the b component (output)
  99507. */
  99508. get b(): NodeMaterialConnectionPoint;
  99509. /**
  99510. * Gets the a component (output)
  99511. */
  99512. get a(): NodeMaterialConnectionPoint;
  99513. protected _inputRename(name: string): string;
  99514. protected _outputRename(name: string): string;
  99515. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99516. }
  99517. }
  99518. declare module BABYLON {
  99519. /**
  99520. * Interface used to configure the node material editor
  99521. */
  99522. export interface INodeMaterialEditorOptions {
  99523. /** Define the URl to load node editor script */
  99524. editorURL?: string;
  99525. }
  99526. /** @hidden */
  99527. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99528. NORMAL: boolean;
  99529. TANGENT: boolean;
  99530. UV1: boolean;
  99531. /** BONES */
  99532. NUM_BONE_INFLUENCERS: number;
  99533. BonesPerMesh: number;
  99534. BONETEXTURE: boolean;
  99535. /** MORPH TARGETS */
  99536. MORPHTARGETS: boolean;
  99537. MORPHTARGETS_NORMAL: boolean;
  99538. MORPHTARGETS_TANGENT: boolean;
  99539. MORPHTARGETS_UV: boolean;
  99540. NUM_MORPH_INFLUENCERS: number;
  99541. /** IMAGE PROCESSING */
  99542. IMAGEPROCESSING: boolean;
  99543. VIGNETTE: boolean;
  99544. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99545. VIGNETTEBLENDMODEOPAQUE: boolean;
  99546. TONEMAPPING: boolean;
  99547. TONEMAPPING_ACES: boolean;
  99548. CONTRAST: boolean;
  99549. EXPOSURE: boolean;
  99550. COLORCURVES: boolean;
  99551. COLORGRADING: boolean;
  99552. COLORGRADING3D: boolean;
  99553. SAMPLER3DGREENDEPTH: boolean;
  99554. SAMPLER3DBGRMAP: boolean;
  99555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99556. /** MISC. */
  99557. BUMPDIRECTUV: number;
  99558. constructor();
  99559. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99560. }
  99561. /**
  99562. * Class used to configure NodeMaterial
  99563. */
  99564. export interface INodeMaterialOptions {
  99565. /**
  99566. * Defines if blocks should emit comments
  99567. */
  99568. emitComments: boolean;
  99569. }
  99570. /**
  99571. * Class used to create a node based material built by assembling shader blocks
  99572. */
  99573. export class NodeMaterial extends PushMaterial {
  99574. private static _BuildIdGenerator;
  99575. private _options;
  99576. private _vertexCompilationState;
  99577. private _fragmentCompilationState;
  99578. private _sharedData;
  99579. private _buildId;
  99580. private _buildWasSuccessful;
  99581. private _cachedWorldViewMatrix;
  99582. private _cachedWorldViewProjectionMatrix;
  99583. private _optimizers;
  99584. private _animationFrame;
  99585. /** Define the Url to load node editor script */
  99586. static EditorURL: string;
  99587. /** Define the Url to load snippets */
  99588. static SnippetUrl: string;
  99589. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99590. static IgnoreTexturesAtLoadTime: boolean;
  99591. private BJSNODEMATERIALEDITOR;
  99592. /** Get the inspector from bundle or global */
  99593. private _getGlobalNodeMaterialEditor;
  99594. /**
  99595. * Snippet ID if the material was created from the snippet server
  99596. */
  99597. snippetId: string;
  99598. /**
  99599. * Gets or sets data used by visual editor
  99600. * @see https://nme.babylonjs.com
  99601. */
  99602. editorData: any;
  99603. /**
  99604. * 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)
  99605. */
  99606. ignoreAlpha: boolean;
  99607. /**
  99608. * Defines the maximum number of lights that can be used in the material
  99609. */
  99610. maxSimultaneousLights: number;
  99611. /**
  99612. * Observable raised when the material is built
  99613. */
  99614. onBuildObservable: Observable<NodeMaterial>;
  99615. /**
  99616. * Gets or sets the root nodes of the material vertex shader
  99617. */
  99618. _vertexOutputNodes: NodeMaterialBlock[];
  99619. /**
  99620. * Gets or sets the root nodes of the material fragment (pixel) shader
  99621. */
  99622. _fragmentOutputNodes: NodeMaterialBlock[];
  99623. /** Gets or sets options to control the node material overall behavior */
  99624. get options(): INodeMaterialOptions;
  99625. set options(options: INodeMaterialOptions);
  99626. /**
  99627. * Default configuration related to image processing available in the standard Material.
  99628. */
  99629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99630. /**
  99631. * Gets the image processing configuration used either in this material.
  99632. */
  99633. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99634. /**
  99635. * Sets the Default image processing configuration used either in the this material.
  99636. *
  99637. * If sets to null, the scene one is in use.
  99638. */
  99639. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99640. /**
  99641. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99642. */
  99643. attachedBlocks: NodeMaterialBlock[];
  99644. /**
  99645. * Specifies the mode of the node material
  99646. * @hidden
  99647. */
  99648. _mode: NodeMaterialModes;
  99649. /**
  99650. * Gets the mode property
  99651. */
  99652. get mode(): NodeMaterialModes;
  99653. /**
  99654. * Create a new node based material
  99655. * @param name defines the material name
  99656. * @param scene defines the hosting scene
  99657. * @param options defines creation option
  99658. */
  99659. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99660. /**
  99661. * Gets the current class name of the material e.g. "NodeMaterial"
  99662. * @returns the class name
  99663. */
  99664. getClassName(): string;
  99665. /**
  99666. * Keep track of the image processing observer to allow dispose and replace.
  99667. */
  99668. private _imageProcessingObserver;
  99669. /**
  99670. * Attaches a new image processing configuration to the Standard Material.
  99671. * @param configuration
  99672. */
  99673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99674. /**
  99675. * Get a block by its name
  99676. * @param name defines the name of the block to retrieve
  99677. * @returns the required block or null if not found
  99678. */
  99679. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99680. /**
  99681. * Get a block by its name
  99682. * @param predicate defines the predicate used to find the good candidate
  99683. * @returns the required block or null if not found
  99684. */
  99685. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99686. /**
  99687. * Get an input block by its name
  99688. * @param predicate defines the predicate used to find the good candidate
  99689. * @returns the required input block or null if not found
  99690. */
  99691. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99692. /**
  99693. * Gets the list of input blocks attached to this material
  99694. * @returns an array of InputBlocks
  99695. */
  99696. getInputBlocks(): InputBlock[];
  99697. /**
  99698. * Adds a new optimizer to the list of optimizers
  99699. * @param optimizer defines the optimizers to add
  99700. * @returns the current material
  99701. */
  99702. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99703. /**
  99704. * Remove an optimizer from the list of optimizers
  99705. * @param optimizer defines the optimizers to remove
  99706. * @returns the current material
  99707. */
  99708. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99709. /**
  99710. * Add a new block to the list of output nodes
  99711. * @param node defines the node to add
  99712. * @returns the current material
  99713. */
  99714. addOutputNode(node: NodeMaterialBlock): this;
  99715. /**
  99716. * Remove a block from the list of root nodes
  99717. * @param node defines the node to remove
  99718. * @returns the current material
  99719. */
  99720. removeOutputNode(node: NodeMaterialBlock): this;
  99721. private _addVertexOutputNode;
  99722. private _removeVertexOutputNode;
  99723. private _addFragmentOutputNode;
  99724. private _removeFragmentOutputNode;
  99725. /**
  99726. * Specifies if the material will require alpha blending
  99727. * @returns a boolean specifying if alpha blending is needed
  99728. */
  99729. needAlphaBlending(): boolean;
  99730. /**
  99731. * Specifies if this material should be rendered in alpha test mode
  99732. * @returns a boolean specifying if an alpha test is needed.
  99733. */
  99734. needAlphaTesting(): boolean;
  99735. private _initializeBlock;
  99736. private _resetDualBlocks;
  99737. /**
  99738. * Remove a block from the current node material
  99739. * @param block defines the block to remove
  99740. */
  99741. removeBlock(block: NodeMaterialBlock): void;
  99742. /**
  99743. * Build the material and generates the inner effect
  99744. * @param verbose defines if the build should log activity
  99745. */
  99746. build(verbose?: boolean): void;
  99747. /**
  99748. * Runs an otpimization phase to try to improve the shader code
  99749. */
  99750. optimize(): void;
  99751. private _prepareDefinesForAttributes;
  99752. /**
  99753. * Create a post process from the material
  99754. * @param camera The camera to apply the render pass to.
  99755. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99757. * @param engine The engine which the post process will be applied. (default: current engine)
  99758. * @param reusable If the post process can be reused on the same frame. (default: false)
  99759. * @param textureType Type of textures used when performing the post process. (default: 0)
  99760. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99761. * @returns the post process created
  99762. */
  99763. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99764. /**
  99765. * Create the post process effect from the material
  99766. * @param postProcess The post process to create the effect for
  99767. */
  99768. createEffectForPostProcess(postProcess: PostProcess): void;
  99769. private _createEffectOrPostProcess;
  99770. private _createEffectForParticles;
  99771. /**
  99772. * Create the effect to be used as the custom effect for a particle system
  99773. * @param particleSystem Particle system to create the effect for
  99774. * @param onCompiled defines a function to call when the effect creation is successful
  99775. * @param onError defines a function to call when the effect creation has failed
  99776. */
  99777. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99778. private _processDefines;
  99779. /**
  99780. * Get if the submesh is ready to be used and all its information available.
  99781. * Child classes can use it to update shaders
  99782. * @param mesh defines the mesh to check
  99783. * @param subMesh defines which submesh to check
  99784. * @param useInstances specifies that instances should be used
  99785. * @returns a boolean indicating that the submesh is ready or not
  99786. */
  99787. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99788. /**
  99789. * Get a string representing the shaders built by the current node graph
  99790. */
  99791. get compiledShaders(): string;
  99792. /**
  99793. * Binds the world matrix to the material
  99794. * @param world defines the world transformation matrix
  99795. */
  99796. bindOnlyWorldMatrix(world: Matrix): void;
  99797. /**
  99798. * Binds the submesh to this material by preparing the effect and shader to draw
  99799. * @param world defines the world transformation matrix
  99800. * @param mesh defines the mesh containing the submesh
  99801. * @param subMesh defines the submesh to bind the material to
  99802. */
  99803. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99804. /**
  99805. * Gets the active textures from the material
  99806. * @returns an array of textures
  99807. */
  99808. getActiveTextures(): BaseTexture[];
  99809. /**
  99810. * Gets the list of texture blocks
  99811. * @returns an array of texture blocks
  99812. */
  99813. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99814. /**
  99815. * Specifies if the material uses a texture
  99816. * @param texture defines the texture to check against the material
  99817. * @returns a boolean specifying if the material uses the texture
  99818. */
  99819. hasTexture(texture: BaseTexture): boolean;
  99820. /**
  99821. * Disposes the material
  99822. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99823. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99824. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99825. */
  99826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99827. /** Creates the node editor window. */
  99828. private _createNodeEditor;
  99829. /**
  99830. * Launch the node material editor
  99831. * @param config Define the configuration of the editor
  99832. * @return a promise fulfilled when the node editor is visible
  99833. */
  99834. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99835. /**
  99836. * Clear the current material
  99837. */
  99838. clear(): void;
  99839. /**
  99840. * Clear the current material and set it to a default state
  99841. */
  99842. setToDefault(): void;
  99843. /**
  99844. * Clear the current material and set it to a default state for post process
  99845. */
  99846. setToDefaultPostProcess(): void;
  99847. /**
  99848. * Clear the current material and set it to a default state for particle
  99849. */
  99850. setToDefaultParticle(): void;
  99851. /**
  99852. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99853. * @param url defines the url to load from
  99854. * @returns a promise that will fullfil when the material is fully loaded
  99855. */
  99856. loadAsync(url: string): Promise<void>;
  99857. private _gatherBlocks;
  99858. /**
  99859. * Generate a string containing the code declaration required to create an equivalent of this material
  99860. * @returns a string
  99861. */
  99862. generateCode(): string;
  99863. /**
  99864. * Serializes this material in a JSON representation
  99865. * @returns the serialized material object
  99866. */
  99867. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99868. private _restoreConnections;
  99869. /**
  99870. * Clear the current graph and load a new one from a serialization object
  99871. * @param source defines the JSON representation of the material
  99872. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99873. */
  99874. loadFromSerialization(source: any, rootUrl?: string): void;
  99875. /**
  99876. * Makes a duplicate of the current material.
  99877. * @param name - name to use for the new material.
  99878. */
  99879. clone(name: string): NodeMaterial;
  99880. /**
  99881. * Creates a node material from parsed material data
  99882. * @param source defines the JSON representation of the material
  99883. * @param scene defines the hosting scene
  99884. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99885. * @returns a new node material
  99886. */
  99887. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99888. /**
  99889. * Creates a node material from a snippet saved in a remote file
  99890. * @param name defines the name of the material to create
  99891. * @param url defines the url to load from
  99892. * @param scene defines the hosting scene
  99893. * @returns a promise that will resolve to the new node material
  99894. */
  99895. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99896. /**
  99897. * Creates a node material from a snippet saved by the node material editor
  99898. * @param snippetId defines the snippet to load
  99899. * @param scene defines the hosting scene
  99900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99901. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99902. * @returns a promise that will resolve to the new node material
  99903. */
  99904. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99905. /**
  99906. * Creates a new node material set to default basic configuration
  99907. * @param name defines the name of the material
  99908. * @param scene defines the hosting scene
  99909. * @returns a new NodeMaterial
  99910. */
  99911. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99912. }
  99913. }
  99914. declare module BABYLON {
  99915. /**
  99916. * Size options for a post process
  99917. */
  99918. export type PostProcessOptions = {
  99919. width: number;
  99920. height: number;
  99921. };
  99922. /**
  99923. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99924. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99925. */
  99926. export class PostProcess {
  99927. /** Name of the PostProcess. */
  99928. name: string;
  99929. /**
  99930. * Gets or sets the unique id of the post process
  99931. */
  99932. uniqueId: number;
  99933. /**
  99934. * Width of the texture to apply the post process on
  99935. */
  99936. width: number;
  99937. /**
  99938. * Height of the texture to apply the post process on
  99939. */
  99940. height: number;
  99941. /**
  99942. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  99943. */
  99944. nodeMaterialSource: Nullable<NodeMaterial>;
  99945. /**
  99946. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  99947. * @hidden
  99948. */
  99949. _outputTexture: Nullable<InternalTexture>;
  99950. /**
  99951. * Sampling mode used by the shader
  99952. * See https://doc.babylonjs.com/classes/3.1/texture
  99953. */
  99954. renderTargetSamplingMode: number;
  99955. /**
  99956. * Clear color to use when screen clearing
  99957. */
  99958. clearColor: Color4;
  99959. /**
  99960. * If the buffer needs to be cleared before applying the post process. (default: true)
  99961. * Should be set to false if shader will overwrite all previous pixels.
  99962. */
  99963. autoClear: boolean;
  99964. /**
  99965. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  99966. */
  99967. alphaMode: number;
  99968. /**
  99969. * Sets the setAlphaBlendConstants of the babylon engine
  99970. */
  99971. alphaConstants: Color4;
  99972. /**
  99973. * Animations to be used for the post processing
  99974. */
  99975. animations: Animation[];
  99976. /**
  99977. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  99978. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  99979. */
  99980. enablePixelPerfectMode: boolean;
  99981. /**
  99982. * Force the postprocess to be applied without taking in account viewport
  99983. */
  99984. forceFullscreenViewport: boolean;
  99985. /**
  99986. * List of inspectable custom properties (used by the Inspector)
  99987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99988. */
  99989. inspectableCustomProperties: IInspectable[];
  99990. /**
  99991. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  99992. *
  99993. * | Value | Type | Description |
  99994. * | ----- | ----------------------------------- | ----------- |
  99995. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  99996. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  99997. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  99998. *
  99999. */
  100000. scaleMode: number;
  100001. /**
  100002. * Force textures to be a power of two (default: false)
  100003. */
  100004. alwaysForcePOT: boolean;
  100005. private _samples;
  100006. /**
  100007. * Number of sample textures (default: 1)
  100008. */
  100009. get samples(): number;
  100010. set samples(n: number);
  100011. /**
  100012. * Modify the scale of the post process to be the same as the viewport (default: false)
  100013. */
  100014. adaptScaleToCurrentViewport: boolean;
  100015. private _camera;
  100016. private _scene;
  100017. private _engine;
  100018. private _options;
  100019. private _reusable;
  100020. private _textureType;
  100021. private _textureFormat;
  100022. /**
  100023. * Smart array of input and output textures for the post process.
  100024. * @hidden
  100025. */
  100026. _textures: SmartArray<InternalTexture>;
  100027. /**
  100028. * The index in _textures that corresponds to the output texture.
  100029. * @hidden
  100030. */
  100031. _currentRenderTextureInd: number;
  100032. private _effect;
  100033. private _samplers;
  100034. private _fragmentUrl;
  100035. private _vertexUrl;
  100036. private _parameters;
  100037. private _scaleRatio;
  100038. protected _indexParameters: any;
  100039. private _shareOutputWithPostProcess;
  100040. private _texelSize;
  100041. private _forcedOutputTexture;
  100042. /**
  100043. * Returns the fragment url or shader name used in the post process.
  100044. * @returns the fragment url or name in the shader store.
  100045. */
  100046. getEffectName(): string;
  100047. /**
  100048. * An event triggered when the postprocess is activated.
  100049. */
  100050. onActivateObservable: Observable<Camera>;
  100051. private _onActivateObserver;
  100052. /**
  100053. * A function that is added to the onActivateObservable
  100054. */
  100055. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100056. /**
  100057. * An event triggered when the postprocess changes its size.
  100058. */
  100059. onSizeChangedObservable: Observable<PostProcess>;
  100060. private _onSizeChangedObserver;
  100061. /**
  100062. * A function that is added to the onSizeChangedObservable
  100063. */
  100064. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100065. /**
  100066. * An event triggered when the postprocess applies its effect.
  100067. */
  100068. onApplyObservable: Observable<Effect>;
  100069. private _onApplyObserver;
  100070. /**
  100071. * A function that is added to the onApplyObservable
  100072. */
  100073. set onApply(callback: (effect: Effect) => void);
  100074. /**
  100075. * An event triggered before rendering the postprocess
  100076. */
  100077. onBeforeRenderObservable: Observable<Effect>;
  100078. private _onBeforeRenderObserver;
  100079. /**
  100080. * A function that is added to the onBeforeRenderObservable
  100081. */
  100082. set onBeforeRender(callback: (effect: Effect) => void);
  100083. /**
  100084. * An event triggered after rendering the postprocess
  100085. */
  100086. onAfterRenderObservable: Observable<Effect>;
  100087. private _onAfterRenderObserver;
  100088. /**
  100089. * A function that is added to the onAfterRenderObservable
  100090. */
  100091. set onAfterRender(callback: (efect: Effect) => void);
  100092. /**
  100093. * 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
  100094. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100095. */
  100096. get inputTexture(): InternalTexture;
  100097. set inputTexture(value: InternalTexture);
  100098. /**
  100099. * Gets the camera which post process is applied to.
  100100. * @returns The camera the post process is applied to.
  100101. */
  100102. getCamera(): Camera;
  100103. /**
  100104. * Gets the texel size of the postprocess.
  100105. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100106. */
  100107. get texelSize(): Vector2;
  100108. /**
  100109. * Creates a new instance PostProcess
  100110. * @param name The name of the PostProcess.
  100111. * @param fragmentUrl The url of the fragment shader to be used.
  100112. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100113. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100114. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100115. * @param camera The camera to apply the render pass to.
  100116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100117. * @param engine The engine which the post process will be applied. (default: current engine)
  100118. * @param reusable If the post process can be reused on the same frame. (default: false)
  100119. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100120. * @param textureType Type of textures used when performing the post process. (default: 0)
  100121. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100122. * @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
  100123. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100124. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100125. */
  100126. constructor(
  100127. /** Name of the PostProcess. */
  100128. 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);
  100129. /**
  100130. * Gets a string idenfifying the name of the class
  100131. * @returns "PostProcess" string
  100132. */
  100133. getClassName(): string;
  100134. /**
  100135. * Gets the engine which this post process belongs to.
  100136. * @returns The engine the post process was enabled with.
  100137. */
  100138. getEngine(): Engine;
  100139. /**
  100140. * The effect that is created when initializing the post process.
  100141. * @returns The created effect corresponding the the postprocess.
  100142. */
  100143. getEffect(): Effect;
  100144. /**
  100145. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100146. * @param postProcess The post process to share the output with.
  100147. * @returns This post process.
  100148. */
  100149. shareOutputWith(postProcess: PostProcess): PostProcess;
  100150. /**
  100151. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100152. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100153. */
  100154. useOwnOutput(): void;
  100155. /**
  100156. * Updates the effect with the current post process compile time values and recompiles the shader.
  100157. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100158. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100159. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100160. * @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
  100161. * @param onCompiled Called when the shader has been compiled.
  100162. * @param onError Called if there is an error when compiling a shader.
  100163. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100164. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100165. */
  100166. 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;
  100167. /**
  100168. * The post process is reusable if it can be used multiple times within one frame.
  100169. * @returns If the post process is reusable
  100170. */
  100171. isReusable(): boolean;
  100172. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100173. markTextureDirty(): void;
  100174. /**
  100175. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100176. * 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.
  100177. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100178. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100179. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100180. * @returns The target texture that was bound to be written to.
  100181. */
  100182. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100183. /**
  100184. * If the post process is supported.
  100185. */
  100186. get isSupported(): boolean;
  100187. /**
  100188. * The aspect ratio of the output texture.
  100189. */
  100190. get aspectRatio(): number;
  100191. /**
  100192. * Get a value indicating if the post-process is ready to be used
  100193. * @returns true if the post-process is ready (shader is compiled)
  100194. */
  100195. isReady(): boolean;
  100196. /**
  100197. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100198. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100199. */
  100200. apply(): Nullable<Effect>;
  100201. private _disposeTextures;
  100202. /**
  100203. * Disposes the post process.
  100204. * @param camera The camera to dispose the post process on.
  100205. */
  100206. dispose(camera?: Camera): void;
  100207. }
  100208. }
  100209. declare module BABYLON {
  100210. /** @hidden */
  100211. export var kernelBlurVaryingDeclaration: {
  100212. name: string;
  100213. shader: string;
  100214. };
  100215. }
  100216. declare module BABYLON {
  100217. /** @hidden */
  100218. export var kernelBlurFragment: {
  100219. name: string;
  100220. shader: string;
  100221. };
  100222. }
  100223. declare module BABYLON {
  100224. /** @hidden */
  100225. export var kernelBlurFragment2: {
  100226. name: string;
  100227. shader: string;
  100228. };
  100229. }
  100230. declare module BABYLON {
  100231. /** @hidden */
  100232. export var kernelBlurPixelShader: {
  100233. name: string;
  100234. shader: string;
  100235. };
  100236. }
  100237. declare module BABYLON {
  100238. /** @hidden */
  100239. export var kernelBlurVertex: {
  100240. name: string;
  100241. shader: string;
  100242. };
  100243. }
  100244. declare module BABYLON {
  100245. /** @hidden */
  100246. export var kernelBlurVertexShader: {
  100247. name: string;
  100248. shader: string;
  100249. };
  100250. }
  100251. declare module BABYLON {
  100252. /**
  100253. * The Blur Post Process which blurs an image based on a kernel and direction.
  100254. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100255. */
  100256. export class BlurPostProcess extends PostProcess {
  100257. /** The direction in which to blur the image. */
  100258. direction: Vector2;
  100259. private blockCompilation;
  100260. protected _kernel: number;
  100261. protected _idealKernel: number;
  100262. protected _packedFloat: boolean;
  100263. private _staticDefines;
  100264. /**
  100265. * Sets the length in pixels of the blur sample region
  100266. */
  100267. set kernel(v: number);
  100268. /**
  100269. * Gets the length in pixels of the blur sample region
  100270. */
  100271. get kernel(): number;
  100272. /**
  100273. * Sets wether or not the blur needs to unpack/repack floats
  100274. */
  100275. set packedFloat(v: boolean);
  100276. /**
  100277. * Gets wether or not the blur is unpacking/repacking floats
  100278. */
  100279. get packedFloat(): boolean;
  100280. /**
  100281. * Creates a new instance BlurPostProcess
  100282. * @param name The name of the effect.
  100283. * @param direction The direction in which to blur the image.
  100284. * @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.
  100285. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100286. * @param camera The camera to apply the render pass to.
  100287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100288. * @param engine The engine which the post process will be applied. (default: current engine)
  100289. * @param reusable If the post process can be reused on the same frame. (default: false)
  100290. * @param textureType Type of textures used when performing the post process. (default: 0)
  100291. * @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)
  100292. */
  100293. constructor(name: string,
  100294. /** The direction in which to blur the image. */
  100295. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100296. /**
  100297. * Updates the effect with the current post process compile time values and recompiles the shader.
  100298. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100299. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100300. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100301. * @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
  100302. * @param onCompiled Called when the shader has been compiled.
  100303. * @param onError Called if there is an error when compiling a shader.
  100304. */
  100305. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100306. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100307. /**
  100308. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100309. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100310. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100311. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100312. * The gaps between physical kernels are compensated for in the weighting of the samples
  100313. * @param idealKernel Ideal blur kernel.
  100314. * @return Nearest best kernel.
  100315. */
  100316. protected _nearestBestKernel(idealKernel: number): number;
  100317. /**
  100318. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100319. * @param x The point on the Gaussian distribution to sample.
  100320. * @return the value of the Gaussian function at x.
  100321. */
  100322. protected _gaussianWeight(x: number): number;
  100323. /**
  100324. * Generates a string that can be used as a floating point number in GLSL.
  100325. * @param x Value to print.
  100326. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100327. * @return GLSL float string.
  100328. */
  100329. protected _glslFloat(x: number, decimalFigures?: number): string;
  100330. }
  100331. }
  100332. declare module BABYLON {
  100333. /**
  100334. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100335. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100336. * You can then easily use it as a reflectionTexture on a flat surface.
  100337. * In case the surface is not a plane, please consider relying on reflection probes.
  100338. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100339. */
  100340. export class MirrorTexture extends RenderTargetTexture {
  100341. private scene;
  100342. /**
  100343. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100344. * 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.
  100345. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100346. */
  100347. mirrorPlane: Plane;
  100348. /**
  100349. * Define the blur ratio used to blur the reflection if needed.
  100350. */
  100351. set blurRatio(value: number);
  100352. get blurRatio(): number;
  100353. /**
  100354. * Define the adaptive blur kernel used to blur the reflection if needed.
  100355. * This will autocompute the closest best match for the `blurKernel`
  100356. */
  100357. set adaptiveBlurKernel(value: number);
  100358. /**
  100359. * Define the blur kernel used to blur the reflection if needed.
  100360. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100361. */
  100362. set blurKernel(value: number);
  100363. /**
  100364. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100365. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100366. */
  100367. set blurKernelX(value: number);
  100368. get blurKernelX(): number;
  100369. /**
  100370. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100371. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100372. */
  100373. set blurKernelY(value: number);
  100374. get blurKernelY(): number;
  100375. private _autoComputeBlurKernel;
  100376. protected _onRatioRescale(): void;
  100377. private _updateGammaSpace;
  100378. private _imageProcessingConfigChangeObserver;
  100379. private _transformMatrix;
  100380. private _mirrorMatrix;
  100381. private _savedViewMatrix;
  100382. private _blurX;
  100383. private _blurY;
  100384. private _adaptiveBlurKernel;
  100385. private _blurKernelX;
  100386. private _blurKernelY;
  100387. private _blurRatio;
  100388. /**
  100389. * Instantiates a Mirror Texture.
  100390. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100391. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100392. * You can then easily use it as a reflectionTexture on a flat surface.
  100393. * In case the surface is not a plane, please consider relying on reflection probes.
  100394. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100395. * @param name
  100396. * @param size
  100397. * @param scene
  100398. * @param generateMipMaps
  100399. * @param type
  100400. * @param samplingMode
  100401. * @param generateDepthBuffer
  100402. */
  100403. constructor(name: string, size: number | {
  100404. width: number;
  100405. height: number;
  100406. } | {
  100407. ratio: number;
  100408. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100409. private _preparePostProcesses;
  100410. /**
  100411. * Clone the mirror texture.
  100412. * @returns the cloned texture
  100413. */
  100414. clone(): MirrorTexture;
  100415. /**
  100416. * Serialize the texture to a JSON representation you could use in Parse later on
  100417. * @returns the serialized JSON representation
  100418. */
  100419. serialize(): any;
  100420. /**
  100421. * Dispose the texture and release its associated resources.
  100422. */
  100423. dispose(): void;
  100424. }
  100425. }
  100426. declare module BABYLON {
  100427. /**
  100428. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100429. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100430. */
  100431. export class Texture extends BaseTexture {
  100432. /**
  100433. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100434. */
  100435. static SerializeBuffers: boolean;
  100436. /** @hidden */
  100437. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100438. /** @hidden */
  100439. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100440. /** @hidden */
  100441. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100442. /** nearest is mag = nearest and min = nearest and mip = linear */
  100443. static readonly NEAREST_SAMPLINGMODE: number;
  100444. /** nearest is mag = nearest and min = nearest and mip = linear */
  100445. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100446. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100447. static readonly BILINEAR_SAMPLINGMODE: number;
  100448. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100449. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100450. /** Trilinear is mag = linear and min = linear and mip = linear */
  100451. static readonly TRILINEAR_SAMPLINGMODE: number;
  100452. /** Trilinear is mag = linear and min = linear and mip = linear */
  100453. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100454. /** mag = nearest and min = nearest and mip = nearest */
  100455. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100456. /** mag = nearest and min = linear and mip = nearest */
  100457. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100458. /** mag = nearest and min = linear and mip = linear */
  100459. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100460. /** mag = nearest and min = linear and mip = none */
  100461. static readonly NEAREST_LINEAR: number;
  100462. /** mag = nearest and min = nearest and mip = none */
  100463. static readonly NEAREST_NEAREST: number;
  100464. /** mag = linear and min = nearest and mip = nearest */
  100465. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100466. /** mag = linear and min = nearest and mip = linear */
  100467. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100468. /** mag = linear and min = linear and mip = none */
  100469. static readonly LINEAR_LINEAR: number;
  100470. /** mag = linear and min = nearest and mip = none */
  100471. static readonly LINEAR_NEAREST: number;
  100472. /** Explicit coordinates mode */
  100473. static readonly EXPLICIT_MODE: number;
  100474. /** Spherical coordinates mode */
  100475. static readonly SPHERICAL_MODE: number;
  100476. /** Planar coordinates mode */
  100477. static readonly PLANAR_MODE: number;
  100478. /** Cubic coordinates mode */
  100479. static readonly CUBIC_MODE: number;
  100480. /** Projection coordinates mode */
  100481. static readonly PROJECTION_MODE: number;
  100482. /** Inverse Cubic coordinates mode */
  100483. static readonly SKYBOX_MODE: number;
  100484. /** Inverse Cubic coordinates mode */
  100485. static readonly INVCUBIC_MODE: number;
  100486. /** Equirectangular coordinates mode */
  100487. static readonly EQUIRECTANGULAR_MODE: number;
  100488. /** Equirectangular Fixed coordinates mode */
  100489. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100490. /** Equirectangular Fixed Mirrored coordinates mode */
  100491. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100492. /** Texture is not repeating outside of 0..1 UVs */
  100493. static readonly CLAMP_ADDRESSMODE: number;
  100494. /** Texture is repeating outside of 0..1 UVs */
  100495. static readonly WRAP_ADDRESSMODE: number;
  100496. /** Texture is repeating and mirrored */
  100497. static readonly MIRROR_ADDRESSMODE: number;
  100498. /**
  100499. * 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
  100500. */
  100501. static UseSerializedUrlIfAny: boolean;
  100502. /**
  100503. * Define the url of the texture.
  100504. */
  100505. url: Nullable<string>;
  100506. /**
  100507. * Define an offset on the texture to offset the u coordinates of the UVs
  100508. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100509. */
  100510. uOffset: number;
  100511. /**
  100512. * Define an offset on the texture to offset the v coordinates of the UVs
  100513. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100514. */
  100515. vOffset: number;
  100516. /**
  100517. * Define an offset on the texture to scale the u coordinates of the UVs
  100518. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100519. */
  100520. uScale: number;
  100521. /**
  100522. * Define an offset on the texture to scale the v coordinates of the UVs
  100523. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100524. */
  100525. vScale: number;
  100526. /**
  100527. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100528. * @see http://doc.babylonjs.com/how_to/more_materials
  100529. */
  100530. uAng: number;
  100531. /**
  100532. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100533. * @see http://doc.babylonjs.com/how_to/more_materials
  100534. */
  100535. vAng: number;
  100536. /**
  100537. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100538. * @see http://doc.babylonjs.com/how_to/more_materials
  100539. */
  100540. wAng: number;
  100541. /**
  100542. * Defines the center of rotation (U)
  100543. */
  100544. uRotationCenter: number;
  100545. /**
  100546. * Defines the center of rotation (V)
  100547. */
  100548. vRotationCenter: number;
  100549. /**
  100550. * Defines the center of rotation (W)
  100551. */
  100552. wRotationCenter: number;
  100553. /**
  100554. * Are mip maps generated for this texture or not.
  100555. */
  100556. get noMipmap(): boolean;
  100557. /**
  100558. * List of inspectable custom properties (used by the Inspector)
  100559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100560. */
  100561. inspectableCustomProperties: Nullable<IInspectable[]>;
  100562. private _noMipmap;
  100563. /** @hidden */
  100564. _invertY: boolean;
  100565. private _rowGenerationMatrix;
  100566. private _cachedTextureMatrix;
  100567. private _projectionModeMatrix;
  100568. private _t0;
  100569. private _t1;
  100570. private _t2;
  100571. private _cachedUOffset;
  100572. private _cachedVOffset;
  100573. private _cachedUScale;
  100574. private _cachedVScale;
  100575. private _cachedUAng;
  100576. private _cachedVAng;
  100577. private _cachedWAng;
  100578. private _cachedProjectionMatrixId;
  100579. private _cachedCoordinatesMode;
  100580. /** @hidden */
  100581. protected _initialSamplingMode: number;
  100582. /** @hidden */
  100583. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100584. private _deleteBuffer;
  100585. protected _format: Nullable<number>;
  100586. private _delayedOnLoad;
  100587. private _delayedOnError;
  100588. private _mimeType?;
  100589. /**
  100590. * Observable triggered once the texture has been loaded.
  100591. */
  100592. onLoadObservable: Observable<Texture>;
  100593. protected _isBlocking: boolean;
  100594. /**
  100595. * Is the texture preventing material to render while loading.
  100596. * If false, a default texture will be used instead of the loading one during the preparation step.
  100597. */
  100598. set isBlocking(value: boolean);
  100599. get isBlocking(): boolean;
  100600. /**
  100601. * Get the current sampling mode associated with the texture.
  100602. */
  100603. get samplingMode(): number;
  100604. /**
  100605. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100606. */
  100607. get invertY(): boolean;
  100608. /**
  100609. * Instantiates a new texture.
  100610. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100611. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100612. * @param url defines the url of the picture to load as a texture
  100613. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100614. * @param noMipmap defines if the texture will require mip maps or not
  100615. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100616. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100617. * @param onLoad defines a callback triggered when the texture has been loaded
  100618. * @param onError defines a callback triggered when an error occurred during the loading session
  100619. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100620. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100621. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100622. * @param mimeType defines an optional mime type information
  100623. */
  100624. 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);
  100625. /**
  100626. * Update the url (and optional buffer) of this texture if url was null during construction.
  100627. * @param url the url of the texture
  100628. * @param buffer the buffer of the texture (defaults to null)
  100629. * @param onLoad callback called when the texture is loaded (defaults to null)
  100630. */
  100631. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100632. /**
  100633. * Finish the loading sequence of a texture flagged as delayed load.
  100634. * @hidden
  100635. */
  100636. delayLoad(): void;
  100637. private _prepareRowForTextureGeneration;
  100638. /**
  100639. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100640. * @returns the transform matrix of the texture.
  100641. */
  100642. getTextureMatrix(uBase?: number): Matrix;
  100643. /**
  100644. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100645. * @returns The reflection texture transform
  100646. */
  100647. getReflectionTextureMatrix(): Matrix;
  100648. /**
  100649. * Clones the texture.
  100650. * @returns the cloned texture
  100651. */
  100652. clone(): Texture;
  100653. /**
  100654. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100655. * @returns The JSON representation of the texture
  100656. */
  100657. serialize(): any;
  100658. /**
  100659. * Get the current class name of the texture useful for serialization or dynamic coding.
  100660. * @returns "Texture"
  100661. */
  100662. getClassName(): string;
  100663. /**
  100664. * Dispose the texture and release its associated resources.
  100665. */
  100666. dispose(): void;
  100667. /**
  100668. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100669. * @param parsedTexture Define the JSON representation of the texture
  100670. * @param scene Define the scene the parsed texture should be instantiated in
  100671. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100672. * @returns The parsed texture if successful
  100673. */
  100674. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100675. /**
  100676. * Creates a texture from its base 64 representation.
  100677. * @param data Define the base64 payload without the data: prefix
  100678. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100679. * @param scene Define the scene the texture should belong to
  100680. * @param noMipmap Forces the texture to not create mip map information if true
  100681. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100682. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100683. * @param onLoad define a callback triggered when the texture has been loaded
  100684. * @param onError define a callback triggered when an error occurred during the loading session
  100685. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100686. * @returns the created texture
  100687. */
  100688. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100689. /**
  100690. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100691. * @param data Define the base64 payload without the data: prefix
  100692. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100693. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100694. * @param scene Define the scene the texture should belong to
  100695. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100696. * @param noMipmap Forces the texture to not create mip map information if true
  100697. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100698. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100699. * @param onLoad define a callback triggered when the texture has been loaded
  100700. * @param onError define a callback triggered when an error occurred during the loading session
  100701. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100702. * @returns the created texture
  100703. */
  100704. 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;
  100705. }
  100706. }
  100707. declare module BABYLON {
  100708. /**
  100709. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100710. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100711. */
  100712. export class PostProcessManager {
  100713. private _scene;
  100714. private _indexBuffer;
  100715. private _vertexBuffers;
  100716. /**
  100717. * Creates a new instance PostProcess
  100718. * @param scene The scene that the post process is associated with.
  100719. */
  100720. constructor(scene: Scene);
  100721. private _prepareBuffers;
  100722. private _buildIndexBuffer;
  100723. /**
  100724. * Rebuilds the vertex buffers of the manager.
  100725. * @hidden
  100726. */
  100727. _rebuild(): void;
  100728. /**
  100729. * Prepares a frame to be run through a post process.
  100730. * @param sourceTexture The input texture to the post procesess. (default: null)
  100731. * @param postProcesses An array of post processes to be run. (default: null)
  100732. * @returns True if the post processes were able to be run.
  100733. * @hidden
  100734. */
  100735. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100736. /**
  100737. * Manually render a set of post processes to a texture.
  100738. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100739. * @param postProcesses An array of post processes to be run.
  100740. * @param targetTexture The target texture to render to.
  100741. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100742. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100743. * @param lodLevel defines which lod of the texture to render to
  100744. */
  100745. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100746. /**
  100747. * Finalize the result of the output of the postprocesses.
  100748. * @param doNotPresent If true the result will not be displayed to the screen.
  100749. * @param targetTexture The target texture to render to.
  100750. * @param faceIndex The index of the face to bind the target texture to.
  100751. * @param postProcesses The array of post processes to render.
  100752. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100753. * @hidden
  100754. */
  100755. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100756. /**
  100757. * Disposes of the post process manager.
  100758. */
  100759. dispose(): void;
  100760. }
  100761. }
  100762. declare module BABYLON {
  100763. /**
  100764. * This Helps creating a texture that will be created from a camera in your scene.
  100765. * It is basically a dynamic texture that could be used to create special effects for instance.
  100766. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100767. */
  100768. export class RenderTargetTexture extends Texture {
  100769. isCube: boolean;
  100770. /**
  100771. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100772. */
  100773. static readonly REFRESHRATE_RENDER_ONCE: number;
  100774. /**
  100775. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100776. */
  100777. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100778. /**
  100779. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100780. * the central point of your effect and can save a lot of performances.
  100781. */
  100782. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100783. /**
  100784. * Use this predicate to dynamically define the list of mesh you want to render.
  100785. * If set, the renderList property will be overwritten.
  100786. */
  100787. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100788. private _renderList;
  100789. /**
  100790. * Use this list to define the list of mesh you want to render.
  100791. */
  100792. get renderList(): Nullable<Array<AbstractMesh>>;
  100793. set renderList(value: Nullable<Array<AbstractMesh>>);
  100794. /**
  100795. * Use this function to overload the renderList array at rendering time.
  100796. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100797. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100798. * the cube (if the RTT is a cube, else layerOrFace=0).
  100799. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100800. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100801. * hold dummy elements!
  100802. */
  100803. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100804. private _hookArray;
  100805. /**
  100806. * Define if particles should be rendered in your texture.
  100807. */
  100808. renderParticles: boolean;
  100809. /**
  100810. * Define if sprites should be rendered in your texture.
  100811. */
  100812. renderSprites: boolean;
  100813. /**
  100814. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100815. */
  100816. coordinatesMode: number;
  100817. /**
  100818. * Define the camera used to render the texture.
  100819. */
  100820. activeCamera: Nullable<Camera>;
  100821. /**
  100822. * Override the mesh isReady function with your own one.
  100823. */
  100824. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100825. /**
  100826. * Override the render function of the texture with your own one.
  100827. */
  100828. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100829. /**
  100830. * Define if camera post processes should be use while rendering the texture.
  100831. */
  100832. useCameraPostProcesses: boolean;
  100833. /**
  100834. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100835. */
  100836. ignoreCameraViewport: boolean;
  100837. private _postProcessManager;
  100838. private _postProcesses;
  100839. private _resizeObserver;
  100840. /**
  100841. * An event triggered when the texture is unbind.
  100842. */
  100843. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100844. /**
  100845. * An event triggered when the texture is unbind.
  100846. */
  100847. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100848. private _onAfterUnbindObserver;
  100849. /**
  100850. * Set a after unbind callback in the texture.
  100851. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100852. */
  100853. set onAfterUnbind(callback: () => void);
  100854. /**
  100855. * An event triggered before rendering the texture
  100856. */
  100857. onBeforeRenderObservable: Observable<number>;
  100858. private _onBeforeRenderObserver;
  100859. /**
  100860. * Set a before render callback in the texture.
  100861. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100862. */
  100863. set onBeforeRender(callback: (faceIndex: number) => void);
  100864. /**
  100865. * An event triggered after rendering the texture
  100866. */
  100867. onAfterRenderObservable: Observable<number>;
  100868. private _onAfterRenderObserver;
  100869. /**
  100870. * Set a after render callback in the texture.
  100871. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100872. */
  100873. set onAfterRender(callback: (faceIndex: number) => void);
  100874. /**
  100875. * An event triggered after the texture clear
  100876. */
  100877. onClearObservable: Observable<Engine>;
  100878. private _onClearObserver;
  100879. /**
  100880. * Set a clear callback in the texture.
  100881. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100882. */
  100883. set onClear(callback: (Engine: Engine) => void);
  100884. /**
  100885. * An event triggered when the texture is resized.
  100886. */
  100887. onResizeObservable: Observable<RenderTargetTexture>;
  100888. /**
  100889. * Define the clear color of the Render Target if it should be different from the scene.
  100890. */
  100891. clearColor: Color4;
  100892. protected _size: number | {
  100893. width: number;
  100894. height: number;
  100895. layers?: number;
  100896. };
  100897. protected _initialSizeParameter: number | {
  100898. width: number;
  100899. height: number;
  100900. } | {
  100901. ratio: number;
  100902. };
  100903. protected _sizeRatio: Nullable<number>;
  100904. /** @hidden */
  100905. _generateMipMaps: boolean;
  100906. protected _renderingManager: RenderingManager;
  100907. /** @hidden */
  100908. _waitingRenderList: string[];
  100909. protected _doNotChangeAspectRatio: boolean;
  100910. protected _currentRefreshId: number;
  100911. protected _refreshRate: number;
  100912. protected _textureMatrix: Matrix;
  100913. protected _samples: number;
  100914. protected _renderTargetOptions: RenderTargetCreationOptions;
  100915. /**
  100916. * Gets render target creation options that were used.
  100917. */
  100918. get renderTargetOptions(): RenderTargetCreationOptions;
  100919. protected _onRatioRescale(): void;
  100920. /**
  100921. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100922. * It must define where the camera used to render the texture is set
  100923. */
  100924. boundingBoxPosition: Vector3;
  100925. private _boundingBoxSize;
  100926. /**
  100927. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100928. * When defined, the cubemap will switch to local mode
  100929. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  100930. * @example https://www.babylonjs-playground.com/#RNASML
  100931. */
  100932. set boundingBoxSize(value: Vector3);
  100933. get boundingBoxSize(): Vector3;
  100934. /**
  100935. * In case the RTT has been created with a depth texture, get the associated
  100936. * depth texture.
  100937. * Otherwise, return null.
  100938. */
  100939. get depthStencilTexture(): Nullable<InternalTexture>;
  100940. /**
  100941. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  100942. * or used a shadow, depth texture...
  100943. * @param name The friendly name of the texture
  100944. * @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)
  100945. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  100946. * @param generateMipMaps True if mip maps need to be generated after render.
  100947. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  100948. * @param type The type of the buffer in the RTT (int, half float, float...)
  100949. * @param isCube True if a cube texture needs to be created
  100950. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  100951. * @param generateDepthBuffer True to generate a depth buffer
  100952. * @param generateStencilBuffer True to generate a stencil buffer
  100953. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  100954. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  100955. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100956. */
  100957. constructor(name: string, size: number | {
  100958. width: number;
  100959. height: number;
  100960. layers?: number;
  100961. } | {
  100962. ratio: number;
  100963. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  100964. /**
  100965. * Creates a depth stencil texture.
  100966. * This is only available in WebGL 2 or with the depth texture extension available.
  100967. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  100968. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  100969. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  100970. */
  100971. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  100972. private _processSizeParameter;
  100973. /**
  100974. * Define the number of samples to use in case of MSAA.
  100975. * It defaults to one meaning no MSAA has been enabled.
  100976. */
  100977. get samples(): number;
  100978. set samples(value: number);
  100979. /**
  100980. * Resets the refresh counter of the texture and start bak from scratch.
  100981. * Could be useful to regenerate the texture if it is setup to render only once.
  100982. */
  100983. resetRefreshCounter(): void;
  100984. /**
  100985. * Define the refresh rate of the texture or the rendering frequency.
  100986. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  100987. */
  100988. get refreshRate(): number;
  100989. set refreshRate(value: number);
  100990. /**
  100991. * Adds a post process to the render target rendering passes.
  100992. * @param postProcess define the post process to add
  100993. */
  100994. addPostProcess(postProcess: PostProcess): void;
  100995. /**
  100996. * Clear all the post processes attached to the render target
  100997. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  100998. */
  100999. clearPostProcesses(dispose?: boolean): void;
  101000. /**
  101001. * Remove one of the post process from the list of attached post processes to the texture
  101002. * @param postProcess define the post process to remove from the list
  101003. */
  101004. removePostProcess(postProcess: PostProcess): void;
  101005. /** @hidden */
  101006. _shouldRender(): boolean;
  101007. /**
  101008. * Gets the actual render size of the texture.
  101009. * @returns the width of the render size
  101010. */
  101011. getRenderSize(): number;
  101012. /**
  101013. * Gets the actual render width of the texture.
  101014. * @returns the width of the render size
  101015. */
  101016. getRenderWidth(): number;
  101017. /**
  101018. * Gets the actual render height of the texture.
  101019. * @returns the height of the render size
  101020. */
  101021. getRenderHeight(): number;
  101022. /**
  101023. * Gets the actual number of layers of the texture.
  101024. * @returns the number of layers
  101025. */
  101026. getRenderLayers(): number;
  101027. /**
  101028. * Get if the texture can be rescaled or not.
  101029. */
  101030. get canRescale(): boolean;
  101031. /**
  101032. * Resize the texture using a ratio.
  101033. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101034. */
  101035. scale(ratio: number): void;
  101036. /**
  101037. * Get the texture reflection matrix used to rotate/transform the reflection.
  101038. * @returns the reflection matrix
  101039. */
  101040. getReflectionTextureMatrix(): Matrix;
  101041. /**
  101042. * Resize the texture to a new desired size.
  101043. * Be carrefull as it will recreate all the data in the new texture.
  101044. * @param size Define the new size. It can be:
  101045. * - a number for squared texture,
  101046. * - an object containing { width: number, height: number }
  101047. * - or an object containing a ratio { ratio: number }
  101048. */
  101049. resize(size: number | {
  101050. width: number;
  101051. height: number;
  101052. } | {
  101053. ratio: number;
  101054. }): void;
  101055. private _defaultRenderListPrepared;
  101056. /**
  101057. * Renders all the objects from the render list into the texture.
  101058. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101059. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101060. */
  101061. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101062. private _bestReflectionRenderTargetDimension;
  101063. private _prepareRenderingManager;
  101064. /**
  101065. * @hidden
  101066. * @param faceIndex face index to bind to if this is a cubetexture
  101067. * @param layer defines the index of the texture to bind in the array
  101068. */
  101069. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101070. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101071. private renderToTarget;
  101072. /**
  101073. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101074. * This allowed control for front to back rendering or reversly depending of the special needs.
  101075. *
  101076. * @param renderingGroupId The rendering group id corresponding to its index
  101077. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101078. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101079. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101080. */
  101081. 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;
  101082. /**
  101083. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101084. *
  101085. * @param renderingGroupId The rendering group id corresponding to its index
  101086. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101087. */
  101088. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101089. /**
  101090. * Clones the texture.
  101091. * @returns the cloned texture
  101092. */
  101093. clone(): RenderTargetTexture;
  101094. /**
  101095. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101096. * @returns The JSON representation of the texture
  101097. */
  101098. serialize(): any;
  101099. /**
  101100. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101101. */
  101102. disposeFramebufferObjects(): void;
  101103. /**
  101104. * Dispose the texture and release its associated resources.
  101105. */
  101106. dispose(): void;
  101107. /** @hidden */
  101108. _rebuild(): void;
  101109. /**
  101110. * Clear the info related to rendering groups preventing retention point in material dispose.
  101111. */
  101112. freeRenderingGroups(): void;
  101113. /**
  101114. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101115. * @returns the view count
  101116. */
  101117. getViewCount(): number;
  101118. }
  101119. }
  101120. declare module BABYLON {
  101121. /**
  101122. * Class used to manipulate GUIDs
  101123. */
  101124. export class GUID {
  101125. /**
  101126. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101127. * Be aware Math.random() could cause collisions, but:
  101128. * "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"
  101129. * @returns a pseudo random id
  101130. */
  101131. static RandomId(): string;
  101132. }
  101133. }
  101134. declare module BABYLON {
  101135. /**
  101136. * Options to be used when creating a shadow depth material
  101137. */
  101138. export interface IIOptionShadowDepthMaterial {
  101139. /** Variables in the vertex shader code that need to have their names remapped.
  101140. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101141. * "var_name" should be either: worldPos or vNormalW
  101142. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101143. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101144. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101145. */
  101146. remappedVariables?: string[];
  101147. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101148. standalone?: boolean;
  101149. }
  101150. /**
  101151. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101152. */
  101153. export class ShadowDepthWrapper {
  101154. private _scene;
  101155. private _options?;
  101156. private _baseMaterial;
  101157. private _onEffectCreatedObserver;
  101158. private _subMeshToEffect;
  101159. private _subMeshToDepthEffect;
  101160. private _meshes;
  101161. /** @hidden */
  101162. _matriceNames: any;
  101163. /** Gets the standalone status of the wrapper */
  101164. get standalone(): boolean;
  101165. /** Gets the base material the wrapper is built upon */
  101166. get baseMaterial(): Material;
  101167. /**
  101168. * Instantiate a new shadow depth wrapper.
  101169. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101170. * generate the shadow depth map. For more information, please refer to the documentation:
  101171. * https://doc.babylonjs.com/babylon101/shadows
  101172. * @param baseMaterial Material to wrap
  101173. * @param scene Define the scene the material belongs to
  101174. * @param options Options used to create the wrapper
  101175. */
  101176. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101177. /**
  101178. * Gets the effect to use to generate the depth map
  101179. * @param subMesh subMesh to get the effect for
  101180. * @param shadowGenerator shadow generator to get the effect for
  101181. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101182. */
  101183. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101184. /**
  101185. * Specifies that the submesh is ready to be used for depth rendering
  101186. * @param subMesh submesh to check
  101187. * @param defines the list of defines to take into account when checking the effect
  101188. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101189. * @param useInstances specifies that instances should be used
  101190. * @returns a boolean indicating that the submesh is ready or not
  101191. */
  101192. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101193. /**
  101194. * Disposes the resources
  101195. */
  101196. dispose(): void;
  101197. private _makeEffect;
  101198. }
  101199. }
  101200. declare module BABYLON {
  101201. /**
  101202. * Options for compiling materials.
  101203. */
  101204. export interface IMaterialCompilationOptions {
  101205. /**
  101206. * Defines whether clip planes are enabled.
  101207. */
  101208. clipPlane: boolean;
  101209. /**
  101210. * Defines whether instances are enabled.
  101211. */
  101212. useInstances: boolean;
  101213. }
  101214. /**
  101215. * Options passed when calling customShaderNameResolve
  101216. */
  101217. export interface ICustomShaderNameResolveOptions {
  101218. /**
  101219. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  101220. */
  101221. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101222. }
  101223. /**
  101224. * Base class for the main features of a material in Babylon.js
  101225. */
  101226. export class Material implements IAnimatable {
  101227. /**
  101228. * Returns the triangle fill mode
  101229. */
  101230. static readonly TriangleFillMode: number;
  101231. /**
  101232. * Returns the wireframe mode
  101233. */
  101234. static readonly WireFrameFillMode: number;
  101235. /**
  101236. * Returns the point fill mode
  101237. */
  101238. static readonly PointFillMode: number;
  101239. /**
  101240. * Returns the point list draw mode
  101241. */
  101242. static readonly PointListDrawMode: number;
  101243. /**
  101244. * Returns the line list draw mode
  101245. */
  101246. static readonly LineListDrawMode: number;
  101247. /**
  101248. * Returns the line loop draw mode
  101249. */
  101250. static readonly LineLoopDrawMode: number;
  101251. /**
  101252. * Returns the line strip draw mode
  101253. */
  101254. static readonly LineStripDrawMode: number;
  101255. /**
  101256. * Returns the triangle strip draw mode
  101257. */
  101258. static readonly TriangleStripDrawMode: number;
  101259. /**
  101260. * Returns the triangle fan draw mode
  101261. */
  101262. static readonly TriangleFanDrawMode: number;
  101263. /**
  101264. * Stores the clock-wise side orientation
  101265. */
  101266. static readonly ClockWiseSideOrientation: number;
  101267. /**
  101268. * Stores the counter clock-wise side orientation
  101269. */
  101270. static readonly CounterClockWiseSideOrientation: number;
  101271. /**
  101272. * The dirty texture flag value
  101273. */
  101274. static readonly TextureDirtyFlag: number;
  101275. /**
  101276. * The dirty light flag value
  101277. */
  101278. static readonly LightDirtyFlag: number;
  101279. /**
  101280. * The dirty fresnel flag value
  101281. */
  101282. static readonly FresnelDirtyFlag: number;
  101283. /**
  101284. * The dirty attribute flag value
  101285. */
  101286. static readonly AttributesDirtyFlag: number;
  101287. /**
  101288. * The dirty misc flag value
  101289. */
  101290. static readonly MiscDirtyFlag: number;
  101291. /**
  101292. * The all dirty flag value
  101293. */
  101294. static readonly AllDirtyFlag: number;
  101295. /**
  101296. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101297. */
  101298. static readonly MATERIAL_OPAQUE: number;
  101299. /**
  101300. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101301. */
  101302. static readonly MATERIAL_ALPHATEST: number;
  101303. /**
  101304. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101305. */
  101306. static readonly MATERIAL_ALPHABLEND: number;
  101307. /**
  101308. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101309. * They are also discarded below the alpha cutoff threshold to improve performances.
  101310. */
  101311. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101312. /**
  101313. * Custom callback helping to override the default shader used in the material.
  101314. */
  101315. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101316. /**
  101317. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101318. */
  101319. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101320. /**
  101321. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101322. * This means that the material can keep using a previous shader while a new one is being compiled.
  101323. * This is mostly used when shader parallel compilation is supported (true by default)
  101324. */
  101325. allowShaderHotSwapping: boolean;
  101326. /**
  101327. * The ID of the material
  101328. */
  101329. id: string;
  101330. /**
  101331. * Gets or sets the unique id of the material
  101332. */
  101333. uniqueId: number;
  101334. /**
  101335. * The name of the material
  101336. */
  101337. name: string;
  101338. /**
  101339. * Gets or sets user defined metadata
  101340. */
  101341. metadata: any;
  101342. /**
  101343. * For internal use only. Please do not use.
  101344. */
  101345. reservedDataStore: any;
  101346. /**
  101347. * Specifies if the ready state should be checked on each call
  101348. */
  101349. checkReadyOnEveryCall: boolean;
  101350. /**
  101351. * Specifies if the ready state should be checked once
  101352. */
  101353. checkReadyOnlyOnce: boolean;
  101354. /**
  101355. * The state of the material
  101356. */
  101357. state: string;
  101358. /**
  101359. * The alpha value of the material
  101360. */
  101361. protected _alpha: number;
  101362. /**
  101363. * List of inspectable custom properties (used by the Inspector)
  101364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101365. */
  101366. inspectableCustomProperties: IInspectable[];
  101367. /**
  101368. * Sets the alpha value of the material
  101369. */
  101370. set alpha(value: number);
  101371. /**
  101372. * Gets the alpha value of the material
  101373. */
  101374. get alpha(): number;
  101375. /**
  101376. * Specifies if back face culling is enabled
  101377. */
  101378. protected _backFaceCulling: boolean;
  101379. /**
  101380. * Sets the back-face culling state
  101381. */
  101382. set backFaceCulling(value: boolean);
  101383. /**
  101384. * Gets the back-face culling state
  101385. */
  101386. get backFaceCulling(): boolean;
  101387. /**
  101388. * Stores the value for side orientation
  101389. */
  101390. sideOrientation: number;
  101391. /**
  101392. * Callback triggered when the material is compiled
  101393. */
  101394. onCompiled: Nullable<(effect: Effect) => void>;
  101395. /**
  101396. * Callback triggered when an error occurs
  101397. */
  101398. onError: Nullable<(effect: Effect, errors: string) => void>;
  101399. /**
  101400. * Callback triggered to get the render target textures
  101401. */
  101402. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101403. /**
  101404. * Gets a boolean indicating that current material needs to register RTT
  101405. */
  101406. get hasRenderTargetTextures(): boolean;
  101407. /**
  101408. * Specifies if the material should be serialized
  101409. */
  101410. doNotSerialize: boolean;
  101411. /**
  101412. * @hidden
  101413. */
  101414. _storeEffectOnSubMeshes: boolean;
  101415. /**
  101416. * Stores the animations for the material
  101417. */
  101418. animations: Nullable<Array<Animation>>;
  101419. /**
  101420. * An event triggered when the material is disposed
  101421. */
  101422. onDisposeObservable: Observable<Material>;
  101423. /**
  101424. * An observer which watches for dispose events
  101425. */
  101426. private _onDisposeObserver;
  101427. private _onUnBindObservable;
  101428. /**
  101429. * Called during a dispose event
  101430. */
  101431. set onDispose(callback: () => void);
  101432. private _onBindObservable;
  101433. /**
  101434. * An event triggered when the material is bound
  101435. */
  101436. get onBindObservable(): Observable<AbstractMesh>;
  101437. /**
  101438. * An observer which watches for bind events
  101439. */
  101440. private _onBindObserver;
  101441. /**
  101442. * Called during a bind event
  101443. */
  101444. set onBind(callback: (Mesh: AbstractMesh) => void);
  101445. /**
  101446. * An event triggered when the material is unbound
  101447. */
  101448. get onUnBindObservable(): Observable<Material>;
  101449. protected _onEffectCreatedObservable: Nullable<Observable<{
  101450. effect: Effect;
  101451. subMesh: Nullable<SubMesh>;
  101452. }>>;
  101453. /**
  101454. * An event triggered when the effect is (re)created
  101455. */
  101456. get onEffectCreatedObservable(): Observable<{
  101457. effect: Effect;
  101458. subMesh: Nullable<SubMesh>;
  101459. }>;
  101460. /**
  101461. * Stores the value of the alpha mode
  101462. */
  101463. private _alphaMode;
  101464. /**
  101465. * Sets the value of the alpha mode.
  101466. *
  101467. * | Value | Type | Description |
  101468. * | --- | --- | --- |
  101469. * | 0 | ALPHA_DISABLE | |
  101470. * | 1 | ALPHA_ADD | |
  101471. * | 2 | ALPHA_COMBINE | |
  101472. * | 3 | ALPHA_SUBTRACT | |
  101473. * | 4 | ALPHA_MULTIPLY | |
  101474. * | 5 | ALPHA_MAXIMIZED | |
  101475. * | 6 | ALPHA_ONEONE | |
  101476. * | 7 | ALPHA_PREMULTIPLIED | |
  101477. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101478. * | 9 | ALPHA_INTERPOLATE | |
  101479. * | 10 | ALPHA_SCREENMODE | |
  101480. *
  101481. */
  101482. set alphaMode(value: number);
  101483. /**
  101484. * Gets the value of the alpha mode
  101485. */
  101486. get alphaMode(): number;
  101487. /**
  101488. * Stores the state of the need depth pre-pass value
  101489. */
  101490. private _needDepthPrePass;
  101491. /**
  101492. * Sets the need depth pre-pass value
  101493. */
  101494. set needDepthPrePass(value: boolean);
  101495. /**
  101496. * Gets the depth pre-pass value
  101497. */
  101498. get needDepthPrePass(): boolean;
  101499. /**
  101500. * Specifies if depth writing should be disabled
  101501. */
  101502. disableDepthWrite: boolean;
  101503. /**
  101504. * Specifies if color writing should be disabled
  101505. */
  101506. disableColorWrite: boolean;
  101507. /**
  101508. * Specifies if depth writing should be forced
  101509. */
  101510. forceDepthWrite: boolean;
  101511. /**
  101512. * Specifies the depth function that should be used. 0 means the default engine function
  101513. */
  101514. depthFunction: number;
  101515. /**
  101516. * Specifies if there should be a separate pass for culling
  101517. */
  101518. separateCullingPass: boolean;
  101519. /**
  101520. * Stores the state specifing if fog should be enabled
  101521. */
  101522. private _fogEnabled;
  101523. /**
  101524. * Sets the state for enabling fog
  101525. */
  101526. set fogEnabled(value: boolean);
  101527. /**
  101528. * Gets the value of the fog enabled state
  101529. */
  101530. get fogEnabled(): boolean;
  101531. /**
  101532. * Stores the size of points
  101533. */
  101534. pointSize: number;
  101535. /**
  101536. * Stores the z offset value
  101537. */
  101538. zOffset: number;
  101539. get wireframe(): boolean;
  101540. /**
  101541. * Sets the state of wireframe mode
  101542. */
  101543. set wireframe(value: boolean);
  101544. /**
  101545. * Gets the value specifying if point clouds are enabled
  101546. */
  101547. get pointsCloud(): boolean;
  101548. /**
  101549. * Sets the state of point cloud mode
  101550. */
  101551. set pointsCloud(value: boolean);
  101552. /**
  101553. * Gets the material fill mode
  101554. */
  101555. get fillMode(): number;
  101556. /**
  101557. * Sets the material fill mode
  101558. */
  101559. set fillMode(value: number);
  101560. /**
  101561. * @hidden
  101562. * Stores the effects for the material
  101563. */
  101564. _effect: Nullable<Effect>;
  101565. /**
  101566. * Specifies if uniform buffers should be used
  101567. */
  101568. private _useUBO;
  101569. /**
  101570. * Stores a reference to the scene
  101571. */
  101572. private _scene;
  101573. /**
  101574. * Stores the fill mode state
  101575. */
  101576. private _fillMode;
  101577. /**
  101578. * Specifies if the depth write state should be cached
  101579. */
  101580. private _cachedDepthWriteState;
  101581. /**
  101582. * Specifies if the color write state should be cached
  101583. */
  101584. private _cachedColorWriteState;
  101585. /**
  101586. * Specifies if the depth function state should be cached
  101587. */
  101588. private _cachedDepthFunctionState;
  101589. /**
  101590. * Stores the uniform buffer
  101591. */
  101592. protected _uniformBuffer: UniformBuffer;
  101593. /** @hidden */
  101594. _indexInSceneMaterialArray: number;
  101595. /** @hidden */
  101596. meshMap: Nullable<{
  101597. [id: string]: AbstractMesh | undefined;
  101598. }>;
  101599. /**
  101600. * Creates a material instance
  101601. * @param name defines the name of the material
  101602. * @param scene defines the scene to reference
  101603. * @param doNotAdd specifies if the material should be added to the scene
  101604. */
  101605. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101606. /**
  101607. * Returns a string representation of the current material
  101608. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101609. * @returns a string with material information
  101610. */
  101611. toString(fullDetails?: boolean): string;
  101612. /**
  101613. * Gets the class name of the material
  101614. * @returns a string with the class name of the material
  101615. */
  101616. getClassName(): string;
  101617. /**
  101618. * Specifies if updates for the material been locked
  101619. */
  101620. get isFrozen(): boolean;
  101621. /**
  101622. * Locks updates for the material
  101623. */
  101624. freeze(): void;
  101625. /**
  101626. * Unlocks updates for the material
  101627. */
  101628. unfreeze(): void;
  101629. /**
  101630. * Specifies if the material is ready to be used
  101631. * @param mesh defines the mesh to check
  101632. * @param useInstances specifies if instances should be used
  101633. * @returns a boolean indicating if the material is ready to be used
  101634. */
  101635. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101636. /**
  101637. * Specifies that the submesh is ready to be used
  101638. * @param mesh defines the mesh to check
  101639. * @param subMesh defines which submesh to check
  101640. * @param useInstances specifies that instances should be used
  101641. * @returns a boolean indicating that the submesh is ready or not
  101642. */
  101643. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101644. /**
  101645. * Returns the material effect
  101646. * @returns the effect associated with the material
  101647. */
  101648. getEffect(): Nullable<Effect>;
  101649. /**
  101650. * Returns the current scene
  101651. * @returns a Scene
  101652. */
  101653. getScene(): Scene;
  101654. /**
  101655. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101656. */
  101657. protected _forceAlphaTest: boolean;
  101658. /**
  101659. * The transparency mode of the material.
  101660. */
  101661. protected _transparencyMode: Nullable<number>;
  101662. /**
  101663. * Gets the current transparency mode.
  101664. */
  101665. get transparencyMode(): Nullable<number>;
  101666. /**
  101667. * Sets the transparency mode of the material.
  101668. *
  101669. * | Value | Type | Description |
  101670. * | ----- | ----------------------------------- | ----------- |
  101671. * | 0 | OPAQUE | |
  101672. * | 1 | ALPHATEST | |
  101673. * | 2 | ALPHABLEND | |
  101674. * | 3 | ALPHATESTANDBLEND | |
  101675. *
  101676. */
  101677. set transparencyMode(value: Nullable<number>);
  101678. /**
  101679. * Returns true if alpha blending should be disabled.
  101680. */
  101681. protected get _disableAlphaBlending(): boolean;
  101682. /**
  101683. * Specifies whether or not this material should be rendered in alpha blend mode.
  101684. * @returns a boolean specifying if alpha blending is needed
  101685. */
  101686. needAlphaBlending(): boolean;
  101687. /**
  101688. * Specifies if the mesh will require alpha blending
  101689. * @param mesh defines the mesh to check
  101690. * @returns a boolean specifying if alpha blending is needed for the mesh
  101691. */
  101692. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101693. /**
  101694. * Specifies whether or not this material should be rendered in alpha test mode.
  101695. * @returns a boolean specifying if an alpha test is needed.
  101696. */
  101697. needAlphaTesting(): boolean;
  101698. /**
  101699. * Specifies if material alpha testing should be turned on for the mesh
  101700. * @param mesh defines the mesh to check
  101701. */
  101702. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101703. /**
  101704. * Gets the texture used for the alpha test
  101705. * @returns the texture to use for alpha testing
  101706. */
  101707. getAlphaTestTexture(): Nullable<BaseTexture>;
  101708. /**
  101709. * Marks the material to indicate that it needs to be re-calculated
  101710. */
  101711. markDirty(): void;
  101712. /** @hidden */
  101713. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101714. /**
  101715. * Binds the material to the mesh
  101716. * @param world defines the world transformation matrix
  101717. * @param mesh defines the mesh to bind the material to
  101718. */
  101719. bind(world: Matrix, mesh?: Mesh): void;
  101720. /**
  101721. * Binds the submesh to the material
  101722. * @param world defines the world transformation matrix
  101723. * @param mesh defines the mesh containing the submesh
  101724. * @param subMesh defines the submesh to bind the material to
  101725. */
  101726. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101727. /**
  101728. * Binds the world matrix to the material
  101729. * @param world defines the world transformation matrix
  101730. */
  101731. bindOnlyWorldMatrix(world: Matrix): void;
  101732. /**
  101733. * Binds the scene's uniform buffer to the effect.
  101734. * @param effect defines the effect to bind to the scene uniform buffer
  101735. * @param sceneUbo defines the uniform buffer storing scene data
  101736. */
  101737. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101738. /**
  101739. * Binds the view matrix to the effect
  101740. * @param effect defines the effect to bind the view matrix to
  101741. */
  101742. bindView(effect: Effect): void;
  101743. /**
  101744. * Binds the view projection matrix to the effect
  101745. * @param effect defines the effect to bind the view projection matrix to
  101746. */
  101747. bindViewProjection(effect: Effect): void;
  101748. /**
  101749. * Processes to execute after binding the material to a mesh
  101750. * @param mesh defines the rendered mesh
  101751. */
  101752. protected _afterBind(mesh?: Mesh): void;
  101753. /**
  101754. * Unbinds the material from the mesh
  101755. */
  101756. unbind(): void;
  101757. /**
  101758. * Gets the active textures from the material
  101759. * @returns an array of textures
  101760. */
  101761. getActiveTextures(): BaseTexture[];
  101762. /**
  101763. * Specifies if the material uses a texture
  101764. * @param texture defines the texture to check against the material
  101765. * @returns a boolean specifying if the material uses the texture
  101766. */
  101767. hasTexture(texture: BaseTexture): boolean;
  101768. /**
  101769. * Makes a duplicate of the material, and gives it a new name
  101770. * @param name defines the new name for the duplicated material
  101771. * @returns the cloned material
  101772. */
  101773. clone(name: string): Nullable<Material>;
  101774. /**
  101775. * Gets the meshes bound to the material
  101776. * @returns an array of meshes bound to the material
  101777. */
  101778. getBindedMeshes(): AbstractMesh[];
  101779. /**
  101780. * Force shader compilation
  101781. * @param mesh defines the mesh associated with this material
  101782. * @param onCompiled defines a function to execute once the material is compiled
  101783. * @param options defines the options to configure the compilation
  101784. * @param onError defines a function to execute if the material fails compiling
  101785. */
  101786. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101787. /**
  101788. * Force shader compilation
  101789. * @param mesh defines the mesh that will use this material
  101790. * @param options defines additional options for compiling the shaders
  101791. * @returns a promise that resolves when the compilation completes
  101792. */
  101793. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101794. private static readonly _AllDirtyCallBack;
  101795. private static readonly _ImageProcessingDirtyCallBack;
  101796. private static readonly _TextureDirtyCallBack;
  101797. private static readonly _FresnelDirtyCallBack;
  101798. private static readonly _MiscDirtyCallBack;
  101799. private static readonly _LightsDirtyCallBack;
  101800. private static readonly _AttributeDirtyCallBack;
  101801. private static _FresnelAndMiscDirtyCallBack;
  101802. private static _TextureAndMiscDirtyCallBack;
  101803. private static readonly _DirtyCallbackArray;
  101804. private static readonly _RunDirtyCallBacks;
  101805. /**
  101806. * Marks a define in the material to indicate that it needs to be re-computed
  101807. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101808. */
  101809. markAsDirty(flag: number): void;
  101810. /**
  101811. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101812. * @param func defines a function which checks material defines against the submeshes
  101813. */
  101814. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101815. /**
  101816. * Indicates that we need to re-calculated for all submeshes
  101817. */
  101818. protected _markAllSubMeshesAsAllDirty(): void;
  101819. /**
  101820. * Indicates that image processing needs to be re-calculated for all submeshes
  101821. */
  101822. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101823. /**
  101824. * Indicates that textures need to be re-calculated for all submeshes
  101825. */
  101826. protected _markAllSubMeshesAsTexturesDirty(): void;
  101827. /**
  101828. * Indicates that fresnel needs to be re-calculated for all submeshes
  101829. */
  101830. protected _markAllSubMeshesAsFresnelDirty(): void;
  101831. /**
  101832. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101833. */
  101834. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101835. /**
  101836. * Indicates that lights need to be re-calculated for all submeshes
  101837. */
  101838. protected _markAllSubMeshesAsLightsDirty(): void;
  101839. /**
  101840. * Indicates that attributes need to be re-calculated for all submeshes
  101841. */
  101842. protected _markAllSubMeshesAsAttributesDirty(): void;
  101843. /**
  101844. * Indicates that misc needs to be re-calculated for all submeshes
  101845. */
  101846. protected _markAllSubMeshesAsMiscDirty(): void;
  101847. /**
  101848. * Indicates that textures and misc need to be re-calculated for all submeshes
  101849. */
  101850. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101851. /**
  101852. * Disposes the material
  101853. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101854. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101855. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101856. */
  101857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101858. /** @hidden */
  101859. private releaseVertexArrayObject;
  101860. /**
  101861. * Serializes this material
  101862. * @returns the serialized material object
  101863. */
  101864. serialize(): any;
  101865. /**
  101866. * Creates a material from parsed material data
  101867. * @param parsedMaterial defines parsed material data
  101868. * @param scene defines the hosting scene
  101869. * @param rootUrl defines the root URL to use to load textures
  101870. * @returns a new material
  101871. */
  101872. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101873. }
  101874. }
  101875. declare module BABYLON {
  101876. /**
  101877. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101878. * separate meshes. This can be use to improve performances.
  101879. * @see http://doc.babylonjs.com/how_to/multi_materials
  101880. */
  101881. export class MultiMaterial extends Material {
  101882. private _subMaterials;
  101883. /**
  101884. * Gets or Sets the list of Materials used within the multi material.
  101885. * They need to be ordered according to the submeshes order in the associated mesh
  101886. */
  101887. get subMaterials(): Nullable<Material>[];
  101888. set subMaterials(value: Nullable<Material>[]);
  101889. /**
  101890. * Function used to align with Node.getChildren()
  101891. * @returns the list of Materials used within the multi material
  101892. */
  101893. getChildren(): Nullable<Material>[];
  101894. /**
  101895. * Instantiates a new Multi Material
  101896. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101897. * separate meshes. This can be use to improve performances.
  101898. * @see http://doc.babylonjs.com/how_to/multi_materials
  101899. * @param name Define the name in the scene
  101900. * @param scene Define the scene the material belongs to
  101901. */
  101902. constructor(name: string, scene: Scene);
  101903. private _hookArray;
  101904. /**
  101905. * Get one of the submaterial by its index in the submaterials array
  101906. * @param index The index to look the sub material at
  101907. * @returns The Material if the index has been defined
  101908. */
  101909. getSubMaterial(index: number): Nullable<Material>;
  101910. /**
  101911. * Get the list of active textures for the whole sub materials list.
  101912. * @returns All the textures that will be used during the rendering
  101913. */
  101914. getActiveTextures(): BaseTexture[];
  101915. /**
  101916. * Gets the current class name of the material e.g. "MultiMaterial"
  101917. * Mainly use in serialization.
  101918. * @returns the class name
  101919. */
  101920. getClassName(): string;
  101921. /**
  101922. * Checks if the material is ready to render the requested sub mesh
  101923. * @param mesh Define the mesh the submesh belongs to
  101924. * @param subMesh Define the sub mesh to look readyness for
  101925. * @param useInstances Define whether or not the material is used with instances
  101926. * @returns true if ready, otherwise false
  101927. */
  101928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101929. /**
  101930. * Clones the current material and its related sub materials
  101931. * @param name Define the name of the newly cloned material
  101932. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  101933. * @returns the cloned material
  101934. */
  101935. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  101936. /**
  101937. * Serializes the materials into a JSON representation.
  101938. * @returns the JSON representation
  101939. */
  101940. serialize(): any;
  101941. /**
  101942. * Dispose the material and release its associated resources
  101943. * @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)
  101944. * @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)
  101945. * @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)
  101946. */
  101947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  101948. /**
  101949. * Creates a MultiMaterial from parsed MultiMaterial data.
  101950. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  101951. * @param scene defines the hosting scene
  101952. * @returns a new MultiMaterial
  101953. */
  101954. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  101955. }
  101956. }
  101957. declare module BABYLON {
  101958. /**
  101959. * Defines a subdivision inside a mesh
  101960. */
  101961. export class SubMesh implements ICullable {
  101962. /** the material index to use */
  101963. materialIndex: number;
  101964. /** vertex index start */
  101965. verticesStart: number;
  101966. /** vertices count */
  101967. verticesCount: number;
  101968. /** index start */
  101969. indexStart: number;
  101970. /** indices count */
  101971. indexCount: number;
  101972. /** @hidden */
  101973. _materialDefines: Nullable<MaterialDefines>;
  101974. /** @hidden */
  101975. _materialEffect: Nullable<Effect>;
  101976. /** @hidden */
  101977. _effectOverride: Nullable<Effect>;
  101978. /**
  101979. * Gets material defines used by the effect associated to the sub mesh
  101980. */
  101981. get materialDefines(): Nullable<MaterialDefines>;
  101982. /**
  101983. * Sets material defines used by the effect associated to the sub mesh
  101984. */
  101985. set materialDefines(defines: Nullable<MaterialDefines>);
  101986. /**
  101987. * Gets associated effect
  101988. */
  101989. get effect(): Nullable<Effect>;
  101990. /**
  101991. * Sets associated effect (effect used to render this submesh)
  101992. * @param effect defines the effect to associate with
  101993. * @param defines defines the set of defines used to compile this effect
  101994. */
  101995. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  101996. /** @hidden */
  101997. _linesIndexCount: number;
  101998. private _mesh;
  101999. private _renderingMesh;
  102000. private _boundingInfo;
  102001. private _linesIndexBuffer;
  102002. /** @hidden */
  102003. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102004. /** @hidden */
  102005. _trianglePlanes: Plane[];
  102006. /** @hidden */
  102007. _lastColliderTransformMatrix: Nullable<Matrix>;
  102008. /** @hidden */
  102009. _renderId: number;
  102010. /** @hidden */
  102011. _alphaIndex: number;
  102012. /** @hidden */
  102013. _distanceToCamera: number;
  102014. /** @hidden */
  102015. _id: number;
  102016. private _currentMaterial;
  102017. /**
  102018. * Add a new submesh to a mesh
  102019. * @param materialIndex defines the material index to use
  102020. * @param verticesStart defines vertex index start
  102021. * @param verticesCount defines vertices count
  102022. * @param indexStart defines index start
  102023. * @param indexCount defines indices count
  102024. * @param mesh defines the parent mesh
  102025. * @param renderingMesh defines an optional rendering mesh
  102026. * @param createBoundingBox defines if bounding box should be created for this submesh
  102027. * @returns the new submesh
  102028. */
  102029. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102030. /**
  102031. * Creates a new submesh
  102032. * @param materialIndex defines the material index to use
  102033. * @param verticesStart defines vertex index start
  102034. * @param verticesCount defines vertices count
  102035. * @param indexStart defines index start
  102036. * @param indexCount defines indices count
  102037. * @param mesh defines the parent mesh
  102038. * @param renderingMesh defines an optional rendering mesh
  102039. * @param createBoundingBox defines if bounding box should be created for this submesh
  102040. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102041. */
  102042. constructor(
  102043. /** the material index to use */
  102044. materialIndex: number,
  102045. /** vertex index start */
  102046. verticesStart: number,
  102047. /** vertices count */
  102048. verticesCount: number,
  102049. /** index start */
  102050. indexStart: number,
  102051. /** indices count */
  102052. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102053. /**
  102054. * Returns true if this submesh covers the entire parent mesh
  102055. * @ignorenaming
  102056. */
  102057. get IsGlobal(): boolean;
  102058. /**
  102059. * Returns the submesh BoudingInfo object
  102060. * @returns current bounding info (or mesh's one if the submesh is global)
  102061. */
  102062. getBoundingInfo(): BoundingInfo;
  102063. /**
  102064. * Sets the submesh BoundingInfo
  102065. * @param boundingInfo defines the new bounding info to use
  102066. * @returns the SubMesh
  102067. */
  102068. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102069. /**
  102070. * Returns the mesh of the current submesh
  102071. * @return the parent mesh
  102072. */
  102073. getMesh(): AbstractMesh;
  102074. /**
  102075. * Returns the rendering mesh of the submesh
  102076. * @returns the rendering mesh (could be different from parent mesh)
  102077. */
  102078. getRenderingMesh(): Mesh;
  102079. /**
  102080. * Returns the replacement mesh of the submesh
  102081. * @returns the replacement mesh (could be different from parent mesh)
  102082. */
  102083. getReplacementMesh(): Nullable<AbstractMesh>;
  102084. /**
  102085. * Returns the effective mesh of the submesh
  102086. * @returns the effective mesh (could be different from parent mesh)
  102087. */
  102088. getEffectiveMesh(): AbstractMesh;
  102089. /**
  102090. * Returns the submesh material
  102091. * @returns null or the current material
  102092. */
  102093. getMaterial(): Nullable<Material>;
  102094. /**
  102095. * Sets a new updated BoundingInfo object to the submesh
  102096. * @param data defines an optional position array to use to determine the bounding info
  102097. * @returns the SubMesh
  102098. */
  102099. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102100. /** @hidden */
  102101. _checkCollision(collider: Collider): boolean;
  102102. /**
  102103. * Updates the submesh BoundingInfo
  102104. * @param world defines the world matrix to use to update the bounding info
  102105. * @returns the submesh
  102106. */
  102107. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102108. /**
  102109. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102110. * @param frustumPlanes defines the frustum planes
  102111. * @returns true if the submesh is intersecting with the frustum
  102112. */
  102113. isInFrustum(frustumPlanes: Plane[]): boolean;
  102114. /**
  102115. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102116. * @param frustumPlanes defines the frustum planes
  102117. * @returns true if the submesh is inside the frustum
  102118. */
  102119. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102120. /**
  102121. * Renders the submesh
  102122. * @param enableAlphaMode defines if alpha needs to be used
  102123. * @returns the submesh
  102124. */
  102125. render(enableAlphaMode: boolean): SubMesh;
  102126. /**
  102127. * @hidden
  102128. */
  102129. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102130. /**
  102131. * Checks if the submesh intersects with a ray
  102132. * @param ray defines the ray to test
  102133. * @returns true is the passed ray intersects the submesh bounding box
  102134. */
  102135. canIntersects(ray: Ray): boolean;
  102136. /**
  102137. * Intersects current submesh with a ray
  102138. * @param ray defines the ray to test
  102139. * @param positions defines mesh's positions array
  102140. * @param indices defines mesh's indices array
  102141. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102143. * @returns intersection info or null if no intersection
  102144. */
  102145. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102146. /** @hidden */
  102147. private _intersectLines;
  102148. /** @hidden */
  102149. private _intersectUnIndexedLines;
  102150. /** @hidden */
  102151. private _intersectTriangles;
  102152. /** @hidden */
  102153. private _intersectUnIndexedTriangles;
  102154. /** @hidden */
  102155. _rebuild(): void;
  102156. /**
  102157. * Creates a new submesh from the passed mesh
  102158. * @param newMesh defines the new hosting mesh
  102159. * @param newRenderingMesh defines an optional rendering mesh
  102160. * @returns the new submesh
  102161. */
  102162. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102163. /**
  102164. * Release associated resources
  102165. */
  102166. dispose(): void;
  102167. /**
  102168. * Gets the class name
  102169. * @returns the string "SubMesh".
  102170. */
  102171. getClassName(): string;
  102172. /**
  102173. * Creates a new submesh from indices data
  102174. * @param materialIndex the index of the main mesh material
  102175. * @param startIndex the index where to start the copy in the mesh indices array
  102176. * @param indexCount the number of indices to copy then from the startIndex
  102177. * @param mesh the main mesh to create the submesh from
  102178. * @param renderingMesh the optional rendering mesh
  102179. * @returns a new submesh
  102180. */
  102181. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102182. }
  102183. }
  102184. declare module BABYLON {
  102185. /**
  102186. * Class used to represent data loading progression
  102187. */
  102188. export class SceneLoaderFlags {
  102189. private static _ForceFullSceneLoadingForIncremental;
  102190. private static _ShowLoadingScreen;
  102191. private static _CleanBoneMatrixWeights;
  102192. private static _loggingLevel;
  102193. /**
  102194. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102195. */
  102196. static get ForceFullSceneLoadingForIncremental(): boolean;
  102197. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102198. /**
  102199. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102200. */
  102201. static get ShowLoadingScreen(): boolean;
  102202. static set ShowLoadingScreen(value: boolean);
  102203. /**
  102204. * Defines the current logging level (while loading the scene)
  102205. * @ignorenaming
  102206. */
  102207. static get loggingLevel(): number;
  102208. static set loggingLevel(value: number);
  102209. /**
  102210. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102211. */
  102212. static get CleanBoneMatrixWeights(): boolean;
  102213. static set CleanBoneMatrixWeights(value: boolean);
  102214. }
  102215. }
  102216. declare module BABYLON {
  102217. /**
  102218. * Class used to store geometry data (vertex buffers + index buffer)
  102219. */
  102220. export class Geometry implements IGetSetVerticesData {
  102221. /**
  102222. * Gets or sets the ID of the geometry
  102223. */
  102224. id: string;
  102225. /**
  102226. * Gets or sets the unique ID of the geometry
  102227. */
  102228. uniqueId: number;
  102229. /**
  102230. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102231. */
  102232. delayLoadState: number;
  102233. /**
  102234. * Gets the file containing the data to load when running in delay load state
  102235. */
  102236. delayLoadingFile: Nullable<string>;
  102237. /**
  102238. * Callback called when the geometry is updated
  102239. */
  102240. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102241. private _scene;
  102242. private _engine;
  102243. private _meshes;
  102244. private _totalVertices;
  102245. /** @hidden */
  102246. _indices: IndicesArray;
  102247. /** @hidden */
  102248. _vertexBuffers: {
  102249. [key: string]: VertexBuffer;
  102250. };
  102251. private _isDisposed;
  102252. private _extend;
  102253. private _boundingBias;
  102254. /** @hidden */
  102255. _delayInfo: Array<string>;
  102256. private _indexBuffer;
  102257. private _indexBufferIsUpdatable;
  102258. /** @hidden */
  102259. _boundingInfo: Nullable<BoundingInfo>;
  102260. /** @hidden */
  102261. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102262. /** @hidden */
  102263. _softwareSkinningFrameId: number;
  102264. private _vertexArrayObjects;
  102265. private _updatable;
  102266. /** @hidden */
  102267. _positions: Nullable<Vector3[]>;
  102268. /**
  102269. * 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
  102270. */
  102271. get boundingBias(): Vector2;
  102272. /**
  102273. * 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
  102274. */
  102275. set boundingBias(value: Vector2);
  102276. /**
  102277. * Static function used to attach a new empty geometry to a mesh
  102278. * @param mesh defines the mesh to attach the geometry to
  102279. * @returns the new Geometry
  102280. */
  102281. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102282. /** Get the list of meshes using this geometry */
  102283. get meshes(): Mesh[];
  102284. /**
  102285. * Creates a new geometry
  102286. * @param id defines the unique ID
  102287. * @param scene defines the hosting scene
  102288. * @param vertexData defines the VertexData used to get geometry data
  102289. * @param updatable defines if geometry must be updatable (false by default)
  102290. * @param mesh defines the mesh that will be associated with the geometry
  102291. */
  102292. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102293. /**
  102294. * Gets the current extend of the geometry
  102295. */
  102296. get extend(): {
  102297. minimum: Vector3;
  102298. maximum: Vector3;
  102299. };
  102300. /**
  102301. * Gets the hosting scene
  102302. * @returns the hosting Scene
  102303. */
  102304. getScene(): Scene;
  102305. /**
  102306. * Gets the hosting engine
  102307. * @returns the hosting Engine
  102308. */
  102309. getEngine(): Engine;
  102310. /**
  102311. * Defines if the geometry is ready to use
  102312. * @returns true if the geometry is ready to be used
  102313. */
  102314. isReady(): boolean;
  102315. /**
  102316. * Gets a value indicating that the geometry should not be serialized
  102317. */
  102318. get doNotSerialize(): boolean;
  102319. /** @hidden */
  102320. _rebuild(): void;
  102321. /**
  102322. * Affects all geometry data in one call
  102323. * @param vertexData defines the geometry data
  102324. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102325. */
  102326. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102327. /**
  102328. * Set specific vertex data
  102329. * @param kind defines the data kind (Position, normal, etc...)
  102330. * @param data defines the vertex data to use
  102331. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102332. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102333. */
  102334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102335. /**
  102336. * Removes a specific vertex data
  102337. * @param kind defines the data kind (Position, normal, etc...)
  102338. */
  102339. removeVerticesData(kind: string): void;
  102340. /**
  102341. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102342. * @param buffer defines the vertex buffer to use
  102343. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102344. */
  102345. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102346. /**
  102347. * Update a specific vertex buffer
  102348. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102349. * It will do nothing if the buffer is not updatable
  102350. * @param kind defines the data kind (Position, normal, etc...)
  102351. * @param data defines the data to use
  102352. * @param offset defines the offset in the target buffer where to store the data
  102353. * @param useBytes set to true if the offset is in bytes
  102354. */
  102355. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102356. /**
  102357. * Update a specific vertex buffer
  102358. * This function will create a new buffer if the current one is not updatable
  102359. * @param kind defines the data kind (Position, normal, etc...)
  102360. * @param data defines the data to use
  102361. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102362. */
  102363. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102364. private _updateBoundingInfo;
  102365. /** @hidden */
  102366. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102367. /**
  102368. * Gets total number of vertices
  102369. * @returns the total number of vertices
  102370. */
  102371. getTotalVertices(): number;
  102372. /**
  102373. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102374. * @param kind defines the data kind (Position, normal, etc...)
  102375. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102376. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102377. * @returns a float array containing vertex data
  102378. */
  102379. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102380. /**
  102381. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102382. * @param kind defines the data kind (Position, normal, etc...)
  102383. * @returns true if the vertex buffer with the specified kind is updatable
  102384. */
  102385. isVertexBufferUpdatable(kind: string): boolean;
  102386. /**
  102387. * Gets a specific vertex buffer
  102388. * @param kind defines the data kind (Position, normal, etc...)
  102389. * @returns a VertexBuffer
  102390. */
  102391. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102392. /**
  102393. * Returns all vertex buffers
  102394. * @return an object holding all vertex buffers indexed by kind
  102395. */
  102396. getVertexBuffers(): Nullable<{
  102397. [key: string]: VertexBuffer;
  102398. }>;
  102399. /**
  102400. * Gets a boolean indicating if specific vertex buffer is present
  102401. * @param kind defines the data kind (Position, normal, etc...)
  102402. * @returns true if data is present
  102403. */
  102404. isVerticesDataPresent(kind: string): boolean;
  102405. /**
  102406. * Gets a list of all attached data kinds (Position, normal, etc...)
  102407. * @returns a list of string containing all kinds
  102408. */
  102409. getVerticesDataKinds(): string[];
  102410. /**
  102411. * Update index buffer
  102412. * @param indices defines the indices to store in the index buffer
  102413. * @param offset defines the offset in the target buffer where to store the data
  102414. * @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)
  102415. */
  102416. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102417. /**
  102418. * Creates a new index buffer
  102419. * @param indices defines the indices to store in the index buffer
  102420. * @param totalVertices defines the total number of vertices (could be null)
  102421. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102422. */
  102423. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102424. /**
  102425. * Return the total number of indices
  102426. * @returns the total number of indices
  102427. */
  102428. getTotalIndices(): number;
  102429. /**
  102430. * Gets the index buffer array
  102431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102433. * @returns the index buffer array
  102434. */
  102435. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102436. /**
  102437. * Gets the index buffer
  102438. * @return the index buffer
  102439. */
  102440. getIndexBuffer(): Nullable<DataBuffer>;
  102441. /** @hidden */
  102442. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102443. /**
  102444. * Release the associated resources for a specific mesh
  102445. * @param mesh defines the source mesh
  102446. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102447. */
  102448. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102449. /**
  102450. * Apply current geometry to a given mesh
  102451. * @param mesh defines the mesh to apply geometry to
  102452. */
  102453. applyToMesh(mesh: Mesh): void;
  102454. private _updateExtend;
  102455. private _applyToMesh;
  102456. private notifyUpdate;
  102457. /**
  102458. * Load the geometry if it was flagged as delay loaded
  102459. * @param scene defines the hosting scene
  102460. * @param onLoaded defines a callback called when the geometry is loaded
  102461. */
  102462. load(scene: Scene, onLoaded?: () => void): void;
  102463. private _queueLoad;
  102464. /**
  102465. * Invert the geometry to move from a right handed system to a left handed one.
  102466. */
  102467. toLeftHanded(): void;
  102468. /** @hidden */
  102469. _resetPointsArrayCache(): void;
  102470. /** @hidden */
  102471. _generatePointsArray(): boolean;
  102472. /**
  102473. * Gets a value indicating if the geometry is disposed
  102474. * @returns true if the geometry was disposed
  102475. */
  102476. isDisposed(): boolean;
  102477. private _disposeVertexArrayObjects;
  102478. /**
  102479. * Free all associated resources
  102480. */
  102481. dispose(): void;
  102482. /**
  102483. * Clone the current geometry into a new geometry
  102484. * @param id defines the unique ID of the new geometry
  102485. * @returns a new geometry object
  102486. */
  102487. copy(id: string): Geometry;
  102488. /**
  102489. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102490. * @return a JSON representation of the current geometry data (without the vertices data)
  102491. */
  102492. serialize(): any;
  102493. private toNumberArray;
  102494. /**
  102495. * Serialize all vertices data into a JSON oject
  102496. * @returns a JSON representation of the current geometry data
  102497. */
  102498. serializeVerticeData(): any;
  102499. /**
  102500. * Extracts a clone of a mesh geometry
  102501. * @param mesh defines the source mesh
  102502. * @param id defines the unique ID of the new geometry object
  102503. * @returns the new geometry object
  102504. */
  102505. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102506. /**
  102507. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102508. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102509. * Be aware Math.random() could cause collisions, but:
  102510. * "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"
  102511. * @returns a string containing a new GUID
  102512. */
  102513. static RandomId(): string;
  102514. /** @hidden */
  102515. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102516. private static _CleanMatricesWeights;
  102517. /**
  102518. * Create a new geometry from persisted data (Using .babylon file format)
  102519. * @param parsedVertexData defines the persisted data
  102520. * @param scene defines the hosting scene
  102521. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102522. * @returns the new geometry object
  102523. */
  102524. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102525. }
  102526. }
  102527. declare module BABYLON {
  102528. /**
  102529. * Define an interface for all classes that will get and set the data on vertices
  102530. */
  102531. export interface IGetSetVerticesData {
  102532. /**
  102533. * Gets a boolean indicating if specific vertex data is present
  102534. * @param kind defines the vertex data kind to use
  102535. * @returns true is data kind is present
  102536. */
  102537. isVerticesDataPresent(kind: string): boolean;
  102538. /**
  102539. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102540. * @param kind defines the data kind (Position, normal, etc...)
  102541. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102542. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102543. * @returns a float array containing vertex data
  102544. */
  102545. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102546. /**
  102547. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102548. * @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.
  102549. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102550. * @returns the indices array or an empty array if the mesh has no geometry
  102551. */
  102552. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102553. /**
  102554. * Set specific vertex data
  102555. * @param kind defines the data kind (Position, normal, etc...)
  102556. * @param data defines the vertex data to use
  102557. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102558. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102559. */
  102560. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102561. /**
  102562. * Update a specific associated vertex buffer
  102563. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102564. * - VertexBuffer.PositionKind
  102565. * - VertexBuffer.UVKind
  102566. * - VertexBuffer.UV2Kind
  102567. * - VertexBuffer.UV3Kind
  102568. * - VertexBuffer.UV4Kind
  102569. * - VertexBuffer.UV5Kind
  102570. * - VertexBuffer.UV6Kind
  102571. * - VertexBuffer.ColorKind
  102572. * - VertexBuffer.MatricesIndicesKind
  102573. * - VertexBuffer.MatricesIndicesExtraKind
  102574. * - VertexBuffer.MatricesWeightsKind
  102575. * - VertexBuffer.MatricesWeightsExtraKind
  102576. * @param data defines the data source
  102577. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102578. * @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)
  102579. */
  102580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102581. /**
  102582. * Creates a new index buffer
  102583. * @param indices defines the indices to store in the index buffer
  102584. * @param totalVertices defines the total number of vertices (could be null)
  102585. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102586. */
  102587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102588. }
  102589. /**
  102590. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102591. */
  102592. export class VertexData {
  102593. /**
  102594. * Mesh side orientation : usually the external or front surface
  102595. */
  102596. static readonly FRONTSIDE: number;
  102597. /**
  102598. * Mesh side orientation : usually the internal or back surface
  102599. */
  102600. static readonly BACKSIDE: number;
  102601. /**
  102602. * Mesh side orientation : both internal and external or front and back surfaces
  102603. */
  102604. static readonly DOUBLESIDE: number;
  102605. /**
  102606. * Mesh side orientation : by default, `FRONTSIDE`
  102607. */
  102608. static readonly DEFAULTSIDE: number;
  102609. /**
  102610. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102611. */
  102612. positions: Nullable<FloatArray>;
  102613. /**
  102614. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102615. */
  102616. normals: Nullable<FloatArray>;
  102617. /**
  102618. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102619. */
  102620. tangents: Nullable<FloatArray>;
  102621. /**
  102622. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102623. */
  102624. uvs: Nullable<FloatArray>;
  102625. /**
  102626. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102627. */
  102628. uvs2: Nullable<FloatArray>;
  102629. /**
  102630. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102631. */
  102632. uvs3: Nullable<FloatArray>;
  102633. /**
  102634. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102635. */
  102636. uvs4: Nullable<FloatArray>;
  102637. /**
  102638. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102639. */
  102640. uvs5: Nullable<FloatArray>;
  102641. /**
  102642. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102643. */
  102644. uvs6: Nullable<FloatArray>;
  102645. /**
  102646. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102647. */
  102648. colors: Nullable<FloatArray>;
  102649. /**
  102650. * 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).
  102651. */
  102652. matricesIndices: Nullable<FloatArray>;
  102653. /**
  102654. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102655. */
  102656. matricesWeights: Nullable<FloatArray>;
  102657. /**
  102658. * An array extending the number of possible indices
  102659. */
  102660. matricesIndicesExtra: Nullable<FloatArray>;
  102661. /**
  102662. * An array extending the number of possible weights when the number of indices is extended
  102663. */
  102664. matricesWeightsExtra: Nullable<FloatArray>;
  102665. /**
  102666. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102667. */
  102668. indices: Nullable<IndicesArray>;
  102669. /**
  102670. * Uses the passed data array to set the set the values for the specified kind of data
  102671. * @param data a linear array of floating numbers
  102672. * @param kind the type of data that is being set, eg positions, colors etc
  102673. */
  102674. set(data: FloatArray, kind: string): void;
  102675. /**
  102676. * Associates the vertexData to the passed Mesh.
  102677. * Sets it as updatable or not (default `false`)
  102678. * @param mesh the mesh the vertexData is applied to
  102679. * @param updatable when used and having the value true allows new data to update the vertexData
  102680. * @returns the VertexData
  102681. */
  102682. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102683. /**
  102684. * Associates the vertexData to the passed Geometry.
  102685. * Sets it as updatable or not (default `false`)
  102686. * @param geometry the geometry the vertexData is applied to
  102687. * @param updatable when used and having the value true allows new data to update the vertexData
  102688. * @returns VertexData
  102689. */
  102690. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102691. /**
  102692. * Updates the associated mesh
  102693. * @param mesh the mesh to be updated
  102694. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102695. * @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
  102696. * @returns VertexData
  102697. */
  102698. updateMesh(mesh: Mesh): VertexData;
  102699. /**
  102700. * Updates the associated geometry
  102701. * @param geometry the geometry to be updated
  102702. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102703. * @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
  102704. * @returns VertexData.
  102705. */
  102706. updateGeometry(geometry: Geometry): VertexData;
  102707. private _applyTo;
  102708. private _update;
  102709. /**
  102710. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102711. * @param matrix the transforming matrix
  102712. * @returns the VertexData
  102713. */
  102714. transform(matrix: Matrix): VertexData;
  102715. /**
  102716. * Merges the passed VertexData into the current one
  102717. * @param other the VertexData to be merged into the current one
  102718. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102719. * @returns the modified VertexData
  102720. */
  102721. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102722. private _mergeElement;
  102723. private _validate;
  102724. /**
  102725. * Serializes the VertexData
  102726. * @returns a serialized object
  102727. */
  102728. serialize(): any;
  102729. /**
  102730. * Extracts the vertexData from a mesh
  102731. * @param mesh the mesh from which to extract the VertexData
  102732. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102733. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102734. * @returns the object VertexData associated to the passed mesh
  102735. */
  102736. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102737. /**
  102738. * Extracts the vertexData from the geometry
  102739. * @param geometry the geometry from which to extract the VertexData
  102740. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102741. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102742. * @returns the object VertexData associated to the passed mesh
  102743. */
  102744. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102745. private static _ExtractFrom;
  102746. /**
  102747. * Creates the VertexData for a Ribbon
  102748. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102749. * * pathArray array of paths, each of which an array of successive Vector3
  102750. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102751. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102752. * * 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
  102753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102754. * * 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)
  102755. * * 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)
  102756. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102757. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102758. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102759. * @returns the VertexData of the ribbon
  102760. */
  102761. static CreateRibbon(options: {
  102762. pathArray: Vector3[][];
  102763. closeArray?: boolean;
  102764. closePath?: boolean;
  102765. offset?: number;
  102766. sideOrientation?: number;
  102767. frontUVs?: Vector4;
  102768. backUVs?: Vector4;
  102769. invertUV?: boolean;
  102770. uvs?: Vector2[];
  102771. colors?: Color4[];
  102772. }): VertexData;
  102773. /**
  102774. * Creates the VertexData for a box
  102775. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102776. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102777. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102778. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102779. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102780. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102781. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102783. * * 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)
  102784. * * 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)
  102785. * @returns the VertexData of the box
  102786. */
  102787. static CreateBox(options: {
  102788. size?: number;
  102789. width?: number;
  102790. height?: number;
  102791. depth?: number;
  102792. faceUV?: Vector4[];
  102793. faceColors?: Color4[];
  102794. sideOrientation?: number;
  102795. frontUVs?: Vector4;
  102796. backUVs?: Vector4;
  102797. }): VertexData;
  102798. /**
  102799. * Creates the VertexData for a tiled box
  102800. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102801. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102802. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102803. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102804. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102805. * @returns the VertexData of the box
  102806. */
  102807. static CreateTiledBox(options: {
  102808. pattern?: number;
  102809. width?: number;
  102810. height?: number;
  102811. depth?: number;
  102812. tileSize?: number;
  102813. tileWidth?: number;
  102814. tileHeight?: number;
  102815. alignHorizontal?: number;
  102816. alignVertical?: number;
  102817. faceUV?: Vector4[];
  102818. faceColors?: Color4[];
  102819. sideOrientation?: number;
  102820. }): VertexData;
  102821. /**
  102822. * Creates the VertexData for a tiled plane
  102823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102824. * * pattern a limited pattern arrangement depending on the number
  102825. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102826. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102827. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102829. * * 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)
  102830. * * 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)
  102831. * @returns the VertexData of the tiled plane
  102832. */
  102833. static CreateTiledPlane(options: {
  102834. pattern?: number;
  102835. tileSize?: number;
  102836. tileWidth?: number;
  102837. tileHeight?: number;
  102838. size?: number;
  102839. width?: number;
  102840. height?: number;
  102841. alignHorizontal?: number;
  102842. alignVertical?: number;
  102843. sideOrientation?: number;
  102844. frontUVs?: Vector4;
  102845. backUVs?: Vector4;
  102846. }): VertexData;
  102847. /**
  102848. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102849. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102850. * * segments sets the number of horizontal strips optional, default 32
  102851. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102852. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102853. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102854. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102855. * * 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
  102856. * * 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
  102857. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102858. * * 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)
  102859. * * 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)
  102860. * @returns the VertexData of the ellipsoid
  102861. */
  102862. static CreateSphere(options: {
  102863. segments?: number;
  102864. diameter?: number;
  102865. diameterX?: number;
  102866. diameterY?: number;
  102867. diameterZ?: number;
  102868. arc?: number;
  102869. slice?: number;
  102870. sideOrientation?: number;
  102871. frontUVs?: Vector4;
  102872. backUVs?: Vector4;
  102873. }): VertexData;
  102874. /**
  102875. * Creates the VertexData for a cylinder, cone or prism
  102876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102877. * * height sets the height (y direction) of the cylinder, optional, default 2
  102878. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102879. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102880. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102881. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102882. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102883. * * 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
  102884. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102885. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102886. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102887. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102889. * * 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)
  102890. * * 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)
  102891. * @returns the VertexData of the cylinder, cone or prism
  102892. */
  102893. static CreateCylinder(options: {
  102894. height?: number;
  102895. diameterTop?: number;
  102896. diameterBottom?: number;
  102897. diameter?: number;
  102898. tessellation?: number;
  102899. subdivisions?: number;
  102900. arc?: number;
  102901. faceColors?: Color4[];
  102902. faceUV?: Vector4[];
  102903. hasRings?: boolean;
  102904. enclose?: boolean;
  102905. sideOrientation?: number;
  102906. frontUVs?: Vector4;
  102907. backUVs?: Vector4;
  102908. }): VertexData;
  102909. /**
  102910. * Creates the VertexData for a torus
  102911. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102912. * * diameter the diameter of the torus, optional default 1
  102913. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102914. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102915. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102916. * * 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)
  102917. * * 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)
  102918. * @returns the VertexData of the torus
  102919. */
  102920. static CreateTorus(options: {
  102921. diameter?: number;
  102922. thickness?: number;
  102923. tessellation?: number;
  102924. sideOrientation?: number;
  102925. frontUVs?: Vector4;
  102926. backUVs?: Vector4;
  102927. }): VertexData;
  102928. /**
  102929. * Creates the VertexData of the LineSystem
  102930. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  102931. * - lines an array of lines, each line being an array of successive Vector3
  102932. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  102933. * @returns the VertexData of the LineSystem
  102934. */
  102935. static CreateLineSystem(options: {
  102936. lines: Vector3[][];
  102937. colors?: Nullable<Color4[][]>;
  102938. }): VertexData;
  102939. /**
  102940. * Create the VertexData for a DashedLines
  102941. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  102942. * - points an array successive Vector3
  102943. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  102944. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  102945. * - dashNb the intended total number of dashes, optional, default 200
  102946. * @returns the VertexData for the DashedLines
  102947. */
  102948. static CreateDashedLines(options: {
  102949. points: Vector3[];
  102950. dashSize?: number;
  102951. gapSize?: number;
  102952. dashNb?: number;
  102953. }): VertexData;
  102954. /**
  102955. * Creates the VertexData for a Ground
  102956. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102957. * - width the width (x direction) of the ground, optional, default 1
  102958. * - height the height (z direction) of the ground, optional, default 1
  102959. * - subdivisions the number of subdivisions per side, optional, default 1
  102960. * @returns the VertexData of the Ground
  102961. */
  102962. static CreateGround(options: {
  102963. width?: number;
  102964. height?: number;
  102965. subdivisions?: number;
  102966. subdivisionsX?: number;
  102967. subdivisionsY?: number;
  102968. }): VertexData;
  102969. /**
  102970. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  102971. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  102972. * * xmin the ground minimum X coordinate, optional, default -1
  102973. * * zmin the ground minimum Z coordinate, optional, default -1
  102974. * * xmax the ground maximum X coordinate, optional, default 1
  102975. * * zmax the ground maximum Z coordinate, optional, default 1
  102976. * * 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}
  102977. * * 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}
  102978. * @returns the VertexData of the TiledGround
  102979. */
  102980. static CreateTiledGround(options: {
  102981. xmin: number;
  102982. zmin: number;
  102983. xmax: number;
  102984. zmax: number;
  102985. subdivisions?: {
  102986. w: number;
  102987. h: number;
  102988. };
  102989. precision?: {
  102990. w: number;
  102991. h: number;
  102992. };
  102993. }): VertexData;
  102994. /**
  102995. * Creates the VertexData of the Ground designed from a heightmap
  102996. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  102997. * * width the width (x direction) of the ground
  102998. * * height the height (z direction) of the ground
  102999. * * subdivisions the number of subdivisions per side
  103000. * * minHeight the minimum altitude on the ground, optional, default 0
  103001. * * maxHeight the maximum altitude on the ground, optional default 1
  103002. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103003. * * buffer the array holding the image color data
  103004. * * bufferWidth the width of image
  103005. * * bufferHeight the height of image
  103006. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103007. * @returns the VertexData of the Ground designed from a heightmap
  103008. */
  103009. static CreateGroundFromHeightMap(options: {
  103010. width: number;
  103011. height: number;
  103012. subdivisions: number;
  103013. minHeight: number;
  103014. maxHeight: number;
  103015. colorFilter: Color3;
  103016. buffer: Uint8Array;
  103017. bufferWidth: number;
  103018. bufferHeight: number;
  103019. alphaFilter: number;
  103020. }): VertexData;
  103021. /**
  103022. * Creates the VertexData for a Plane
  103023. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103024. * * size sets the width and height of the plane to the value of size, optional default 1
  103025. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103026. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103028. * * 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)
  103029. * * 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)
  103030. * @returns the VertexData of the box
  103031. */
  103032. static CreatePlane(options: {
  103033. size?: number;
  103034. width?: number;
  103035. height?: number;
  103036. sideOrientation?: number;
  103037. frontUVs?: Vector4;
  103038. backUVs?: Vector4;
  103039. }): VertexData;
  103040. /**
  103041. * Creates the VertexData of the Disc or regular Polygon
  103042. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103043. * * radius the radius of the disc, optional default 0.5
  103044. * * tessellation the number of polygon sides, optional, default 64
  103045. * * 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
  103046. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103047. * * 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)
  103048. * * 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)
  103049. * @returns the VertexData of the box
  103050. */
  103051. static CreateDisc(options: {
  103052. radius?: number;
  103053. tessellation?: number;
  103054. arc?: number;
  103055. sideOrientation?: number;
  103056. frontUVs?: Vector4;
  103057. backUVs?: Vector4;
  103058. }): VertexData;
  103059. /**
  103060. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103061. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103062. * @param polygon a mesh built from polygonTriangulation.build()
  103063. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103064. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103065. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103066. * @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)
  103067. * @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)
  103068. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103069. * @returns the VertexData of the Polygon
  103070. */
  103071. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103072. /**
  103073. * Creates the VertexData of the IcoSphere
  103074. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103075. * * radius the radius of the IcoSphere, optional default 1
  103076. * * radiusX allows stretching in the x direction, optional, default radius
  103077. * * radiusY allows stretching in the y direction, optional, default radius
  103078. * * radiusZ allows stretching in the z direction, optional, default radius
  103079. * * flat when true creates a flat shaded mesh, optional, default true
  103080. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103082. * * 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)
  103083. * * 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)
  103084. * @returns the VertexData of the IcoSphere
  103085. */
  103086. static CreateIcoSphere(options: {
  103087. radius?: number;
  103088. radiusX?: number;
  103089. radiusY?: number;
  103090. radiusZ?: number;
  103091. flat?: boolean;
  103092. subdivisions?: number;
  103093. sideOrientation?: number;
  103094. frontUVs?: Vector4;
  103095. backUVs?: Vector4;
  103096. }): VertexData;
  103097. /**
  103098. * Creates the VertexData for a Polyhedron
  103099. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103100. * * type provided types are:
  103101. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103102. * * 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)
  103103. * * size the size of the IcoSphere, optional default 1
  103104. * * sizeX allows stretching in the x direction, optional, default size
  103105. * * sizeY allows stretching in the y direction, optional, default size
  103106. * * sizeZ allows stretching in the z direction, optional, default size
  103107. * * 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
  103108. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103109. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103110. * * flat when true creates a flat shaded mesh, optional, default true
  103111. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103113. * * 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)
  103114. * * 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)
  103115. * @returns the VertexData of the Polyhedron
  103116. */
  103117. static CreatePolyhedron(options: {
  103118. type?: number;
  103119. size?: number;
  103120. sizeX?: number;
  103121. sizeY?: number;
  103122. sizeZ?: number;
  103123. custom?: any;
  103124. faceUV?: Vector4[];
  103125. faceColors?: Color4[];
  103126. flat?: boolean;
  103127. sideOrientation?: number;
  103128. frontUVs?: Vector4;
  103129. backUVs?: Vector4;
  103130. }): VertexData;
  103131. /**
  103132. * Creates the VertexData for a TorusKnot
  103133. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103134. * * radius the radius of the torus knot, optional, default 2
  103135. * * tube the thickness of the tube, optional, default 0.5
  103136. * * radialSegments the number of sides on each tube segments, optional, default 32
  103137. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103138. * * p the number of windings around the z axis, optional, default 2
  103139. * * q the number of windings around the x axis, optional, default 3
  103140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103141. * * 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)
  103142. * * 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)
  103143. * @returns the VertexData of the Torus Knot
  103144. */
  103145. static CreateTorusKnot(options: {
  103146. radius?: number;
  103147. tube?: number;
  103148. radialSegments?: number;
  103149. tubularSegments?: number;
  103150. p?: number;
  103151. q?: number;
  103152. sideOrientation?: number;
  103153. frontUVs?: Vector4;
  103154. backUVs?: Vector4;
  103155. }): VertexData;
  103156. /**
  103157. * Compute normals for given positions and indices
  103158. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103159. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103160. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103161. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103162. * * facetNormals : optional array of facet normals (vector3)
  103163. * * facetPositions : optional array of facet positions (vector3)
  103164. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103165. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103166. * * bInfo : optional bounding info, required for facetPartitioning computation
  103167. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103168. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103169. * * useRightHandedSystem: optional boolean to for right handed system computation
  103170. * * depthSort : optional boolean to enable the facet depth sort computation
  103171. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103172. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103173. */
  103174. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103175. facetNormals?: any;
  103176. facetPositions?: any;
  103177. facetPartitioning?: any;
  103178. ratio?: number;
  103179. bInfo?: any;
  103180. bbSize?: Vector3;
  103181. subDiv?: any;
  103182. useRightHandedSystem?: boolean;
  103183. depthSort?: boolean;
  103184. distanceTo?: Vector3;
  103185. depthSortedFacets?: any;
  103186. }): void;
  103187. /** @hidden */
  103188. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103189. /**
  103190. * Applies VertexData created from the imported parameters to the geometry
  103191. * @param parsedVertexData the parsed data from an imported file
  103192. * @param geometry the geometry to apply the VertexData to
  103193. */
  103194. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103195. }
  103196. }
  103197. declare module BABYLON {
  103198. /**
  103199. * Defines a target to use with MorphTargetManager
  103200. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103201. */
  103202. export class MorphTarget implements IAnimatable {
  103203. /** defines the name of the target */
  103204. name: string;
  103205. /**
  103206. * Gets or sets the list of animations
  103207. */
  103208. animations: Animation[];
  103209. private _scene;
  103210. private _positions;
  103211. private _normals;
  103212. private _tangents;
  103213. private _uvs;
  103214. private _influence;
  103215. private _uniqueId;
  103216. /**
  103217. * Observable raised when the influence changes
  103218. */
  103219. onInfluenceChanged: Observable<boolean>;
  103220. /** @hidden */
  103221. _onDataLayoutChanged: Observable<void>;
  103222. /**
  103223. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103224. */
  103225. get influence(): number;
  103226. set influence(influence: number);
  103227. /**
  103228. * Gets or sets the id of the morph Target
  103229. */
  103230. id: string;
  103231. private _animationPropertiesOverride;
  103232. /**
  103233. * Gets or sets the animation properties override
  103234. */
  103235. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103236. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103237. /**
  103238. * Creates a new MorphTarget
  103239. * @param name defines the name of the target
  103240. * @param influence defines the influence to use
  103241. * @param scene defines the scene the morphtarget belongs to
  103242. */
  103243. constructor(
  103244. /** defines the name of the target */
  103245. name: string, influence?: number, scene?: Nullable<Scene>);
  103246. /**
  103247. * Gets the unique ID of this manager
  103248. */
  103249. get uniqueId(): number;
  103250. /**
  103251. * Gets a boolean defining if the target contains position data
  103252. */
  103253. get hasPositions(): boolean;
  103254. /**
  103255. * Gets a boolean defining if the target contains normal data
  103256. */
  103257. get hasNormals(): boolean;
  103258. /**
  103259. * Gets a boolean defining if the target contains tangent data
  103260. */
  103261. get hasTangents(): boolean;
  103262. /**
  103263. * Gets a boolean defining if the target contains texture coordinates data
  103264. */
  103265. get hasUVs(): boolean;
  103266. /**
  103267. * Affects position data to this target
  103268. * @param data defines the position data to use
  103269. */
  103270. setPositions(data: Nullable<FloatArray>): void;
  103271. /**
  103272. * Gets the position data stored in this target
  103273. * @returns a FloatArray containing the position data (or null if not present)
  103274. */
  103275. getPositions(): Nullable<FloatArray>;
  103276. /**
  103277. * Affects normal data to this target
  103278. * @param data defines the normal data to use
  103279. */
  103280. setNormals(data: Nullable<FloatArray>): void;
  103281. /**
  103282. * Gets the normal data stored in this target
  103283. * @returns a FloatArray containing the normal data (or null if not present)
  103284. */
  103285. getNormals(): Nullable<FloatArray>;
  103286. /**
  103287. * Affects tangent data to this target
  103288. * @param data defines the tangent data to use
  103289. */
  103290. setTangents(data: Nullable<FloatArray>): void;
  103291. /**
  103292. * Gets the tangent data stored in this target
  103293. * @returns a FloatArray containing the tangent data (or null if not present)
  103294. */
  103295. getTangents(): Nullable<FloatArray>;
  103296. /**
  103297. * Affects texture coordinates data to this target
  103298. * @param data defines the texture coordinates data to use
  103299. */
  103300. setUVs(data: Nullable<FloatArray>): void;
  103301. /**
  103302. * Gets the texture coordinates data stored in this target
  103303. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103304. */
  103305. getUVs(): Nullable<FloatArray>;
  103306. /**
  103307. * Clone the current target
  103308. * @returns a new MorphTarget
  103309. */
  103310. clone(): MorphTarget;
  103311. /**
  103312. * Serializes the current target into a Serialization object
  103313. * @returns the serialized object
  103314. */
  103315. serialize(): any;
  103316. /**
  103317. * Returns the string "MorphTarget"
  103318. * @returns "MorphTarget"
  103319. */
  103320. getClassName(): string;
  103321. /**
  103322. * Creates a new target from serialized data
  103323. * @param serializationObject defines the serialized data to use
  103324. * @returns a new MorphTarget
  103325. */
  103326. static Parse(serializationObject: any): MorphTarget;
  103327. /**
  103328. * Creates a MorphTarget from mesh data
  103329. * @param mesh defines the source mesh
  103330. * @param name defines the name to use for the new target
  103331. * @param influence defines the influence to attach to the target
  103332. * @returns a new MorphTarget
  103333. */
  103334. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103335. }
  103336. }
  103337. declare module BABYLON {
  103338. /**
  103339. * This class is used to deform meshes using morphing between different targets
  103340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103341. */
  103342. export class MorphTargetManager {
  103343. private _targets;
  103344. private _targetInfluenceChangedObservers;
  103345. private _targetDataLayoutChangedObservers;
  103346. private _activeTargets;
  103347. private _scene;
  103348. private _influences;
  103349. private _supportsNormals;
  103350. private _supportsTangents;
  103351. private _supportsUVs;
  103352. private _vertexCount;
  103353. private _uniqueId;
  103354. private _tempInfluences;
  103355. /**
  103356. * Gets or sets a boolean indicating if normals must be morphed
  103357. */
  103358. enableNormalMorphing: boolean;
  103359. /**
  103360. * Gets or sets a boolean indicating if tangents must be morphed
  103361. */
  103362. enableTangentMorphing: boolean;
  103363. /**
  103364. * Gets or sets a boolean indicating if UV must be morphed
  103365. */
  103366. enableUVMorphing: boolean;
  103367. /**
  103368. * Creates a new MorphTargetManager
  103369. * @param scene defines the current scene
  103370. */
  103371. constructor(scene?: Nullable<Scene>);
  103372. /**
  103373. * Gets the unique ID of this manager
  103374. */
  103375. get uniqueId(): number;
  103376. /**
  103377. * Gets the number of vertices handled by this manager
  103378. */
  103379. get vertexCount(): number;
  103380. /**
  103381. * Gets a boolean indicating if this manager supports morphing of normals
  103382. */
  103383. get supportsNormals(): boolean;
  103384. /**
  103385. * Gets a boolean indicating if this manager supports morphing of tangents
  103386. */
  103387. get supportsTangents(): boolean;
  103388. /**
  103389. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103390. */
  103391. get supportsUVs(): boolean;
  103392. /**
  103393. * Gets the number of targets stored in this manager
  103394. */
  103395. get numTargets(): number;
  103396. /**
  103397. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103398. */
  103399. get numInfluencers(): number;
  103400. /**
  103401. * Gets the list of influences (one per target)
  103402. */
  103403. get influences(): Float32Array;
  103404. /**
  103405. * Gets the active target at specified index. An active target is a target with an influence > 0
  103406. * @param index defines the index to check
  103407. * @returns the requested target
  103408. */
  103409. getActiveTarget(index: number): MorphTarget;
  103410. /**
  103411. * Gets the target at specified index
  103412. * @param index defines the index to check
  103413. * @returns the requested target
  103414. */
  103415. getTarget(index: number): MorphTarget;
  103416. /**
  103417. * Add a new target to this manager
  103418. * @param target defines the target to add
  103419. */
  103420. addTarget(target: MorphTarget): void;
  103421. /**
  103422. * Removes a target from the manager
  103423. * @param target defines the target to remove
  103424. */
  103425. removeTarget(target: MorphTarget): void;
  103426. /**
  103427. * Clone the current manager
  103428. * @returns a new MorphTargetManager
  103429. */
  103430. clone(): MorphTargetManager;
  103431. /**
  103432. * Serializes the current manager into a Serialization object
  103433. * @returns the serialized object
  103434. */
  103435. serialize(): any;
  103436. private _syncActiveTargets;
  103437. /**
  103438. * Syncrhonize the targets with all the meshes using this morph target manager
  103439. */
  103440. synchronize(): void;
  103441. /**
  103442. * Creates a new MorphTargetManager from serialized data
  103443. * @param serializationObject defines the serialized data
  103444. * @param scene defines the hosting scene
  103445. * @returns the new MorphTargetManager
  103446. */
  103447. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103448. }
  103449. }
  103450. declare module BABYLON {
  103451. /**
  103452. * Class used to represent a specific level of detail of a mesh
  103453. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103454. */
  103455. export class MeshLODLevel {
  103456. /** Defines the distance where this level should start being displayed */
  103457. distance: number;
  103458. /** Defines the mesh to use to render this level */
  103459. mesh: Nullable<Mesh>;
  103460. /**
  103461. * Creates a new LOD level
  103462. * @param distance defines the distance where this level should star being displayed
  103463. * @param mesh defines the mesh to use to render this level
  103464. */
  103465. constructor(
  103466. /** Defines the distance where this level should start being displayed */
  103467. distance: number,
  103468. /** Defines the mesh to use to render this level */
  103469. mesh: Nullable<Mesh>);
  103470. }
  103471. }
  103472. declare module BABYLON {
  103473. /**
  103474. * Mesh representing the gorund
  103475. */
  103476. export class GroundMesh extends Mesh {
  103477. /** If octree should be generated */
  103478. generateOctree: boolean;
  103479. private _heightQuads;
  103480. /** @hidden */
  103481. _subdivisionsX: number;
  103482. /** @hidden */
  103483. _subdivisionsY: number;
  103484. /** @hidden */
  103485. _width: number;
  103486. /** @hidden */
  103487. _height: number;
  103488. /** @hidden */
  103489. _minX: number;
  103490. /** @hidden */
  103491. _maxX: number;
  103492. /** @hidden */
  103493. _minZ: number;
  103494. /** @hidden */
  103495. _maxZ: number;
  103496. constructor(name: string, scene: Scene);
  103497. /**
  103498. * "GroundMesh"
  103499. * @returns "GroundMesh"
  103500. */
  103501. getClassName(): string;
  103502. /**
  103503. * The minimum of x and y subdivisions
  103504. */
  103505. get subdivisions(): number;
  103506. /**
  103507. * X subdivisions
  103508. */
  103509. get subdivisionsX(): number;
  103510. /**
  103511. * Y subdivisions
  103512. */
  103513. get subdivisionsY(): number;
  103514. /**
  103515. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103516. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103517. * @param chunksCount the number of subdivisions for x and y
  103518. * @param octreeBlocksSize (Default: 32)
  103519. */
  103520. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103521. /**
  103522. * Returns a height (y) value in the Worl system :
  103523. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103524. * @param x x coordinate
  103525. * @param z z coordinate
  103526. * @returns the ground y position if (x, z) are outside the ground surface.
  103527. */
  103528. getHeightAtCoordinates(x: number, z: number): number;
  103529. /**
  103530. * Returns a normalized vector (Vector3) orthogonal to the ground
  103531. * at the ground coordinates (x, z) expressed in the World system.
  103532. * @param x x coordinate
  103533. * @param z z coordinate
  103534. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103535. */
  103536. getNormalAtCoordinates(x: number, z: number): Vector3;
  103537. /**
  103538. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103539. * at the ground coordinates (x, z) expressed in the World system.
  103540. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103541. * @param x x coordinate
  103542. * @param z z coordinate
  103543. * @param ref vector to store the result
  103544. * @returns the GroundMesh.
  103545. */
  103546. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103547. /**
  103548. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103549. * if the ground has been updated.
  103550. * This can be used in the render loop.
  103551. * @returns the GroundMesh.
  103552. */
  103553. updateCoordinateHeights(): GroundMesh;
  103554. private _getFacetAt;
  103555. private _initHeightQuads;
  103556. private _computeHeightQuads;
  103557. /**
  103558. * Serializes this ground mesh
  103559. * @param serializationObject object to write serialization to
  103560. */
  103561. serialize(serializationObject: any): void;
  103562. /**
  103563. * Parses a serialized ground mesh
  103564. * @param parsedMesh the serialized mesh
  103565. * @param scene the scene to create the ground mesh in
  103566. * @returns the created ground mesh
  103567. */
  103568. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103569. }
  103570. }
  103571. declare module BABYLON {
  103572. /**
  103573. * Interface for Physics-Joint data
  103574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103575. */
  103576. export interface PhysicsJointData {
  103577. /**
  103578. * The main pivot of the joint
  103579. */
  103580. mainPivot?: Vector3;
  103581. /**
  103582. * The connected pivot of the joint
  103583. */
  103584. connectedPivot?: Vector3;
  103585. /**
  103586. * The main axis of the joint
  103587. */
  103588. mainAxis?: Vector3;
  103589. /**
  103590. * The connected axis of the joint
  103591. */
  103592. connectedAxis?: Vector3;
  103593. /**
  103594. * The collision of the joint
  103595. */
  103596. collision?: boolean;
  103597. /**
  103598. * Native Oimo/Cannon/Energy data
  103599. */
  103600. nativeParams?: any;
  103601. }
  103602. /**
  103603. * This is a holder class for the physics joint created by the physics plugin
  103604. * It holds a set of functions to control the underlying joint
  103605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103606. */
  103607. export class PhysicsJoint {
  103608. /**
  103609. * The type of the physics joint
  103610. */
  103611. type: number;
  103612. /**
  103613. * The data for the physics joint
  103614. */
  103615. jointData: PhysicsJointData;
  103616. private _physicsJoint;
  103617. protected _physicsPlugin: IPhysicsEnginePlugin;
  103618. /**
  103619. * Initializes the physics joint
  103620. * @param type The type of the physics joint
  103621. * @param jointData The data for the physics joint
  103622. */
  103623. constructor(
  103624. /**
  103625. * The type of the physics joint
  103626. */
  103627. type: number,
  103628. /**
  103629. * The data for the physics joint
  103630. */
  103631. jointData: PhysicsJointData);
  103632. /**
  103633. * Gets the physics joint
  103634. */
  103635. get physicsJoint(): any;
  103636. /**
  103637. * Sets the physics joint
  103638. */
  103639. set physicsJoint(newJoint: any);
  103640. /**
  103641. * Sets the physics plugin
  103642. */
  103643. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103644. /**
  103645. * Execute a function that is physics-plugin specific.
  103646. * @param {Function} func the function that will be executed.
  103647. * It accepts two parameters: the physics world and the physics joint
  103648. */
  103649. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103650. /**
  103651. * Distance-Joint type
  103652. */
  103653. static DistanceJoint: number;
  103654. /**
  103655. * Hinge-Joint type
  103656. */
  103657. static HingeJoint: number;
  103658. /**
  103659. * Ball-and-Socket joint type
  103660. */
  103661. static BallAndSocketJoint: number;
  103662. /**
  103663. * Wheel-Joint type
  103664. */
  103665. static WheelJoint: number;
  103666. /**
  103667. * Slider-Joint type
  103668. */
  103669. static SliderJoint: number;
  103670. /**
  103671. * Prismatic-Joint type
  103672. */
  103673. static PrismaticJoint: number;
  103674. /**
  103675. * Universal-Joint type
  103676. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103677. */
  103678. static UniversalJoint: number;
  103679. /**
  103680. * Hinge-Joint 2 type
  103681. */
  103682. static Hinge2Joint: number;
  103683. /**
  103684. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103685. */
  103686. static PointToPointJoint: number;
  103687. /**
  103688. * Spring-Joint type
  103689. */
  103690. static SpringJoint: number;
  103691. /**
  103692. * Lock-Joint type
  103693. */
  103694. static LockJoint: number;
  103695. }
  103696. /**
  103697. * A class representing a physics distance joint
  103698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103699. */
  103700. export class DistanceJoint extends PhysicsJoint {
  103701. /**
  103702. *
  103703. * @param jointData The data for the Distance-Joint
  103704. */
  103705. constructor(jointData: DistanceJointData);
  103706. /**
  103707. * Update the predefined distance.
  103708. * @param maxDistance The maximum preferred distance
  103709. * @param minDistance The minimum preferred distance
  103710. */
  103711. updateDistance(maxDistance: number, minDistance?: number): void;
  103712. }
  103713. /**
  103714. * Represents a Motor-Enabled Joint
  103715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103716. */
  103717. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103718. /**
  103719. * Initializes the Motor-Enabled Joint
  103720. * @param type The type of the joint
  103721. * @param jointData The physica joint data for the joint
  103722. */
  103723. constructor(type: number, jointData: PhysicsJointData);
  103724. /**
  103725. * Set the motor values.
  103726. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103727. * @param force the force to apply
  103728. * @param maxForce max force for this motor.
  103729. */
  103730. setMotor(force?: number, maxForce?: number): void;
  103731. /**
  103732. * Set the motor's limits.
  103733. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103734. * @param upperLimit The upper limit of the motor
  103735. * @param lowerLimit The lower limit of the motor
  103736. */
  103737. setLimit(upperLimit: number, lowerLimit?: number): void;
  103738. }
  103739. /**
  103740. * This class represents a single physics Hinge-Joint
  103741. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103742. */
  103743. export class HingeJoint extends MotorEnabledJoint {
  103744. /**
  103745. * Initializes the Hinge-Joint
  103746. * @param jointData The joint data for the Hinge-Joint
  103747. */
  103748. constructor(jointData: PhysicsJointData);
  103749. /**
  103750. * Set the motor values.
  103751. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103752. * @param {number} force the force to apply
  103753. * @param {number} maxForce max force for this motor.
  103754. */
  103755. setMotor(force?: number, maxForce?: number): void;
  103756. /**
  103757. * Set the motor's limits.
  103758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103759. * @param upperLimit The upper limit of the motor
  103760. * @param lowerLimit The lower limit of the motor
  103761. */
  103762. setLimit(upperLimit: number, lowerLimit?: number): void;
  103763. }
  103764. /**
  103765. * This class represents a dual hinge physics joint (same as wheel joint)
  103766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103767. */
  103768. export class Hinge2Joint extends MotorEnabledJoint {
  103769. /**
  103770. * Initializes the Hinge2-Joint
  103771. * @param jointData The joint data for the Hinge2-Joint
  103772. */
  103773. constructor(jointData: PhysicsJointData);
  103774. /**
  103775. * Set the motor values.
  103776. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103777. * @param {number} targetSpeed the speed the motor is to reach
  103778. * @param {number} maxForce max force for this motor.
  103779. * @param {motorIndex} the motor's index, 0 or 1.
  103780. */
  103781. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103782. /**
  103783. * Set the motor limits.
  103784. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103785. * @param {number} upperLimit the upper limit
  103786. * @param {number} lowerLimit lower limit
  103787. * @param {motorIndex} the motor's index, 0 or 1.
  103788. */
  103789. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103790. }
  103791. /**
  103792. * Interface for a motor enabled joint
  103793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103794. */
  103795. export interface IMotorEnabledJoint {
  103796. /**
  103797. * Physics joint
  103798. */
  103799. physicsJoint: any;
  103800. /**
  103801. * Sets the motor of the motor-enabled joint
  103802. * @param force The force of the motor
  103803. * @param maxForce The maximum force of the motor
  103804. * @param motorIndex The index of the motor
  103805. */
  103806. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103807. /**
  103808. * Sets the limit of the motor
  103809. * @param upperLimit The upper limit of the motor
  103810. * @param lowerLimit The lower limit of the motor
  103811. * @param motorIndex The index of the motor
  103812. */
  103813. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103814. }
  103815. /**
  103816. * Joint data for a Distance-Joint
  103817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103818. */
  103819. export interface DistanceJointData extends PhysicsJointData {
  103820. /**
  103821. * Max distance the 2 joint objects can be apart
  103822. */
  103823. maxDistance: number;
  103824. }
  103825. /**
  103826. * Joint data from a spring joint
  103827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103828. */
  103829. export interface SpringJointData extends PhysicsJointData {
  103830. /**
  103831. * Length of the spring
  103832. */
  103833. length: number;
  103834. /**
  103835. * Stiffness of the spring
  103836. */
  103837. stiffness: number;
  103838. /**
  103839. * Damping of the spring
  103840. */
  103841. damping: number;
  103842. /** this callback will be called when applying the force to the impostors. */
  103843. forceApplicationCallback: () => void;
  103844. }
  103845. }
  103846. declare module BABYLON {
  103847. /**
  103848. * Holds the data for the raycast result
  103849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103850. */
  103851. export class PhysicsRaycastResult {
  103852. private _hasHit;
  103853. private _hitDistance;
  103854. private _hitNormalWorld;
  103855. private _hitPointWorld;
  103856. private _rayFromWorld;
  103857. private _rayToWorld;
  103858. /**
  103859. * Gets if there was a hit
  103860. */
  103861. get hasHit(): boolean;
  103862. /**
  103863. * Gets the distance from the hit
  103864. */
  103865. get hitDistance(): number;
  103866. /**
  103867. * Gets the hit normal/direction in the world
  103868. */
  103869. get hitNormalWorld(): Vector3;
  103870. /**
  103871. * Gets the hit point in the world
  103872. */
  103873. get hitPointWorld(): Vector3;
  103874. /**
  103875. * Gets the ray "start point" of the ray in the world
  103876. */
  103877. get rayFromWorld(): Vector3;
  103878. /**
  103879. * Gets the ray "end point" of the ray in the world
  103880. */
  103881. get rayToWorld(): Vector3;
  103882. /**
  103883. * Sets the hit data (normal & point in world space)
  103884. * @param hitNormalWorld defines the normal in world space
  103885. * @param hitPointWorld defines the point in world space
  103886. */
  103887. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103888. /**
  103889. * Sets the distance from the start point to the hit point
  103890. * @param distance
  103891. */
  103892. setHitDistance(distance: number): void;
  103893. /**
  103894. * Calculates the distance manually
  103895. */
  103896. calculateHitDistance(): void;
  103897. /**
  103898. * Resets all the values to default
  103899. * @param from The from point on world space
  103900. * @param to The to point on world space
  103901. */
  103902. reset(from?: Vector3, to?: Vector3): void;
  103903. }
  103904. /**
  103905. * Interface for the size containing width and height
  103906. */
  103907. interface IXYZ {
  103908. /**
  103909. * X
  103910. */
  103911. x: number;
  103912. /**
  103913. * Y
  103914. */
  103915. y: number;
  103916. /**
  103917. * Z
  103918. */
  103919. z: number;
  103920. }
  103921. }
  103922. declare module BABYLON {
  103923. /**
  103924. * Interface used to describe a physics joint
  103925. */
  103926. export interface PhysicsImpostorJoint {
  103927. /** Defines the main impostor to which the joint is linked */
  103928. mainImpostor: PhysicsImpostor;
  103929. /** Defines the impostor that is connected to the main impostor using this joint */
  103930. connectedImpostor: PhysicsImpostor;
  103931. /** Defines the joint itself */
  103932. joint: PhysicsJoint;
  103933. }
  103934. /** @hidden */
  103935. export interface IPhysicsEnginePlugin {
  103936. world: any;
  103937. name: string;
  103938. setGravity(gravity: Vector3): void;
  103939. setTimeStep(timeStep: number): void;
  103940. getTimeStep(): number;
  103941. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  103942. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103943. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  103944. generatePhysicsBody(impostor: PhysicsImpostor): void;
  103945. removePhysicsBody(impostor: PhysicsImpostor): void;
  103946. generateJoint(joint: PhysicsImpostorJoint): void;
  103947. removeJoint(joint: PhysicsImpostorJoint): void;
  103948. isSupported(): boolean;
  103949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  103950. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  103951. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103952. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  103953. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103954. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  103955. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  103956. getBodyMass(impostor: PhysicsImpostor): number;
  103957. getBodyFriction(impostor: PhysicsImpostor): number;
  103958. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  103959. getBodyRestitution(impostor: PhysicsImpostor): number;
  103960. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  103961. getBodyPressure?(impostor: PhysicsImpostor): number;
  103962. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  103963. getBodyStiffness?(impostor: PhysicsImpostor): number;
  103964. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  103965. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  103966. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  103967. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  103968. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  103969. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103970. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  103971. sleepBody(impostor: PhysicsImpostor): void;
  103972. wakeUpBody(impostor: PhysicsImpostor): void;
  103973. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  103974. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  103975. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  103976. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103977. getRadius(impostor: PhysicsImpostor): number;
  103978. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  103979. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  103980. dispose(): void;
  103981. }
  103982. /**
  103983. * Interface used to define a physics engine
  103984. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  103985. */
  103986. export interface IPhysicsEngine {
  103987. /**
  103988. * Gets the gravity vector used by the simulation
  103989. */
  103990. gravity: Vector3;
  103991. /**
  103992. * Sets the gravity vector used by the simulation
  103993. * @param gravity defines the gravity vector to use
  103994. */
  103995. setGravity(gravity: Vector3): void;
  103996. /**
  103997. * Set the time step of the physics engine.
  103998. * Default is 1/60.
  103999. * To slow it down, enter 1/600 for example.
  104000. * To speed it up, 1/30
  104001. * @param newTimeStep the new timestep to apply to this world.
  104002. */
  104003. setTimeStep(newTimeStep: number): void;
  104004. /**
  104005. * Get the time step of the physics engine.
  104006. * @returns the current time step
  104007. */
  104008. getTimeStep(): number;
  104009. /**
  104010. * Set the sub time step of the physics engine.
  104011. * Default is 0 meaning there is no sub steps
  104012. * To increase physics resolution precision, set a small value (like 1 ms)
  104013. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104014. */
  104015. setSubTimeStep(subTimeStep: number): void;
  104016. /**
  104017. * Get the sub time step of the physics engine.
  104018. * @returns the current sub time step
  104019. */
  104020. getSubTimeStep(): number;
  104021. /**
  104022. * Release all resources
  104023. */
  104024. dispose(): void;
  104025. /**
  104026. * Gets the name of the current physics plugin
  104027. * @returns the name of the plugin
  104028. */
  104029. getPhysicsPluginName(): string;
  104030. /**
  104031. * Adding a new impostor for the impostor tracking.
  104032. * This will be done by the impostor itself.
  104033. * @param impostor the impostor to add
  104034. */
  104035. addImpostor(impostor: PhysicsImpostor): void;
  104036. /**
  104037. * Remove an impostor from the engine.
  104038. * This impostor and its mesh will not longer be updated by the physics engine.
  104039. * @param impostor the impostor to remove
  104040. */
  104041. removeImpostor(impostor: PhysicsImpostor): void;
  104042. /**
  104043. * Add a joint to the physics engine
  104044. * @param mainImpostor defines the main impostor to which the joint is added.
  104045. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104046. * @param joint defines the joint that will connect both impostors.
  104047. */
  104048. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104049. /**
  104050. * Removes a joint from the simulation
  104051. * @param mainImpostor defines the impostor used with the joint
  104052. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104053. * @param joint defines the joint to remove
  104054. */
  104055. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104056. /**
  104057. * Gets the current plugin used to run the simulation
  104058. * @returns current plugin
  104059. */
  104060. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104061. /**
  104062. * Gets the list of physic impostors
  104063. * @returns an array of PhysicsImpostor
  104064. */
  104065. getImpostors(): Array<PhysicsImpostor>;
  104066. /**
  104067. * Gets the impostor for a physics enabled object
  104068. * @param object defines the object impersonated by the impostor
  104069. * @returns the PhysicsImpostor or null if not found
  104070. */
  104071. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104072. /**
  104073. * Gets the impostor for a physics body object
  104074. * @param body defines physics body used by the impostor
  104075. * @returns the PhysicsImpostor or null if not found
  104076. */
  104077. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104078. /**
  104079. * Does a raycast in the physics world
  104080. * @param from when should the ray start?
  104081. * @param to when should the ray end?
  104082. * @returns PhysicsRaycastResult
  104083. */
  104084. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104085. /**
  104086. * Called by the scene. No need to call it.
  104087. * @param delta defines the timespam between frames
  104088. */
  104089. _step(delta: number): void;
  104090. }
  104091. }
  104092. declare module BABYLON {
  104093. /**
  104094. * The interface for the physics imposter parameters
  104095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104096. */
  104097. export interface PhysicsImpostorParameters {
  104098. /**
  104099. * The mass of the physics imposter
  104100. */
  104101. mass: number;
  104102. /**
  104103. * The friction of the physics imposter
  104104. */
  104105. friction?: number;
  104106. /**
  104107. * The coefficient of restitution of the physics imposter
  104108. */
  104109. restitution?: number;
  104110. /**
  104111. * The native options of the physics imposter
  104112. */
  104113. nativeOptions?: any;
  104114. /**
  104115. * Specifies if the parent should be ignored
  104116. */
  104117. ignoreParent?: boolean;
  104118. /**
  104119. * Specifies if bi-directional transformations should be disabled
  104120. */
  104121. disableBidirectionalTransformation?: boolean;
  104122. /**
  104123. * The pressure inside the physics imposter, soft object only
  104124. */
  104125. pressure?: number;
  104126. /**
  104127. * The stiffness the physics imposter, soft object only
  104128. */
  104129. stiffness?: number;
  104130. /**
  104131. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104132. */
  104133. velocityIterations?: number;
  104134. /**
  104135. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104136. */
  104137. positionIterations?: number;
  104138. /**
  104139. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104140. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104141. * Add to fix multiple points
  104142. */
  104143. fixedPoints?: number;
  104144. /**
  104145. * The collision margin around a soft object
  104146. */
  104147. margin?: number;
  104148. /**
  104149. * The collision margin around a soft object
  104150. */
  104151. damping?: number;
  104152. /**
  104153. * The path for a rope based on an extrusion
  104154. */
  104155. path?: any;
  104156. /**
  104157. * The shape of an extrusion used for a rope based on an extrusion
  104158. */
  104159. shape?: any;
  104160. }
  104161. /**
  104162. * Interface for a physics-enabled object
  104163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104164. */
  104165. export interface IPhysicsEnabledObject {
  104166. /**
  104167. * The position of the physics-enabled object
  104168. */
  104169. position: Vector3;
  104170. /**
  104171. * The rotation of the physics-enabled object
  104172. */
  104173. rotationQuaternion: Nullable<Quaternion>;
  104174. /**
  104175. * The scale of the physics-enabled object
  104176. */
  104177. scaling: Vector3;
  104178. /**
  104179. * The rotation of the physics-enabled object
  104180. */
  104181. rotation?: Vector3;
  104182. /**
  104183. * The parent of the physics-enabled object
  104184. */
  104185. parent?: any;
  104186. /**
  104187. * The bounding info of the physics-enabled object
  104188. * @returns The bounding info of the physics-enabled object
  104189. */
  104190. getBoundingInfo(): BoundingInfo;
  104191. /**
  104192. * Computes the world matrix
  104193. * @param force Specifies if the world matrix should be computed by force
  104194. * @returns A world matrix
  104195. */
  104196. computeWorldMatrix(force: boolean): Matrix;
  104197. /**
  104198. * Gets the world matrix
  104199. * @returns A world matrix
  104200. */
  104201. getWorldMatrix?(): Matrix;
  104202. /**
  104203. * Gets the child meshes
  104204. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104205. * @returns An array of abstract meshes
  104206. */
  104207. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104208. /**
  104209. * Gets the vertex data
  104210. * @param kind The type of vertex data
  104211. * @returns A nullable array of numbers, or a float32 array
  104212. */
  104213. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104214. /**
  104215. * Gets the indices from the mesh
  104216. * @returns A nullable array of index arrays
  104217. */
  104218. getIndices?(): Nullable<IndicesArray>;
  104219. /**
  104220. * Gets the scene from the mesh
  104221. * @returns the indices array or null
  104222. */
  104223. getScene?(): Scene;
  104224. /**
  104225. * Gets the absolute position from the mesh
  104226. * @returns the absolute position
  104227. */
  104228. getAbsolutePosition(): Vector3;
  104229. /**
  104230. * Gets the absolute pivot point from the mesh
  104231. * @returns the absolute pivot point
  104232. */
  104233. getAbsolutePivotPoint(): Vector3;
  104234. /**
  104235. * Rotates the mesh
  104236. * @param axis The axis of rotation
  104237. * @param amount The amount of rotation
  104238. * @param space The space of the rotation
  104239. * @returns The rotation transform node
  104240. */
  104241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104242. /**
  104243. * Translates the mesh
  104244. * @param axis The axis of translation
  104245. * @param distance The distance of translation
  104246. * @param space The space of the translation
  104247. * @returns The transform node
  104248. */
  104249. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104250. /**
  104251. * Sets the absolute position of the mesh
  104252. * @param absolutePosition The absolute position of the mesh
  104253. * @returns The transform node
  104254. */
  104255. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104256. /**
  104257. * Gets the class name of the mesh
  104258. * @returns The class name
  104259. */
  104260. getClassName(): string;
  104261. }
  104262. /**
  104263. * Represents a physics imposter
  104264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104265. */
  104266. export class PhysicsImpostor {
  104267. /**
  104268. * The physics-enabled object used as the physics imposter
  104269. */
  104270. object: IPhysicsEnabledObject;
  104271. /**
  104272. * The type of the physics imposter
  104273. */
  104274. type: number;
  104275. private _options;
  104276. private _scene?;
  104277. /**
  104278. * The default object size of the imposter
  104279. */
  104280. static DEFAULT_OBJECT_SIZE: Vector3;
  104281. /**
  104282. * The identity quaternion of the imposter
  104283. */
  104284. static IDENTITY_QUATERNION: Quaternion;
  104285. /** @hidden */
  104286. _pluginData: any;
  104287. private _physicsEngine;
  104288. private _physicsBody;
  104289. private _bodyUpdateRequired;
  104290. private _onBeforePhysicsStepCallbacks;
  104291. private _onAfterPhysicsStepCallbacks;
  104292. /** @hidden */
  104293. _onPhysicsCollideCallbacks: Array<{
  104294. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104295. otherImpostors: Array<PhysicsImpostor>;
  104296. }>;
  104297. private _deltaPosition;
  104298. private _deltaRotation;
  104299. private _deltaRotationConjugated;
  104300. /** @hidden */
  104301. _isFromLine: boolean;
  104302. private _parent;
  104303. private _isDisposed;
  104304. private static _tmpVecs;
  104305. private static _tmpQuat;
  104306. /**
  104307. * Specifies if the physics imposter is disposed
  104308. */
  104309. get isDisposed(): boolean;
  104310. /**
  104311. * Gets the mass of the physics imposter
  104312. */
  104313. get mass(): number;
  104314. set mass(value: number);
  104315. /**
  104316. * Gets the coefficient of friction
  104317. */
  104318. get friction(): number;
  104319. /**
  104320. * Sets the coefficient of friction
  104321. */
  104322. set friction(value: number);
  104323. /**
  104324. * Gets the coefficient of restitution
  104325. */
  104326. get restitution(): number;
  104327. /**
  104328. * Sets the coefficient of restitution
  104329. */
  104330. set restitution(value: number);
  104331. /**
  104332. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104333. */
  104334. get pressure(): number;
  104335. /**
  104336. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104337. */
  104338. set pressure(value: number);
  104339. /**
  104340. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104341. */
  104342. get stiffness(): number;
  104343. /**
  104344. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104345. */
  104346. set stiffness(value: number);
  104347. /**
  104348. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104349. */
  104350. get velocityIterations(): number;
  104351. /**
  104352. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104353. */
  104354. set velocityIterations(value: number);
  104355. /**
  104356. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104357. */
  104358. get positionIterations(): number;
  104359. /**
  104360. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104361. */
  104362. set positionIterations(value: number);
  104363. /**
  104364. * The unique id of the physics imposter
  104365. * set by the physics engine when adding this impostor to the array
  104366. */
  104367. uniqueId: number;
  104368. /**
  104369. * @hidden
  104370. */
  104371. soft: boolean;
  104372. /**
  104373. * @hidden
  104374. */
  104375. segments: number;
  104376. private _joints;
  104377. /**
  104378. * Initializes the physics imposter
  104379. * @param object The physics-enabled object used as the physics imposter
  104380. * @param type The type of the physics imposter
  104381. * @param _options The options for the physics imposter
  104382. * @param _scene The Babylon scene
  104383. */
  104384. constructor(
  104385. /**
  104386. * The physics-enabled object used as the physics imposter
  104387. */
  104388. object: IPhysicsEnabledObject,
  104389. /**
  104390. * The type of the physics imposter
  104391. */
  104392. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104393. /**
  104394. * This function will completly initialize this impostor.
  104395. * It will create a new body - but only if this mesh has no parent.
  104396. * If it has, this impostor will not be used other than to define the impostor
  104397. * of the child mesh.
  104398. * @hidden
  104399. */
  104400. _init(): void;
  104401. private _getPhysicsParent;
  104402. /**
  104403. * Should a new body be generated.
  104404. * @returns boolean specifying if body initialization is required
  104405. */
  104406. isBodyInitRequired(): boolean;
  104407. /**
  104408. * Sets the updated scaling
  104409. * @param updated Specifies if the scaling is updated
  104410. */
  104411. setScalingUpdated(): void;
  104412. /**
  104413. * Force a regeneration of this or the parent's impostor's body.
  104414. * Use under cautious - This will remove all joints already implemented.
  104415. */
  104416. forceUpdate(): void;
  104417. /**
  104418. * Gets the body that holds this impostor. Either its own, or its parent.
  104419. */
  104420. get physicsBody(): any;
  104421. /**
  104422. * Get the parent of the physics imposter
  104423. * @returns Physics imposter or null
  104424. */
  104425. get parent(): Nullable<PhysicsImpostor>;
  104426. /**
  104427. * Sets the parent of the physics imposter
  104428. */
  104429. set parent(value: Nullable<PhysicsImpostor>);
  104430. /**
  104431. * Set the physics body. Used mainly by the physics engine/plugin
  104432. */
  104433. set physicsBody(physicsBody: any);
  104434. /**
  104435. * Resets the update flags
  104436. */
  104437. resetUpdateFlags(): void;
  104438. /**
  104439. * Gets the object extend size
  104440. * @returns the object extend size
  104441. */
  104442. getObjectExtendSize(): Vector3;
  104443. /**
  104444. * Gets the object center
  104445. * @returns The object center
  104446. */
  104447. getObjectCenter(): Vector3;
  104448. /**
  104449. * Get a specific parameter from the options parameters
  104450. * @param paramName The object parameter name
  104451. * @returns The object parameter
  104452. */
  104453. getParam(paramName: string): any;
  104454. /**
  104455. * Sets a specific parameter in the options given to the physics plugin
  104456. * @param paramName The parameter name
  104457. * @param value The value of the parameter
  104458. */
  104459. setParam(paramName: string, value: number): void;
  104460. /**
  104461. * Specifically change the body's mass option. Won't recreate the physics body object
  104462. * @param mass The mass of the physics imposter
  104463. */
  104464. setMass(mass: number): void;
  104465. /**
  104466. * Gets the linear velocity
  104467. * @returns linear velocity or null
  104468. */
  104469. getLinearVelocity(): Nullable<Vector3>;
  104470. /**
  104471. * Sets the linear velocity
  104472. * @param velocity linear velocity or null
  104473. */
  104474. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104475. /**
  104476. * Gets the angular velocity
  104477. * @returns angular velocity or null
  104478. */
  104479. getAngularVelocity(): Nullable<Vector3>;
  104480. /**
  104481. * Sets the angular velocity
  104482. * @param velocity The velocity or null
  104483. */
  104484. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104485. /**
  104486. * Execute a function with the physics plugin native code
  104487. * Provide a function the will have two variables - the world object and the physics body object
  104488. * @param func The function to execute with the physics plugin native code
  104489. */
  104490. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104491. /**
  104492. * Register a function that will be executed before the physics world is stepping forward
  104493. * @param func The function to execute before the physics world is stepped forward
  104494. */
  104495. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104496. /**
  104497. * Unregister a function that will be executed before the physics world is stepping forward
  104498. * @param func The function to execute before the physics world is stepped forward
  104499. */
  104500. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104501. /**
  104502. * Register a function that will be executed after the physics step
  104503. * @param func The function to execute after physics step
  104504. */
  104505. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104506. /**
  104507. * Unregisters a function that will be executed after the physics step
  104508. * @param func The function to execute after physics step
  104509. */
  104510. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104511. /**
  104512. * register a function that will be executed when this impostor collides against a different body
  104513. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104514. * @param func Callback that is executed on collision
  104515. */
  104516. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104517. /**
  104518. * Unregisters the physics imposter on contact
  104519. * @param collideAgainst The physics object to collide against
  104520. * @param func Callback to execute on collision
  104521. */
  104522. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104523. private _tmpQuat;
  104524. private _tmpQuat2;
  104525. /**
  104526. * Get the parent rotation
  104527. * @returns The parent rotation
  104528. */
  104529. getParentsRotation(): Quaternion;
  104530. /**
  104531. * this function is executed by the physics engine.
  104532. */
  104533. beforeStep: () => void;
  104534. /**
  104535. * this function is executed by the physics engine
  104536. */
  104537. afterStep: () => void;
  104538. /**
  104539. * Legacy collision detection event support
  104540. */
  104541. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104542. /**
  104543. * event and body object due to cannon's event-based architecture.
  104544. */
  104545. onCollide: (e: {
  104546. body: any;
  104547. }) => void;
  104548. /**
  104549. * Apply a force
  104550. * @param force The force to apply
  104551. * @param contactPoint The contact point for the force
  104552. * @returns The physics imposter
  104553. */
  104554. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104555. /**
  104556. * Apply an impulse
  104557. * @param force The impulse force
  104558. * @param contactPoint The contact point for the impulse force
  104559. * @returns The physics imposter
  104560. */
  104561. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104562. /**
  104563. * A help function to create a joint
  104564. * @param otherImpostor A physics imposter used to create a joint
  104565. * @param jointType The type of joint
  104566. * @param jointData The data for the joint
  104567. * @returns The physics imposter
  104568. */
  104569. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104570. /**
  104571. * Add a joint to this impostor with a different impostor
  104572. * @param otherImpostor A physics imposter used to add a joint
  104573. * @param joint The joint to add
  104574. * @returns The physics imposter
  104575. */
  104576. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104577. /**
  104578. * Add an anchor to a cloth impostor
  104579. * @param otherImpostor rigid impostor to anchor to
  104580. * @param width ratio across width from 0 to 1
  104581. * @param height ratio up height from 0 to 1
  104582. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104583. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104584. * @returns impostor the soft imposter
  104585. */
  104586. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104587. /**
  104588. * Add a hook to a rope impostor
  104589. * @param otherImpostor rigid impostor to anchor to
  104590. * @param length ratio across rope from 0 to 1
  104591. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104592. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104593. * @returns impostor the rope imposter
  104594. */
  104595. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104596. /**
  104597. * Will keep this body still, in a sleep mode.
  104598. * @returns the physics imposter
  104599. */
  104600. sleep(): PhysicsImpostor;
  104601. /**
  104602. * Wake the body up.
  104603. * @returns The physics imposter
  104604. */
  104605. wakeUp(): PhysicsImpostor;
  104606. /**
  104607. * Clones the physics imposter
  104608. * @param newObject The physics imposter clones to this physics-enabled object
  104609. * @returns A nullable physics imposter
  104610. */
  104611. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104612. /**
  104613. * Disposes the physics imposter
  104614. */
  104615. dispose(): void;
  104616. /**
  104617. * Sets the delta position
  104618. * @param position The delta position amount
  104619. */
  104620. setDeltaPosition(position: Vector3): void;
  104621. /**
  104622. * Sets the delta rotation
  104623. * @param rotation The delta rotation amount
  104624. */
  104625. setDeltaRotation(rotation: Quaternion): void;
  104626. /**
  104627. * Gets the box size of the physics imposter and stores the result in the input parameter
  104628. * @param result Stores the box size
  104629. * @returns The physics imposter
  104630. */
  104631. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104632. /**
  104633. * Gets the radius of the physics imposter
  104634. * @returns Radius of the physics imposter
  104635. */
  104636. getRadius(): number;
  104637. /**
  104638. * Sync a bone with this impostor
  104639. * @param bone The bone to sync to the impostor.
  104640. * @param boneMesh The mesh that the bone is influencing.
  104641. * @param jointPivot The pivot of the joint / bone in local space.
  104642. * @param distToJoint Optional distance from the impostor to the joint.
  104643. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104644. */
  104645. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104646. /**
  104647. * Sync impostor to a bone
  104648. * @param bone The bone that the impostor will be synced to.
  104649. * @param boneMesh The mesh that the bone is influencing.
  104650. * @param jointPivot The pivot of the joint / bone in local space.
  104651. * @param distToJoint Optional distance from the impostor to the joint.
  104652. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104653. * @param boneAxis Optional vector3 axis the bone is aligned with
  104654. */
  104655. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104656. /**
  104657. * No-Imposter type
  104658. */
  104659. static NoImpostor: number;
  104660. /**
  104661. * Sphere-Imposter type
  104662. */
  104663. static SphereImpostor: number;
  104664. /**
  104665. * Box-Imposter type
  104666. */
  104667. static BoxImpostor: number;
  104668. /**
  104669. * Plane-Imposter type
  104670. */
  104671. static PlaneImpostor: number;
  104672. /**
  104673. * Mesh-imposter type
  104674. */
  104675. static MeshImpostor: number;
  104676. /**
  104677. * Capsule-Impostor type (Ammo.js plugin only)
  104678. */
  104679. static CapsuleImpostor: number;
  104680. /**
  104681. * Cylinder-Imposter type
  104682. */
  104683. static CylinderImpostor: number;
  104684. /**
  104685. * Particle-Imposter type
  104686. */
  104687. static ParticleImpostor: number;
  104688. /**
  104689. * Heightmap-Imposter type
  104690. */
  104691. static HeightmapImpostor: number;
  104692. /**
  104693. * ConvexHull-Impostor type (Ammo.js plugin only)
  104694. */
  104695. static ConvexHullImpostor: number;
  104696. /**
  104697. * Custom-Imposter type (Ammo.js plugin only)
  104698. */
  104699. static CustomImpostor: number;
  104700. /**
  104701. * Rope-Imposter type
  104702. */
  104703. static RopeImpostor: number;
  104704. /**
  104705. * Cloth-Imposter type
  104706. */
  104707. static ClothImpostor: number;
  104708. /**
  104709. * Softbody-Imposter type
  104710. */
  104711. static SoftbodyImpostor: number;
  104712. }
  104713. }
  104714. declare module BABYLON {
  104715. /**
  104716. * @hidden
  104717. **/
  104718. export class _CreationDataStorage {
  104719. closePath?: boolean;
  104720. closeArray?: boolean;
  104721. idx: number[];
  104722. dashSize: number;
  104723. gapSize: number;
  104724. path3D: Path3D;
  104725. pathArray: Vector3[][];
  104726. arc: number;
  104727. radius: number;
  104728. cap: number;
  104729. tessellation: number;
  104730. }
  104731. /**
  104732. * @hidden
  104733. **/
  104734. class _InstanceDataStorage {
  104735. visibleInstances: any;
  104736. batchCache: _InstancesBatch;
  104737. instancesBufferSize: number;
  104738. instancesBuffer: Nullable<Buffer>;
  104739. instancesData: Float32Array;
  104740. overridenInstanceCount: number;
  104741. isFrozen: boolean;
  104742. previousBatch: Nullable<_InstancesBatch>;
  104743. hardwareInstancedRendering: boolean;
  104744. sideOrientation: number;
  104745. manualUpdate: boolean;
  104746. }
  104747. /**
  104748. * @hidden
  104749. **/
  104750. export class _InstancesBatch {
  104751. mustReturn: boolean;
  104752. visibleInstances: Nullable<InstancedMesh[]>[];
  104753. renderSelf: boolean[];
  104754. hardwareInstancedRendering: boolean[];
  104755. }
  104756. /**
  104757. * @hidden
  104758. **/
  104759. class _ThinInstanceDataStorage {
  104760. instancesCount: number;
  104761. matrixBuffer: Nullable<Buffer>;
  104762. matrixBufferSize: number;
  104763. matrixData: Nullable<Float32Array>;
  104764. boundingVectors: Array<Vector3>;
  104765. }
  104766. /**
  104767. * Class used to represent renderable models
  104768. */
  104769. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104770. /**
  104771. * Mesh side orientation : usually the external or front surface
  104772. */
  104773. static readonly FRONTSIDE: number;
  104774. /**
  104775. * Mesh side orientation : usually the internal or back surface
  104776. */
  104777. static readonly BACKSIDE: number;
  104778. /**
  104779. * Mesh side orientation : both internal and external or front and back surfaces
  104780. */
  104781. static readonly DOUBLESIDE: number;
  104782. /**
  104783. * Mesh side orientation : by default, `FRONTSIDE`
  104784. */
  104785. static readonly DEFAULTSIDE: number;
  104786. /**
  104787. * Mesh cap setting : no cap
  104788. */
  104789. static readonly NO_CAP: number;
  104790. /**
  104791. * Mesh cap setting : one cap at the beginning of the mesh
  104792. */
  104793. static readonly CAP_START: number;
  104794. /**
  104795. * Mesh cap setting : one cap at the end of the mesh
  104796. */
  104797. static readonly CAP_END: number;
  104798. /**
  104799. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104800. */
  104801. static readonly CAP_ALL: number;
  104802. /**
  104803. * Mesh pattern setting : no flip or rotate
  104804. */
  104805. static readonly NO_FLIP: number;
  104806. /**
  104807. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104808. */
  104809. static readonly FLIP_TILE: number;
  104810. /**
  104811. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104812. */
  104813. static readonly ROTATE_TILE: number;
  104814. /**
  104815. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104816. */
  104817. static readonly FLIP_ROW: number;
  104818. /**
  104819. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104820. */
  104821. static readonly ROTATE_ROW: number;
  104822. /**
  104823. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104824. */
  104825. static readonly FLIP_N_ROTATE_TILE: number;
  104826. /**
  104827. * Mesh pattern setting : rotate pattern and rotate
  104828. */
  104829. static readonly FLIP_N_ROTATE_ROW: number;
  104830. /**
  104831. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104832. */
  104833. static readonly CENTER: number;
  104834. /**
  104835. * Mesh tile positioning : part tiles on left
  104836. */
  104837. static readonly LEFT: number;
  104838. /**
  104839. * Mesh tile positioning : part tiles on right
  104840. */
  104841. static readonly RIGHT: number;
  104842. /**
  104843. * Mesh tile positioning : part tiles on top
  104844. */
  104845. static readonly TOP: number;
  104846. /**
  104847. * Mesh tile positioning : part tiles on bottom
  104848. */
  104849. static readonly BOTTOM: number;
  104850. /**
  104851. * Gets the default side orientation.
  104852. * @param orientation the orientation to value to attempt to get
  104853. * @returns the default orientation
  104854. * @hidden
  104855. */
  104856. static _GetDefaultSideOrientation(orientation?: number): number;
  104857. private _internalMeshDataInfo;
  104858. /**
  104859. * An event triggered before rendering the mesh
  104860. */
  104861. get onBeforeRenderObservable(): Observable<Mesh>;
  104862. /**
  104863. * An event triggered before binding the mesh
  104864. */
  104865. get onBeforeBindObservable(): Observable<Mesh>;
  104866. /**
  104867. * An event triggered after rendering the mesh
  104868. */
  104869. get onAfterRenderObservable(): Observable<Mesh>;
  104870. /**
  104871. * An event triggered before drawing the mesh
  104872. */
  104873. get onBeforeDrawObservable(): Observable<Mesh>;
  104874. private _onBeforeDrawObserver;
  104875. /**
  104876. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104877. */
  104878. set onBeforeDraw(callback: () => void);
  104879. get hasInstances(): boolean;
  104880. get hasThinInstances(): boolean;
  104881. /**
  104882. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104883. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104884. */
  104885. delayLoadState: number;
  104886. /**
  104887. * Gets the list of instances created from this mesh
  104888. * it is not supposed to be modified manually.
  104889. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104890. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104891. */
  104892. instances: InstancedMesh[];
  104893. /**
  104894. * Gets the file containing delay loading data for this mesh
  104895. */
  104896. delayLoadingFile: string;
  104897. /** @hidden */
  104898. _binaryInfo: any;
  104899. /**
  104900. * User defined function used to change how LOD level selection is done
  104901. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104902. */
  104903. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104904. /**
  104905. * Gets or sets the morph target manager
  104906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104907. */
  104908. get morphTargetManager(): Nullable<MorphTargetManager>;
  104909. set morphTargetManager(value: Nullable<MorphTargetManager>);
  104910. /** @hidden */
  104911. _creationDataStorage: Nullable<_CreationDataStorage>;
  104912. /** @hidden */
  104913. _geometry: Nullable<Geometry>;
  104914. /** @hidden */
  104915. _delayInfo: Array<string>;
  104916. /** @hidden */
  104917. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  104918. /** @hidden */
  104919. _instanceDataStorage: _InstanceDataStorage;
  104920. /** @hidden */
  104921. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  104922. private _effectiveMaterial;
  104923. /** @hidden */
  104924. _shouldGenerateFlatShading: boolean;
  104925. /** @hidden */
  104926. _originalBuilderSideOrientation: number;
  104927. /**
  104928. * Use this property to change the original side orientation defined at construction time
  104929. */
  104930. overrideMaterialSideOrientation: Nullable<number>;
  104931. /**
  104932. * Gets the source mesh (the one used to clone this one from)
  104933. */
  104934. get source(): Nullable<Mesh>;
  104935. /**
  104936. * Gets or sets a boolean indicating that this mesh does not use index buffer
  104937. */
  104938. get isUnIndexed(): boolean;
  104939. set isUnIndexed(value: boolean);
  104940. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  104941. get worldMatrixInstancedBuffer(): Float32Array;
  104942. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  104943. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  104944. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  104945. /**
  104946. * @constructor
  104947. * @param name The value used by scene.getMeshByName() to do a lookup.
  104948. * @param scene The scene to add this mesh to.
  104949. * @param parent The parent of this mesh, if it has one
  104950. * @param source An optional Mesh from which geometry is shared, cloned.
  104951. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  104952. * When false, achieved by calling a clone(), also passing False.
  104953. * This will make creation of children, recursive.
  104954. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  104955. */
  104956. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  104957. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  104958. doNotInstantiate: boolean;
  104959. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  104960. /**
  104961. * Gets the class name
  104962. * @returns the string "Mesh".
  104963. */
  104964. getClassName(): string;
  104965. /** @hidden */
  104966. get _isMesh(): boolean;
  104967. /**
  104968. * Returns a description of this mesh
  104969. * @param fullDetails define if full details about this mesh must be used
  104970. * @returns a descriptive string representing this mesh
  104971. */
  104972. toString(fullDetails?: boolean): string;
  104973. /** @hidden */
  104974. _unBindEffect(): void;
  104975. /**
  104976. * Gets a boolean indicating if this mesh has LOD
  104977. */
  104978. get hasLODLevels(): boolean;
  104979. /**
  104980. * Gets the list of MeshLODLevel associated with the current mesh
  104981. * @returns an array of MeshLODLevel
  104982. */
  104983. getLODLevels(): MeshLODLevel[];
  104984. private _sortLODLevels;
  104985. /**
  104986. * Add a mesh as LOD level triggered at the given distance.
  104987. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104988. * @param distance The distance from the center of the object to show this level
  104989. * @param mesh The mesh to be added as LOD level (can be null)
  104990. * @return This mesh (for chaining)
  104991. */
  104992. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  104993. /**
  104994. * Returns the LOD level mesh at the passed distance or null if not found.
  104995. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104996. * @param distance The distance from the center of the object to show this level
  104997. * @returns a Mesh or `null`
  104998. */
  104999. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105000. /**
  105001. * Remove a mesh from the LOD array
  105002. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105003. * @param mesh defines the mesh to be removed
  105004. * @return This mesh (for chaining)
  105005. */
  105006. removeLODLevel(mesh: Mesh): Mesh;
  105007. /**
  105008. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105009. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105010. * @param camera defines the camera to use to compute distance
  105011. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105012. * @return This mesh (for chaining)
  105013. */
  105014. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105015. /**
  105016. * Gets the mesh internal Geometry object
  105017. */
  105018. get geometry(): Nullable<Geometry>;
  105019. /**
  105020. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105021. * @returns the total number of vertices
  105022. */
  105023. getTotalVertices(): number;
  105024. /**
  105025. * Returns the content of an associated vertex buffer
  105026. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105027. * - VertexBuffer.PositionKind
  105028. * - VertexBuffer.UVKind
  105029. * - VertexBuffer.UV2Kind
  105030. * - VertexBuffer.UV3Kind
  105031. * - VertexBuffer.UV4Kind
  105032. * - VertexBuffer.UV5Kind
  105033. * - VertexBuffer.UV6Kind
  105034. * - VertexBuffer.ColorKind
  105035. * - VertexBuffer.MatricesIndicesKind
  105036. * - VertexBuffer.MatricesIndicesExtraKind
  105037. * - VertexBuffer.MatricesWeightsKind
  105038. * - VertexBuffer.MatricesWeightsExtraKind
  105039. * @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
  105040. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105041. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105042. */
  105043. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105044. /**
  105045. * Returns the mesh VertexBuffer object from the requested `kind`
  105046. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105047. * - VertexBuffer.PositionKind
  105048. * - VertexBuffer.NormalKind
  105049. * - VertexBuffer.UVKind
  105050. * - VertexBuffer.UV2Kind
  105051. * - VertexBuffer.UV3Kind
  105052. * - VertexBuffer.UV4Kind
  105053. * - VertexBuffer.UV5Kind
  105054. * - VertexBuffer.UV6Kind
  105055. * - VertexBuffer.ColorKind
  105056. * - VertexBuffer.MatricesIndicesKind
  105057. * - VertexBuffer.MatricesIndicesExtraKind
  105058. * - VertexBuffer.MatricesWeightsKind
  105059. * - VertexBuffer.MatricesWeightsExtraKind
  105060. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105061. */
  105062. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105063. /**
  105064. * Tests if a specific vertex buffer is associated with this mesh
  105065. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105066. * - VertexBuffer.PositionKind
  105067. * - VertexBuffer.NormalKind
  105068. * - VertexBuffer.UVKind
  105069. * - VertexBuffer.UV2Kind
  105070. * - VertexBuffer.UV3Kind
  105071. * - VertexBuffer.UV4Kind
  105072. * - VertexBuffer.UV5Kind
  105073. * - VertexBuffer.UV6Kind
  105074. * - VertexBuffer.ColorKind
  105075. * - VertexBuffer.MatricesIndicesKind
  105076. * - VertexBuffer.MatricesIndicesExtraKind
  105077. * - VertexBuffer.MatricesWeightsKind
  105078. * - VertexBuffer.MatricesWeightsExtraKind
  105079. * @returns a boolean
  105080. */
  105081. isVerticesDataPresent(kind: string): boolean;
  105082. /**
  105083. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105084. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105085. * - VertexBuffer.PositionKind
  105086. * - VertexBuffer.UVKind
  105087. * - VertexBuffer.UV2Kind
  105088. * - VertexBuffer.UV3Kind
  105089. * - VertexBuffer.UV4Kind
  105090. * - VertexBuffer.UV5Kind
  105091. * - VertexBuffer.UV6Kind
  105092. * - VertexBuffer.ColorKind
  105093. * - VertexBuffer.MatricesIndicesKind
  105094. * - VertexBuffer.MatricesIndicesExtraKind
  105095. * - VertexBuffer.MatricesWeightsKind
  105096. * - VertexBuffer.MatricesWeightsExtraKind
  105097. * @returns a boolean
  105098. */
  105099. isVertexBufferUpdatable(kind: string): boolean;
  105100. /**
  105101. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105102. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105103. * - VertexBuffer.PositionKind
  105104. * - VertexBuffer.NormalKind
  105105. * - VertexBuffer.UVKind
  105106. * - VertexBuffer.UV2Kind
  105107. * - VertexBuffer.UV3Kind
  105108. * - VertexBuffer.UV4Kind
  105109. * - VertexBuffer.UV5Kind
  105110. * - VertexBuffer.UV6Kind
  105111. * - VertexBuffer.ColorKind
  105112. * - VertexBuffer.MatricesIndicesKind
  105113. * - VertexBuffer.MatricesIndicesExtraKind
  105114. * - VertexBuffer.MatricesWeightsKind
  105115. * - VertexBuffer.MatricesWeightsExtraKind
  105116. * @returns an array of strings
  105117. */
  105118. getVerticesDataKinds(): string[];
  105119. /**
  105120. * Returns a positive integer : the total number of indices in this mesh geometry.
  105121. * @returns the numner of indices or zero if the mesh has no geometry.
  105122. */
  105123. getTotalIndices(): number;
  105124. /**
  105125. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105126. * @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.
  105127. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105128. * @returns the indices array or an empty array if the mesh has no geometry
  105129. */
  105130. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105131. get isBlocked(): boolean;
  105132. /**
  105133. * Determine if the current mesh is ready to be rendered
  105134. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105135. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105136. * @returns true if all associated assets are ready (material, textures, shaders)
  105137. */
  105138. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105139. /**
  105140. * 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.
  105141. */
  105142. get areNormalsFrozen(): boolean;
  105143. /**
  105144. * 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.
  105145. * @returns the current mesh
  105146. */
  105147. freezeNormals(): Mesh;
  105148. /**
  105149. * 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
  105150. * @returns the current mesh
  105151. */
  105152. unfreezeNormals(): Mesh;
  105153. /**
  105154. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105155. */
  105156. set overridenInstanceCount(count: number);
  105157. /** @hidden */
  105158. _preActivate(): Mesh;
  105159. /** @hidden */
  105160. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105161. /** @hidden */
  105162. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105163. protected _afterComputeWorldMatrix(): void;
  105164. /** @hidden */
  105165. _postActivate(): void;
  105166. /**
  105167. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105168. * This means the mesh underlying bounding box and sphere are recomputed.
  105169. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105170. * @returns the current mesh
  105171. */
  105172. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105173. /** @hidden */
  105174. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105175. /**
  105176. * This function will subdivide the mesh into multiple submeshes
  105177. * @param count defines the expected number of submeshes
  105178. */
  105179. subdivide(count: number): void;
  105180. /**
  105181. * Copy a FloatArray into a specific associated vertex buffer
  105182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105183. * - VertexBuffer.PositionKind
  105184. * - VertexBuffer.UVKind
  105185. * - VertexBuffer.UV2Kind
  105186. * - VertexBuffer.UV3Kind
  105187. * - VertexBuffer.UV4Kind
  105188. * - VertexBuffer.UV5Kind
  105189. * - VertexBuffer.UV6Kind
  105190. * - VertexBuffer.ColorKind
  105191. * - VertexBuffer.MatricesIndicesKind
  105192. * - VertexBuffer.MatricesIndicesExtraKind
  105193. * - VertexBuffer.MatricesWeightsKind
  105194. * - VertexBuffer.MatricesWeightsExtraKind
  105195. * @param data defines the data source
  105196. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105197. * @param stride defines the data stride size (can be null)
  105198. * @returns the current mesh
  105199. */
  105200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105201. /**
  105202. * Delete a vertex buffer associated with this mesh
  105203. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105204. * - VertexBuffer.PositionKind
  105205. * - VertexBuffer.UVKind
  105206. * - VertexBuffer.UV2Kind
  105207. * - VertexBuffer.UV3Kind
  105208. * - VertexBuffer.UV4Kind
  105209. * - VertexBuffer.UV5Kind
  105210. * - VertexBuffer.UV6Kind
  105211. * - VertexBuffer.ColorKind
  105212. * - VertexBuffer.MatricesIndicesKind
  105213. * - VertexBuffer.MatricesIndicesExtraKind
  105214. * - VertexBuffer.MatricesWeightsKind
  105215. * - VertexBuffer.MatricesWeightsExtraKind
  105216. */
  105217. removeVerticesData(kind: string): void;
  105218. /**
  105219. * Flags an associated vertex buffer as updatable
  105220. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105221. * - VertexBuffer.PositionKind
  105222. * - VertexBuffer.UVKind
  105223. * - VertexBuffer.UV2Kind
  105224. * - VertexBuffer.UV3Kind
  105225. * - VertexBuffer.UV4Kind
  105226. * - VertexBuffer.UV5Kind
  105227. * - VertexBuffer.UV6Kind
  105228. * - VertexBuffer.ColorKind
  105229. * - VertexBuffer.MatricesIndicesKind
  105230. * - VertexBuffer.MatricesIndicesExtraKind
  105231. * - VertexBuffer.MatricesWeightsKind
  105232. * - VertexBuffer.MatricesWeightsExtraKind
  105233. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105234. */
  105235. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105236. /**
  105237. * Sets the mesh global Vertex Buffer
  105238. * @param buffer defines the buffer to use
  105239. * @returns the current mesh
  105240. */
  105241. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105242. /**
  105243. * Update a specific associated vertex buffer
  105244. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105245. * - VertexBuffer.PositionKind
  105246. * - VertexBuffer.UVKind
  105247. * - VertexBuffer.UV2Kind
  105248. * - VertexBuffer.UV3Kind
  105249. * - VertexBuffer.UV4Kind
  105250. * - VertexBuffer.UV5Kind
  105251. * - VertexBuffer.UV6Kind
  105252. * - VertexBuffer.ColorKind
  105253. * - VertexBuffer.MatricesIndicesKind
  105254. * - VertexBuffer.MatricesIndicesExtraKind
  105255. * - VertexBuffer.MatricesWeightsKind
  105256. * - VertexBuffer.MatricesWeightsExtraKind
  105257. * @param data defines the data source
  105258. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105259. * @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)
  105260. * @returns the current mesh
  105261. */
  105262. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105263. /**
  105264. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105265. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105266. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105267. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105268. * @returns the current mesh
  105269. */
  105270. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105271. /**
  105272. * Creates a un-shared specific occurence of the geometry for the mesh.
  105273. * @returns the current mesh
  105274. */
  105275. makeGeometryUnique(): Mesh;
  105276. /**
  105277. * Set the index buffer of this mesh
  105278. * @param indices defines the source data
  105279. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105280. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105281. * @returns the current mesh
  105282. */
  105283. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105284. /**
  105285. * Update the current index buffer
  105286. * @param indices defines the source data
  105287. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105288. * @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)
  105289. * @returns the current mesh
  105290. */
  105291. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105292. /**
  105293. * Invert the geometry to move from a right handed system to a left handed one.
  105294. * @returns the current mesh
  105295. */
  105296. toLeftHanded(): Mesh;
  105297. /** @hidden */
  105298. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105299. /** @hidden */
  105300. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105301. /**
  105302. * Registers for this mesh a javascript function called just before the rendering process
  105303. * @param func defines the function to call before rendering this mesh
  105304. * @returns the current mesh
  105305. */
  105306. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105307. /**
  105308. * Disposes a previously registered javascript function called before the rendering
  105309. * @param func defines the function to remove
  105310. * @returns the current mesh
  105311. */
  105312. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105313. /**
  105314. * Registers for this mesh a javascript function called just after the rendering is complete
  105315. * @param func defines the function to call after rendering this mesh
  105316. * @returns the current mesh
  105317. */
  105318. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105319. /**
  105320. * Disposes a previously registered javascript function called after the rendering.
  105321. * @param func defines the function to remove
  105322. * @returns the current mesh
  105323. */
  105324. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105325. /** @hidden */
  105326. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105327. /** @hidden */
  105328. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105329. /** @hidden */
  105330. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105331. /** @hidden */
  105332. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105333. /** @hidden */
  105334. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105335. /** @hidden */
  105336. _rebuild(): void;
  105337. /** @hidden */
  105338. _freeze(): void;
  105339. /** @hidden */
  105340. _unFreeze(): void;
  105341. /**
  105342. * 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
  105343. * @param subMesh defines the subMesh to render
  105344. * @param enableAlphaMode defines if alpha mode can be changed
  105345. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105346. * @returns the current mesh
  105347. */
  105348. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105349. private _onBeforeDraw;
  105350. /**
  105351. * Renormalize the mesh and patch it up if there are no weights
  105352. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105353. * However in the case of zero weights then we set just a single influence to 1.
  105354. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105355. */
  105356. cleanMatrixWeights(): void;
  105357. private normalizeSkinFourWeights;
  105358. private normalizeSkinWeightsAndExtra;
  105359. /**
  105360. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105361. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105362. * the user know there was an issue with importing the mesh
  105363. * @returns a validation object with skinned, valid and report string
  105364. */
  105365. validateSkinning(): {
  105366. skinned: boolean;
  105367. valid: boolean;
  105368. report: string;
  105369. };
  105370. /** @hidden */
  105371. _checkDelayState(): Mesh;
  105372. private _queueLoad;
  105373. /**
  105374. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105375. * A mesh is in the frustum if its bounding box intersects the frustum
  105376. * @param frustumPlanes defines the frustum to test
  105377. * @returns true if the mesh is in the frustum planes
  105378. */
  105379. isInFrustum(frustumPlanes: Plane[]): boolean;
  105380. /**
  105381. * Sets the mesh material by the material or multiMaterial `id` property
  105382. * @param id is a string identifying the material or the multiMaterial
  105383. * @returns the current mesh
  105384. */
  105385. setMaterialByID(id: string): Mesh;
  105386. /**
  105387. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105388. * @returns an array of IAnimatable
  105389. */
  105390. getAnimatables(): IAnimatable[];
  105391. /**
  105392. * Modifies the mesh geometry according to the passed transformation matrix.
  105393. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105394. * The mesh normals are modified using the same transformation.
  105395. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105396. * @param transform defines the transform matrix to use
  105397. * @see http://doc.babylonjs.com/resources/baking_transformations
  105398. * @returns the current mesh
  105399. */
  105400. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105401. /**
  105402. * Modifies the mesh geometry according to its own current World Matrix.
  105403. * The mesh World Matrix is then reset.
  105404. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105405. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105406. * @see http://doc.babylonjs.com/resources/baking_transformations
  105407. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105408. * @returns the current mesh
  105409. */
  105410. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105411. /** @hidden */
  105412. get _positions(): Nullable<Vector3[]>;
  105413. /** @hidden */
  105414. _resetPointsArrayCache(): Mesh;
  105415. /** @hidden */
  105416. _generatePointsArray(): boolean;
  105417. /**
  105418. * Returns a new Mesh object generated from the current mesh properties.
  105419. * This method must not get confused with createInstance()
  105420. * @param name is a string, the name given to the new mesh
  105421. * @param newParent can be any Node object (default `null`)
  105422. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105423. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105424. * @returns a new mesh
  105425. */
  105426. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105427. /**
  105428. * Releases resources associated with this mesh.
  105429. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105430. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105431. */
  105432. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105433. /** @hidden */
  105434. _disposeInstanceSpecificData(): void;
  105435. /** @hidden */
  105436. _disposeThinInstanceSpecificData(): void;
  105437. /**
  105438. * Modifies the mesh geometry according to a displacement map.
  105439. * 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.
  105440. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105441. * @param url is a string, the URL from the image file is to be downloaded.
  105442. * @param minHeight is the lower limit of the displacement.
  105443. * @param maxHeight is the upper limit of the displacement.
  105444. * @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.
  105445. * @param uvOffset is an optional vector2 used to offset UV.
  105446. * @param uvScale is an optional vector2 used to scale UV.
  105447. * @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.
  105448. * @returns the Mesh.
  105449. */
  105450. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105451. /**
  105452. * Modifies the mesh geometry according to a displacementMap buffer.
  105453. * 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.
  105454. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105455. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105456. * @param heightMapWidth is the width of the buffer image.
  105457. * @param heightMapHeight is the height of the buffer image.
  105458. * @param minHeight is the lower limit of the displacement.
  105459. * @param maxHeight is the upper limit of the displacement.
  105460. * @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.
  105461. * @param uvOffset is an optional vector2 used to offset UV.
  105462. * @param uvScale is an optional vector2 used to scale UV.
  105463. * @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.
  105464. * @returns the Mesh.
  105465. */
  105466. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105467. /**
  105468. * Modify the mesh to get a flat shading rendering.
  105469. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105470. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105471. * @returns current mesh
  105472. */
  105473. convertToFlatShadedMesh(): Mesh;
  105474. /**
  105475. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105476. * In other words, more vertices, no more indices and a single bigger VBO.
  105477. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105478. * @returns current mesh
  105479. */
  105480. convertToUnIndexedMesh(): Mesh;
  105481. /**
  105482. * Inverses facet orientations.
  105483. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105484. * @param flipNormals will also inverts the normals
  105485. * @returns current mesh
  105486. */
  105487. flipFaces(flipNormals?: boolean): Mesh;
  105488. /**
  105489. * Increase the number of facets and hence vertices in a mesh
  105490. * Vertex normals are interpolated from existing vertex normals
  105491. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105492. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105493. */
  105494. increaseVertices(numberPerEdge: number): void;
  105495. /**
  105496. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105497. * This will undo any application of covertToFlatShadedMesh
  105498. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105499. */
  105500. forceSharedVertices(): void;
  105501. /** @hidden */
  105502. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105503. /** @hidden */
  105504. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105505. /**
  105506. * Creates a new InstancedMesh object from the mesh model.
  105507. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105508. * @param name defines the name of the new instance
  105509. * @returns a new InstancedMesh
  105510. */
  105511. createInstance(name: string): InstancedMesh;
  105512. /**
  105513. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105514. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105515. * @returns the current mesh
  105516. */
  105517. synchronizeInstances(): Mesh;
  105518. /**
  105519. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105520. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105521. * This should be used together with the simplification to avoid disappearing triangles.
  105522. * @param successCallback an optional success callback to be called after the optimization finished.
  105523. * @returns the current mesh
  105524. */
  105525. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105526. /**
  105527. * Serialize current mesh
  105528. * @param serializationObject defines the object which will receive the serialization data
  105529. */
  105530. serialize(serializationObject: any): void;
  105531. /** @hidden */
  105532. _syncGeometryWithMorphTargetManager(): void;
  105533. /** @hidden */
  105534. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105535. /**
  105536. * Returns a new Mesh object parsed from the source provided.
  105537. * @param parsedMesh is the source
  105538. * @param scene defines the hosting scene
  105539. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105540. * @returns a new Mesh
  105541. */
  105542. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105543. /**
  105544. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105545. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105546. * @param name defines the name of the mesh to create
  105547. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105548. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105549. * @param closePath creates a seam between the first and the last points of each path of the path array
  105550. * @param offset is taken in account only if the `pathArray` is containing a single path
  105551. * @param scene defines the hosting scene
  105552. * @param updatable defines if the mesh must be flagged as updatable
  105553. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105554. * @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)
  105555. * @returns a new Mesh
  105556. */
  105557. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105558. /**
  105559. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105560. * @param name defines the name of the mesh to create
  105561. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105562. * @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
  105563. * @param scene defines the hosting scene
  105564. * @param updatable defines if the mesh must be flagged as updatable
  105565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105566. * @returns a new Mesh
  105567. */
  105568. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105569. /**
  105570. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105571. * @param name defines the name of the mesh to create
  105572. * @param size sets the size (float) of each box side (default 1)
  105573. * @param scene defines the hosting scene
  105574. * @param updatable defines if the mesh must be flagged as updatable
  105575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105576. * @returns a new Mesh
  105577. */
  105578. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105579. /**
  105580. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105581. * @param name defines the name of the mesh to create
  105582. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105583. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105584. * @param scene defines the hosting scene
  105585. * @param updatable defines if the mesh must be flagged as updatable
  105586. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105587. * @returns a new Mesh
  105588. */
  105589. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105590. /**
  105591. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105592. * @param name defines the name of the mesh to create
  105593. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105594. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105595. * @param scene defines the hosting scene
  105596. * @returns a new Mesh
  105597. */
  105598. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105599. /**
  105600. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105601. * @param name defines the name of the mesh to create
  105602. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105603. * @param diameterTop set the top cap diameter (floats, default 1)
  105604. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105605. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105606. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105607. * @param scene defines the hosting scene
  105608. * @param updatable defines if the mesh must be flagged as updatable
  105609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105610. * @returns a new Mesh
  105611. */
  105612. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105613. /**
  105614. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105615. * @param name defines the name of the mesh to create
  105616. * @param diameter sets the diameter size (float) of the torus (default 1)
  105617. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105618. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105619. * @param scene defines the hosting scene
  105620. * @param updatable defines if the mesh must be flagged as updatable
  105621. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105622. * @returns a new Mesh
  105623. */
  105624. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105625. /**
  105626. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105627. * @param name defines the name of the mesh to create
  105628. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105629. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105630. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105631. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105632. * @param p the number of windings on X axis (positive integers, default 2)
  105633. * @param q the number of windings on Y axis (positive integers, default 3)
  105634. * @param scene defines the hosting scene
  105635. * @param updatable defines if the mesh must be flagged as updatable
  105636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105637. * @returns a new Mesh
  105638. */
  105639. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105640. /**
  105641. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105642. * @param name defines the name of the mesh to create
  105643. * @param points is an array successive Vector3
  105644. * @param scene defines the hosting scene
  105645. * @param updatable defines if the mesh must be flagged as updatable
  105646. * @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).
  105647. * @returns a new Mesh
  105648. */
  105649. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105650. /**
  105651. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105652. * @param name defines the name of the mesh to create
  105653. * @param points is an array successive Vector3
  105654. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105655. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105656. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105657. * @param scene defines the hosting scene
  105658. * @param updatable defines if the mesh must be flagged as updatable
  105659. * @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)
  105660. * @returns a new Mesh
  105661. */
  105662. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105663. /**
  105664. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105665. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105666. * 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.
  105667. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105668. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105669. * Remember you can only change the shape positions, not their number when updating a polygon.
  105670. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105671. * @param name defines the name of the mesh to create
  105672. * @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
  105673. * @param scene defines the hosting scene
  105674. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105675. * @param updatable defines if the mesh must be flagged as updatable
  105676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105677. * @param earcutInjection can be used to inject your own earcut reference
  105678. * @returns a new Mesh
  105679. */
  105680. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105681. /**
  105682. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105683. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105684. * @param name defines the name of the mesh to create
  105685. * @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
  105686. * @param depth defines the height of extrusion
  105687. * @param scene defines the hosting scene
  105688. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105689. * @param updatable defines if the mesh must be flagged as updatable
  105690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105691. * @param earcutInjection can be used to inject your own earcut reference
  105692. * @returns a new Mesh
  105693. */
  105694. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105695. /**
  105696. * Creates an extruded shape mesh.
  105697. * 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
  105698. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105699. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105700. * @param name defines the name of the mesh to create
  105701. * @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
  105702. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105703. * @param scale is the value to scale the shape
  105704. * @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
  105705. * @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
  105706. * @param scene defines the hosting scene
  105707. * @param updatable defines if the mesh must be flagged as updatable
  105708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105709. * @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)
  105710. * @returns a new Mesh
  105711. */
  105712. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105713. /**
  105714. * Creates an custom extruded shape mesh.
  105715. * The custom extrusion is a parametric shape.
  105716. * It has no predefined shape. Its final shape will depend on the input parameters.
  105717. * Please consider using the same method from the MeshBuilder class instead
  105718. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105719. * @param name defines the name of the mesh to create
  105720. * @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
  105721. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105722. * @param scaleFunction is a custom Javascript function called on each path point
  105723. * @param rotationFunction is a custom Javascript function called on each path point
  105724. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105725. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105726. * @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
  105727. * @param scene defines the hosting scene
  105728. * @param updatable defines if the mesh must be flagged as updatable
  105729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105730. * @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)
  105731. * @returns a new Mesh
  105732. */
  105733. 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;
  105734. /**
  105735. * Creates lathe mesh.
  105736. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105737. * Please consider using the same method from the MeshBuilder class instead
  105738. * @param name defines the name of the mesh to create
  105739. * @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
  105740. * @param radius is the radius value of the lathe
  105741. * @param tessellation is the side number of the lathe.
  105742. * @param scene defines the hosting scene
  105743. * @param updatable defines if the mesh must be flagged as updatable
  105744. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105745. * @returns a new Mesh
  105746. */
  105747. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105748. /**
  105749. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105750. * @param name defines the name of the mesh to create
  105751. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105752. * @param scene defines the hosting scene
  105753. * @param updatable defines if the mesh must be flagged as updatable
  105754. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105755. * @returns a new Mesh
  105756. */
  105757. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105758. /**
  105759. * Creates a ground mesh.
  105760. * Please consider using the same method from the MeshBuilder class instead
  105761. * @param name defines the name of the mesh to create
  105762. * @param width set the width of the ground
  105763. * @param height set the height of the ground
  105764. * @param subdivisions sets the number of subdivisions per side
  105765. * @param scene defines the hosting scene
  105766. * @param updatable defines if the mesh must be flagged as updatable
  105767. * @returns a new Mesh
  105768. */
  105769. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105770. /**
  105771. * Creates a tiled ground mesh.
  105772. * Please consider using the same method from the MeshBuilder class instead
  105773. * @param name defines the name of the mesh to create
  105774. * @param xmin set the ground minimum X coordinate
  105775. * @param zmin set the ground minimum Y coordinate
  105776. * @param xmax set the ground maximum X coordinate
  105777. * @param zmax set the ground maximum Z coordinate
  105778. * @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
  105779. * @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
  105780. * @param scene defines the hosting scene
  105781. * @param updatable defines if the mesh must be flagged as updatable
  105782. * @returns a new Mesh
  105783. */
  105784. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105785. w: number;
  105786. h: number;
  105787. }, precision: {
  105788. w: number;
  105789. h: number;
  105790. }, scene: Scene, updatable?: boolean): Mesh;
  105791. /**
  105792. * Creates a ground mesh from a height map.
  105793. * Please consider using the same method from the MeshBuilder class instead
  105794. * @see http://doc.babylonjs.com/babylon101/height_map
  105795. * @param name defines the name of the mesh to create
  105796. * @param url sets the URL of the height map image resource
  105797. * @param width set the ground width size
  105798. * @param height set the ground height size
  105799. * @param subdivisions sets the number of subdivision per side
  105800. * @param minHeight is the minimum altitude on the ground
  105801. * @param maxHeight is the maximum altitude on the ground
  105802. * @param scene defines the hosting scene
  105803. * @param updatable defines if the mesh must be flagged as updatable
  105804. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105805. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105806. * @returns a new Mesh
  105807. */
  105808. 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;
  105809. /**
  105810. * Creates a tube mesh.
  105811. * The tube is a parametric shape.
  105812. * It has no predefined shape. Its final shape will depend on the input parameters.
  105813. * Please consider using the same method from the MeshBuilder class instead
  105814. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105815. * @param name defines the name of the mesh to create
  105816. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105817. * @param radius sets the tube radius size
  105818. * @param tessellation is the number of sides on the tubular surface
  105819. * @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
  105820. * @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
  105821. * @param scene defines the hosting scene
  105822. * @param updatable defines if the mesh must be flagged as updatable
  105823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105824. * @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)
  105825. * @returns a new Mesh
  105826. */
  105827. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105828. (i: number, distance: number): number;
  105829. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105830. /**
  105831. * Creates a polyhedron mesh.
  105832. * Please consider using the same method from the MeshBuilder class instead.
  105833. * * 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
  105834. * * The parameter `size` (positive float, default 1) sets the polygon size
  105835. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105836. * * 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`
  105837. * * 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
  105838. * * 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)`)
  105839. * * 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
  105840. * * 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
  105841. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105842. * * If you create a double-sided mesh, you can choose what parts of 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
  105843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105844. * @param name defines the name of the mesh to create
  105845. * @param options defines the options used to create the mesh
  105846. * @param scene defines the hosting scene
  105847. * @returns a new Mesh
  105848. */
  105849. static CreatePolyhedron(name: string, options: {
  105850. type?: number;
  105851. size?: number;
  105852. sizeX?: number;
  105853. sizeY?: number;
  105854. sizeZ?: number;
  105855. custom?: any;
  105856. faceUV?: Vector4[];
  105857. faceColors?: Color4[];
  105858. updatable?: boolean;
  105859. sideOrientation?: number;
  105860. }, scene: Scene): Mesh;
  105861. /**
  105862. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105863. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105864. * * 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`)
  105865. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105866. * * 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
  105867. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105868. * * If you create a double-sided mesh, you can choose what parts of 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
  105869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105870. * @param name defines the name of the mesh
  105871. * @param options defines the options used to create the mesh
  105872. * @param scene defines the hosting scene
  105873. * @returns a new Mesh
  105874. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105875. */
  105876. static CreateIcoSphere(name: string, options: {
  105877. radius?: number;
  105878. flat?: boolean;
  105879. subdivisions?: number;
  105880. sideOrientation?: number;
  105881. updatable?: boolean;
  105882. }, scene: Scene): Mesh;
  105883. /**
  105884. * Creates a decal mesh.
  105885. * Please consider using the same method from the MeshBuilder class instead.
  105886. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105887. * @param name defines the name of the mesh
  105888. * @param sourceMesh defines the mesh receiving the decal
  105889. * @param position sets the position of the decal in world coordinates
  105890. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105891. * @param size sets the decal scaling
  105892. * @param angle sets the angle to rotate the decal
  105893. * @returns a new Mesh
  105894. */
  105895. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105896. /**
  105897. * Prepare internal position array for software CPU skinning
  105898. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105899. */
  105900. setPositionsForCPUSkinning(): Float32Array;
  105901. /**
  105902. * Prepare internal normal array for software CPU skinning
  105903. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105904. */
  105905. setNormalsForCPUSkinning(): Float32Array;
  105906. /**
  105907. * Updates the vertex buffer by applying transformation from the bones
  105908. * @param skeleton defines the skeleton to apply to current mesh
  105909. * @returns the current mesh
  105910. */
  105911. applySkeleton(skeleton: Skeleton): Mesh;
  105912. /**
  105913. * 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
  105914. * @param meshes defines the list of meshes to scan
  105915. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  105916. */
  105917. static MinMax(meshes: AbstractMesh[]): {
  105918. min: Vector3;
  105919. max: Vector3;
  105920. };
  105921. /**
  105922. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  105923. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  105924. * @returns a vector3
  105925. */
  105926. static Center(meshesOrMinMaxVector: {
  105927. min: Vector3;
  105928. max: Vector3;
  105929. } | AbstractMesh[]): Vector3;
  105930. /**
  105931. * Merge the array of meshes into a single mesh for performance reasons.
  105932. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  105933. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  105934. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  105935. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  105936. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  105937. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  105938. * @returns a new mesh
  105939. */
  105940. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  105941. /** @hidden */
  105942. addInstance(instance: InstancedMesh): void;
  105943. /** @hidden */
  105944. removeInstance(instance: InstancedMesh): void;
  105945. }
  105946. }
  105947. declare module BABYLON {
  105948. /**
  105949. * This is the base class of all the camera used in the application.
  105950. * @see http://doc.babylonjs.com/features/cameras
  105951. */
  105952. export class Camera extends Node {
  105953. /** @hidden */
  105954. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  105955. /**
  105956. * This is the default projection mode used by the cameras.
  105957. * It helps recreating a feeling of perspective and better appreciate depth.
  105958. * This is the best way to simulate real life cameras.
  105959. */
  105960. static readonly PERSPECTIVE_CAMERA: number;
  105961. /**
  105962. * This helps creating camera with an orthographic mode.
  105963. * 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.
  105964. */
  105965. static readonly ORTHOGRAPHIC_CAMERA: number;
  105966. /**
  105967. * This is the default FOV mode for perspective cameras.
  105968. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  105969. */
  105970. static readonly FOVMODE_VERTICAL_FIXED: number;
  105971. /**
  105972. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  105973. */
  105974. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  105975. /**
  105976. * This specifies ther is no need for a camera rig.
  105977. * Basically only one eye is rendered corresponding to the camera.
  105978. */
  105979. static readonly RIG_MODE_NONE: number;
  105980. /**
  105981. * Simulates a camera Rig with one blue eye and one red eye.
  105982. * This can be use with 3d blue and red glasses.
  105983. */
  105984. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  105985. /**
  105986. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  105987. */
  105988. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  105989. /**
  105990. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  105991. */
  105992. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  105993. /**
  105994. * Defines that both eyes of the camera will be rendered over under each other.
  105995. */
  105996. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  105997. /**
  105998. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  105999. */
  106000. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106001. /**
  106002. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106003. */
  106004. static readonly RIG_MODE_VR: number;
  106005. /**
  106006. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106007. */
  106008. static readonly RIG_MODE_WEBVR: number;
  106009. /**
  106010. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106011. */
  106012. static readonly RIG_MODE_CUSTOM: number;
  106013. /**
  106014. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106015. */
  106016. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106017. /**
  106018. * Define the input manager associated with the camera.
  106019. */
  106020. inputs: CameraInputsManager<Camera>;
  106021. /** @hidden */
  106022. _position: Vector3;
  106023. /**
  106024. * Define the current local position of the camera in the scene
  106025. */
  106026. get position(): Vector3;
  106027. set position(newPosition: Vector3);
  106028. /**
  106029. * The vector the camera should consider as up.
  106030. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106031. */
  106032. upVector: Vector3;
  106033. /**
  106034. * Define the current limit on the left side for an orthographic camera
  106035. * In scene unit
  106036. */
  106037. orthoLeft: Nullable<number>;
  106038. /**
  106039. * Define the current limit on the right side for an orthographic camera
  106040. * In scene unit
  106041. */
  106042. orthoRight: Nullable<number>;
  106043. /**
  106044. * Define the current limit on the bottom side for an orthographic camera
  106045. * In scene unit
  106046. */
  106047. orthoBottom: Nullable<number>;
  106048. /**
  106049. * Define the current limit on the top side for an orthographic camera
  106050. * In scene unit
  106051. */
  106052. orthoTop: Nullable<number>;
  106053. /**
  106054. * Field Of View is set in Radians. (default is 0.8)
  106055. */
  106056. fov: number;
  106057. /**
  106058. * Define the minimum distance the camera can see from.
  106059. * This is important to note that the depth buffer are not infinite and the closer it starts
  106060. * the more your scene might encounter depth fighting issue.
  106061. */
  106062. minZ: number;
  106063. /**
  106064. * Define the maximum distance the camera can see to.
  106065. * This is important to note that the depth buffer are not infinite and the further it end
  106066. * the more your scene might encounter depth fighting issue.
  106067. */
  106068. maxZ: number;
  106069. /**
  106070. * Define the default inertia of the camera.
  106071. * This helps giving a smooth feeling to the camera movement.
  106072. */
  106073. inertia: number;
  106074. /**
  106075. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106076. */
  106077. mode: number;
  106078. /**
  106079. * Define whether the camera is intermediate.
  106080. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106081. */
  106082. isIntermediate: boolean;
  106083. /**
  106084. * Define the viewport of the camera.
  106085. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106086. */
  106087. viewport: Viewport;
  106088. /**
  106089. * Restricts the camera to viewing objects with the same layerMask.
  106090. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106091. */
  106092. layerMask: number;
  106093. /**
  106094. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106095. */
  106096. fovMode: number;
  106097. /**
  106098. * Rig mode of the camera.
  106099. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106100. * This is normally controlled byt the camera themselves as internal use.
  106101. */
  106102. cameraRigMode: number;
  106103. /**
  106104. * Defines the distance between both "eyes" in case of a RIG
  106105. */
  106106. interaxialDistance: number;
  106107. /**
  106108. * Defines if stereoscopic rendering is done side by side or over under.
  106109. */
  106110. isStereoscopicSideBySide: boolean;
  106111. /**
  106112. * 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
  106113. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106114. * else in the scene. (Eg. security camera)
  106115. *
  106116. * 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)
  106117. */
  106118. customRenderTargets: RenderTargetTexture[];
  106119. /**
  106120. * When set, the camera will render to this render target instead of the default canvas
  106121. *
  106122. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106123. */
  106124. outputRenderTarget: Nullable<RenderTargetTexture>;
  106125. /**
  106126. * Observable triggered when the camera view matrix has changed.
  106127. */
  106128. onViewMatrixChangedObservable: Observable<Camera>;
  106129. /**
  106130. * Observable triggered when the camera Projection matrix has changed.
  106131. */
  106132. onProjectionMatrixChangedObservable: Observable<Camera>;
  106133. /**
  106134. * Observable triggered when the inputs have been processed.
  106135. */
  106136. onAfterCheckInputsObservable: Observable<Camera>;
  106137. /**
  106138. * Observable triggered when reset has been called and applied to the camera.
  106139. */
  106140. onRestoreStateObservable: Observable<Camera>;
  106141. /**
  106142. * Is this camera a part of a rig system?
  106143. */
  106144. isRigCamera: boolean;
  106145. /**
  106146. * If isRigCamera set to true this will be set with the parent camera.
  106147. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106148. */
  106149. rigParent?: Camera;
  106150. /** @hidden */
  106151. _cameraRigParams: any;
  106152. /** @hidden */
  106153. _rigCameras: Camera[];
  106154. /** @hidden */
  106155. _rigPostProcess: Nullable<PostProcess>;
  106156. protected _webvrViewMatrix: Matrix;
  106157. /** @hidden */
  106158. _skipRendering: boolean;
  106159. /** @hidden */
  106160. _projectionMatrix: Matrix;
  106161. /** @hidden */
  106162. _postProcesses: Nullable<PostProcess>[];
  106163. /** @hidden */
  106164. _activeMeshes: SmartArray<AbstractMesh>;
  106165. protected _globalPosition: Vector3;
  106166. /** @hidden */
  106167. _computedViewMatrix: Matrix;
  106168. private _doNotComputeProjectionMatrix;
  106169. private _transformMatrix;
  106170. private _frustumPlanes;
  106171. private _refreshFrustumPlanes;
  106172. private _storedFov;
  106173. private _stateStored;
  106174. /**
  106175. * Instantiates a new camera object.
  106176. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106177. * @see http://doc.babylonjs.com/features/cameras
  106178. * @param name Defines the name of the camera in the scene
  106179. * @param position Defines the position of the camera
  106180. * @param scene Defines the scene the camera belongs too
  106181. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106182. */
  106183. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106184. /**
  106185. * Store current camera state (fov, position, etc..)
  106186. * @returns the camera
  106187. */
  106188. storeState(): Camera;
  106189. /**
  106190. * Restores the camera state values if it has been stored. You must call storeState() first
  106191. */
  106192. protected _restoreStateValues(): boolean;
  106193. /**
  106194. * Restored camera state. You must call storeState() first.
  106195. * @returns true if restored and false otherwise
  106196. */
  106197. restoreState(): boolean;
  106198. /**
  106199. * Gets the class name of the camera.
  106200. * @returns the class name
  106201. */
  106202. getClassName(): string;
  106203. /** @hidden */
  106204. readonly _isCamera: boolean;
  106205. /**
  106206. * Gets a string representation of the camera useful for debug purpose.
  106207. * @param fullDetails Defines that a more verboe level of logging is required
  106208. * @returns the string representation
  106209. */
  106210. toString(fullDetails?: boolean): string;
  106211. /**
  106212. * Gets the current world space position of the camera.
  106213. */
  106214. get globalPosition(): Vector3;
  106215. /**
  106216. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106217. * @returns the active meshe list
  106218. */
  106219. getActiveMeshes(): SmartArray<AbstractMesh>;
  106220. /**
  106221. * Check whether a mesh is part of the current active mesh list of the camera
  106222. * @param mesh Defines the mesh to check
  106223. * @returns true if active, false otherwise
  106224. */
  106225. isActiveMesh(mesh: Mesh): boolean;
  106226. /**
  106227. * Is this camera ready to be used/rendered
  106228. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106229. * @return true if the camera is ready
  106230. */
  106231. isReady(completeCheck?: boolean): boolean;
  106232. /** @hidden */
  106233. _initCache(): void;
  106234. /** @hidden */
  106235. _updateCache(ignoreParentClass?: boolean): void;
  106236. /** @hidden */
  106237. _isSynchronized(): boolean;
  106238. /** @hidden */
  106239. _isSynchronizedViewMatrix(): boolean;
  106240. /** @hidden */
  106241. _isSynchronizedProjectionMatrix(): boolean;
  106242. /**
  106243. * Attach the input controls to a specific dom element to get the input from.
  106244. * @param element Defines the element the controls should be listened from
  106245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106246. */
  106247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106248. /**
  106249. * Detach the current controls from the specified dom element.
  106250. * @param element Defines the element to stop listening the inputs from
  106251. */
  106252. detachControl(element: HTMLElement): void;
  106253. /**
  106254. * Update the camera state according to the different inputs gathered during the frame.
  106255. */
  106256. update(): void;
  106257. /** @hidden */
  106258. _checkInputs(): void;
  106259. /** @hidden */
  106260. get rigCameras(): Camera[];
  106261. /**
  106262. * Gets the post process used by the rig cameras
  106263. */
  106264. get rigPostProcess(): Nullable<PostProcess>;
  106265. /**
  106266. * Internal, gets the first post proces.
  106267. * @returns the first post process to be run on this camera.
  106268. */
  106269. _getFirstPostProcess(): Nullable<PostProcess>;
  106270. private _cascadePostProcessesToRigCams;
  106271. /**
  106272. * Attach a post process to the camera.
  106273. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106274. * @param postProcess The post process to attach to the camera
  106275. * @param insertAt The position of the post process in case several of them are in use in the scene
  106276. * @returns the position the post process has been inserted at
  106277. */
  106278. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106279. /**
  106280. * Detach a post process to the camera.
  106281. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106282. * @param postProcess The post process to detach from the camera
  106283. */
  106284. detachPostProcess(postProcess: PostProcess): void;
  106285. /**
  106286. * Gets the current world matrix of the camera
  106287. */
  106288. getWorldMatrix(): Matrix;
  106289. /** @hidden */
  106290. _getViewMatrix(): Matrix;
  106291. /**
  106292. * Gets the current view matrix of the camera.
  106293. * @param force forces the camera to recompute the matrix without looking at the cached state
  106294. * @returns the view matrix
  106295. */
  106296. getViewMatrix(force?: boolean): Matrix;
  106297. /**
  106298. * Freeze the projection matrix.
  106299. * It will prevent the cache check of the camera projection compute and can speed up perf
  106300. * if no parameter of the camera are meant to change
  106301. * @param projection Defines manually a projection if necessary
  106302. */
  106303. freezeProjectionMatrix(projection?: Matrix): void;
  106304. /**
  106305. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106306. */
  106307. unfreezeProjectionMatrix(): void;
  106308. /**
  106309. * Gets the current projection matrix of the camera.
  106310. * @param force forces the camera to recompute the matrix without looking at the cached state
  106311. * @returns the projection matrix
  106312. */
  106313. getProjectionMatrix(force?: boolean): Matrix;
  106314. /**
  106315. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106316. * @returns a Matrix
  106317. */
  106318. getTransformationMatrix(): Matrix;
  106319. private _updateFrustumPlanes;
  106320. /**
  106321. * Checks if a cullable object (mesh...) is in the camera frustum
  106322. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106323. * @param target The object to check
  106324. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106325. * @returns true if the object is in frustum otherwise false
  106326. */
  106327. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106328. /**
  106329. * Checks if a cullable object (mesh...) is in the camera frustum
  106330. * Unlike isInFrustum this cheks the full bounding box
  106331. * @param target The object to check
  106332. * @returns true if the object is in frustum otherwise false
  106333. */
  106334. isCompletelyInFrustum(target: ICullable): boolean;
  106335. /**
  106336. * Gets a ray in the forward direction from the camera.
  106337. * @param length Defines the length of the ray to create
  106338. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106339. * @param origin Defines the start point of the ray which defaults to the camera position
  106340. * @returns the forward ray
  106341. */
  106342. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106343. /**
  106344. * Releases resources associated with this node.
  106345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106347. */
  106348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106349. /** @hidden */
  106350. _isLeftCamera: boolean;
  106351. /**
  106352. * Gets the left camera of a rig setup in case of Rigged Camera
  106353. */
  106354. get isLeftCamera(): boolean;
  106355. /** @hidden */
  106356. _isRightCamera: boolean;
  106357. /**
  106358. * Gets the right camera of a rig setup in case of Rigged Camera
  106359. */
  106360. get isRightCamera(): boolean;
  106361. /**
  106362. * Gets the left camera of a rig setup in case of Rigged Camera
  106363. */
  106364. get leftCamera(): Nullable<FreeCamera>;
  106365. /**
  106366. * Gets the right camera of a rig setup in case of Rigged Camera
  106367. */
  106368. get rightCamera(): Nullable<FreeCamera>;
  106369. /**
  106370. * Gets the left camera target of a rig setup in case of Rigged Camera
  106371. * @returns the target position
  106372. */
  106373. getLeftTarget(): Nullable<Vector3>;
  106374. /**
  106375. * Gets the right camera target of a rig setup in case of Rigged Camera
  106376. * @returns the target position
  106377. */
  106378. getRightTarget(): Nullable<Vector3>;
  106379. /**
  106380. * @hidden
  106381. */
  106382. setCameraRigMode(mode: number, rigParams: any): void;
  106383. /** @hidden */
  106384. static _setStereoscopicRigMode(camera: Camera): void;
  106385. /** @hidden */
  106386. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106387. /** @hidden */
  106388. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106389. /** @hidden */
  106390. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106391. /** @hidden */
  106392. _getVRProjectionMatrix(): Matrix;
  106393. protected _updateCameraRotationMatrix(): void;
  106394. protected _updateWebVRCameraRotationMatrix(): void;
  106395. /**
  106396. * This function MUST be overwritten by the different WebVR cameras available.
  106397. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106398. * @hidden
  106399. */
  106400. _getWebVRProjectionMatrix(): Matrix;
  106401. /**
  106402. * This function MUST be overwritten by the different WebVR cameras available.
  106403. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106404. * @hidden
  106405. */
  106406. _getWebVRViewMatrix(): Matrix;
  106407. /** @hidden */
  106408. setCameraRigParameter(name: string, value: any): void;
  106409. /**
  106410. * needs to be overridden by children so sub has required properties to be copied
  106411. * @hidden
  106412. */
  106413. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106414. /**
  106415. * May need to be overridden by children
  106416. * @hidden
  106417. */
  106418. _updateRigCameras(): void;
  106419. /** @hidden */
  106420. _setupInputs(): void;
  106421. /**
  106422. * Serialiaze the camera setup to a json represention
  106423. * @returns the JSON representation
  106424. */
  106425. serialize(): any;
  106426. /**
  106427. * Clones the current camera.
  106428. * @param name The cloned camera name
  106429. * @returns the cloned camera
  106430. */
  106431. clone(name: string): Camera;
  106432. /**
  106433. * Gets the direction of the camera relative to a given local axis.
  106434. * @param localAxis Defines the reference axis to provide a relative direction.
  106435. * @return the direction
  106436. */
  106437. getDirection(localAxis: Vector3): Vector3;
  106438. /**
  106439. * Returns the current camera absolute rotation
  106440. */
  106441. get absoluteRotation(): Quaternion;
  106442. /**
  106443. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106444. * @param localAxis Defines the reference axis to provide a relative direction.
  106445. * @param result Defines the vector to store the result in
  106446. */
  106447. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106448. /**
  106449. * Gets a camera constructor for a given camera type
  106450. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106451. * @param name The name of the camera the result will be able to instantiate
  106452. * @param scene The scene the result will construct the camera in
  106453. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106454. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106455. * @returns a factory method to construc the camera
  106456. */
  106457. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106458. /**
  106459. * Compute the world matrix of the camera.
  106460. * @returns the camera world matrix
  106461. */
  106462. computeWorldMatrix(): Matrix;
  106463. /**
  106464. * Parse a JSON and creates the camera from the parsed information
  106465. * @param parsedCamera The JSON to parse
  106466. * @param scene The scene to instantiate the camera in
  106467. * @returns the newly constructed camera
  106468. */
  106469. static Parse(parsedCamera: any, scene: Scene): Camera;
  106470. }
  106471. }
  106472. declare module BABYLON {
  106473. /**
  106474. * Class containing static functions to help procedurally build meshes
  106475. */
  106476. export class DiscBuilder {
  106477. /**
  106478. * Creates a plane polygonal mesh. By default, this is a disc
  106479. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106480. * * 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
  106481. * * 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
  106482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106485. * @param name defines the name of the mesh
  106486. * @param options defines the options used to create the mesh
  106487. * @param scene defines the hosting scene
  106488. * @returns the plane polygonal mesh
  106489. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106490. */
  106491. static CreateDisc(name: string, options: {
  106492. radius?: number;
  106493. tessellation?: number;
  106494. arc?: number;
  106495. updatable?: boolean;
  106496. sideOrientation?: number;
  106497. frontUVs?: Vector4;
  106498. backUVs?: Vector4;
  106499. }, scene?: Nullable<Scene>): Mesh;
  106500. }
  106501. }
  106502. declare module BABYLON {
  106503. /**
  106504. * Options to be used when creating a FresnelParameters.
  106505. */
  106506. export type IFresnelParametersCreationOptions = {
  106507. /**
  106508. * Define the color used on edges (grazing angle)
  106509. */
  106510. leftColor?: Color3;
  106511. /**
  106512. * Define the color used on center
  106513. */
  106514. rightColor?: Color3;
  106515. /**
  106516. * Define bias applied to computed fresnel term
  106517. */
  106518. bias?: number;
  106519. /**
  106520. * Defined the power exponent applied to fresnel term
  106521. */
  106522. power?: number;
  106523. /**
  106524. * Define if the fresnel effect is enable or not.
  106525. */
  106526. isEnabled?: boolean;
  106527. };
  106528. /**
  106529. * Serialized format for FresnelParameters.
  106530. */
  106531. export type IFresnelParametersSerialized = {
  106532. /**
  106533. * Define the color used on edges (grazing angle) [as an array]
  106534. */
  106535. leftColor: number[];
  106536. /**
  106537. * Define the color used on center [as an array]
  106538. */
  106539. rightColor: number[];
  106540. /**
  106541. * Define bias applied to computed fresnel term
  106542. */
  106543. bias: number;
  106544. /**
  106545. * Defined the power exponent applied to fresnel term
  106546. */
  106547. power?: number;
  106548. /**
  106549. * Define if the fresnel effect is enable or not.
  106550. */
  106551. isEnabled: boolean;
  106552. };
  106553. /**
  106554. * This represents all the required information to add a fresnel effect on a material:
  106555. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106556. */
  106557. export class FresnelParameters {
  106558. private _isEnabled;
  106559. /**
  106560. * Define if the fresnel effect is enable or not.
  106561. */
  106562. get isEnabled(): boolean;
  106563. set isEnabled(value: boolean);
  106564. /**
  106565. * Define the color used on edges (grazing angle)
  106566. */
  106567. leftColor: Color3;
  106568. /**
  106569. * Define the color used on center
  106570. */
  106571. rightColor: Color3;
  106572. /**
  106573. * Define bias applied to computed fresnel term
  106574. */
  106575. bias: number;
  106576. /**
  106577. * Defined the power exponent applied to fresnel term
  106578. */
  106579. power: number;
  106580. /**
  106581. * Creates a new FresnelParameters object.
  106582. *
  106583. * @param options provide your own settings to optionally to override defaults
  106584. */
  106585. constructor(options?: IFresnelParametersCreationOptions);
  106586. /**
  106587. * Clones the current fresnel and its valuues
  106588. * @returns a clone fresnel configuration
  106589. */
  106590. clone(): FresnelParameters;
  106591. /**
  106592. * Determines equality between FresnelParameters objects
  106593. * @param otherFresnelParameters defines the second operand
  106594. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106595. */
  106596. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106597. /**
  106598. * Serializes the current fresnel parameters to a JSON representation.
  106599. * @return the JSON serialization
  106600. */
  106601. serialize(): IFresnelParametersSerialized;
  106602. /**
  106603. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106604. * @param parsedFresnelParameters Define the JSON representation
  106605. * @returns the parsed parameters
  106606. */
  106607. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106608. }
  106609. }
  106610. declare module BABYLON {
  106611. /**
  106612. * This groups all the flags used to control the materials channel.
  106613. */
  106614. export class MaterialFlags {
  106615. private static _DiffuseTextureEnabled;
  106616. /**
  106617. * Are diffuse textures enabled in the application.
  106618. */
  106619. static get DiffuseTextureEnabled(): boolean;
  106620. static set DiffuseTextureEnabled(value: boolean);
  106621. private static _AmbientTextureEnabled;
  106622. /**
  106623. * Are ambient textures enabled in the application.
  106624. */
  106625. static get AmbientTextureEnabled(): boolean;
  106626. static set AmbientTextureEnabled(value: boolean);
  106627. private static _OpacityTextureEnabled;
  106628. /**
  106629. * Are opacity textures enabled in the application.
  106630. */
  106631. static get OpacityTextureEnabled(): boolean;
  106632. static set OpacityTextureEnabled(value: boolean);
  106633. private static _ReflectionTextureEnabled;
  106634. /**
  106635. * Are reflection textures enabled in the application.
  106636. */
  106637. static get ReflectionTextureEnabled(): boolean;
  106638. static set ReflectionTextureEnabled(value: boolean);
  106639. private static _EmissiveTextureEnabled;
  106640. /**
  106641. * Are emissive textures enabled in the application.
  106642. */
  106643. static get EmissiveTextureEnabled(): boolean;
  106644. static set EmissiveTextureEnabled(value: boolean);
  106645. private static _SpecularTextureEnabled;
  106646. /**
  106647. * Are specular textures enabled in the application.
  106648. */
  106649. static get SpecularTextureEnabled(): boolean;
  106650. static set SpecularTextureEnabled(value: boolean);
  106651. private static _BumpTextureEnabled;
  106652. /**
  106653. * Are bump textures enabled in the application.
  106654. */
  106655. static get BumpTextureEnabled(): boolean;
  106656. static set BumpTextureEnabled(value: boolean);
  106657. private static _LightmapTextureEnabled;
  106658. /**
  106659. * Are lightmap textures enabled in the application.
  106660. */
  106661. static get LightmapTextureEnabled(): boolean;
  106662. static set LightmapTextureEnabled(value: boolean);
  106663. private static _RefractionTextureEnabled;
  106664. /**
  106665. * Are refraction textures enabled in the application.
  106666. */
  106667. static get RefractionTextureEnabled(): boolean;
  106668. static set RefractionTextureEnabled(value: boolean);
  106669. private static _ColorGradingTextureEnabled;
  106670. /**
  106671. * Are color grading textures enabled in the application.
  106672. */
  106673. static get ColorGradingTextureEnabled(): boolean;
  106674. static set ColorGradingTextureEnabled(value: boolean);
  106675. private static _FresnelEnabled;
  106676. /**
  106677. * Are fresnels enabled in the application.
  106678. */
  106679. static get FresnelEnabled(): boolean;
  106680. static set FresnelEnabled(value: boolean);
  106681. private static _ClearCoatTextureEnabled;
  106682. /**
  106683. * Are clear coat textures enabled in the application.
  106684. */
  106685. static get ClearCoatTextureEnabled(): boolean;
  106686. static set ClearCoatTextureEnabled(value: boolean);
  106687. private static _ClearCoatBumpTextureEnabled;
  106688. /**
  106689. * Are clear coat bump textures enabled in the application.
  106690. */
  106691. static get ClearCoatBumpTextureEnabled(): boolean;
  106692. static set ClearCoatBumpTextureEnabled(value: boolean);
  106693. private static _ClearCoatTintTextureEnabled;
  106694. /**
  106695. * Are clear coat tint textures enabled in the application.
  106696. */
  106697. static get ClearCoatTintTextureEnabled(): boolean;
  106698. static set ClearCoatTintTextureEnabled(value: boolean);
  106699. private static _SheenTextureEnabled;
  106700. /**
  106701. * Are sheen textures enabled in the application.
  106702. */
  106703. static get SheenTextureEnabled(): boolean;
  106704. static set SheenTextureEnabled(value: boolean);
  106705. private static _AnisotropicTextureEnabled;
  106706. /**
  106707. * Are anisotropic textures enabled in the application.
  106708. */
  106709. static get AnisotropicTextureEnabled(): boolean;
  106710. static set AnisotropicTextureEnabled(value: boolean);
  106711. private static _ThicknessTextureEnabled;
  106712. /**
  106713. * Are thickness textures enabled in the application.
  106714. */
  106715. static get ThicknessTextureEnabled(): boolean;
  106716. static set ThicknessTextureEnabled(value: boolean);
  106717. }
  106718. }
  106719. declare module BABYLON {
  106720. /** @hidden */
  106721. export var defaultFragmentDeclaration: {
  106722. name: string;
  106723. shader: string;
  106724. };
  106725. }
  106726. declare module BABYLON {
  106727. /** @hidden */
  106728. export var defaultUboDeclaration: {
  106729. name: string;
  106730. shader: string;
  106731. };
  106732. }
  106733. declare module BABYLON {
  106734. /** @hidden */
  106735. export var lightFragmentDeclaration: {
  106736. name: string;
  106737. shader: string;
  106738. };
  106739. }
  106740. declare module BABYLON {
  106741. /** @hidden */
  106742. export var lightUboDeclaration: {
  106743. name: string;
  106744. shader: string;
  106745. };
  106746. }
  106747. declare module BABYLON {
  106748. /** @hidden */
  106749. export var lightsFragmentFunctions: {
  106750. name: string;
  106751. shader: string;
  106752. };
  106753. }
  106754. declare module BABYLON {
  106755. /** @hidden */
  106756. export var shadowsFragmentFunctions: {
  106757. name: string;
  106758. shader: string;
  106759. };
  106760. }
  106761. declare module BABYLON {
  106762. /** @hidden */
  106763. export var fresnelFunction: {
  106764. name: string;
  106765. shader: string;
  106766. };
  106767. }
  106768. declare module BABYLON {
  106769. /** @hidden */
  106770. export var bumpFragmentMainFunctions: {
  106771. name: string;
  106772. shader: string;
  106773. };
  106774. }
  106775. declare module BABYLON {
  106776. /** @hidden */
  106777. export var bumpFragmentFunctions: {
  106778. name: string;
  106779. shader: string;
  106780. };
  106781. }
  106782. declare module BABYLON {
  106783. /** @hidden */
  106784. export var logDepthDeclaration: {
  106785. name: string;
  106786. shader: string;
  106787. };
  106788. }
  106789. declare module BABYLON {
  106790. /** @hidden */
  106791. export var bumpFragment: {
  106792. name: string;
  106793. shader: string;
  106794. };
  106795. }
  106796. declare module BABYLON {
  106797. /** @hidden */
  106798. export var depthPrePass: {
  106799. name: string;
  106800. shader: string;
  106801. };
  106802. }
  106803. declare module BABYLON {
  106804. /** @hidden */
  106805. export var lightFragment: {
  106806. name: string;
  106807. shader: string;
  106808. };
  106809. }
  106810. declare module BABYLON {
  106811. /** @hidden */
  106812. export var logDepthFragment: {
  106813. name: string;
  106814. shader: string;
  106815. };
  106816. }
  106817. declare module BABYLON {
  106818. /** @hidden */
  106819. export var defaultPixelShader: {
  106820. name: string;
  106821. shader: string;
  106822. };
  106823. }
  106824. declare module BABYLON {
  106825. /** @hidden */
  106826. export var defaultVertexDeclaration: {
  106827. name: string;
  106828. shader: string;
  106829. };
  106830. }
  106831. declare module BABYLON {
  106832. /** @hidden */
  106833. export var bumpVertexDeclaration: {
  106834. name: string;
  106835. shader: string;
  106836. };
  106837. }
  106838. declare module BABYLON {
  106839. /** @hidden */
  106840. export var bumpVertex: {
  106841. name: string;
  106842. shader: string;
  106843. };
  106844. }
  106845. declare module BABYLON {
  106846. /** @hidden */
  106847. export var fogVertex: {
  106848. name: string;
  106849. shader: string;
  106850. };
  106851. }
  106852. declare module BABYLON {
  106853. /** @hidden */
  106854. export var shadowsVertex: {
  106855. name: string;
  106856. shader: string;
  106857. };
  106858. }
  106859. declare module BABYLON {
  106860. /** @hidden */
  106861. export var pointCloudVertex: {
  106862. name: string;
  106863. shader: string;
  106864. };
  106865. }
  106866. declare module BABYLON {
  106867. /** @hidden */
  106868. export var logDepthVertex: {
  106869. name: string;
  106870. shader: string;
  106871. };
  106872. }
  106873. declare module BABYLON {
  106874. /** @hidden */
  106875. export var defaultVertexShader: {
  106876. name: string;
  106877. shader: string;
  106878. };
  106879. }
  106880. declare module BABYLON {
  106881. /** @hidden */
  106882. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106883. MAINUV1: boolean;
  106884. MAINUV2: boolean;
  106885. DIFFUSE: boolean;
  106886. DIFFUSEDIRECTUV: number;
  106887. AMBIENT: boolean;
  106888. AMBIENTDIRECTUV: number;
  106889. OPACITY: boolean;
  106890. OPACITYDIRECTUV: number;
  106891. OPACITYRGB: boolean;
  106892. REFLECTION: boolean;
  106893. EMISSIVE: boolean;
  106894. EMISSIVEDIRECTUV: number;
  106895. SPECULAR: boolean;
  106896. SPECULARDIRECTUV: number;
  106897. BUMP: boolean;
  106898. BUMPDIRECTUV: number;
  106899. PARALLAX: boolean;
  106900. PARALLAXOCCLUSION: boolean;
  106901. SPECULAROVERALPHA: boolean;
  106902. CLIPPLANE: boolean;
  106903. CLIPPLANE2: boolean;
  106904. CLIPPLANE3: boolean;
  106905. CLIPPLANE4: boolean;
  106906. CLIPPLANE5: boolean;
  106907. CLIPPLANE6: boolean;
  106908. ALPHATEST: boolean;
  106909. DEPTHPREPASS: boolean;
  106910. ALPHAFROMDIFFUSE: boolean;
  106911. POINTSIZE: boolean;
  106912. FOG: boolean;
  106913. SPECULARTERM: boolean;
  106914. DIFFUSEFRESNEL: boolean;
  106915. OPACITYFRESNEL: boolean;
  106916. REFLECTIONFRESNEL: boolean;
  106917. REFRACTIONFRESNEL: boolean;
  106918. EMISSIVEFRESNEL: boolean;
  106919. FRESNEL: boolean;
  106920. NORMAL: boolean;
  106921. UV1: boolean;
  106922. UV2: boolean;
  106923. VERTEXCOLOR: boolean;
  106924. VERTEXALPHA: boolean;
  106925. NUM_BONE_INFLUENCERS: number;
  106926. BonesPerMesh: number;
  106927. BONETEXTURE: boolean;
  106928. INSTANCES: boolean;
  106929. THIN_INSTANCES: boolean;
  106930. GLOSSINESS: boolean;
  106931. ROUGHNESS: boolean;
  106932. EMISSIVEASILLUMINATION: boolean;
  106933. LINKEMISSIVEWITHDIFFUSE: boolean;
  106934. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106935. LIGHTMAP: boolean;
  106936. LIGHTMAPDIRECTUV: number;
  106937. OBJECTSPACE_NORMALMAP: boolean;
  106938. USELIGHTMAPASSHADOWMAP: boolean;
  106939. REFLECTIONMAP_3D: boolean;
  106940. REFLECTIONMAP_SPHERICAL: boolean;
  106941. REFLECTIONMAP_PLANAR: boolean;
  106942. REFLECTIONMAP_CUBIC: boolean;
  106943. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106944. REFLECTIONMAP_PROJECTION: boolean;
  106945. REFLECTIONMAP_SKYBOX: boolean;
  106946. REFLECTIONMAP_EXPLICIT: boolean;
  106947. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106948. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106949. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106950. INVERTCUBICMAP: boolean;
  106951. LOGARITHMICDEPTH: boolean;
  106952. REFRACTION: boolean;
  106953. REFRACTIONMAP_3D: boolean;
  106954. REFLECTIONOVERALPHA: boolean;
  106955. TWOSIDEDLIGHTING: boolean;
  106956. SHADOWFLOAT: boolean;
  106957. MORPHTARGETS: boolean;
  106958. MORPHTARGETS_NORMAL: boolean;
  106959. MORPHTARGETS_TANGENT: boolean;
  106960. MORPHTARGETS_UV: boolean;
  106961. NUM_MORPH_INFLUENCERS: number;
  106962. NONUNIFORMSCALING: boolean;
  106963. PREMULTIPLYALPHA: boolean;
  106964. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  106965. ALPHABLEND: boolean;
  106966. RGBDLIGHTMAP: boolean;
  106967. RGBDREFLECTION: boolean;
  106968. RGBDREFRACTION: boolean;
  106969. IMAGEPROCESSING: boolean;
  106970. VIGNETTE: boolean;
  106971. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106972. VIGNETTEBLENDMODEOPAQUE: boolean;
  106973. TONEMAPPING: boolean;
  106974. TONEMAPPING_ACES: boolean;
  106975. CONTRAST: boolean;
  106976. COLORCURVES: boolean;
  106977. COLORGRADING: boolean;
  106978. COLORGRADING3D: boolean;
  106979. SAMPLER3DGREENDEPTH: boolean;
  106980. SAMPLER3DBGRMAP: boolean;
  106981. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106982. MULTIVIEW: boolean;
  106983. /**
  106984. * If the reflection texture on this material is in linear color space
  106985. * @hidden
  106986. */
  106987. IS_REFLECTION_LINEAR: boolean;
  106988. /**
  106989. * If the refraction texture on this material is in linear color space
  106990. * @hidden
  106991. */
  106992. IS_REFRACTION_LINEAR: boolean;
  106993. EXPOSURE: boolean;
  106994. constructor();
  106995. setReflectionMode(modeToEnable: string): void;
  106996. }
  106997. /**
  106998. * This is the default material used in Babylon. It is the best trade off between quality
  106999. * and performances.
  107000. * @see http://doc.babylonjs.com/babylon101/materials
  107001. */
  107002. export class StandardMaterial extends PushMaterial {
  107003. private _diffuseTexture;
  107004. /**
  107005. * The basic texture of the material as viewed under a light.
  107006. */
  107007. diffuseTexture: Nullable<BaseTexture>;
  107008. private _ambientTexture;
  107009. /**
  107010. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107011. */
  107012. ambientTexture: Nullable<BaseTexture>;
  107013. private _opacityTexture;
  107014. /**
  107015. * Define the transparency of the material from a texture.
  107016. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107017. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107018. */
  107019. opacityTexture: Nullable<BaseTexture>;
  107020. private _reflectionTexture;
  107021. /**
  107022. * Define the texture used to display the reflection.
  107023. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107024. */
  107025. reflectionTexture: Nullable<BaseTexture>;
  107026. private _emissiveTexture;
  107027. /**
  107028. * Define texture of the material as if self lit.
  107029. * This will be mixed in the final result even in the absence of light.
  107030. */
  107031. emissiveTexture: Nullable<BaseTexture>;
  107032. private _specularTexture;
  107033. /**
  107034. * Define how the color and intensity of the highlight given by the light in the material.
  107035. */
  107036. specularTexture: Nullable<BaseTexture>;
  107037. private _bumpTexture;
  107038. /**
  107039. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107040. * 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.
  107041. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107042. */
  107043. bumpTexture: Nullable<BaseTexture>;
  107044. private _lightmapTexture;
  107045. /**
  107046. * Complex lighting can be computationally expensive to compute at runtime.
  107047. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107048. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107049. */
  107050. lightmapTexture: Nullable<BaseTexture>;
  107051. private _refractionTexture;
  107052. /**
  107053. * Define the texture used to display the refraction.
  107054. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107055. */
  107056. refractionTexture: Nullable<BaseTexture>;
  107057. /**
  107058. * The color of the material lit by the environmental background lighting.
  107059. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107060. */
  107061. ambientColor: Color3;
  107062. /**
  107063. * The basic color of the material as viewed under a light.
  107064. */
  107065. diffuseColor: Color3;
  107066. /**
  107067. * Define how the color and intensity of the highlight given by the light in the material.
  107068. */
  107069. specularColor: Color3;
  107070. /**
  107071. * Define the color of the material as if self lit.
  107072. * This will be mixed in the final result even in the absence of light.
  107073. */
  107074. emissiveColor: Color3;
  107075. /**
  107076. * Defines how sharp are the highlights in the material.
  107077. * The bigger the value the sharper giving a more glossy feeling to the result.
  107078. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107079. */
  107080. specularPower: number;
  107081. private _useAlphaFromDiffuseTexture;
  107082. /**
  107083. * Does the transparency come from the diffuse texture alpha channel.
  107084. */
  107085. useAlphaFromDiffuseTexture: boolean;
  107086. private _useEmissiveAsIllumination;
  107087. /**
  107088. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107089. */
  107090. useEmissiveAsIllumination: boolean;
  107091. private _linkEmissiveWithDiffuse;
  107092. /**
  107093. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107094. * the emissive level when the final color is close to one.
  107095. */
  107096. linkEmissiveWithDiffuse: boolean;
  107097. private _useSpecularOverAlpha;
  107098. /**
  107099. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107100. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107101. */
  107102. useSpecularOverAlpha: boolean;
  107103. private _useReflectionOverAlpha;
  107104. /**
  107105. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107106. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107107. */
  107108. useReflectionOverAlpha: boolean;
  107109. private _disableLighting;
  107110. /**
  107111. * Does lights from the scene impacts this material.
  107112. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107113. */
  107114. disableLighting: boolean;
  107115. private _useObjectSpaceNormalMap;
  107116. /**
  107117. * Allows using an object space normal map (instead of tangent space).
  107118. */
  107119. useObjectSpaceNormalMap: boolean;
  107120. private _useParallax;
  107121. /**
  107122. * Is parallax enabled or not.
  107123. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107124. */
  107125. useParallax: boolean;
  107126. private _useParallaxOcclusion;
  107127. /**
  107128. * Is parallax occlusion enabled or not.
  107129. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107130. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107131. */
  107132. useParallaxOcclusion: boolean;
  107133. /**
  107134. * 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.
  107135. */
  107136. parallaxScaleBias: number;
  107137. private _roughness;
  107138. /**
  107139. * Helps to define how blurry the reflections should appears in the material.
  107140. */
  107141. roughness: number;
  107142. /**
  107143. * In case of refraction, define the value of the index of refraction.
  107144. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107145. */
  107146. indexOfRefraction: number;
  107147. /**
  107148. * Invert the refraction texture alongside the y axis.
  107149. * It can be useful with procedural textures or probe for instance.
  107150. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107151. */
  107152. invertRefractionY: boolean;
  107153. /**
  107154. * Defines the alpha limits in alpha test mode.
  107155. */
  107156. alphaCutOff: number;
  107157. private _useLightmapAsShadowmap;
  107158. /**
  107159. * In case of light mapping, define whether the map contains light or shadow informations.
  107160. */
  107161. useLightmapAsShadowmap: boolean;
  107162. private _diffuseFresnelParameters;
  107163. /**
  107164. * Define the diffuse fresnel parameters of the material.
  107165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107166. */
  107167. diffuseFresnelParameters: FresnelParameters;
  107168. private _opacityFresnelParameters;
  107169. /**
  107170. * Define the opacity fresnel parameters of the material.
  107171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107172. */
  107173. opacityFresnelParameters: FresnelParameters;
  107174. private _reflectionFresnelParameters;
  107175. /**
  107176. * Define the reflection fresnel parameters of the material.
  107177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107178. */
  107179. reflectionFresnelParameters: FresnelParameters;
  107180. private _refractionFresnelParameters;
  107181. /**
  107182. * Define the refraction fresnel parameters of the material.
  107183. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107184. */
  107185. refractionFresnelParameters: FresnelParameters;
  107186. private _emissiveFresnelParameters;
  107187. /**
  107188. * Define the emissive fresnel parameters of the material.
  107189. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107190. */
  107191. emissiveFresnelParameters: FresnelParameters;
  107192. private _useReflectionFresnelFromSpecular;
  107193. /**
  107194. * If true automatically deducts the fresnels values from the material specularity.
  107195. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107196. */
  107197. useReflectionFresnelFromSpecular: boolean;
  107198. private _useGlossinessFromSpecularMapAlpha;
  107199. /**
  107200. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107201. */
  107202. useGlossinessFromSpecularMapAlpha: boolean;
  107203. private _maxSimultaneousLights;
  107204. /**
  107205. * Defines the maximum number of lights that can be used in the material
  107206. */
  107207. maxSimultaneousLights: number;
  107208. private _invertNormalMapX;
  107209. /**
  107210. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107211. */
  107212. invertNormalMapX: boolean;
  107213. private _invertNormalMapY;
  107214. /**
  107215. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107216. */
  107217. invertNormalMapY: boolean;
  107218. private _twoSidedLighting;
  107219. /**
  107220. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107221. */
  107222. twoSidedLighting: boolean;
  107223. /**
  107224. * Default configuration related to image processing available in the standard Material.
  107225. */
  107226. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107227. /**
  107228. * Gets the image processing configuration used either in this material.
  107229. */
  107230. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107231. /**
  107232. * Sets the Default image processing configuration used either in the this material.
  107233. *
  107234. * If sets to null, the scene one is in use.
  107235. */
  107236. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107237. /**
  107238. * Keep track of the image processing observer to allow dispose and replace.
  107239. */
  107240. private _imageProcessingObserver;
  107241. /**
  107242. * Attaches a new image processing configuration to the Standard Material.
  107243. * @param configuration
  107244. */
  107245. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107246. /**
  107247. * Gets wether the color curves effect is enabled.
  107248. */
  107249. get cameraColorCurvesEnabled(): boolean;
  107250. /**
  107251. * Sets wether the color curves effect is enabled.
  107252. */
  107253. set cameraColorCurvesEnabled(value: boolean);
  107254. /**
  107255. * Gets wether the color grading effect is enabled.
  107256. */
  107257. get cameraColorGradingEnabled(): boolean;
  107258. /**
  107259. * Gets wether the color grading effect is enabled.
  107260. */
  107261. set cameraColorGradingEnabled(value: boolean);
  107262. /**
  107263. * Gets wether tonemapping is enabled or not.
  107264. */
  107265. get cameraToneMappingEnabled(): boolean;
  107266. /**
  107267. * Sets wether tonemapping is enabled or not
  107268. */
  107269. set cameraToneMappingEnabled(value: boolean);
  107270. /**
  107271. * The camera exposure used on this material.
  107272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107273. * This corresponds to a photographic exposure.
  107274. */
  107275. get cameraExposure(): number;
  107276. /**
  107277. * The camera exposure used on this material.
  107278. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107279. * This corresponds to a photographic exposure.
  107280. */
  107281. set cameraExposure(value: number);
  107282. /**
  107283. * Gets The camera contrast used on this material.
  107284. */
  107285. get cameraContrast(): number;
  107286. /**
  107287. * Sets The camera contrast used on this material.
  107288. */
  107289. set cameraContrast(value: number);
  107290. /**
  107291. * Gets the Color Grading 2D Lookup Texture.
  107292. */
  107293. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107294. /**
  107295. * Sets the Color Grading 2D Lookup Texture.
  107296. */
  107297. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107298. /**
  107299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107301. * 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;
  107302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107303. */
  107304. get cameraColorCurves(): Nullable<ColorCurves>;
  107305. /**
  107306. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107307. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107308. * 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;
  107309. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107310. */
  107311. set cameraColorCurves(value: Nullable<ColorCurves>);
  107312. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107313. protected _worldViewProjectionMatrix: Matrix;
  107314. protected _globalAmbientColor: Color3;
  107315. protected _useLogarithmicDepth: boolean;
  107316. protected _rebuildInParallel: boolean;
  107317. /**
  107318. * Instantiates a new standard material.
  107319. * This is the default material used in Babylon. It is the best trade off between quality
  107320. * and performances.
  107321. * @see http://doc.babylonjs.com/babylon101/materials
  107322. * @param name Define the name of the material in the scene
  107323. * @param scene Define the scene the material belong to
  107324. */
  107325. constructor(name: string, scene: Scene);
  107326. /**
  107327. * Gets a boolean indicating that current material needs to register RTT
  107328. */
  107329. get hasRenderTargetTextures(): boolean;
  107330. /**
  107331. * Gets the current class name of the material e.g. "StandardMaterial"
  107332. * Mainly use in serialization.
  107333. * @returns the class name
  107334. */
  107335. getClassName(): string;
  107336. /**
  107337. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107338. * You can try switching to logarithmic depth.
  107339. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107340. */
  107341. get useLogarithmicDepth(): boolean;
  107342. set useLogarithmicDepth(value: boolean);
  107343. /**
  107344. * Specifies if the material will require alpha blending
  107345. * @returns a boolean specifying if alpha blending is needed
  107346. */
  107347. needAlphaBlending(): boolean;
  107348. /**
  107349. * Specifies if this material should be rendered in alpha test mode
  107350. * @returns a boolean specifying if an alpha test is needed.
  107351. */
  107352. needAlphaTesting(): boolean;
  107353. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107354. /**
  107355. * Get the texture used for alpha test purpose.
  107356. * @returns the diffuse texture in case of the standard material.
  107357. */
  107358. getAlphaTestTexture(): Nullable<BaseTexture>;
  107359. /**
  107360. * Get if the submesh is ready to be used and all its information available.
  107361. * Child classes can use it to update shaders
  107362. * @param mesh defines the mesh to check
  107363. * @param subMesh defines which submesh to check
  107364. * @param useInstances specifies that instances should be used
  107365. * @returns a boolean indicating that the submesh is ready or not
  107366. */
  107367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107368. /**
  107369. * Builds the material UBO layouts.
  107370. * Used internally during the effect preparation.
  107371. */
  107372. buildUniformLayout(): void;
  107373. /**
  107374. * Unbinds the material from the mesh
  107375. */
  107376. unbind(): void;
  107377. /**
  107378. * Binds the submesh to this material by preparing the effect and shader to draw
  107379. * @param world defines the world transformation matrix
  107380. * @param mesh defines the mesh containing the submesh
  107381. * @param subMesh defines the submesh to bind the material to
  107382. */
  107383. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107384. /**
  107385. * Get the list of animatables in the material.
  107386. * @returns the list of animatables object used in the material
  107387. */
  107388. getAnimatables(): IAnimatable[];
  107389. /**
  107390. * Gets the active textures from the material
  107391. * @returns an array of textures
  107392. */
  107393. getActiveTextures(): BaseTexture[];
  107394. /**
  107395. * Specifies if the material uses a texture
  107396. * @param texture defines the texture to check against the material
  107397. * @returns a boolean specifying if the material uses the texture
  107398. */
  107399. hasTexture(texture: BaseTexture): boolean;
  107400. /**
  107401. * Disposes the material
  107402. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107403. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107404. */
  107405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107406. /**
  107407. * Makes a duplicate of the material, and gives it a new name
  107408. * @param name defines the new name for the duplicated material
  107409. * @returns the cloned material
  107410. */
  107411. clone(name: string): StandardMaterial;
  107412. /**
  107413. * Serializes this material in a JSON representation
  107414. * @returns the serialized material object
  107415. */
  107416. serialize(): any;
  107417. /**
  107418. * Creates a standard material from parsed material data
  107419. * @param source defines the JSON representation of the material
  107420. * @param scene defines the hosting scene
  107421. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107422. * @returns a new standard material
  107423. */
  107424. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107425. /**
  107426. * Are diffuse textures enabled in the application.
  107427. */
  107428. static get DiffuseTextureEnabled(): boolean;
  107429. static set DiffuseTextureEnabled(value: boolean);
  107430. /**
  107431. * Are ambient textures enabled in the application.
  107432. */
  107433. static get AmbientTextureEnabled(): boolean;
  107434. static set AmbientTextureEnabled(value: boolean);
  107435. /**
  107436. * Are opacity textures enabled in the application.
  107437. */
  107438. static get OpacityTextureEnabled(): boolean;
  107439. static set OpacityTextureEnabled(value: boolean);
  107440. /**
  107441. * Are reflection textures enabled in the application.
  107442. */
  107443. static get ReflectionTextureEnabled(): boolean;
  107444. static set ReflectionTextureEnabled(value: boolean);
  107445. /**
  107446. * Are emissive textures enabled in the application.
  107447. */
  107448. static get EmissiveTextureEnabled(): boolean;
  107449. static set EmissiveTextureEnabled(value: boolean);
  107450. /**
  107451. * Are specular textures enabled in the application.
  107452. */
  107453. static get SpecularTextureEnabled(): boolean;
  107454. static set SpecularTextureEnabled(value: boolean);
  107455. /**
  107456. * Are bump textures enabled in the application.
  107457. */
  107458. static get BumpTextureEnabled(): boolean;
  107459. static set BumpTextureEnabled(value: boolean);
  107460. /**
  107461. * Are lightmap textures enabled in the application.
  107462. */
  107463. static get LightmapTextureEnabled(): boolean;
  107464. static set LightmapTextureEnabled(value: boolean);
  107465. /**
  107466. * Are refraction textures enabled in the application.
  107467. */
  107468. static get RefractionTextureEnabled(): boolean;
  107469. static set RefractionTextureEnabled(value: boolean);
  107470. /**
  107471. * Are color grading textures enabled in the application.
  107472. */
  107473. static get ColorGradingTextureEnabled(): boolean;
  107474. static set ColorGradingTextureEnabled(value: boolean);
  107475. /**
  107476. * Are fresnels enabled in the application.
  107477. */
  107478. static get FresnelEnabled(): boolean;
  107479. static set FresnelEnabled(value: boolean);
  107480. }
  107481. }
  107482. declare module BABYLON {
  107483. /**
  107484. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107485. *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.
  107486. * The SPS is also a particle system. It provides some methods to manage the particles.
  107487. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107488. *
  107489. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107490. */
  107491. export class SolidParticleSystem implements IDisposable {
  107492. /**
  107493. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107494. * Example : var p = SPS.particles[i];
  107495. */
  107496. particles: SolidParticle[];
  107497. /**
  107498. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107499. */
  107500. nbParticles: number;
  107501. /**
  107502. * If the particles must ever face the camera (default false). Useful for planar particles.
  107503. */
  107504. billboard: boolean;
  107505. /**
  107506. * Recompute normals when adding a shape
  107507. */
  107508. recomputeNormals: boolean;
  107509. /**
  107510. * This a counter ofr your own usage. It's not set by any SPS functions.
  107511. */
  107512. counter: number;
  107513. /**
  107514. * The SPS name. This name is also given to the underlying mesh.
  107515. */
  107516. name: string;
  107517. /**
  107518. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107519. */
  107520. mesh: Mesh;
  107521. /**
  107522. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107523. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107524. */
  107525. vars: any;
  107526. /**
  107527. * This array is populated when the SPS is set as 'pickable'.
  107528. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107529. * Each element of this array is an object `{idx: int, faceId: int}`.
  107530. * `idx` is the picked particle index in the `SPS.particles` array
  107531. * `faceId` is the picked face index counted within this particle.
  107532. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107533. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107534. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107535. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107536. */
  107537. pickedParticles: {
  107538. idx: number;
  107539. faceId: number;
  107540. }[];
  107541. /**
  107542. * This array is populated when the SPS is set as 'pickable'
  107543. * Each key of this array is a submesh index.
  107544. * Each element of this array is a second array defined like this :
  107545. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107546. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107547. * `idx` is the picked particle index in the `SPS.particles` array
  107548. * `faceId` is the picked face index counted within this particle.
  107549. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107550. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107551. */
  107552. pickedBySubMesh: {
  107553. idx: number;
  107554. faceId: number;
  107555. }[][];
  107556. /**
  107557. * This array is populated when `enableDepthSort` is set to true.
  107558. * Each element of this array is an instance of the class DepthSortedParticle.
  107559. */
  107560. depthSortedParticles: DepthSortedParticle[];
  107561. /**
  107562. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107563. * @hidden
  107564. */
  107565. _bSphereOnly: boolean;
  107566. /**
  107567. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107568. * @hidden
  107569. */
  107570. _bSphereRadiusFactor: number;
  107571. private _scene;
  107572. private _positions;
  107573. private _indices;
  107574. private _normals;
  107575. private _colors;
  107576. private _uvs;
  107577. private _indices32;
  107578. private _positions32;
  107579. private _normals32;
  107580. private _fixedNormal32;
  107581. private _colors32;
  107582. private _uvs32;
  107583. private _index;
  107584. private _updatable;
  107585. private _pickable;
  107586. private _isVisibilityBoxLocked;
  107587. private _alwaysVisible;
  107588. private _depthSort;
  107589. private _expandable;
  107590. private _shapeCounter;
  107591. private _copy;
  107592. private _color;
  107593. private _computeParticleColor;
  107594. private _computeParticleTexture;
  107595. private _computeParticleRotation;
  107596. private _computeParticleVertex;
  107597. private _computeBoundingBox;
  107598. private _depthSortParticles;
  107599. private _camera;
  107600. private _mustUnrotateFixedNormals;
  107601. private _particlesIntersect;
  107602. private _needs32Bits;
  107603. private _isNotBuilt;
  107604. private _lastParticleId;
  107605. private _idxOfId;
  107606. private _multimaterialEnabled;
  107607. private _useModelMaterial;
  107608. private _indicesByMaterial;
  107609. private _materialIndexes;
  107610. private _depthSortFunction;
  107611. private _materialSortFunction;
  107612. private _materials;
  107613. private _multimaterial;
  107614. private _materialIndexesById;
  107615. private _defaultMaterial;
  107616. private _autoUpdateSubMeshes;
  107617. private _tmpVertex;
  107618. /**
  107619. * Creates a SPS (Solid Particle System) object.
  107620. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107621. * @param scene (Scene) is the scene in which the SPS is added.
  107622. * @param options defines the options of the sps e.g.
  107623. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107624. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107625. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107626. * * 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.
  107627. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107628. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107629. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107630. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107631. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107632. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107633. */
  107634. constructor(name: string, scene: Scene, options?: {
  107635. updatable?: boolean;
  107636. isPickable?: boolean;
  107637. enableDepthSort?: boolean;
  107638. particleIntersection?: boolean;
  107639. boundingSphereOnly?: boolean;
  107640. bSphereRadiusFactor?: number;
  107641. expandable?: boolean;
  107642. useModelMaterial?: boolean;
  107643. enableMultiMaterial?: boolean;
  107644. });
  107645. /**
  107646. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107647. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107648. * @returns the created mesh
  107649. */
  107650. buildMesh(): Mesh;
  107651. /**
  107652. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107653. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107654. * Thus the particles generated from `digest()` have their property `position` set yet.
  107655. * @param mesh ( Mesh ) is the mesh to be digested
  107656. * @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
  107657. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107658. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107659. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107660. * @returns the current SPS
  107661. */
  107662. digest(mesh: Mesh, options?: {
  107663. facetNb?: number;
  107664. number?: number;
  107665. delta?: number;
  107666. storage?: [];
  107667. }): SolidParticleSystem;
  107668. /**
  107669. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107670. * @hidden
  107671. */
  107672. private _unrotateFixedNormals;
  107673. /**
  107674. * Resets the temporary working copy particle
  107675. * @hidden
  107676. */
  107677. private _resetCopy;
  107678. /**
  107679. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107680. * @param p the current index in the positions array to be updated
  107681. * @param ind the current index in the indices array
  107682. * @param shape a Vector3 array, the shape geometry
  107683. * @param positions the positions array to be updated
  107684. * @param meshInd the shape indices array
  107685. * @param indices the indices array to be updated
  107686. * @param meshUV the shape uv array
  107687. * @param uvs the uv array to be updated
  107688. * @param meshCol the shape color array
  107689. * @param colors the color array to be updated
  107690. * @param meshNor the shape normals array
  107691. * @param normals the normals array to be updated
  107692. * @param idx the particle index
  107693. * @param idxInShape the particle index in its shape
  107694. * @param options the addShape() method passed options
  107695. * @model the particle model
  107696. * @hidden
  107697. */
  107698. private _meshBuilder;
  107699. /**
  107700. * Returns a shape Vector3 array from positions float array
  107701. * @param positions float array
  107702. * @returns a vector3 array
  107703. * @hidden
  107704. */
  107705. private _posToShape;
  107706. /**
  107707. * Returns a shapeUV array from a float uvs (array deep copy)
  107708. * @param uvs as a float array
  107709. * @returns a shapeUV array
  107710. * @hidden
  107711. */
  107712. private _uvsToShapeUV;
  107713. /**
  107714. * Adds a new particle object in the particles array
  107715. * @param idx particle index in particles array
  107716. * @param id particle id
  107717. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107718. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107719. * @param model particle ModelShape object
  107720. * @param shapeId model shape identifier
  107721. * @param idxInShape index of the particle in the current model
  107722. * @param bInfo model bounding info object
  107723. * @param storage target storage array, if any
  107724. * @hidden
  107725. */
  107726. private _addParticle;
  107727. /**
  107728. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107729. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107730. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107731. * @param nb (positive integer) the number of particles to be created from this model
  107732. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107733. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107734. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107735. * @returns the number of shapes in the system
  107736. */
  107737. addShape(mesh: Mesh, nb: number, options?: {
  107738. positionFunction?: any;
  107739. vertexFunction?: any;
  107740. storage?: [];
  107741. }): number;
  107742. /**
  107743. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107744. * @hidden
  107745. */
  107746. private _rebuildParticle;
  107747. /**
  107748. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  107749. * @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.
  107750. * @returns the SPS.
  107751. */
  107752. rebuildMesh(reset?: boolean): SolidParticleSystem;
  107753. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  107754. * Returns an array with the removed particles.
  107755. * 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.
  107756. * The SPS can't be empty so at least one particle needs to remain in place.
  107757. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  107758. * @param start index of the first particle to remove
  107759. * @param end index of the last particle to remove (included)
  107760. * @returns an array populated with the removed particles
  107761. */
  107762. removeParticles(start: number, end: number): SolidParticle[];
  107763. /**
  107764. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  107765. * @param solidParticleArray an array populated with Solid Particles objects
  107766. * @returns the SPS
  107767. */
  107768. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  107769. /**
  107770. * Creates a new particle and modifies the SPS mesh geometry :
  107771. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  107772. * - calls _addParticle() to populate the particle array
  107773. * factorized code from addShape() and insertParticlesFromArray()
  107774. * @param idx particle index in the particles array
  107775. * @param i particle index in its shape
  107776. * @param modelShape particle ModelShape object
  107777. * @param shape shape vertex array
  107778. * @param meshInd shape indices array
  107779. * @param meshUV shape uv array
  107780. * @param meshCol shape color array
  107781. * @param meshNor shape normals array
  107782. * @param bbInfo shape bounding info
  107783. * @param storage target particle storage
  107784. * @options addShape() passed options
  107785. * @hidden
  107786. */
  107787. private _insertNewParticle;
  107788. /**
  107789. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  107790. * This method calls `updateParticle()` for each particle of the SPS.
  107791. * For an animated SPS, it is usually called within the render loop.
  107792. * 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.
  107793. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  107794. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  107795. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  107796. * @returns the SPS.
  107797. */
  107798. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  107799. /**
  107800. * Disposes the SPS.
  107801. */
  107802. dispose(): void;
  107803. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  107804. * idx is the particle index in the SPS
  107805. * faceId is the picked face index counted within this particle.
  107806. * Returns null if the pickInfo can't identify a picked particle.
  107807. * @param pickingInfo (PickingInfo object)
  107808. * @returns {idx: number, faceId: number} or null
  107809. */
  107810. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  107811. idx: number;
  107812. faceId: number;
  107813. }>;
  107814. /**
  107815. * Returns a SolidParticle object from its identifier : particle.id
  107816. * @param id (integer) the particle Id
  107817. * @returns the searched particle or null if not found in the SPS.
  107818. */
  107819. getParticleById(id: number): Nullable<SolidParticle>;
  107820. /**
  107821. * Returns a new array populated with the particles having the passed shapeId.
  107822. * @param shapeId (integer) the shape identifier
  107823. * @returns a new solid particle array
  107824. */
  107825. getParticlesByShapeId(shapeId: number): SolidParticle[];
  107826. /**
  107827. * Populates the passed array "ref" with the particles having the passed shapeId.
  107828. * @param shapeId the shape identifier
  107829. * @returns the SPS
  107830. * @param ref
  107831. */
  107832. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  107833. /**
  107834. * Computes the required SubMeshes according the materials assigned to the particles.
  107835. * @returns the solid particle system.
  107836. * Does nothing if called before the SPS mesh is built.
  107837. */
  107838. computeSubMeshes(): SolidParticleSystem;
  107839. /**
  107840. * Sorts the solid particles by material when MultiMaterial is enabled.
  107841. * Updates the indices32 array.
  107842. * Updates the indicesByMaterial array.
  107843. * Updates the mesh indices array.
  107844. * @returns the SPS
  107845. * @hidden
  107846. */
  107847. private _sortParticlesByMaterial;
  107848. /**
  107849. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  107850. * @hidden
  107851. */
  107852. private _setMaterialIndexesById;
  107853. /**
  107854. * Returns an array with unique values of Materials from the passed array
  107855. * @param array the material array to be checked and filtered
  107856. * @hidden
  107857. */
  107858. private _filterUniqueMaterialId;
  107859. /**
  107860. * Sets a new Standard Material as _defaultMaterial if not already set.
  107861. * @hidden
  107862. */
  107863. private _setDefaultMaterial;
  107864. /**
  107865. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  107866. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107867. * @returns the SPS.
  107868. */
  107869. refreshVisibleSize(): SolidParticleSystem;
  107870. /**
  107871. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  107872. * @param size the size (float) of the visibility box
  107873. * note : this doesn't lock the SPS mesh bounding box.
  107874. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107875. */
  107876. setVisibilityBox(size: number): void;
  107877. /**
  107878. * Gets whether the SPS as always visible or not
  107879. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107880. */
  107881. get isAlwaysVisible(): boolean;
  107882. /**
  107883. * Sets the SPS as always visible or not
  107884. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107885. */
  107886. set isAlwaysVisible(val: boolean);
  107887. /**
  107888. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107889. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107890. */
  107891. set isVisibilityBoxLocked(val: boolean);
  107892. /**
  107893. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  107894. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  107895. */
  107896. get isVisibilityBoxLocked(): boolean;
  107897. /**
  107898. * Tells to `setParticles()` to compute the particle rotations or not.
  107899. * Default value : true. The SPS is faster when it's set to false.
  107900. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107901. */
  107902. set computeParticleRotation(val: boolean);
  107903. /**
  107904. * Tells to `setParticles()` to compute the particle colors or not.
  107905. * Default value : true. The SPS is faster when it's set to false.
  107906. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107907. */
  107908. set computeParticleColor(val: boolean);
  107909. set computeParticleTexture(val: boolean);
  107910. /**
  107911. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  107912. * Default value : false. The SPS is faster when it's set to false.
  107913. * Note : the particle custom vertex positions aren't stored values.
  107914. */
  107915. set computeParticleVertex(val: boolean);
  107916. /**
  107917. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  107918. */
  107919. set computeBoundingBox(val: boolean);
  107920. /**
  107921. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  107922. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107923. * Default : `true`
  107924. */
  107925. set depthSortParticles(val: boolean);
  107926. /**
  107927. * Gets if `setParticles()` computes the particle rotations or not.
  107928. * Default value : true. The SPS is faster when it's set to false.
  107929. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  107930. */
  107931. get computeParticleRotation(): boolean;
  107932. /**
  107933. * Gets if `setParticles()` computes the particle colors or not.
  107934. * Default value : true. The SPS is faster when it's set to false.
  107935. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  107936. */
  107937. get computeParticleColor(): boolean;
  107938. /**
  107939. * Gets if `setParticles()` computes the particle textures or not.
  107940. * Default value : true. The SPS is faster when it's set to false.
  107941. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  107942. */
  107943. get computeParticleTexture(): boolean;
  107944. /**
  107945. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  107946. * Default value : false. The SPS is faster when it's set to false.
  107947. * Note : the particle custom vertex positions aren't stored values.
  107948. */
  107949. get computeParticleVertex(): boolean;
  107950. /**
  107951. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  107952. */
  107953. get computeBoundingBox(): boolean;
  107954. /**
  107955. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  107956. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  107957. * Default : `true`
  107958. */
  107959. get depthSortParticles(): boolean;
  107960. /**
  107961. * Gets if the SPS is created as expandable at construction time.
  107962. * Default : `false`
  107963. */
  107964. get expandable(): boolean;
  107965. /**
  107966. * Gets if the SPS supports the Multi Materials
  107967. */
  107968. get multimaterialEnabled(): boolean;
  107969. /**
  107970. * Gets if the SPS uses the model materials for its own multimaterial.
  107971. */
  107972. get useModelMaterial(): boolean;
  107973. /**
  107974. * The SPS used material array.
  107975. */
  107976. get materials(): Material[];
  107977. /**
  107978. * Sets the SPS MultiMaterial from the passed materials.
  107979. * Note : the passed array is internally copied and not used then by reference.
  107980. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  107981. */
  107982. setMultiMaterial(materials: Material[]): void;
  107983. /**
  107984. * The SPS computed multimaterial object
  107985. */
  107986. get multimaterial(): MultiMaterial;
  107987. set multimaterial(mm: MultiMaterial);
  107988. /**
  107989. * If the subMeshes must be updated on the next call to setParticles()
  107990. */
  107991. get autoUpdateSubMeshes(): boolean;
  107992. set autoUpdateSubMeshes(val: boolean);
  107993. /**
  107994. * This function does nothing. It may be overwritten to set all the particle first values.
  107995. * The SPS doesn't call this function, you may have to call it by your own.
  107996. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  107997. */
  107998. initParticles(): void;
  107999. /**
  108000. * This function does nothing. It may be overwritten to recycle a particle.
  108001. * The SPS doesn't call this function, you may have to call it by your own.
  108002. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108003. * @param particle The particle to recycle
  108004. * @returns the recycled particle
  108005. */
  108006. recycleParticle(particle: SolidParticle): SolidParticle;
  108007. /**
  108008. * Updates a particle : this function should be overwritten by the user.
  108009. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108010. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108011. * @example : just set a particle position or velocity and recycle conditions
  108012. * @param particle The particle to update
  108013. * @returns the updated particle
  108014. */
  108015. updateParticle(particle: SolidParticle): SolidParticle;
  108016. /**
  108017. * Updates a vertex of a particle : it can be overwritten by the user.
  108018. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108019. * @param particle the current particle
  108020. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108021. * @param pt the index of the current vertex in the particle shape
  108022. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108023. * @example : just set a vertex particle position or color
  108024. * @returns the sps
  108025. */
  108026. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108027. /**
  108028. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108029. * This does nothing and may be overwritten by the user.
  108030. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108031. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108032. * @param update the boolean update value actually passed to setParticles()
  108033. */
  108034. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108035. /**
  108036. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108037. * This will be passed three parameters.
  108038. * This does nothing and may be overwritten by the user.
  108039. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108040. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108041. * @param update the boolean update value actually passed to setParticles()
  108042. */
  108043. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108044. }
  108045. }
  108046. declare module BABYLON {
  108047. /**
  108048. * Represents one particle of a solid particle system.
  108049. */
  108050. export class SolidParticle {
  108051. /**
  108052. * particle global index
  108053. */
  108054. idx: number;
  108055. /**
  108056. * particle identifier
  108057. */
  108058. id: number;
  108059. /**
  108060. * The color of the particle
  108061. */
  108062. color: Nullable<Color4>;
  108063. /**
  108064. * The world space position of the particle.
  108065. */
  108066. position: Vector3;
  108067. /**
  108068. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108069. */
  108070. rotation: Vector3;
  108071. /**
  108072. * The world space rotation quaternion of the particle.
  108073. */
  108074. rotationQuaternion: Nullable<Quaternion>;
  108075. /**
  108076. * The scaling of the particle.
  108077. */
  108078. scaling: Vector3;
  108079. /**
  108080. * The uvs of the particle.
  108081. */
  108082. uvs: Vector4;
  108083. /**
  108084. * The current speed of the particle.
  108085. */
  108086. velocity: Vector3;
  108087. /**
  108088. * The pivot point in the particle local space.
  108089. */
  108090. pivot: Vector3;
  108091. /**
  108092. * Must the particle be translated from its pivot point in its local space ?
  108093. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108094. * Default : false
  108095. */
  108096. translateFromPivot: boolean;
  108097. /**
  108098. * Is the particle active or not ?
  108099. */
  108100. alive: boolean;
  108101. /**
  108102. * Is the particle visible or not ?
  108103. */
  108104. isVisible: boolean;
  108105. /**
  108106. * Index of this particle in the global "positions" array (Internal use)
  108107. * @hidden
  108108. */
  108109. _pos: number;
  108110. /**
  108111. * @hidden Index of this particle in the global "indices" array (Internal use)
  108112. */
  108113. _ind: number;
  108114. /**
  108115. * @hidden ModelShape of this particle (Internal use)
  108116. */
  108117. _model: ModelShape;
  108118. /**
  108119. * ModelShape id of this particle
  108120. */
  108121. shapeId: number;
  108122. /**
  108123. * Index of the particle in its shape id
  108124. */
  108125. idxInShape: number;
  108126. /**
  108127. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108128. */
  108129. _modelBoundingInfo: BoundingInfo;
  108130. /**
  108131. * @hidden Particle BoundingInfo object (Internal use)
  108132. */
  108133. _boundingInfo: BoundingInfo;
  108134. /**
  108135. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108136. */
  108137. _sps: SolidParticleSystem;
  108138. /**
  108139. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108140. */
  108141. _stillInvisible: boolean;
  108142. /**
  108143. * @hidden Last computed particle rotation matrix
  108144. */
  108145. _rotationMatrix: number[];
  108146. /**
  108147. * Parent particle Id, if any.
  108148. * Default null.
  108149. */
  108150. parentId: Nullable<number>;
  108151. /**
  108152. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108153. */
  108154. materialIndex: Nullable<number>;
  108155. /**
  108156. * Custom object or properties.
  108157. */
  108158. props: Nullable<any>;
  108159. /**
  108160. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108161. * The possible values are :
  108162. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108163. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108164. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108165. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108166. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108167. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108168. * */
  108169. cullingStrategy: number;
  108170. /**
  108171. * @hidden Internal global position in the SPS.
  108172. */
  108173. _globalPosition: Vector3;
  108174. /**
  108175. * Creates a Solid Particle object.
  108176. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108177. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108178. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108179. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108180. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108181. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108182. * @param shapeId (integer) is the model shape identifier in the SPS.
  108183. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108184. * @param sps defines the sps it is associated to
  108185. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108186. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108187. */
  108188. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108189. /**
  108190. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108191. * @param target the particle target
  108192. * @returns the current particle
  108193. */
  108194. copyToRef(target: SolidParticle): SolidParticle;
  108195. /**
  108196. * Legacy support, changed scale to scaling
  108197. */
  108198. get scale(): Vector3;
  108199. /**
  108200. * Legacy support, changed scale to scaling
  108201. */
  108202. set scale(scale: Vector3);
  108203. /**
  108204. * Legacy support, changed quaternion to rotationQuaternion
  108205. */
  108206. get quaternion(): Nullable<Quaternion>;
  108207. /**
  108208. * Legacy support, changed quaternion to rotationQuaternion
  108209. */
  108210. set quaternion(q: Nullable<Quaternion>);
  108211. /**
  108212. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108213. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108214. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108215. * @returns true if it intersects
  108216. */
  108217. intersectsMesh(target: Mesh | SolidParticle): boolean;
  108218. /**
  108219. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108220. * A particle is in the frustum if its bounding box intersects the frustum
  108221. * @param frustumPlanes defines the frustum to test
  108222. * @returns true if the particle is in the frustum planes
  108223. */
  108224. isInFrustum(frustumPlanes: Plane[]): boolean;
  108225. /**
  108226. * get the rotation matrix of the particle
  108227. * @hidden
  108228. */
  108229. getRotationMatrix(m: Matrix): void;
  108230. }
  108231. /**
  108232. * Represents the shape of the model used by one particle of a solid particle system.
  108233. * SPS internal tool, don't use it manually.
  108234. */
  108235. export class ModelShape {
  108236. /**
  108237. * The shape id
  108238. * @hidden
  108239. */
  108240. shapeID: number;
  108241. /**
  108242. * flat array of model positions (internal use)
  108243. * @hidden
  108244. */
  108245. _shape: Vector3[];
  108246. /**
  108247. * flat array of model UVs (internal use)
  108248. * @hidden
  108249. */
  108250. _shapeUV: number[];
  108251. /**
  108252. * color array of the model
  108253. * @hidden
  108254. */
  108255. _shapeColors: number[];
  108256. /**
  108257. * indices array of the model
  108258. * @hidden
  108259. */
  108260. _indices: number[];
  108261. /**
  108262. * normals array of the model
  108263. * @hidden
  108264. */
  108265. _normals: number[];
  108266. /**
  108267. * length of the shape in the model indices array (internal use)
  108268. * @hidden
  108269. */
  108270. _indicesLength: number;
  108271. /**
  108272. * Custom position function (internal use)
  108273. * @hidden
  108274. */
  108275. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  108276. /**
  108277. * Custom vertex function (internal use)
  108278. * @hidden
  108279. */
  108280. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  108281. /**
  108282. * Model material (internal use)
  108283. * @hidden
  108284. */
  108285. _material: Nullable<Material>;
  108286. /**
  108287. * 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.
  108288. * SPS internal tool, don't use it manually.
  108289. * @hidden
  108290. */
  108291. 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>);
  108292. }
  108293. /**
  108294. * Represents a Depth Sorted Particle in the solid particle system.
  108295. * @hidden
  108296. */
  108297. export class DepthSortedParticle {
  108298. /**
  108299. * Particle index
  108300. */
  108301. idx: number;
  108302. /**
  108303. * Index of the particle in the "indices" array
  108304. */
  108305. ind: number;
  108306. /**
  108307. * Length of the particle shape in the "indices" array
  108308. */
  108309. indicesLength: number;
  108310. /**
  108311. * Squared distance from the particle to the camera
  108312. */
  108313. sqDistance: number;
  108314. /**
  108315. * Material index when used with MultiMaterials
  108316. */
  108317. materialIndex: number;
  108318. /**
  108319. * Creates a new sorted particle
  108320. * @param materialIndex
  108321. */
  108322. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108323. }
  108324. /**
  108325. * Represents a solid particle vertex
  108326. */
  108327. export class SolidParticleVertex {
  108328. /**
  108329. * Vertex position
  108330. */
  108331. position: Vector3;
  108332. /**
  108333. * Vertex color
  108334. */
  108335. color: Color4;
  108336. /**
  108337. * Vertex UV
  108338. */
  108339. uv: Vector2;
  108340. /**
  108341. * Creates a new solid particle vertex
  108342. */
  108343. constructor();
  108344. /** Vertex x coordinate */
  108345. get x(): number;
  108346. set x(val: number);
  108347. /** Vertex y coordinate */
  108348. get y(): number;
  108349. set y(val: number);
  108350. /** Vertex z coordinate */
  108351. get z(): number;
  108352. set z(val: number);
  108353. }
  108354. }
  108355. declare module BABYLON {
  108356. /**
  108357. * @hidden
  108358. */
  108359. export class _MeshCollisionData {
  108360. _checkCollisions: boolean;
  108361. _collisionMask: number;
  108362. _collisionGroup: number;
  108363. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108364. _collider: Nullable<Collider>;
  108365. _oldPositionForCollisions: Vector3;
  108366. _diffPositionForCollisions: Vector3;
  108367. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108368. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108369. }
  108370. }
  108371. declare module BABYLON {
  108372. /** @hidden */
  108373. class _FacetDataStorage {
  108374. facetPositions: Vector3[];
  108375. facetNormals: Vector3[];
  108376. facetPartitioning: number[][];
  108377. facetNb: number;
  108378. partitioningSubdivisions: number;
  108379. partitioningBBoxRatio: number;
  108380. facetDataEnabled: boolean;
  108381. facetParameters: any;
  108382. bbSize: Vector3;
  108383. subDiv: {
  108384. max: number;
  108385. X: number;
  108386. Y: number;
  108387. Z: number;
  108388. };
  108389. facetDepthSort: boolean;
  108390. facetDepthSortEnabled: boolean;
  108391. depthSortedIndices: IndicesArray;
  108392. depthSortedFacets: {
  108393. ind: number;
  108394. sqDistance: number;
  108395. }[];
  108396. facetDepthSortFunction: (f1: {
  108397. ind: number;
  108398. sqDistance: number;
  108399. }, f2: {
  108400. ind: number;
  108401. sqDistance: number;
  108402. }) => number;
  108403. facetDepthSortFrom: Vector3;
  108404. facetDepthSortOrigin: Vector3;
  108405. invertedMatrix: Matrix;
  108406. }
  108407. /**
  108408. * @hidden
  108409. **/
  108410. class _InternalAbstractMeshDataInfo {
  108411. _hasVertexAlpha: boolean;
  108412. _useVertexColors: boolean;
  108413. _numBoneInfluencers: number;
  108414. _applyFog: boolean;
  108415. _receiveShadows: boolean;
  108416. _facetData: _FacetDataStorage;
  108417. _visibility: number;
  108418. _skeleton: Nullable<Skeleton>;
  108419. _layerMask: number;
  108420. _computeBonesUsingShaders: boolean;
  108421. _isActive: boolean;
  108422. _onlyForInstances: boolean;
  108423. _isActiveIntermediate: boolean;
  108424. _onlyForInstancesIntermediate: boolean;
  108425. _actAsRegularMesh: boolean;
  108426. }
  108427. /**
  108428. * Class used to store all common mesh properties
  108429. */
  108430. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108431. /** No occlusion */
  108432. static OCCLUSION_TYPE_NONE: number;
  108433. /** Occlusion set to optimisitic */
  108434. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108435. /** Occlusion set to strict */
  108436. static OCCLUSION_TYPE_STRICT: number;
  108437. /** Use an accurante occlusion algorithm */
  108438. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108439. /** Use a conservative occlusion algorithm */
  108440. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108441. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108442. * Test order :
  108443. * Is the bounding sphere outside the frustum ?
  108444. * If not, are the bounding box vertices outside the frustum ?
  108445. * It not, then the cullable object is in the frustum.
  108446. */
  108447. static readonly CULLINGSTRATEGY_STANDARD: number;
  108448. /** Culling strategy : Bounding Sphere Only.
  108449. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108450. * It's also less accurate than the standard because some not visible objects can still be selected.
  108451. * Test : is the bounding sphere outside the frustum ?
  108452. * If not, then the cullable object is in the frustum.
  108453. */
  108454. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108455. /** Culling strategy : Optimistic Inclusion.
  108456. * This in an inclusion test first, then the standard exclusion test.
  108457. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108458. * 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.
  108459. * Anyway, it's as accurate as the standard strategy.
  108460. * Test :
  108461. * Is the cullable object bounding sphere center in the frustum ?
  108462. * If not, apply the default culling strategy.
  108463. */
  108464. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108465. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108466. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108467. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108468. * 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.
  108469. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108470. * Test :
  108471. * Is the cullable object bounding sphere center in the frustum ?
  108472. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108473. */
  108474. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108475. /**
  108476. * No billboard
  108477. */
  108478. static get BILLBOARDMODE_NONE(): number;
  108479. /** Billboard on X axis */
  108480. static get BILLBOARDMODE_X(): number;
  108481. /** Billboard on Y axis */
  108482. static get BILLBOARDMODE_Y(): number;
  108483. /** Billboard on Z axis */
  108484. static get BILLBOARDMODE_Z(): number;
  108485. /** Billboard on all axes */
  108486. static get BILLBOARDMODE_ALL(): number;
  108487. /** Billboard on using position instead of orientation */
  108488. static get BILLBOARDMODE_USE_POSITION(): number;
  108489. /** @hidden */
  108490. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108491. /**
  108492. * The culling strategy to use to check whether the mesh must be rendered or not.
  108493. * This value can be changed at any time and will be used on the next render mesh selection.
  108494. * The possible values are :
  108495. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108496. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108497. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108498. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108499. * Please read each static variable documentation to get details about the culling process.
  108500. * */
  108501. cullingStrategy: number;
  108502. /**
  108503. * Gets the number of facets in the mesh
  108504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108505. */
  108506. get facetNb(): number;
  108507. /**
  108508. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108510. */
  108511. get partitioningSubdivisions(): number;
  108512. set partitioningSubdivisions(nb: number);
  108513. /**
  108514. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108515. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108517. */
  108518. get partitioningBBoxRatio(): number;
  108519. set partitioningBBoxRatio(ratio: number);
  108520. /**
  108521. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108522. * Works only for updatable meshes.
  108523. * Doesn't work with multi-materials
  108524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108525. */
  108526. get mustDepthSortFacets(): boolean;
  108527. set mustDepthSortFacets(sort: boolean);
  108528. /**
  108529. * The location (Vector3) where the facet depth sort must be computed from.
  108530. * By default, the active camera position.
  108531. * Used only when facet depth sort is enabled
  108532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108533. */
  108534. get facetDepthSortFrom(): Vector3;
  108535. set facetDepthSortFrom(location: Vector3);
  108536. /**
  108537. * gets a boolean indicating if facetData is enabled
  108538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108539. */
  108540. get isFacetDataEnabled(): boolean;
  108541. /** @hidden */
  108542. _updateNonUniformScalingState(value: boolean): boolean;
  108543. /**
  108544. * An event triggered when this mesh collides with another one
  108545. */
  108546. onCollideObservable: Observable<AbstractMesh>;
  108547. /** Set a function to call when this mesh collides with another one */
  108548. set onCollide(callback: () => void);
  108549. /**
  108550. * An event triggered when the collision's position changes
  108551. */
  108552. onCollisionPositionChangeObservable: Observable<Vector3>;
  108553. /** Set a function to call when the collision's position changes */
  108554. set onCollisionPositionChange(callback: () => void);
  108555. /**
  108556. * An event triggered when material is changed
  108557. */
  108558. onMaterialChangedObservable: Observable<AbstractMesh>;
  108559. /**
  108560. * Gets or sets the orientation for POV movement & rotation
  108561. */
  108562. definedFacingForward: boolean;
  108563. /** @hidden */
  108564. _occlusionQuery: Nullable<WebGLQuery>;
  108565. /** @hidden */
  108566. _renderingGroup: Nullable<RenderingGroup>;
  108567. /**
  108568. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108569. */
  108570. get visibility(): number;
  108571. /**
  108572. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108573. */
  108574. set visibility(value: number);
  108575. /** Gets or sets the alpha index used to sort transparent meshes
  108576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108577. */
  108578. alphaIndex: number;
  108579. /**
  108580. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108581. */
  108582. isVisible: boolean;
  108583. /**
  108584. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108585. */
  108586. isPickable: boolean;
  108587. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108588. showSubMeshesBoundingBox: boolean;
  108589. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108590. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108591. */
  108592. isBlocker: boolean;
  108593. /**
  108594. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108595. */
  108596. enablePointerMoveEvents: boolean;
  108597. /**
  108598. * Specifies the rendering group id for this mesh (0 by default)
  108599. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108600. */
  108601. renderingGroupId: number;
  108602. private _material;
  108603. /** Gets or sets current material */
  108604. get material(): Nullable<Material>;
  108605. set material(value: Nullable<Material>);
  108606. /**
  108607. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108608. * @see http://doc.babylonjs.com/babylon101/shadows
  108609. */
  108610. get receiveShadows(): boolean;
  108611. set receiveShadows(value: boolean);
  108612. /** Defines color to use when rendering outline */
  108613. outlineColor: Color3;
  108614. /** Define width to use when rendering outline */
  108615. outlineWidth: number;
  108616. /** Defines color to use when rendering overlay */
  108617. overlayColor: Color3;
  108618. /** Defines alpha to use when rendering overlay */
  108619. overlayAlpha: number;
  108620. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108621. get hasVertexAlpha(): boolean;
  108622. set hasVertexAlpha(value: boolean);
  108623. /** 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) */
  108624. get useVertexColors(): boolean;
  108625. set useVertexColors(value: boolean);
  108626. /**
  108627. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108628. */
  108629. get computeBonesUsingShaders(): boolean;
  108630. set computeBonesUsingShaders(value: boolean);
  108631. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108632. get numBoneInfluencers(): number;
  108633. set numBoneInfluencers(value: number);
  108634. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108635. get applyFog(): boolean;
  108636. set applyFog(value: boolean);
  108637. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108638. useOctreeForRenderingSelection: boolean;
  108639. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108640. useOctreeForPicking: boolean;
  108641. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108642. useOctreeForCollisions: boolean;
  108643. /**
  108644. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108645. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108646. */
  108647. get layerMask(): number;
  108648. set layerMask(value: number);
  108649. /**
  108650. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108651. */
  108652. alwaysSelectAsActiveMesh: boolean;
  108653. /**
  108654. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108655. */
  108656. doNotSyncBoundingInfo: boolean;
  108657. /**
  108658. * Gets or sets the current action manager
  108659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108660. */
  108661. actionManager: Nullable<AbstractActionManager>;
  108662. private _meshCollisionData;
  108663. /**
  108664. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108666. */
  108667. ellipsoid: Vector3;
  108668. /**
  108669. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108671. */
  108672. ellipsoidOffset: Vector3;
  108673. /**
  108674. * Gets or sets a collision mask used to mask collisions (default is -1).
  108675. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108676. */
  108677. get collisionMask(): number;
  108678. set collisionMask(mask: number);
  108679. /**
  108680. * Gets or sets the current collision group mask (-1 by default).
  108681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108682. */
  108683. get collisionGroup(): number;
  108684. set collisionGroup(mask: number);
  108685. /**
  108686. * Gets or sets current surrounding meshes (null by default).
  108687. *
  108688. * By default collision detection is tested against every mesh in the scene.
  108689. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108690. * meshes will be tested for the collision.
  108691. *
  108692. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108693. */
  108694. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108695. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108696. /**
  108697. * Defines edge width used when edgesRenderer is enabled
  108698. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108699. */
  108700. edgesWidth: number;
  108701. /**
  108702. * Defines edge color used when edgesRenderer is enabled
  108703. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108704. */
  108705. edgesColor: Color4;
  108706. /** @hidden */
  108707. _edgesRenderer: Nullable<IEdgesRenderer>;
  108708. /** @hidden */
  108709. _masterMesh: Nullable<AbstractMesh>;
  108710. /** @hidden */
  108711. _boundingInfo: Nullable<BoundingInfo>;
  108712. /** @hidden */
  108713. _renderId: number;
  108714. /**
  108715. * Gets or sets the list of subMeshes
  108716. * @see http://doc.babylonjs.com/how_to/multi_materials
  108717. */
  108718. subMeshes: SubMesh[];
  108719. /** @hidden */
  108720. _intersectionsInProgress: AbstractMesh[];
  108721. /** @hidden */
  108722. _unIndexed: boolean;
  108723. /** @hidden */
  108724. _lightSources: Light[];
  108725. /** Gets the list of lights affecting that mesh */
  108726. get lightSources(): Light[];
  108727. /** @hidden */
  108728. get _positions(): Nullable<Vector3[]>;
  108729. /** @hidden */
  108730. _waitingData: {
  108731. lods: Nullable<any>;
  108732. actions: Nullable<any>;
  108733. freezeWorldMatrix: Nullable<boolean>;
  108734. };
  108735. /** @hidden */
  108736. _bonesTransformMatrices: Nullable<Float32Array>;
  108737. /** @hidden */
  108738. _transformMatrixTexture: Nullable<RawTexture>;
  108739. /**
  108740. * Gets or sets a skeleton to apply skining transformations
  108741. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108742. */
  108743. set skeleton(value: Nullable<Skeleton>);
  108744. get skeleton(): Nullable<Skeleton>;
  108745. /**
  108746. * An event triggered when the mesh is rebuilt.
  108747. */
  108748. onRebuildObservable: Observable<AbstractMesh>;
  108749. /**
  108750. * Creates a new AbstractMesh
  108751. * @param name defines the name of the mesh
  108752. * @param scene defines the hosting scene
  108753. */
  108754. constructor(name: string, scene?: Nullable<Scene>);
  108755. /**
  108756. * Returns the string "AbstractMesh"
  108757. * @returns "AbstractMesh"
  108758. */
  108759. getClassName(): string;
  108760. /**
  108761. * Gets a string representation of the current mesh
  108762. * @param fullDetails defines a boolean indicating if full details must be included
  108763. * @returns a string representation of the current mesh
  108764. */
  108765. toString(fullDetails?: boolean): string;
  108766. /**
  108767. * @hidden
  108768. */
  108769. protected _getEffectiveParent(): Nullable<Node>;
  108770. /** @hidden */
  108771. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  108772. /** @hidden */
  108773. _rebuild(): void;
  108774. /** @hidden */
  108775. _resyncLightSources(): void;
  108776. /** @hidden */
  108777. _resyncLightSource(light: Light): void;
  108778. /** @hidden */
  108779. _unBindEffect(): void;
  108780. /** @hidden */
  108781. _removeLightSource(light: Light, dispose: boolean): void;
  108782. private _markSubMeshesAsDirty;
  108783. /** @hidden */
  108784. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  108785. /** @hidden */
  108786. _markSubMeshesAsAttributesDirty(): void;
  108787. /** @hidden */
  108788. _markSubMeshesAsMiscDirty(): void;
  108789. /**
  108790. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  108791. */
  108792. get scaling(): Vector3;
  108793. set scaling(newScaling: Vector3);
  108794. /**
  108795. * Returns true if the mesh is blocked. Implemented by child classes
  108796. */
  108797. get isBlocked(): boolean;
  108798. /**
  108799. * Returns the mesh itself by default. Implemented by child classes
  108800. * @param camera defines the camera to use to pick the right LOD level
  108801. * @returns the currentAbstractMesh
  108802. */
  108803. getLOD(camera: Camera): Nullable<AbstractMesh>;
  108804. /**
  108805. * Returns 0 by default. Implemented by child classes
  108806. * @returns an integer
  108807. */
  108808. getTotalVertices(): number;
  108809. /**
  108810. * Returns a positive integer : the total number of indices in this mesh geometry.
  108811. * @returns the numner of indices or zero if the mesh has no geometry.
  108812. */
  108813. getTotalIndices(): number;
  108814. /**
  108815. * Returns null by default. Implemented by child classes
  108816. * @returns null
  108817. */
  108818. getIndices(): Nullable<IndicesArray>;
  108819. /**
  108820. * Returns the array of the requested vertex data kind. Implemented by child classes
  108821. * @param kind defines the vertex data kind to use
  108822. * @returns null
  108823. */
  108824. getVerticesData(kind: string): Nullable<FloatArray>;
  108825. /**
  108826. * Sets the vertex data of the mesh geometry for the requested `kind`.
  108827. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  108828. * Note that a new underlying VertexBuffer object is created each call.
  108829. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  108830. * @param kind defines vertex data kind:
  108831. * * VertexBuffer.PositionKind
  108832. * * VertexBuffer.UVKind
  108833. * * VertexBuffer.UV2Kind
  108834. * * VertexBuffer.UV3Kind
  108835. * * VertexBuffer.UV4Kind
  108836. * * VertexBuffer.UV5Kind
  108837. * * VertexBuffer.UV6Kind
  108838. * * VertexBuffer.ColorKind
  108839. * * VertexBuffer.MatricesIndicesKind
  108840. * * VertexBuffer.MatricesIndicesExtraKind
  108841. * * VertexBuffer.MatricesWeightsKind
  108842. * * VertexBuffer.MatricesWeightsExtraKind
  108843. * @param data defines the data source
  108844. * @param updatable defines if the data must be flagged as updatable (or static)
  108845. * @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
  108846. * @returns the current mesh
  108847. */
  108848. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108849. /**
  108850. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  108851. * If the mesh has no geometry, it is simply returned as it is.
  108852. * @param kind defines vertex data kind:
  108853. * * VertexBuffer.PositionKind
  108854. * * VertexBuffer.UVKind
  108855. * * VertexBuffer.UV2Kind
  108856. * * VertexBuffer.UV3Kind
  108857. * * VertexBuffer.UV4Kind
  108858. * * VertexBuffer.UV5Kind
  108859. * * VertexBuffer.UV6Kind
  108860. * * VertexBuffer.ColorKind
  108861. * * VertexBuffer.MatricesIndicesKind
  108862. * * VertexBuffer.MatricesIndicesExtraKind
  108863. * * VertexBuffer.MatricesWeightsKind
  108864. * * VertexBuffer.MatricesWeightsExtraKind
  108865. * @param data defines the data source
  108866. * @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
  108867. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  108868. * @returns the current mesh
  108869. */
  108870. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108871. /**
  108872. * Sets the mesh indices,
  108873. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  108874. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  108875. * @param totalVertices Defines the total number of vertices
  108876. * @returns the current mesh
  108877. */
  108878. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  108879. /**
  108880. * Gets a boolean indicating if specific vertex data is present
  108881. * @param kind defines the vertex data kind to use
  108882. * @returns true is data kind is present
  108883. */
  108884. isVerticesDataPresent(kind: string): boolean;
  108885. /**
  108886. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  108887. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  108888. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  108889. * @returns a BoundingInfo
  108890. */
  108891. getBoundingInfo(): BoundingInfo;
  108892. /**
  108893. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  108894. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  108895. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  108896. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  108897. * @returns the current mesh
  108898. */
  108899. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  108900. /**
  108901. * Overwrite the current bounding info
  108902. * @param boundingInfo defines the new bounding info
  108903. * @returns the current mesh
  108904. */
  108905. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  108906. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  108907. get useBones(): boolean;
  108908. /** @hidden */
  108909. _preActivate(): void;
  108910. /** @hidden */
  108911. _preActivateForIntermediateRendering(renderId: number): void;
  108912. /** @hidden */
  108913. _activate(renderId: number, intermediateRendering: boolean): boolean;
  108914. /** @hidden */
  108915. _postActivate(): void;
  108916. /** @hidden */
  108917. _freeze(): void;
  108918. /** @hidden */
  108919. _unFreeze(): void;
  108920. /**
  108921. * Gets the current world matrix
  108922. * @returns a Matrix
  108923. */
  108924. getWorldMatrix(): Matrix;
  108925. /** @hidden */
  108926. _getWorldMatrixDeterminant(): number;
  108927. /**
  108928. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  108929. */
  108930. get isAnInstance(): boolean;
  108931. /**
  108932. * Gets a boolean indicating if this mesh has instances
  108933. */
  108934. get hasInstances(): boolean;
  108935. /**
  108936. * Gets a boolean indicating if this mesh has thin instances
  108937. */
  108938. get hasThinInstances(): boolean;
  108939. /**
  108940. * Perform relative position change from the point of view of behind the front of the mesh.
  108941. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108942. * Supports definition of mesh facing forward or backward
  108943. * @param amountRight defines the distance on the right axis
  108944. * @param amountUp defines the distance on the up axis
  108945. * @param amountForward defines the distance on the forward axis
  108946. * @returns the current mesh
  108947. */
  108948. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  108949. /**
  108950. * Calculate relative position change from the point of view of behind the front of the mesh.
  108951. * This is performed taking into account the meshes current rotation, so you do not have to care.
  108952. * Supports definition of mesh facing forward or backward
  108953. * @param amountRight defines the distance on the right axis
  108954. * @param amountUp defines the distance on the up axis
  108955. * @param amountForward defines the distance on the forward axis
  108956. * @returns the new displacement vector
  108957. */
  108958. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  108959. /**
  108960. * Perform relative rotation change from the point of view of behind the front of the mesh.
  108961. * Supports definition of mesh facing forward or backward
  108962. * @param flipBack defines the flip
  108963. * @param twirlClockwise defines the twirl
  108964. * @param tiltRight defines the tilt
  108965. * @returns the current mesh
  108966. */
  108967. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  108968. /**
  108969. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  108970. * Supports definition of mesh facing forward or backward.
  108971. * @param flipBack defines the flip
  108972. * @param twirlClockwise defines the twirl
  108973. * @param tiltRight defines the tilt
  108974. * @returns the new rotation vector
  108975. */
  108976. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  108977. /**
  108978. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108979. * This means the mesh underlying bounding box and sphere are recomputed.
  108980. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108981. * @returns the current mesh
  108982. */
  108983. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  108984. /** @hidden */
  108985. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  108986. /** @hidden */
  108987. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  108988. /** @hidden */
  108989. _updateBoundingInfo(): AbstractMesh;
  108990. /** @hidden */
  108991. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  108992. /** @hidden */
  108993. protected _afterComputeWorldMatrix(): void;
  108994. /** @hidden */
  108995. get _effectiveMesh(): AbstractMesh;
  108996. /**
  108997. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108998. * A mesh is in the frustum if its bounding box intersects the frustum
  108999. * @param frustumPlanes defines the frustum to test
  109000. * @returns true if the mesh is in the frustum planes
  109001. */
  109002. isInFrustum(frustumPlanes: Plane[]): boolean;
  109003. /**
  109004. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109005. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109006. * @param frustumPlanes defines the frustum to test
  109007. * @returns true if the mesh is completely in the frustum planes
  109008. */
  109009. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109010. /**
  109011. * True if the mesh intersects another mesh or a SolidParticle object
  109012. * @param mesh defines a target mesh or SolidParticle to test
  109013. * @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)
  109014. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109015. * @returns true if there is an intersection
  109016. */
  109017. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109018. /**
  109019. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109020. * @param point defines the point to test
  109021. * @returns true if there is an intersection
  109022. */
  109023. intersectsPoint(point: Vector3): boolean;
  109024. /**
  109025. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109026. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109027. */
  109028. get checkCollisions(): boolean;
  109029. set checkCollisions(collisionEnabled: boolean);
  109030. /**
  109031. * Gets Collider object used to compute collisions (not physics)
  109032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109033. */
  109034. get collider(): Nullable<Collider>;
  109035. /**
  109036. * Move the mesh using collision engine
  109037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109038. * @param displacement defines the requested displacement vector
  109039. * @returns the current mesh
  109040. */
  109041. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109042. private _onCollisionPositionChange;
  109043. /** @hidden */
  109044. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109045. /** @hidden */
  109046. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109047. /** @hidden */
  109048. _checkCollision(collider: Collider): AbstractMesh;
  109049. /** @hidden */
  109050. _generatePointsArray(): boolean;
  109051. /**
  109052. * Checks if the passed Ray intersects with the mesh
  109053. * @param ray defines the ray to use
  109054. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109055. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109056. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109057. * @returns the picking info
  109058. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109059. */
  109060. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109061. /**
  109062. * Clones the current mesh
  109063. * @param name defines the mesh name
  109064. * @param newParent defines the new mesh parent
  109065. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109066. * @returns the new mesh
  109067. */
  109068. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109069. /**
  109070. * Disposes all the submeshes of the current meshnp
  109071. * @returns the current mesh
  109072. */
  109073. releaseSubMeshes(): AbstractMesh;
  109074. /**
  109075. * Releases resources associated with this abstract mesh.
  109076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109078. */
  109079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109080. /**
  109081. * Adds the passed mesh as a child to the current mesh
  109082. * @param mesh defines the child mesh
  109083. * @returns the current mesh
  109084. */
  109085. addChild(mesh: AbstractMesh): AbstractMesh;
  109086. /**
  109087. * Removes the passed mesh from the current mesh children list
  109088. * @param mesh defines the child mesh
  109089. * @returns the current mesh
  109090. */
  109091. removeChild(mesh: AbstractMesh): AbstractMesh;
  109092. /** @hidden */
  109093. private _initFacetData;
  109094. /**
  109095. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109096. * This method can be called within the render loop.
  109097. * 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
  109098. * @returns the current mesh
  109099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109100. */
  109101. updateFacetData(): AbstractMesh;
  109102. /**
  109103. * Returns the facetLocalNormals array.
  109104. * The normals are expressed in the mesh local spac
  109105. * @returns an array of Vector3
  109106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109107. */
  109108. getFacetLocalNormals(): Vector3[];
  109109. /**
  109110. * Returns the facetLocalPositions array.
  109111. * The facet positions are expressed in the mesh local space
  109112. * @returns an array of Vector3
  109113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109114. */
  109115. getFacetLocalPositions(): Vector3[];
  109116. /**
  109117. * Returns the facetLocalPartioning array
  109118. * @returns an array of array of numbers
  109119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109120. */
  109121. getFacetLocalPartitioning(): number[][];
  109122. /**
  109123. * Returns the i-th facet position in the world system.
  109124. * This method allocates a new Vector3 per call
  109125. * @param i defines the facet index
  109126. * @returns a new Vector3
  109127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109128. */
  109129. getFacetPosition(i: number): Vector3;
  109130. /**
  109131. * Sets the reference Vector3 with the i-th facet position in the world system
  109132. * @param i defines the facet index
  109133. * @param ref defines the target vector
  109134. * @returns the current mesh
  109135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109136. */
  109137. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109138. /**
  109139. * Returns the i-th facet normal in the world system.
  109140. * This method allocates a new Vector3 per call
  109141. * @param i defines the facet index
  109142. * @returns a new Vector3
  109143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109144. */
  109145. getFacetNormal(i: number): Vector3;
  109146. /**
  109147. * Sets the reference Vector3 with the i-th facet normal in the world system
  109148. * @param i defines the facet index
  109149. * @param ref defines the target vector
  109150. * @returns the current mesh
  109151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109152. */
  109153. getFacetNormalToRef(i: number, ref: Vector3): this;
  109154. /**
  109155. * 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)
  109156. * @param x defines x coordinate
  109157. * @param y defines y coordinate
  109158. * @param z defines z coordinate
  109159. * @returns the array of facet indexes
  109160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109161. */
  109162. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109163. /**
  109164. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109165. * @param projected sets as the (x,y,z) world projection on the facet
  109166. * @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
  109167. * @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
  109168. * @param x defines x coordinate
  109169. * @param y defines y coordinate
  109170. * @param z defines z coordinate
  109171. * @returns the face index if found (or null instead)
  109172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109173. */
  109174. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109175. /**
  109176. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109177. * @param projected sets as the (x,y,z) local projection on the facet
  109178. * @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
  109179. * @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
  109180. * @param x defines x coordinate
  109181. * @param y defines y coordinate
  109182. * @param z defines z coordinate
  109183. * @returns the face index if found (or null instead)
  109184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109185. */
  109186. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109187. /**
  109188. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109189. * @returns the parameters
  109190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109191. */
  109192. getFacetDataParameters(): any;
  109193. /**
  109194. * Disables the feature FacetData and frees the related memory
  109195. * @returns the current mesh
  109196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109197. */
  109198. disableFacetData(): AbstractMesh;
  109199. /**
  109200. * Updates the AbstractMesh indices array
  109201. * @param indices defines the data source
  109202. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109203. * @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)
  109204. * @returns the current mesh
  109205. */
  109206. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109207. /**
  109208. * Creates new normals data for the mesh
  109209. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109210. * @returns the current mesh
  109211. */
  109212. createNormals(updatable: boolean): AbstractMesh;
  109213. /**
  109214. * Align the mesh with a normal
  109215. * @param normal defines the normal to use
  109216. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  109217. * @returns the current mesh
  109218. */
  109219. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  109220. /** @hidden */
  109221. _checkOcclusionQuery(): boolean;
  109222. /**
  109223. * Disables the mesh edge rendering mode
  109224. * @returns the currentAbstractMesh
  109225. */
  109226. disableEdgesRendering(): AbstractMesh;
  109227. /**
  109228. * Enables the edge rendering mode on the mesh.
  109229. * This mode makes the mesh edges visible
  109230. * @param epsilon defines the maximal distance between two angles to detect a face
  109231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109232. * @returns the currentAbstractMesh
  109233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109234. */
  109235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109236. }
  109237. }
  109238. declare module BABYLON {
  109239. /**
  109240. * Interface used to define ActionEvent
  109241. */
  109242. export interface IActionEvent {
  109243. /** The mesh or sprite that triggered the action */
  109244. source: any;
  109245. /** The X mouse cursor position at the time of the event */
  109246. pointerX: number;
  109247. /** The Y mouse cursor position at the time of the event */
  109248. pointerY: number;
  109249. /** The mesh that is currently pointed at (can be null) */
  109250. meshUnderPointer: Nullable<AbstractMesh>;
  109251. /** the original (browser) event that triggered the ActionEvent */
  109252. sourceEvent?: any;
  109253. /** additional data for the event */
  109254. additionalData?: any;
  109255. }
  109256. /**
  109257. * ActionEvent is the event being sent when an action is triggered.
  109258. */
  109259. export class ActionEvent implements IActionEvent {
  109260. /** The mesh or sprite that triggered the action */
  109261. source: any;
  109262. /** The X mouse cursor position at the time of the event */
  109263. pointerX: number;
  109264. /** The Y mouse cursor position at the time of the event */
  109265. pointerY: number;
  109266. /** The mesh that is currently pointed at (can be null) */
  109267. meshUnderPointer: Nullable<AbstractMesh>;
  109268. /** the original (browser) event that triggered the ActionEvent */
  109269. sourceEvent?: any;
  109270. /** additional data for the event */
  109271. additionalData?: any;
  109272. /**
  109273. * Creates a new ActionEvent
  109274. * @param source The mesh or sprite that triggered the action
  109275. * @param pointerX The X mouse cursor position at the time of the event
  109276. * @param pointerY The Y mouse cursor position at the time of the event
  109277. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  109278. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  109279. * @param additionalData additional data for the event
  109280. */
  109281. constructor(
  109282. /** The mesh or sprite that triggered the action */
  109283. source: any,
  109284. /** The X mouse cursor position at the time of the event */
  109285. pointerX: number,
  109286. /** The Y mouse cursor position at the time of the event */
  109287. pointerY: number,
  109288. /** The mesh that is currently pointed at (can be null) */
  109289. meshUnderPointer: Nullable<AbstractMesh>,
  109290. /** the original (browser) event that triggered the ActionEvent */
  109291. sourceEvent?: any,
  109292. /** additional data for the event */
  109293. additionalData?: any);
  109294. /**
  109295. * Helper function to auto-create an ActionEvent from a source mesh.
  109296. * @param source The source mesh that triggered the event
  109297. * @param evt The original (browser) event
  109298. * @param additionalData additional data for the event
  109299. * @returns the new ActionEvent
  109300. */
  109301. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109302. /**
  109303. * Helper function to auto-create an ActionEvent from a source sprite
  109304. * @param source The source sprite that triggered the event
  109305. * @param scene Scene associated with the sprite
  109306. * @param evt The original (browser) event
  109307. * @param additionalData additional data for the event
  109308. * @returns the new ActionEvent
  109309. */
  109310. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109311. /**
  109312. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109313. * @param scene the scene where the event occurred
  109314. * @param evt The original (browser) event
  109315. * @returns the new ActionEvent
  109316. */
  109317. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109318. /**
  109319. * Helper function to auto-create an ActionEvent from a primitive
  109320. * @param prim defines the target primitive
  109321. * @param pointerPos defines the pointer position
  109322. * @param evt The original (browser) event
  109323. * @param additionalData additional data for the event
  109324. * @returns the new ActionEvent
  109325. */
  109326. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109327. }
  109328. }
  109329. declare module BABYLON {
  109330. /**
  109331. * Abstract class used to decouple action Manager from scene and meshes.
  109332. * Do not instantiate.
  109333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109334. */
  109335. export abstract class AbstractActionManager implements IDisposable {
  109336. /** Gets the list of active triggers */
  109337. static Triggers: {
  109338. [key: string]: number;
  109339. };
  109340. /** Gets the cursor to use when hovering items */
  109341. hoverCursor: string;
  109342. /** Gets the list of actions */
  109343. actions: IAction[];
  109344. /**
  109345. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109346. */
  109347. isRecursive: boolean;
  109348. /**
  109349. * Releases all associated resources
  109350. */
  109351. abstract dispose(): void;
  109352. /**
  109353. * Does this action manager has pointer triggers
  109354. */
  109355. abstract get hasPointerTriggers(): boolean;
  109356. /**
  109357. * Does this action manager has pick triggers
  109358. */
  109359. abstract get hasPickTriggers(): boolean;
  109360. /**
  109361. * Process a specific trigger
  109362. * @param trigger defines the trigger to process
  109363. * @param evt defines the event details to be processed
  109364. */
  109365. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109366. /**
  109367. * Does this action manager handles actions of any of the given triggers
  109368. * @param triggers defines the triggers to be tested
  109369. * @return a boolean indicating whether one (or more) of the triggers is handled
  109370. */
  109371. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109372. /**
  109373. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109374. * speed.
  109375. * @param triggerA defines the trigger to be tested
  109376. * @param triggerB defines the trigger to be tested
  109377. * @return a boolean indicating whether one (or more) of the triggers is handled
  109378. */
  109379. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109380. /**
  109381. * Does this action manager handles actions of a given trigger
  109382. * @param trigger defines the trigger to be tested
  109383. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109384. * @return whether the trigger is handled
  109385. */
  109386. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109387. /**
  109388. * Serialize this manager to a JSON object
  109389. * @param name defines the property name to store this manager
  109390. * @returns a JSON representation of this manager
  109391. */
  109392. abstract serialize(name: string): any;
  109393. /**
  109394. * Registers an action to this action manager
  109395. * @param action defines the action to be registered
  109396. * @return the action amended (prepared) after registration
  109397. */
  109398. abstract registerAction(action: IAction): Nullable<IAction>;
  109399. /**
  109400. * Unregisters an action to this action manager
  109401. * @param action defines the action to be unregistered
  109402. * @return a boolean indicating whether the action has been unregistered
  109403. */
  109404. abstract unregisterAction(action: IAction): Boolean;
  109405. /**
  109406. * Does exist one action manager with at least one trigger
  109407. **/
  109408. static get HasTriggers(): boolean;
  109409. /**
  109410. * Does exist one action manager with at least one pick trigger
  109411. **/
  109412. static get HasPickTriggers(): boolean;
  109413. /**
  109414. * Does exist one action manager that handles actions of a given trigger
  109415. * @param trigger defines the trigger to be tested
  109416. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109417. **/
  109418. static HasSpecificTrigger(trigger: number): boolean;
  109419. }
  109420. }
  109421. declare module BABYLON {
  109422. /**
  109423. * Defines how a node can be built from a string name.
  109424. */
  109425. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109426. /**
  109427. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109428. */
  109429. export class Node implements IBehaviorAware<Node> {
  109430. /** @hidden */
  109431. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109432. private static _NodeConstructors;
  109433. /**
  109434. * Add a new node constructor
  109435. * @param type defines the type name of the node to construct
  109436. * @param constructorFunc defines the constructor function
  109437. */
  109438. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109439. /**
  109440. * Returns a node constructor based on type name
  109441. * @param type defines the type name
  109442. * @param name defines the new node name
  109443. * @param scene defines the hosting scene
  109444. * @param options defines optional options to transmit to constructors
  109445. * @returns the new constructor or null
  109446. */
  109447. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109448. /**
  109449. * Gets or sets the name of the node
  109450. */
  109451. name: string;
  109452. /**
  109453. * Gets or sets the id of the node
  109454. */
  109455. id: string;
  109456. /**
  109457. * Gets or sets the unique id of the node
  109458. */
  109459. uniqueId: number;
  109460. /**
  109461. * Gets or sets a string used to store user defined state for the node
  109462. */
  109463. state: string;
  109464. /**
  109465. * Gets or sets an object used to store user defined information for the node
  109466. */
  109467. metadata: any;
  109468. /**
  109469. * For internal use only. Please do not use.
  109470. */
  109471. reservedDataStore: any;
  109472. /**
  109473. * List of inspectable custom properties (used by the Inspector)
  109474. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109475. */
  109476. inspectableCustomProperties: IInspectable[];
  109477. private _doNotSerialize;
  109478. /**
  109479. * Gets or sets a boolean used to define if the node must be serialized
  109480. */
  109481. get doNotSerialize(): boolean;
  109482. set doNotSerialize(value: boolean);
  109483. /** @hidden */
  109484. _isDisposed: boolean;
  109485. /**
  109486. * Gets a list of Animations associated with the node
  109487. */
  109488. animations: Animation[];
  109489. protected _ranges: {
  109490. [name: string]: Nullable<AnimationRange>;
  109491. };
  109492. /**
  109493. * Callback raised when the node is ready to be used
  109494. */
  109495. onReady: Nullable<(node: Node) => void>;
  109496. private _isEnabled;
  109497. private _isParentEnabled;
  109498. private _isReady;
  109499. /** @hidden */
  109500. _currentRenderId: number;
  109501. private _parentUpdateId;
  109502. /** @hidden */
  109503. _childUpdateId: number;
  109504. /** @hidden */
  109505. _waitingParentId: Nullable<string>;
  109506. /** @hidden */
  109507. _scene: Scene;
  109508. /** @hidden */
  109509. _cache: any;
  109510. private _parentNode;
  109511. private _children;
  109512. /** @hidden */
  109513. _worldMatrix: Matrix;
  109514. /** @hidden */
  109515. _worldMatrixDeterminant: number;
  109516. /** @hidden */
  109517. _worldMatrixDeterminantIsDirty: boolean;
  109518. /** @hidden */
  109519. private _sceneRootNodesIndex;
  109520. /**
  109521. * Gets a boolean indicating if the node has been disposed
  109522. * @returns true if the node was disposed
  109523. */
  109524. isDisposed(): boolean;
  109525. /**
  109526. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109527. * @see https://doc.babylonjs.com/how_to/parenting
  109528. */
  109529. set parent(parent: Nullable<Node>);
  109530. get parent(): Nullable<Node>;
  109531. /** @hidden */
  109532. _addToSceneRootNodes(): void;
  109533. /** @hidden */
  109534. _removeFromSceneRootNodes(): void;
  109535. private _animationPropertiesOverride;
  109536. /**
  109537. * Gets or sets the animation properties override
  109538. */
  109539. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109540. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109541. /**
  109542. * Gets a string idenfifying the name of the class
  109543. * @returns "Node" string
  109544. */
  109545. getClassName(): string;
  109546. /** @hidden */
  109547. readonly _isNode: boolean;
  109548. /**
  109549. * An event triggered when the mesh is disposed
  109550. */
  109551. onDisposeObservable: Observable<Node>;
  109552. private _onDisposeObserver;
  109553. /**
  109554. * Sets a callback that will be raised when the node will be disposed
  109555. */
  109556. set onDispose(callback: () => void);
  109557. /**
  109558. * Creates a new Node
  109559. * @param name the name and id to be given to this node
  109560. * @param scene the scene this node will be added to
  109561. */
  109562. constructor(name: string, scene?: Nullable<Scene>);
  109563. /**
  109564. * Gets the scene of the node
  109565. * @returns a scene
  109566. */
  109567. getScene(): Scene;
  109568. /**
  109569. * Gets the engine of the node
  109570. * @returns a Engine
  109571. */
  109572. getEngine(): Engine;
  109573. private _behaviors;
  109574. /**
  109575. * Attach a behavior to the node
  109576. * @see http://doc.babylonjs.com/features/behaviour
  109577. * @param behavior defines the behavior to attach
  109578. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109579. * @returns the current Node
  109580. */
  109581. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109582. /**
  109583. * Remove an attached behavior
  109584. * @see http://doc.babylonjs.com/features/behaviour
  109585. * @param behavior defines the behavior to attach
  109586. * @returns the current Node
  109587. */
  109588. removeBehavior(behavior: Behavior<Node>): Node;
  109589. /**
  109590. * Gets the list of attached behaviors
  109591. * @see http://doc.babylonjs.com/features/behaviour
  109592. */
  109593. get behaviors(): Behavior<Node>[];
  109594. /**
  109595. * Gets an attached behavior by name
  109596. * @param name defines the name of the behavior to look for
  109597. * @see http://doc.babylonjs.com/features/behaviour
  109598. * @returns null if behavior was not found else the requested behavior
  109599. */
  109600. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109601. /**
  109602. * Returns the latest update of the World matrix
  109603. * @returns a Matrix
  109604. */
  109605. getWorldMatrix(): Matrix;
  109606. /** @hidden */
  109607. _getWorldMatrixDeterminant(): number;
  109608. /**
  109609. * Returns directly the latest state of the mesh World matrix.
  109610. * A Matrix is returned.
  109611. */
  109612. get worldMatrixFromCache(): Matrix;
  109613. /** @hidden */
  109614. _initCache(): void;
  109615. /** @hidden */
  109616. updateCache(force?: boolean): void;
  109617. /** @hidden */
  109618. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109619. /** @hidden */
  109620. _updateCache(ignoreParentClass?: boolean): void;
  109621. /** @hidden */
  109622. _isSynchronized(): boolean;
  109623. /** @hidden */
  109624. _markSyncedWithParent(): void;
  109625. /** @hidden */
  109626. isSynchronizedWithParent(): boolean;
  109627. /** @hidden */
  109628. isSynchronized(): boolean;
  109629. /**
  109630. * Is this node ready to be used/rendered
  109631. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109632. * @return true if the node is ready
  109633. */
  109634. isReady(completeCheck?: boolean): boolean;
  109635. /**
  109636. * Is this node enabled?
  109637. * 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
  109638. * @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
  109639. * @return whether this node (and its parent) is enabled
  109640. */
  109641. isEnabled(checkAncestors?: boolean): boolean;
  109642. /** @hidden */
  109643. protected _syncParentEnabledState(): void;
  109644. /**
  109645. * Set the enabled state of this node
  109646. * @param value defines the new enabled state
  109647. */
  109648. setEnabled(value: boolean): void;
  109649. /**
  109650. * Is this node a descendant of the given node?
  109651. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109652. * @param ancestor defines the parent node to inspect
  109653. * @returns a boolean indicating if this node is a descendant of the given node
  109654. */
  109655. isDescendantOf(ancestor: Node): boolean;
  109656. /** @hidden */
  109657. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109658. /**
  109659. * Will return all nodes that have this node as ascendant
  109660. * @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
  109661. * @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
  109662. * @return all children nodes of all types
  109663. */
  109664. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109665. /**
  109666. * Get all child-meshes of this node
  109667. * @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)
  109668. * @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
  109669. * @returns an array of AbstractMesh
  109670. */
  109671. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109672. /**
  109673. * Get all direct children of this node
  109674. * @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
  109675. * @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)
  109676. * @returns an array of Node
  109677. */
  109678. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109679. /** @hidden */
  109680. _setReady(state: boolean): void;
  109681. /**
  109682. * Get an animation by name
  109683. * @param name defines the name of the animation to look for
  109684. * @returns null if not found else the requested animation
  109685. */
  109686. getAnimationByName(name: string): Nullable<Animation>;
  109687. /**
  109688. * Creates an animation range for this node
  109689. * @param name defines the name of the range
  109690. * @param from defines the starting key
  109691. * @param to defines the end key
  109692. */
  109693. createAnimationRange(name: string, from: number, to: number): void;
  109694. /**
  109695. * Delete a specific animation range
  109696. * @param name defines the name of the range to delete
  109697. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109698. */
  109699. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109700. /**
  109701. * Get an animation range by name
  109702. * @param name defines the name of the animation range to look for
  109703. * @returns null if not found else the requested animation range
  109704. */
  109705. getAnimationRange(name: string): Nullable<AnimationRange>;
  109706. /**
  109707. * Gets the list of all animation ranges defined on this node
  109708. * @returns an array
  109709. */
  109710. getAnimationRanges(): Nullable<AnimationRange>[];
  109711. /**
  109712. * Will start the animation sequence
  109713. * @param name defines the range frames for animation sequence
  109714. * @param loop defines if the animation should loop (false by default)
  109715. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109716. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109717. * @returns the object created for this animation. If range does not exist, it will return null
  109718. */
  109719. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109720. /**
  109721. * Serialize animation ranges into a JSON compatible object
  109722. * @returns serialization object
  109723. */
  109724. serializeAnimationRanges(): any;
  109725. /**
  109726. * Computes the world matrix of the node
  109727. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109728. * @returns the world matrix
  109729. */
  109730. computeWorldMatrix(force?: boolean): Matrix;
  109731. /**
  109732. * Releases resources associated with this node.
  109733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109735. */
  109736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109737. /**
  109738. * Parse animation range data from a serialization object and store them into a given node
  109739. * @param node defines where to store the animation ranges
  109740. * @param parsedNode defines the serialization object to read data from
  109741. * @param scene defines the hosting scene
  109742. */
  109743. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109744. /**
  109745. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109746. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109747. * @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
  109748. * @returns the new bounding vectors
  109749. */
  109750. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  109751. min: Vector3;
  109752. max: Vector3;
  109753. };
  109754. }
  109755. }
  109756. declare module BABYLON {
  109757. /**
  109758. * @hidden
  109759. */
  109760. export class _IAnimationState {
  109761. key: number;
  109762. repeatCount: number;
  109763. workValue?: any;
  109764. loopMode?: number;
  109765. offsetValue?: any;
  109766. highLimitValue?: any;
  109767. }
  109768. /**
  109769. * Class used to store any kind of animation
  109770. */
  109771. export class Animation {
  109772. /**Name of the animation */
  109773. name: string;
  109774. /**Property to animate */
  109775. targetProperty: string;
  109776. /**The frames per second of the animation */
  109777. framePerSecond: number;
  109778. /**The data type of the animation */
  109779. dataType: number;
  109780. /**The loop mode of the animation */
  109781. loopMode?: number | undefined;
  109782. /**Specifies if blending should be enabled */
  109783. enableBlending?: boolean | undefined;
  109784. /**
  109785. * Use matrix interpolation instead of using direct key value when animating matrices
  109786. */
  109787. static AllowMatricesInterpolation: boolean;
  109788. /**
  109789. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  109790. */
  109791. static AllowMatrixDecomposeForInterpolation: boolean;
  109792. /** Define the Url to load snippets */
  109793. static SnippetUrl: string;
  109794. /** Snippet ID if the animation was created from the snippet server */
  109795. snippetId: string;
  109796. /**
  109797. * Stores the key frames of the animation
  109798. */
  109799. private _keys;
  109800. /**
  109801. * Stores the easing function of the animation
  109802. */
  109803. private _easingFunction;
  109804. /**
  109805. * @hidden Internal use only
  109806. */
  109807. _runtimeAnimations: RuntimeAnimation[];
  109808. /**
  109809. * The set of event that will be linked to this animation
  109810. */
  109811. private _events;
  109812. /**
  109813. * Stores an array of target property paths
  109814. */
  109815. targetPropertyPath: string[];
  109816. /**
  109817. * Stores the blending speed of the animation
  109818. */
  109819. blendingSpeed: number;
  109820. /**
  109821. * Stores the animation ranges for the animation
  109822. */
  109823. private _ranges;
  109824. /**
  109825. * @hidden Internal use
  109826. */
  109827. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  109828. /**
  109829. * Sets up an animation
  109830. * @param property The property to animate
  109831. * @param animationType The animation type to apply
  109832. * @param framePerSecond The frames per second of the animation
  109833. * @param easingFunction The easing function used in the animation
  109834. * @returns The created animation
  109835. */
  109836. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  109837. /**
  109838. * Create and start an animation on a node
  109839. * @param name defines the name of the global animation that will be run on all nodes
  109840. * @param node defines the root node where the animation will take place
  109841. * @param targetProperty defines property to animate
  109842. * @param framePerSecond defines the number of frame per second yo use
  109843. * @param totalFrame defines the number of frames in total
  109844. * @param from defines the initial value
  109845. * @param to defines the final value
  109846. * @param loopMode defines which loop mode you want to use (off by default)
  109847. * @param easingFunction defines the easing function to use (linear by default)
  109848. * @param onAnimationEnd defines the callback to call when animation end
  109849. * @returns the animatable created for this animation
  109850. */
  109851. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109852. /**
  109853. * Create and start an animation on a node and its descendants
  109854. * @param name defines the name of the global animation that will be run on all nodes
  109855. * @param node defines the root node where the animation will take place
  109856. * @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
  109857. * @param targetProperty defines property to animate
  109858. * @param framePerSecond defines the number of frame per second to use
  109859. * @param totalFrame defines the number of frames in total
  109860. * @param from defines the initial value
  109861. * @param to defines the final value
  109862. * @param loopMode defines which loop mode you want to use (off by default)
  109863. * @param easingFunction defines the easing function to use (linear by default)
  109864. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  109865. * @returns the list of animatables created for all nodes
  109866. * @example https://www.babylonjs-playground.com/#MH0VLI
  109867. */
  109868. 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[]>;
  109869. /**
  109870. * Creates a new animation, merges it with the existing animations and starts it
  109871. * @param name Name of the animation
  109872. * @param node Node which contains the scene that begins the animations
  109873. * @param targetProperty Specifies which property to animate
  109874. * @param framePerSecond The frames per second of the animation
  109875. * @param totalFrame The total number of frames
  109876. * @param from The frame at the beginning of the animation
  109877. * @param to The frame at the end of the animation
  109878. * @param loopMode Specifies the loop mode of the animation
  109879. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  109880. * @param onAnimationEnd Callback to run once the animation is complete
  109881. * @returns Nullable animation
  109882. */
  109883. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  109884. /**
  109885. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109886. * @param sourceAnimation defines the Animation containing keyframes to convert
  109887. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109888. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  109889. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  109890. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  109891. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  109892. */
  109893. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  109894. /**
  109895. * Transition property of an host to the target Value
  109896. * @param property The property to transition
  109897. * @param targetValue The target Value of the property
  109898. * @param host The object where the property to animate belongs
  109899. * @param scene Scene used to run the animation
  109900. * @param frameRate Framerate (in frame/s) to use
  109901. * @param transition The transition type we want to use
  109902. * @param duration The duration of the animation, in milliseconds
  109903. * @param onAnimationEnd Callback trigger at the end of the animation
  109904. * @returns Nullable animation
  109905. */
  109906. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  109907. /**
  109908. * Return the array of runtime animations currently using this animation
  109909. */
  109910. get runtimeAnimations(): RuntimeAnimation[];
  109911. /**
  109912. * Specifies if any of the runtime animations are currently running
  109913. */
  109914. get hasRunningRuntimeAnimations(): boolean;
  109915. /**
  109916. * Initializes the animation
  109917. * @param name Name of the animation
  109918. * @param targetProperty Property to animate
  109919. * @param framePerSecond The frames per second of the animation
  109920. * @param dataType The data type of the animation
  109921. * @param loopMode The loop mode of the animation
  109922. * @param enableBlending Specifies if blending should be enabled
  109923. */
  109924. constructor(
  109925. /**Name of the animation */
  109926. name: string,
  109927. /**Property to animate */
  109928. targetProperty: string,
  109929. /**The frames per second of the animation */
  109930. framePerSecond: number,
  109931. /**The data type of the animation */
  109932. dataType: number,
  109933. /**The loop mode of the animation */
  109934. loopMode?: number | undefined,
  109935. /**Specifies if blending should be enabled */
  109936. enableBlending?: boolean | undefined);
  109937. /**
  109938. * Converts the animation to a string
  109939. * @param fullDetails support for multiple levels of logging within scene loading
  109940. * @returns String form of the animation
  109941. */
  109942. toString(fullDetails?: boolean): string;
  109943. /**
  109944. * Add an event to this animation
  109945. * @param event Event to add
  109946. */
  109947. addEvent(event: AnimationEvent): void;
  109948. /**
  109949. * Remove all events found at the given frame
  109950. * @param frame The frame to remove events from
  109951. */
  109952. removeEvents(frame: number): void;
  109953. /**
  109954. * Retrieves all the events from the animation
  109955. * @returns Events from the animation
  109956. */
  109957. getEvents(): AnimationEvent[];
  109958. /**
  109959. * Creates an animation range
  109960. * @param name Name of the animation range
  109961. * @param from Starting frame of the animation range
  109962. * @param to Ending frame of the animation
  109963. */
  109964. createRange(name: string, from: number, to: number): void;
  109965. /**
  109966. * Deletes an animation range by name
  109967. * @param name Name of the animation range to delete
  109968. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  109969. */
  109970. deleteRange(name: string, deleteFrames?: boolean): void;
  109971. /**
  109972. * Gets the animation range by name, or null if not defined
  109973. * @param name Name of the animation range
  109974. * @returns Nullable animation range
  109975. */
  109976. getRange(name: string): Nullable<AnimationRange>;
  109977. /**
  109978. * Gets the key frames from the animation
  109979. * @returns The key frames of the animation
  109980. */
  109981. getKeys(): Array<IAnimationKey>;
  109982. /**
  109983. * Gets the highest frame rate of the animation
  109984. * @returns Highest frame rate of the animation
  109985. */
  109986. getHighestFrame(): number;
  109987. /**
  109988. * Gets the easing function of the animation
  109989. * @returns Easing function of the animation
  109990. */
  109991. getEasingFunction(): IEasingFunction;
  109992. /**
  109993. * Sets the easing function of the animation
  109994. * @param easingFunction A custom mathematical formula for animation
  109995. */
  109996. setEasingFunction(easingFunction: EasingFunction): void;
  109997. /**
  109998. * Interpolates a scalar linearly
  109999. * @param startValue Start value of the animation curve
  110000. * @param endValue End value of the animation curve
  110001. * @param gradient Scalar amount to interpolate
  110002. * @returns Interpolated scalar value
  110003. */
  110004. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110005. /**
  110006. * Interpolates a scalar cubically
  110007. * @param startValue Start value of the animation curve
  110008. * @param outTangent End tangent of the animation
  110009. * @param endValue End value of the animation curve
  110010. * @param inTangent Start tangent of the animation curve
  110011. * @param gradient Scalar amount to interpolate
  110012. * @returns Interpolated scalar value
  110013. */
  110014. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110015. /**
  110016. * Interpolates a quaternion using a spherical linear interpolation
  110017. * @param startValue Start value of the animation curve
  110018. * @param endValue End value of the animation curve
  110019. * @param gradient Scalar amount to interpolate
  110020. * @returns Interpolated quaternion value
  110021. */
  110022. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110023. /**
  110024. * Interpolates a quaternion cubically
  110025. * @param startValue Start value of the animation curve
  110026. * @param outTangent End tangent of the animation curve
  110027. * @param endValue End value of the animation curve
  110028. * @param inTangent Start tangent of the animation curve
  110029. * @param gradient Scalar amount to interpolate
  110030. * @returns Interpolated quaternion value
  110031. */
  110032. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110033. /**
  110034. * Interpolates a Vector3 linearl
  110035. * @param startValue Start value of the animation curve
  110036. * @param endValue End value of the animation curve
  110037. * @param gradient Scalar amount to interpolate
  110038. * @returns Interpolated scalar value
  110039. */
  110040. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110041. /**
  110042. * Interpolates a Vector3 cubically
  110043. * @param startValue Start value of the animation curve
  110044. * @param outTangent End tangent of the animation
  110045. * @param endValue End value of the animation curve
  110046. * @param inTangent Start tangent of the animation curve
  110047. * @param gradient Scalar amount to interpolate
  110048. * @returns InterpolatedVector3 value
  110049. */
  110050. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110051. /**
  110052. * Interpolates a Vector2 linearly
  110053. * @param startValue Start value of the animation curve
  110054. * @param endValue End value of the animation curve
  110055. * @param gradient Scalar amount to interpolate
  110056. * @returns Interpolated Vector2 value
  110057. */
  110058. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110059. /**
  110060. * Interpolates a Vector2 cubically
  110061. * @param startValue Start value of the animation curve
  110062. * @param outTangent End tangent of the animation
  110063. * @param endValue End value of the animation curve
  110064. * @param inTangent Start tangent of the animation curve
  110065. * @param gradient Scalar amount to interpolate
  110066. * @returns Interpolated Vector2 value
  110067. */
  110068. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110069. /**
  110070. * Interpolates a size linearly
  110071. * @param startValue Start value of the animation curve
  110072. * @param endValue End value of the animation curve
  110073. * @param gradient Scalar amount to interpolate
  110074. * @returns Interpolated Size value
  110075. */
  110076. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110077. /**
  110078. * Interpolates a Color3 linearly
  110079. * @param startValue Start value of the animation curve
  110080. * @param endValue End value of the animation curve
  110081. * @param gradient Scalar amount to interpolate
  110082. * @returns Interpolated Color3 value
  110083. */
  110084. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110085. /**
  110086. * Interpolates a Color4 linearly
  110087. * @param startValue Start value of the animation curve
  110088. * @param endValue End value of the animation curve
  110089. * @param gradient Scalar amount to interpolate
  110090. * @returns Interpolated Color3 value
  110091. */
  110092. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110093. /**
  110094. * @hidden Internal use only
  110095. */
  110096. _getKeyValue(value: any): any;
  110097. /**
  110098. * @hidden Internal use only
  110099. */
  110100. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110101. /**
  110102. * Defines the function to use to interpolate matrices
  110103. * @param startValue defines the start matrix
  110104. * @param endValue defines the end matrix
  110105. * @param gradient defines the gradient between both matrices
  110106. * @param result defines an optional target matrix where to store the interpolation
  110107. * @returns the interpolated matrix
  110108. */
  110109. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110110. /**
  110111. * Makes a copy of the animation
  110112. * @returns Cloned animation
  110113. */
  110114. clone(): Animation;
  110115. /**
  110116. * Sets the key frames of the animation
  110117. * @param values The animation key frames to set
  110118. */
  110119. setKeys(values: Array<IAnimationKey>): void;
  110120. /**
  110121. * Serializes the animation to an object
  110122. * @returns Serialized object
  110123. */
  110124. serialize(): any;
  110125. /**
  110126. * Float animation type
  110127. */
  110128. static readonly ANIMATIONTYPE_FLOAT: number;
  110129. /**
  110130. * Vector3 animation type
  110131. */
  110132. static readonly ANIMATIONTYPE_VECTOR3: number;
  110133. /**
  110134. * Quaternion animation type
  110135. */
  110136. static readonly ANIMATIONTYPE_QUATERNION: number;
  110137. /**
  110138. * Matrix animation type
  110139. */
  110140. static readonly ANIMATIONTYPE_MATRIX: number;
  110141. /**
  110142. * Color3 animation type
  110143. */
  110144. static readonly ANIMATIONTYPE_COLOR3: number;
  110145. /**
  110146. * Color3 animation type
  110147. */
  110148. static readonly ANIMATIONTYPE_COLOR4: number;
  110149. /**
  110150. * Vector2 animation type
  110151. */
  110152. static readonly ANIMATIONTYPE_VECTOR2: number;
  110153. /**
  110154. * Size animation type
  110155. */
  110156. static readonly ANIMATIONTYPE_SIZE: number;
  110157. /**
  110158. * Relative Loop Mode
  110159. */
  110160. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110161. /**
  110162. * Cycle Loop Mode
  110163. */
  110164. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110165. /**
  110166. * Constant Loop Mode
  110167. */
  110168. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110169. /** @hidden */
  110170. static _UniversalLerp(left: any, right: any, amount: number): any;
  110171. /**
  110172. * Parses an animation object and creates an animation
  110173. * @param parsedAnimation Parsed animation object
  110174. * @returns Animation object
  110175. */
  110176. static Parse(parsedAnimation: any): Animation;
  110177. /**
  110178. * Appends the serialized animations from the source animations
  110179. * @param source Source containing the animations
  110180. * @param destination Target to store the animations
  110181. */
  110182. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110183. /**
  110184. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110185. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110186. * @param url defines the url to load from
  110187. * @returns a promise that will resolve to the new animation or an array of animations
  110188. */
  110189. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110190. /**
  110191. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110192. * @param snippetId defines the snippet to load
  110193. * @returns a promise that will resolve to the new animation or a new array of animations
  110194. */
  110195. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110196. }
  110197. }
  110198. declare module BABYLON {
  110199. /**
  110200. * Interface containing an array of animations
  110201. */
  110202. export interface IAnimatable {
  110203. /**
  110204. * Array of animations
  110205. */
  110206. animations: Nullable<Array<Animation>>;
  110207. }
  110208. }
  110209. declare module BABYLON {
  110210. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  110211. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110212. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110213. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110214. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110215. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110216. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110217. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110218. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110219. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110220. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110221. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110222. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110223. /**
  110224. * Decorator used to define property that can be serialized as reference to a camera
  110225. * @param sourceName defines the name of the property to decorate
  110226. */
  110227. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110228. /**
  110229. * Class used to help serialization objects
  110230. */
  110231. export class SerializationHelper {
  110232. /** @hidden */
  110233. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  110234. /** @hidden */
  110235. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  110236. /** @hidden */
  110237. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  110238. /** @hidden */
  110239. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  110240. /**
  110241. * Appends the serialized animations from the source animations
  110242. * @param source Source containing the animations
  110243. * @param destination Target to store the animations
  110244. */
  110245. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110246. /**
  110247. * Static function used to serialized a specific entity
  110248. * @param entity defines the entity to serialize
  110249. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  110250. * @returns a JSON compatible object representing the serialization of the entity
  110251. */
  110252. static Serialize<T>(entity: T, serializationObject?: any): any;
  110253. /**
  110254. * Creates a new entity from a serialization data object
  110255. * @param creationFunction defines a function used to instanciated the new entity
  110256. * @param source defines the source serialization data
  110257. * @param scene defines the hosting scene
  110258. * @param rootUrl defines the root url for resources
  110259. * @returns a new entity
  110260. */
  110261. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  110262. /**
  110263. * Clones an object
  110264. * @param creationFunction defines the function used to instanciate the new object
  110265. * @param source defines the source object
  110266. * @returns the cloned object
  110267. */
  110268. static Clone<T>(creationFunction: () => T, source: T): T;
  110269. /**
  110270. * Instanciates a new object based on a source one (some data will be shared between both object)
  110271. * @param creationFunction defines the function used to instanciate the new object
  110272. * @param source defines the source object
  110273. * @returns the new object
  110274. */
  110275. static Instanciate<T>(creationFunction: () => T, source: T): T;
  110276. }
  110277. }
  110278. declare module BABYLON {
  110279. /**
  110280. * Base class of all the textures in babylon.
  110281. * It groups all the common properties the materials, post process, lights... might need
  110282. * in order to make a correct use of the texture.
  110283. */
  110284. export class BaseTexture implements IAnimatable {
  110285. /**
  110286. * Default anisotropic filtering level for the application.
  110287. * It is set to 4 as a good tradeoff between perf and quality.
  110288. */
  110289. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  110290. /**
  110291. * Gets or sets the unique id of the texture
  110292. */
  110293. uniqueId: number;
  110294. /**
  110295. * Define the name of the texture.
  110296. */
  110297. name: string;
  110298. /**
  110299. * Gets or sets an object used to store user defined information.
  110300. */
  110301. metadata: any;
  110302. /**
  110303. * For internal use only. Please do not use.
  110304. */
  110305. reservedDataStore: any;
  110306. private _hasAlpha;
  110307. /**
  110308. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110309. */
  110310. set hasAlpha(value: boolean);
  110311. get hasAlpha(): boolean;
  110312. /**
  110313. * Defines if the alpha value should be determined via the rgb values.
  110314. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110315. */
  110316. getAlphaFromRGB: boolean;
  110317. /**
  110318. * Intensity or strength of the texture.
  110319. * It is commonly used by materials to fine tune the intensity of the texture
  110320. */
  110321. level: number;
  110322. /**
  110323. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110324. * This is part of the texture as textures usually maps to one uv set.
  110325. */
  110326. coordinatesIndex: number;
  110327. private _coordinatesMode;
  110328. /**
  110329. * How a texture is mapped.
  110330. *
  110331. * | Value | Type | Description |
  110332. * | ----- | ----------------------------------- | ----------- |
  110333. * | 0 | EXPLICIT_MODE | |
  110334. * | 1 | SPHERICAL_MODE | |
  110335. * | 2 | PLANAR_MODE | |
  110336. * | 3 | CUBIC_MODE | |
  110337. * | 4 | PROJECTION_MODE | |
  110338. * | 5 | SKYBOX_MODE | |
  110339. * | 6 | INVCUBIC_MODE | |
  110340. * | 7 | EQUIRECTANGULAR_MODE | |
  110341. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110342. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110343. */
  110344. set coordinatesMode(value: number);
  110345. get coordinatesMode(): number;
  110346. /**
  110347. * | Value | Type | Description |
  110348. * | ----- | ------------------ | ----------- |
  110349. * | 0 | CLAMP_ADDRESSMODE | |
  110350. * | 1 | WRAP_ADDRESSMODE | |
  110351. * | 2 | MIRROR_ADDRESSMODE | |
  110352. */
  110353. wrapU: number;
  110354. /**
  110355. * | Value | Type | Description |
  110356. * | ----- | ------------------ | ----------- |
  110357. * | 0 | CLAMP_ADDRESSMODE | |
  110358. * | 1 | WRAP_ADDRESSMODE | |
  110359. * | 2 | MIRROR_ADDRESSMODE | |
  110360. */
  110361. wrapV: number;
  110362. /**
  110363. * | Value | Type | Description |
  110364. * | ----- | ------------------ | ----------- |
  110365. * | 0 | CLAMP_ADDRESSMODE | |
  110366. * | 1 | WRAP_ADDRESSMODE | |
  110367. * | 2 | MIRROR_ADDRESSMODE | |
  110368. */
  110369. wrapR: number;
  110370. /**
  110371. * With compliant hardware and browser (supporting anisotropic filtering)
  110372. * this defines the level of anisotropic filtering in the texture.
  110373. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110374. */
  110375. anisotropicFilteringLevel: number;
  110376. /**
  110377. * Define if the texture is a cube texture or if false a 2d texture.
  110378. */
  110379. get isCube(): boolean;
  110380. set isCube(value: boolean);
  110381. /**
  110382. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110383. */
  110384. get is3D(): boolean;
  110385. set is3D(value: boolean);
  110386. /**
  110387. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110388. */
  110389. get is2DArray(): boolean;
  110390. set is2DArray(value: boolean);
  110391. /**
  110392. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110393. * HDR texture are usually stored in linear space.
  110394. * This only impacts the PBR and Background materials
  110395. */
  110396. gammaSpace: boolean;
  110397. /**
  110398. * Gets or sets whether or not the texture contains RGBD data.
  110399. */
  110400. get isRGBD(): boolean;
  110401. set isRGBD(value: boolean);
  110402. /**
  110403. * Is Z inverted in the texture (useful in a cube texture).
  110404. */
  110405. invertZ: boolean;
  110406. /**
  110407. * Are mip maps generated for this texture or not.
  110408. */
  110409. get noMipmap(): boolean;
  110410. /**
  110411. * @hidden
  110412. */
  110413. lodLevelInAlpha: boolean;
  110414. /**
  110415. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110416. */
  110417. get lodGenerationOffset(): number;
  110418. set lodGenerationOffset(value: number);
  110419. /**
  110420. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110421. */
  110422. get lodGenerationScale(): number;
  110423. set lodGenerationScale(value: number);
  110424. /**
  110425. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110426. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110427. * average roughness values.
  110428. */
  110429. get linearSpecularLOD(): boolean;
  110430. set linearSpecularLOD(value: boolean);
  110431. /**
  110432. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110433. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110434. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110435. */
  110436. get irradianceTexture(): Nullable<BaseTexture>;
  110437. set irradianceTexture(value: Nullable<BaseTexture>);
  110438. /**
  110439. * Define if the texture is a render target.
  110440. */
  110441. isRenderTarget: boolean;
  110442. /**
  110443. * Define the unique id of the texture in the scene.
  110444. */
  110445. get uid(): string;
  110446. /** @hidden */
  110447. _prefiltered: boolean;
  110448. /**
  110449. * Return a string representation of the texture.
  110450. * @returns the texture as a string
  110451. */
  110452. toString(): string;
  110453. /**
  110454. * Get the class name of the texture.
  110455. * @returns "BaseTexture"
  110456. */
  110457. getClassName(): string;
  110458. /**
  110459. * Define the list of animation attached to the texture.
  110460. */
  110461. animations: Animation[];
  110462. /**
  110463. * An event triggered when the texture is disposed.
  110464. */
  110465. onDisposeObservable: Observable<BaseTexture>;
  110466. private _onDisposeObserver;
  110467. /**
  110468. * Callback triggered when the texture has been disposed.
  110469. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110470. */
  110471. set onDispose(callback: () => void);
  110472. /**
  110473. * Define the current state of the loading sequence when in delayed load mode.
  110474. */
  110475. delayLoadState: number;
  110476. private _scene;
  110477. private _engine;
  110478. /** @hidden */
  110479. _texture: Nullable<InternalTexture>;
  110480. private _uid;
  110481. /**
  110482. * Define if the texture is preventinga material to render or not.
  110483. * If not and the texture is not ready, the engine will use a default black texture instead.
  110484. */
  110485. get isBlocking(): boolean;
  110486. /**
  110487. * Instantiates a new BaseTexture.
  110488. * Base class of all the textures in babylon.
  110489. * It groups all the common properties the materials, post process, lights... might need
  110490. * in order to make a correct use of the texture.
  110491. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110492. */
  110493. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110494. /**
  110495. * Get the scene the texture belongs to.
  110496. * @returns the scene or null if undefined
  110497. */
  110498. getScene(): Nullable<Scene>;
  110499. /** @hidden */
  110500. protected _getEngine(): Nullable<ThinEngine>;
  110501. /**
  110502. * Get the texture transform matrix used to offset tile the texture for istance.
  110503. * @returns the transformation matrix
  110504. */
  110505. getTextureMatrix(): Matrix;
  110506. /**
  110507. * Get the texture reflection matrix used to rotate/transform the reflection.
  110508. * @returns the reflection matrix
  110509. */
  110510. getReflectionTextureMatrix(): Matrix;
  110511. /**
  110512. * Get the underlying lower level texture from Babylon.
  110513. * @returns the insternal texture
  110514. */
  110515. getInternalTexture(): Nullable<InternalTexture>;
  110516. /**
  110517. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110518. * @returns true if ready or not blocking
  110519. */
  110520. isReadyOrNotBlocking(): boolean;
  110521. /**
  110522. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110523. * @returns true if fully ready
  110524. */
  110525. isReady(): boolean;
  110526. private _cachedSize;
  110527. /**
  110528. * Get the size of the texture.
  110529. * @returns the texture size.
  110530. */
  110531. getSize(): ISize;
  110532. /**
  110533. * Get the base size of the texture.
  110534. * It can be different from the size if the texture has been resized for POT for instance
  110535. * @returns the base size
  110536. */
  110537. getBaseSize(): ISize;
  110538. /**
  110539. * Update the sampling mode of the texture.
  110540. * Default is Trilinear mode.
  110541. *
  110542. * | Value | Type | Description |
  110543. * | ----- | ------------------ | ----------- |
  110544. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110545. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110546. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110547. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110548. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110549. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110550. * | 7 | NEAREST_LINEAR | |
  110551. * | 8 | NEAREST_NEAREST | |
  110552. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110553. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110554. * | 11 | LINEAR_LINEAR | |
  110555. * | 12 | LINEAR_NEAREST | |
  110556. *
  110557. * > _mag_: magnification filter (close to the viewer)
  110558. * > _min_: minification filter (far from the viewer)
  110559. * > _mip_: filter used between mip map levels
  110560. *@param samplingMode Define the new sampling mode of the texture
  110561. */
  110562. updateSamplingMode(samplingMode: number): void;
  110563. /**
  110564. * Scales the texture if is `canRescale()`
  110565. * @param ratio the resize factor we want to use to rescale
  110566. */
  110567. scale(ratio: number): void;
  110568. /**
  110569. * Get if the texture can rescale.
  110570. */
  110571. get canRescale(): boolean;
  110572. /** @hidden */
  110573. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110574. /** @hidden */
  110575. _rebuild(): void;
  110576. /**
  110577. * Triggers the load sequence in delayed load mode.
  110578. */
  110579. delayLoad(): void;
  110580. /**
  110581. * Clones the texture.
  110582. * @returns the cloned texture
  110583. */
  110584. clone(): Nullable<BaseTexture>;
  110585. /**
  110586. * Get the texture underlying type (INT, FLOAT...)
  110587. */
  110588. get textureType(): number;
  110589. /**
  110590. * Get the texture underlying format (RGB, RGBA...)
  110591. */
  110592. get textureFormat(): number;
  110593. /**
  110594. * Indicates that textures need to be re-calculated for all materials
  110595. */
  110596. protected _markAllSubMeshesAsTexturesDirty(): void;
  110597. /**
  110598. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110599. * This will returns an RGBA array buffer containing either in values (0-255) or
  110600. * float values (0-1) depending of the underlying buffer type.
  110601. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110602. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110603. * @param buffer defines a user defined buffer to fill with data (can be null)
  110604. * @returns The Array buffer containing the pixels data.
  110605. */
  110606. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110607. /**
  110608. * Release and destroy the underlying lower level texture aka internalTexture.
  110609. */
  110610. releaseInternalTexture(): void;
  110611. /** @hidden */
  110612. get _lodTextureHigh(): Nullable<BaseTexture>;
  110613. /** @hidden */
  110614. get _lodTextureMid(): Nullable<BaseTexture>;
  110615. /** @hidden */
  110616. get _lodTextureLow(): Nullable<BaseTexture>;
  110617. /**
  110618. * Dispose the texture and release its associated resources.
  110619. */
  110620. dispose(): void;
  110621. /**
  110622. * Serialize the texture into a JSON representation that can be parsed later on.
  110623. * @returns the JSON representation of the texture
  110624. */
  110625. serialize(): any;
  110626. /**
  110627. * Helper function to be called back once a list of texture contains only ready textures.
  110628. * @param textures Define the list of textures to wait for
  110629. * @param callback Define the callback triggered once the entire list will be ready
  110630. */
  110631. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110632. private static _isScene;
  110633. }
  110634. }
  110635. declare module BABYLON {
  110636. /**
  110637. * Options to be used when creating an effect.
  110638. */
  110639. export interface IEffectCreationOptions {
  110640. /**
  110641. * Atrributes that will be used in the shader.
  110642. */
  110643. attributes: string[];
  110644. /**
  110645. * Uniform varible names that will be set in the shader.
  110646. */
  110647. uniformsNames: string[];
  110648. /**
  110649. * Uniform buffer variable names that will be set in the shader.
  110650. */
  110651. uniformBuffersNames: string[];
  110652. /**
  110653. * Sampler texture variable names that will be set in the shader.
  110654. */
  110655. samplers: string[];
  110656. /**
  110657. * Define statements that will be set in the shader.
  110658. */
  110659. defines: any;
  110660. /**
  110661. * Possible fallbacks for this effect to improve performance when needed.
  110662. */
  110663. fallbacks: Nullable<IEffectFallbacks>;
  110664. /**
  110665. * Callback that will be called when the shader is compiled.
  110666. */
  110667. onCompiled: Nullable<(effect: Effect) => void>;
  110668. /**
  110669. * Callback that will be called if an error occurs during shader compilation.
  110670. */
  110671. onError: Nullable<(effect: Effect, errors: string) => void>;
  110672. /**
  110673. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110674. */
  110675. indexParameters?: any;
  110676. /**
  110677. * Max number of lights that can be used in the shader.
  110678. */
  110679. maxSimultaneousLights?: number;
  110680. /**
  110681. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110682. */
  110683. transformFeedbackVaryings?: Nullable<string[]>;
  110684. /**
  110685. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  110686. */
  110687. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110688. }
  110689. /**
  110690. * Effect containing vertex and fragment shader that can be executed on an object.
  110691. */
  110692. export class Effect implements IDisposable {
  110693. /**
  110694. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110695. */
  110696. static ShadersRepository: string;
  110697. /**
  110698. * Enable logging of the shader code when a compilation error occurs
  110699. */
  110700. static LogShaderCodeOnCompilationError: boolean;
  110701. /**
  110702. * Name of the effect.
  110703. */
  110704. name: any;
  110705. /**
  110706. * String container all the define statements that should be set on the shader.
  110707. */
  110708. defines: string;
  110709. /**
  110710. * Callback that will be called when the shader is compiled.
  110711. */
  110712. onCompiled: Nullable<(effect: Effect) => void>;
  110713. /**
  110714. * Callback that will be called if an error occurs during shader compilation.
  110715. */
  110716. onError: Nullable<(effect: Effect, errors: string) => void>;
  110717. /**
  110718. * Callback that will be called when effect is bound.
  110719. */
  110720. onBind: Nullable<(effect: Effect) => void>;
  110721. /**
  110722. * Unique ID of the effect.
  110723. */
  110724. uniqueId: number;
  110725. /**
  110726. * Observable that will be called when the shader is compiled.
  110727. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110728. */
  110729. onCompileObservable: Observable<Effect>;
  110730. /**
  110731. * Observable that will be called if an error occurs during shader compilation.
  110732. */
  110733. onErrorObservable: Observable<Effect>;
  110734. /** @hidden */
  110735. _onBindObservable: Nullable<Observable<Effect>>;
  110736. /**
  110737. * @hidden
  110738. * Specifies if the effect was previously ready
  110739. */
  110740. _wasPreviouslyReady: boolean;
  110741. /**
  110742. * Observable that will be called when effect is bound.
  110743. */
  110744. get onBindObservable(): Observable<Effect>;
  110745. /** @hidden */
  110746. _bonesComputationForcedToCPU: boolean;
  110747. private static _uniqueIdSeed;
  110748. private _engine;
  110749. private _uniformBuffersNames;
  110750. private _uniformBuffersNamesList;
  110751. private _uniformsNames;
  110752. private _samplerList;
  110753. private _samplers;
  110754. private _isReady;
  110755. private _compilationError;
  110756. private _allFallbacksProcessed;
  110757. private _attributesNames;
  110758. private _attributes;
  110759. private _attributeLocationByName;
  110760. private _uniforms;
  110761. /**
  110762. * Key for the effect.
  110763. * @hidden
  110764. */
  110765. _key: string;
  110766. private _indexParameters;
  110767. private _fallbacks;
  110768. private _vertexSourceCode;
  110769. private _fragmentSourceCode;
  110770. private _vertexSourceCodeOverride;
  110771. private _fragmentSourceCodeOverride;
  110772. private _transformFeedbackVaryings;
  110773. /**
  110774. * Compiled shader to webGL program.
  110775. * @hidden
  110776. */
  110777. _pipelineContext: Nullable<IPipelineContext>;
  110778. private _valueCache;
  110779. private static _baseCache;
  110780. /**
  110781. * Instantiates an effect.
  110782. * An effect can be used to create/manage/execute vertex and fragment shaders.
  110783. * @param baseName Name of the effect.
  110784. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  110785. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  110786. * @param samplers List of sampler variables that will be passed to the shader.
  110787. * @param engine Engine to be used to render the effect
  110788. * @param defines Define statements to be added to the shader.
  110789. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  110790. * @param onCompiled Callback that will be called when the shader is compiled.
  110791. * @param onError Callback that will be called if an error occurs during shader compilation.
  110792. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110793. */
  110794. 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);
  110795. private _useFinalCode;
  110796. /**
  110797. * Unique key for this effect
  110798. */
  110799. get key(): string;
  110800. /**
  110801. * If the effect has been compiled and prepared.
  110802. * @returns if the effect is compiled and prepared.
  110803. */
  110804. isReady(): boolean;
  110805. private _isReadyInternal;
  110806. /**
  110807. * The engine the effect was initialized with.
  110808. * @returns the engine.
  110809. */
  110810. getEngine(): Engine;
  110811. /**
  110812. * The pipeline context for this effect
  110813. * @returns the associated pipeline context
  110814. */
  110815. getPipelineContext(): Nullable<IPipelineContext>;
  110816. /**
  110817. * The set of names of attribute variables for the shader.
  110818. * @returns An array of attribute names.
  110819. */
  110820. getAttributesNames(): string[];
  110821. /**
  110822. * Returns the attribute at the given index.
  110823. * @param index The index of the attribute.
  110824. * @returns The location of the attribute.
  110825. */
  110826. getAttributeLocation(index: number): number;
  110827. /**
  110828. * Returns the attribute based on the name of the variable.
  110829. * @param name of the attribute to look up.
  110830. * @returns the attribute location.
  110831. */
  110832. getAttributeLocationByName(name: string): number;
  110833. /**
  110834. * The number of attributes.
  110835. * @returns the numnber of attributes.
  110836. */
  110837. getAttributesCount(): number;
  110838. /**
  110839. * Gets the index of a uniform variable.
  110840. * @param uniformName of the uniform to look up.
  110841. * @returns the index.
  110842. */
  110843. getUniformIndex(uniformName: string): number;
  110844. /**
  110845. * Returns the attribute based on the name of the variable.
  110846. * @param uniformName of the uniform to look up.
  110847. * @returns the location of the uniform.
  110848. */
  110849. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  110850. /**
  110851. * Returns an array of sampler variable names
  110852. * @returns The array of sampler variable names.
  110853. */
  110854. getSamplers(): string[];
  110855. /**
  110856. * Returns an array of uniform variable names
  110857. * @returns The array of uniform variable names.
  110858. */
  110859. getUniformNames(): string[];
  110860. /**
  110861. * Returns an array of uniform buffer variable names
  110862. * @returns The array of uniform buffer variable names.
  110863. */
  110864. getUniformBuffersNames(): string[];
  110865. /**
  110866. * Returns the index parameters used to create the effect
  110867. * @returns The index parameters object
  110868. */
  110869. getIndexParameters(): any;
  110870. /**
  110871. * The error from the last compilation.
  110872. * @returns the error string.
  110873. */
  110874. getCompilationError(): string;
  110875. /**
  110876. * Gets a boolean indicating that all fallbacks were used during compilation
  110877. * @returns true if all fallbacks were used
  110878. */
  110879. allFallbacksProcessed(): boolean;
  110880. /**
  110881. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  110882. * @param func The callback to be used.
  110883. */
  110884. executeWhenCompiled(func: (effect: Effect) => void): void;
  110885. private _checkIsReady;
  110886. private _loadShader;
  110887. /**
  110888. * Gets the vertex shader source code of this effect
  110889. */
  110890. get vertexSourceCode(): string;
  110891. /**
  110892. * Gets the fragment shader source code of this effect
  110893. */
  110894. get fragmentSourceCode(): string;
  110895. /**
  110896. * Recompiles the webGL program
  110897. * @param vertexSourceCode The source code for the vertex shader.
  110898. * @param fragmentSourceCode The source code for the fragment shader.
  110899. * @param onCompiled Callback called when completed.
  110900. * @param onError Callback called on error.
  110901. * @hidden
  110902. */
  110903. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  110904. /**
  110905. * Prepares the effect
  110906. * @hidden
  110907. */
  110908. _prepareEffect(): void;
  110909. private _getShaderCodeAndErrorLine;
  110910. private _processCompilationErrors;
  110911. /**
  110912. * Checks if the effect is supported. (Must be called after compilation)
  110913. */
  110914. get isSupported(): boolean;
  110915. /**
  110916. * Binds a texture to the engine to be used as output of the shader.
  110917. * @param channel Name of the output variable.
  110918. * @param texture Texture to bind.
  110919. * @hidden
  110920. */
  110921. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  110922. /**
  110923. * Sets a texture on the engine to be used in the shader.
  110924. * @param channel Name of the sampler variable.
  110925. * @param texture Texture to set.
  110926. */
  110927. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  110928. /**
  110929. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  110930. * @param channel Name of the sampler variable.
  110931. * @param texture Texture to set.
  110932. */
  110933. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  110934. /**
  110935. * Sets an array of textures on the engine to be used in the shader.
  110936. * @param channel Name of the variable.
  110937. * @param textures Textures to set.
  110938. */
  110939. setTextureArray(channel: string, textures: BaseTexture[]): void;
  110940. /**
  110941. * 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)
  110942. * @param channel Name of the sampler variable.
  110943. * @param postProcess Post process to get the input texture from.
  110944. */
  110945. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  110946. /**
  110947. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  110948. * 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)
  110949. * @param channel Name of the sampler variable.
  110950. * @param postProcess Post process to get the output texture from.
  110951. */
  110952. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  110953. /** @hidden */
  110954. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  110955. /** @hidden */
  110956. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  110957. /** @hidden */
  110958. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  110959. /** @hidden */
  110960. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  110961. /**
  110962. * Binds a buffer to a uniform.
  110963. * @param buffer Buffer to bind.
  110964. * @param name Name of the uniform variable to bind to.
  110965. */
  110966. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  110967. /**
  110968. * Binds block to a uniform.
  110969. * @param blockName Name of the block to bind.
  110970. * @param index Index to bind.
  110971. */
  110972. bindUniformBlock(blockName: string, index: number): void;
  110973. /**
  110974. * Sets an interger value on a uniform variable.
  110975. * @param uniformName Name of the variable.
  110976. * @param value Value to be set.
  110977. * @returns this effect.
  110978. */
  110979. setInt(uniformName: string, value: number): Effect;
  110980. /**
  110981. * Sets an int array on a uniform variable.
  110982. * @param uniformName Name of the variable.
  110983. * @param array array to be set.
  110984. * @returns this effect.
  110985. */
  110986. setIntArray(uniformName: string, array: Int32Array): Effect;
  110987. /**
  110988. * 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)
  110989. * @param uniformName Name of the variable.
  110990. * @param array array to be set.
  110991. * @returns this effect.
  110992. */
  110993. setIntArray2(uniformName: string, array: Int32Array): Effect;
  110994. /**
  110995. * 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)
  110996. * @param uniformName Name of the variable.
  110997. * @param array array to be set.
  110998. * @returns this effect.
  110999. */
  111000. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111001. /**
  111002. * 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)
  111003. * @param uniformName Name of the variable.
  111004. * @param array array to be set.
  111005. * @returns this effect.
  111006. */
  111007. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111008. /**
  111009. * Sets an float array on a uniform variable.
  111010. * @param uniformName Name of the variable.
  111011. * @param array array to be set.
  111012. * @returns this effect.
  111013. */
  111014. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111015. /**
  111016. * 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)
  111017. * @param uniformName Name of the variable.
  111018. * @param array array to be set.
  111019. * @returns this effect.
  111020. */
  111021. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111022. /**
  111023. * 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)
  111024. * @param uniformName Name of the variable.
  111025. * @param array array to be set.
  111026. * @returns this effect.
  111027. */
  111028. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111029. /**
  111030. * 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)
  111031. * @param uniformName Name of the variable.
  111032. * @param array array to be set.
  111033. * @returns this effect.
  111034. */
  111035. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111036. /**
  111037. * Sets an array on a uniform variable.
  111038. * @param uniformName Name of the variable.
  111039. * @param array array to be set.
  111040. * @returns this effect.
  111041. */
  111042. setArray(uniformName: string, array: number[]): Effect;
  111043. /**
  111044. * 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)
  111045. * @param uniformName Name of the variable.
  111046. * @param array array to be set.
  111047. * @returns this effect.
  111048. */
  111049. setArray2(uniformName: string, array: number[]): Effect;
  111050. /**
  111051. * 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)
  111052. * @param uniformName Name of the variable.
  111053. * @param array array to be set.
  111054. * @returns this effect.
  111055. */
  111056. setArray3(uniformName: string, array: number[]): Effect;
  111057. /**
  111058. * 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)
  111059. * @param uniformName Name of the variable.
  111060. * @param array array to be set.
  111061. * @returns this effect.
  111062. */
  111063. setArray4(uniformName: string, array: number[]): Effect;
  111064. /**
  111065. * Sets matrices on a uniform variable.
  111066. * @param uniformName Name of the variable.
  111067. * @param matrices matrices to be set.
  111068. * @returns this effect.
  111069. */
  111070. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111071. /**
  111072. * Sets matrix on a uniform variable.
  111073. * @param uniformName Name of the variable.
  111074. * @param matrix matrix to be set.
  111075. * @returns this effect.
  111076. */
  111077. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111078. /**
  111079. * 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)
  111080. * @param uniformName Name of the variable.
  111081. * @param matrix matrix to be set.
  111082. * @returns this effect.
  111083. */
  111084. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111085. /**
  111086. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111087. * @param uniformName Name of the variable.
  111088. * @param matrix matrix to be set.
  111089. * @returns this effect.
  111090. */
  111091. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111092. /**
  111093. * Sets a float on a uniform variable.
  111094. * @param uniformName Name of the variable.
  111095. * @param value value to be set.
  111096. * @returns this effect.
  111097. */
  111098. setFloat(uniformName: string, value: number): Effect;
  111099. /**
  111100. * Sets a boolean on a uniform variable.
  111101. * @param uniformName Name of the variable.
  111102. * @param bool value to be set.
  111103. * @returns this effect.
  111104. */
  111105. setBool(uniformName: string, bool: boolean): Effect;
  111106. /**
  111107. * Sets a Vector2 on a uniform variable.
  111108. * @param uniformName Name of the variable.
  111109. * @param vector2 vector2 to be set.
  111110. * @returns this effect.
  111111. */
  111112. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111113. /**
  111114. * Sets a float2 on a uniform variable.
  111115. * @param uniformName Name of the variable.
  111116. * @param x First float in float2.
  111117. * @param y Second float in float2.
  111118. * @returns this effect.
  111119. */
  111120. setFloat2(uniformName: string, x: number, y: number): Effect;
  111121. /**
  111122. * Sets a Vector3 on a uniform variable.
  111123. * @param uniformName Name of the variable.
  111124. * @param vector3 Value to be set.
  111125. * @returns this effect.
  111126. */
  111127. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111128. /**
  111129. * Sets a float3 on a uniform variable.
  111130. * @param uniformName Name of the variable.
  111131. * @param x First float in float3.
  111132. * @param y Second float in float3.
  111133. * @param z Third float in float3.
  111134. * @returns this effect.
  111135. */
  111136. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111137. /**
  111138. * Sets a Vector4 on a uniform variable.
  111139. * @param uniformName Name of the variable.
  111140. * @param vector4 Value to be set.
  111141. * @returns this effect.
  111142. */
  111143. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111144. /**
  111145. * Sets a float4 on a uniform variable.
  111146. * @param uniformName Name of the variable.
  111147. * @param x First float in float4.
  111148. * @param y Second float in float4.
  111149. * @param z Third float in float4.
  111150. * @param w Fourth float in float4.
  111151. * @returns this effect.
  111152. */
  111153. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111154. /**
  111155. * Sets a Color3 on a uniform variable.
  111156. * @param uniformName Name of the variable.
  111157. * @param color3 Value to be set.
  111158. * @returns this effect.
  111159. */
  111160. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111161. /**
  111162. * Sets a Color4 on a uniform variable.
  111163. * @param uniformName Name of the variable.
  111164. * @param color3 Value to be set.
  111165. * @param alpha Alpha value to be set.
  111166. * @returns this effect.
  111167. */
  111168. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111169. /**
  111170. * Sets a Color4 on a uniform variable
  111171. * @param uniformName defines the name of the variable
  111172. * @param color4 defines the value to be set
  111173. * @returns this effect.
  111174. */
  111175. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111176. /** Release all associated resources */
  111177. dispose(): void;
  111178. /**
  111179. * This function will add a new shader to the shader store
  111180. * @param name the name of the shader
  111181. * @param pixelShader optional pixel shader content
  111182. * @param vertexShader optional vertex shader content
  111183. */
  111184. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111185. /**
  111186. * Store of each shader (The can be looked up using effect.key)
  111187. */
  111188. static ShadersStore: {
  111189. [key: string]: string;
  111190. };
  111191. /**
  111192. * Store of each included file for a shader (The can be looked up using effect.key)
  111193. */
  111194. static IncludesShadersStore: {
  111195. [key: string]: string;
  111196. };
  111197. /**
  111198. * Resets the cache of effects.
  111199. */
  111200. static ResetCache(): void;
  111201. }
  111202. }
  111203. declare module BABYLON {
  111204. /**
  111205. * Interface used to describe the capabilities of the engine relatively to the current browser
  111206. */
  111207. export interface EngineCapabilities {
  111208. /** Maximum textures units per fragment shader */
  111209. maxTexturesImageUnits: number;
  111210. /** Maximum texture units per vertex shader */
  111211. maxVertexTextureImageUnits: number;
  111212. /** Maximum textures units in the entire pipeline */
  111213. maxCombinedTexturesImageUnits: number;
  111214. /** Maximum texture size */
  111215. maxTextureSize: number;
  111216. /** Maximum texture samples */
  111217. maxSamples?: number;
  111218. /** Maximum cube texture size */
  111219. maxCubemapTextureSize: number;
  111220. /** Maximum render texture size */
  111221. maxRenderTextureSize: number;
  111222. /** Maximum number of vertex attributes */
  111223. maxVertexAttribs: number;
  111224. /** Maximum number of varyings */
  111225. maxVaryingVectors: number;
  111226. /** Maximum number of uniforms per vertex shader */
  111227. maxVertexUniformVectors: number;
  111228. /** Maximum number of uniforms per fragment shader */
  111229. maxFragmentUniformVectors: number;
  111230. /** Defines if standard derivates (dx/dy) are supported */
  111231. standardDerivatives: boolean;
  111232. /** Defines if s3tc texture compression is supported */
  111233. s3tc?: WEBGL_compressed_texture_s3tc;
  111234. /** Defines if pvrtc texture compression is supported */
  111235. pvrtc: any;
  111236. /** Defines if etc1 texture compression is supported */
  111237. etc1: any;
  111238. /** Defines if etc2 texture compression is supported */
  111239. etc2: any;
  111240. /** Defines if astc texture compression is supported */
  111241. astc: any;
  111242. /** Defines if float textures are supported */
  111243. textureFloat: boolean;
  111244. /** Defines if vertex array objects are supported */
  111245. vertexArrayObject: boolean;
  111246. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  111247. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  111248. /** Gets the maximum level of anisotropy supported */
  111249. maxAnisotropy: number;
  111250. /** Defines if instancing is supported */
  111251. instancedArrays: boolean;
  111252. /** Defines if 32 bits indices are supported */
  111253. uintIndices: boolean;
  111254. /** Defines if high precision shaders are supported */
  111255. highPrecisionShaderSupported: boolean;
  111256. /** Defines if depth reading in the fragment shader is supported */
  111257. fragmentDepthSupported: boolean;
  111258. /** Defines if float texture linear filtering is supported*/
  111259. textureFloatLinearFiltering: boolean;
  111260. /** Defines if rendering to float textures is supported */
  111261. textureFloatRender: boolean;
  111262. /** Defines if half float textures are supported*/
  111263. textureHalfFloat: boolean;
  111264. /** Defines if half float texture linear filtering is supported*/
  111265. textureHalfFloatLinearFiltering: boolean;
  111266. /** Defines if rendering to half float textures is supported */
  111267. textureHalfFloatRender: boolean;
  111268. /** Defines if textureLOD shader command is supported */
  111269. textureLOD: boolean;
  111270. /** Defines if draw buffers extension is supported */
  111271. drawBuffersExtension: boolean;
  111272. /** Defines if depth textures are supported */
  111273. depthTextureExtension: boolean;
  111274. /** Defines if float color buffer are supported */
  111275. colorBufferFloat: boolean;
  111276. /** Gets disjoint timer query extension (null if not supported) */
  111277. timerQuery?: EXT_disjoint_timer_query;
  111278. /** Defines if timestamp can be used with timer query */
  111279. canUseTimestampForTimerQuery: boolean;
  111280. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  111281. multiview?: any;
  111282. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  111283. oculusMultiview?: any;
  111284. /** Function used to let the system compiles shaders in background */
  111285. parallelShaderCompile?: {
  111286. COMPLETION_STATUS_KHR: number;
  111287. };
  111288. /** Max number of texture samples for MSAA */
  111289. maxMSAASamples: number;
  111290. /** Defines if the blend min max extension is supported */
  111291. blendMinMax: boolean;
  111292. }
  111293. }
  111294. declare module BABYLON {
  111295. /**
  111296. * @hidden
  111297. **/
  111298. export class DepthCullingState {
  111299. private _isDepthTestDirty;
  111300. private _isDepthMaskDirty;
  111301. private _isDepthFuncDirty;
  111302. private _isCullFaceDirty;
  111303. private _isCullDirty;
  111304. private _isZOffsetDirty;
  111305. private _isFrontFaceDirty;
  111306. private _depthTest;
  111307. private _depthMask;
  111308. private _depthFunc;
  111309. private _cull;
  111310. private _cullFace;
  111311. private _zOffset;
  111312. private _frontFace;
  111313. /**
  111314. * Initializes the state.
  111315. */
  111316. constructor();
  111317. get isDirty(): boolean;
  111318. get zOffset(): number;
  111319. set zOffset(value: number);
  111320. get cullFace(): Nullable<number>;
  111321. set cullFace(value: Nullable<number>);
  111322. get cull(): Nullable<boolean>;
  111323. set cull(value: Nullable<boolean>);
  111324. get depthFunc(): Nullable<number>;
  111325. set depthFunc(value: Nullable<number>);
  111326. get depthMask(): boolean;
  111327. set depthMask(value: boolean);
  111328. get depthTest(): boolean;
  111329. set depthTest(value: boolean);
  111330. get frontFace(): Nullable<number>;
  111331. set frontFace(value: Nullable<number>);
  111332. reset(): void;
  111333. apply(gl: WebGLRenderingContext): void;
  111334. }
  111335. }
  111336. declare module BABYLON {
  111337. /**
  111338. * @hidden
  111339. **/
  111340. export class StencilState {
  111341. /** 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 */
  111342. static readonly ALWAYS: number;
  111343. /** Passed to stencilOperation to specify that stencil value must be kept */
  111344. static readonly KEEP: number;
  111345. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111346. static readonly REPLACE: number;
  111347. private _isStencilTestDirty;
  111348. private _isStencilMaskDirty;
  111349. private _isStencilFuncDirty;
  111350. private _isStencilOpDirty;
  111351. private _stencilTest;
  111352. private _stencilMask;
  111353. private _stencilFunc;
  111354. private _stencilFuncRef;
  111355. private _stencilFuncMask;
  111356. private _stencilOpStencilFail;
  111357. private _stencilOpDepthFail;
  111358. private _stencilOpStencilDepthPass;
  111359. get isDirty(): boolean;
  111360. get stencilFunc(): number;
  111361. set stencilFunc(value: number);
  111362. get stencilFuncRef(): number;
  111363. set stencilFuncRef(value: number);
  111364. get stencilFuncMask(): number;
  111365. set stencilFuncMask(value: number);
  111366. get stencilOpStencilFail(): number;
  111367. set stencilOpStencilFail(value: number);
  111368. get stencilOpDepthFail(): number;
  111369. set stencilOpDepthFail(value: number);
  111370. get stencilOpStencilDepthPass(): number;
  111371. set stencilOpStencilDepthPass(value: number);
  111372. get stencilMask(): number;
  111373. set stencilMask(value: number);
  111374. get stencilTest(): boolean;
  111375. set stencilTest(value: boolean);
  111376. constructor();
  111377. reset(): void;
  111378. apply(gl: WebGLRenderingContext): void;
  111379. }
  111380. }
  111381. declare module BABYLON {
  111382. /**
  111383. * @hidden
  111384. **/
  111385. export class AlphaState {
  111386. private _isAlphaBlendDirty;
  111387. private _isBlendFunctionParametersDirty;
  111388. private _isBlendEquationParametersDirty;
  111389. private _isBlendConstantsDirty;
  111390. private _alphaBlend;
  111391. private _blendFunctionParameters;
  111392. private _blendEquationParameters;
  111393. private _blendConstants;
  111394. /**
  111395. * Initializes the state.
  111396. */
  111397. constructor();
  111398. get isDirty(): boolean;
  111399. get alphaBlend(): boolean;
  111400. set alphaBlend(value: boolean);
  111401. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111402. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111403. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111404. reset(): void;
  111405. apply(gl: WebGLRenderingContext): void;
  111406. }
  111407. }
  111408. declare module BABYLON {
  111409. /** @hidden */
  111410. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111411. attributeProcessor(attribute: string): string;
  111412. varyingProcessor(varying: string, isFragment: boolean): string;
  111413. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111414. }
  111415. }
  111416. declare module BABYLON {
  111417. /**
  111418. * Interface for attribute information associated with buffer instanciation
  111419. */
  111420. export interface InstancingAttributeInfo {
  111421. /**
  111422. * Name of the GLSL attribute
  111423. * if attribute index is not specified, this is used to retrieve the index from the effect
  111424. */
  111425. attributeName: string;
  111426. /**
  111427. * Index/offset of the attribute in the vertex shader
  111428. * if not specified, this will be computes from the name.
  111429. */
  111430. index?: number;
  111431. /**
  111432. * size of the attribute, 1, 2, 3 or 4
  111433. */
  111434. attributeSize: number;
  111435. /**
  111436. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111437. */
  111438. offset: number;
  111439. /**
  111440. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111441. * default to 1
  111442. */
  111443. divisor?: number;
  111444. /**
  111445. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111446. * default is FLOAT
  111447. */
  111448. attributeType?: number;
  111449. /**
  111450. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111451. */
  111452. normalized?: boolean;
  111453. }
  111454. }
  111455. declare module BABYLON {
  111456. interface ThinEngine {
  111457. /**
  111458. * Update a video texture
  111459. * @param texture defines the texture to update
  111460. * @param video defines the video element to use
  111461. * @param invertY defines if data must be stored with Y axis inverted
  111462. */
  111463. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111464. }
  111465. }
  111466. declare module BABYLON {
  111467. /**
  111468. * Settings for finer control over video usage
  111469. */
  111470. export interface VideoTextureSettings {
  111471. /**
  111472. * Applies `autoplay` to video, if specified
  111473. */
  111474. autoPlay?: boolean;
  111475. /**
  111476. * Applies `loop` to video, if specified
  111477. */
  111478. loop?: boolean;
  111479. /**
  111480. * Automatically updates internal texture from video at every frame in the render loop
  111481. */
  111482. autoUpdateTexture: boolean;
  111483. /**
  111484. * Image src displayed during the video loading or until the user interacts with the video.
  111485. */
  111486. poster?: string;
  111487. }
  111488. /**
  111489. * If you want to display a video in your scene, this is the special texture for that.
  111490. * This special texture works similar to other textures, with the exception of a few parameters.
  111491. * @see https://doc.babylonjs.com/how_to/video_texture
  111492. */
  111493. export class VideoTexture extends Texture {
  111494. /**
  111495. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111496. */
  111497. readonly autoUpdateTexture: boolean;
  111498. /**
  111499. * The video instance used by the texture internally
  111500. */
  111501. readonly video: HTMLVideoElement;
  111502. private _onUserActionRequestedObservable;
  111503. /**
  111504. * Event triggerd when a dom action is required by the user to play the video.
  111505. * This happens due to recent changes in browser policies preventing video to auto start.
  111506. */
  111507. get onUserActionRequestedObservable(): Observable<Texture>;
  111508. private _generateMipMaps;
  111509. private _stillImageCaptured;
  111510. private _displayingPosterTexture;
  111511. private _settings;
  111512. private _createInternalTextureOnEvent;
  111513. private _frameId;
  111514. private _currentSrc;
  111515. /**
  111516. * Creates a video texture.
  111517. * If you want to display a video in your scene, this is the special texture for that.
  111518. * This special texture works similar to other textures, with the exception of a few parameters.
  111519. * @see https://doc.babylonjs.com/how_to/video_texture
  111520. * @param name optional name, will detect from video source, if not defined
  111521. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111522. * @param scene is obviously the current scene.
  111523. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111524. * @param invertY is false by default but can be used to invert video on Y axis
  111525. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111526. * @param settings allows finer control over video usage
  111527. */
  111528. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111529. private _getName;
  111530. private _getVideo;
  111531. private _createInternalTexture;
  111532. private reset;
  111533. /**
  111534. * @hidden Internal method to initiate `update`.
  111535. */
  111536. _rebuild(): void;
  111537. /**
  111538. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111539. */
  111540. update(): void;
  111541. /**
  111542. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111543. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111544. */
  111545. updateTexture(isVisible: boolean): void;
  111546. protected _updateInternalTexture: () => void;
  111547. /**
  111548. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111549. * @param url New url.
  111550. */
  111551. updateURL(url: string): void;
  111552. /**
  111553. * Clones the texture.
  111554. * @returns the cloned texture
  111555. */
  111556. clone(): VideoTexture;
  111557. /**
  111558. * Dispose the texture and release its associated resources.
  111559. */
  111560. dispose(): void;
  111561. /**
  111562. * Creates a video texture straight from a stream.
  111563. * @param scene Define the scene the texture should be created in
  111564. * @param stream Define the stream the texture should be created from
  111565. * @returns The created video texture as a promise
  111566. */
  111567. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111568. /**
  111569. * Creates a video texture straight from your WebCam video feed.
  111570. * @param scene Define the scene the texture should be created in
  111571. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111572. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111573. * @returns The created video texture as a promise
  111574. */
  111575. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111576. minWidth: number;
  111577. maxWidth: number;
  111578. minHeight: number;
  111579. maxHeight: number;
  111580. deviceId: string;
  111581. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111582. /**
  111583. * Creates a video texture straight from your WebCam video feed.
  111584. * @param scene Define the scene the texture should be created in
  111585. * @param onReady Define a callback to triggered once the texture will be ready
  111586. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111587. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111588. */
  111589. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111590. minWidth: number;
  111591. maxWidth: number;
  111592. minHeight: number;
  111593. maxHeight: number;
  111594. deviceId: string;
  111595. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111596. }
  111597. }
  111598. declare module BABYLON {
  111599. /**
  111600. * Defines the interface used by objects working like Scene
  111601. * @hidden
  111602. */
  111603. export interface ISceneLike {
  111604. _addPendingData(data: any): void;
  111605. _removePendingData(data: any): void;
  111606. offlineProvider: IOfflineProvider;
  111607. }
  111608. /** Interface defining initialization parameters for Engine class */
  111609. export interface EngineOptions extends WebGLContextAttributes {
  111610. /**
  111611. * Defines if the engine should no exceed a specified device ratio
  111612. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111613. */
  111614. limitDeviceRatio?: number;
  111615. /**
  111616. * Defines if webvr should be enabled automatically
  111617. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111618. */
  111619. autoEnableWebVR?: boolean;
  111620. /**
  111621. * Defines if webgl2 should be turned off even if supported
  111622. * @see http://doc.babylonjs.com/features/webgl2
  111623. */
  111624. disableWebGL2Support?: boolean;
  111625. /**
  111626. * Defines if webaudio should be initialized as well
  111627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111628. */
  111629. audioEngine?: boolean;
  111630. /**
  111631. * Defines if animations should run using a deterministic lock step
  111632. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111633. */
  111634. deterministicLockstep?: boolean;
  111635. /** Defines the maximum steps to use with deterministic lock step mode */
  111636. lockstepMaxSteps?: number;
  111637. /** Defines the seconds between each deterministic lock step */
  111638. timeStep?: number;
  111639. /**
  111640. * Defines that engine should ignore context lost events
  111641. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111642. */
  111643. doNotHandleContextLost?: boolean;
  111644. /**
  111645. * Defines that engine should ignore modifying touch action attribute and style
  111646. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111647. */
  111648. doNotHandleTouchAction?: boolean;
  111649. /**
  111650. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  111651. */
  111652. useHighPrecisionFloats?: boolean;
  111653. /**
  111654. * Make the canvas XR Compatible for XR sessions
  111655. */
  111656. xrCompatible?: boolean;
  111657. }
  111658. /**
  111659. * The base engine class (root of all engines)
  111660. */
  111661. export class ThinEngine {
  111662. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  111663. static ExceptionList: ({
  111664. key: string;
  111665. capture: string;
  111666. captureConstraint: number;
  111667. targets: string[];
  111668. } | {
  111669. key: string;
  111670. capture: null;
  111671. captureConstraint: null;
  111672. targets: string[];
  111673. })[];
  111674. /** @hidden */
  111675. static _TextureLoaders: IInternalTextureLoader[];
  111676. /**
  111677. * Returns the current npm package of the sdk
  111678. */
  111679. static get NpmPackage(): string;
  111680. /**
  111681. * Returns the current version of the framework
  111682. */
  111683. static get Version(): string;
  111684. /**
  111685. * Returns a string describing the current engine
  111686. */
  111687. get description(): string;
  111688. /**
  111689. * Gets or sets the epsilon value used by collision engine
  111690. */
  111691. static CollisionsEpsilon: number;
  111692. /**
  111693. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111694. */
  111695. static get ShadersRepository(): string;
  111696. static set ShadersRepository(value: string);
  111697. /** @hidden */
  111698. _shaderProcessor: IShaderProcessor;
  111699. /**
  111700. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111701. */
  111702. forcePOTTextures: boolean;
  111703. /**
  111704. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111705. */
  111706. isFullscreen: boolean;
  111707. /**
  111708. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111709. */
  111710. cullBackFaces: boolean;
  111711. /**
  111712. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111713. */
  111714. renderEvenInBackground: boolean;
  111715. /**
  111716. * Gets or sets a boolean indicating that cache can be kept between frames
  111717. */
  111718. preventCacheWipeBetweenFrames: boolean;
  111719. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111720. validateShaderPrograms: boolean;
  111721. /**
  111722. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111723. * This can provide greater z depth for distant objects.
  111724. */
  111725. useReverseDepthBuffer: boolean;
  111726. /**
  111727. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  111728. */
  111729. disableUniformBuffers: boolean;
  111730. /** @hidden */
  111731. _uniformBuffers: UniformBuffer[];
  111732. /**
  111733. * Gets a boolean indicating that the engine supports uniform buffers
  111734. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  111735. */
  111736. get supportsUniformBuffers(): boolean;
  111737. /** @hidden */
  111738. _gl: WebGLRenderingContext;
  111739. /** @hidden */
  111740. _webGLVersion: number;
  111741. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  111742. protected _windowIsBackground: boolean;
  111743. protected _creationOptions: EngineOptions;
  111744. protected _highPrecisionShadersAllowed: boolean;
  111745. /** @hidden */
  111746. get _shouldUseHighPrecisionShader(): boolean;
  111747. /**
  111748. * Gets a boolean indicating that only power of 2 textures are supported
  111749. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  111750. */
  111751. get needPOTTextures(): boolean;
  111752. /** @hidden */
  111753. _badOS: boolean;
  111754. /** @hidden */
  111755. _badDesktopOS: boolean;
  111756. private _hardwareScalingLevel;
  111757. /** @hidden */
  111758. _caps: EngineCapabilities;
  111759. private _isStencilEnable;
  111760. private _glVersion;
  111761. private _glRenderer;
  111762. private _glVendor;
  111763. /** @hidden */
  111764. _videoTextureSupported: boolean;
  111765. protected _renderingQueueLaunched: boolean;
  111766. protected _activeRenderLoops: (() => void)[];
  111767. /**
  111768. * Observable signaled when a context lost event is raised
  111769. */
  111770. onContextLostObservable: Observable<ThinEngine>;
  111771. /**
  111772. * Observable signaled when a context restored event is raised
  111773. */
  111774. onContextRestoredObservable: Observable<ThinEngine>;
  111775. private _onContextLost;
  111776. private _onContextRestored;
  111777. protected _contextWasLost: boolean;
  111778. /** @hidden */
  111779. _doNotHandleContextLost: boolean;
  111780. /**
  111781. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  111782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  111783. */
  111784. get doNotHandleContextLost(): boolean;
  111785. set doNotHandleContextLost(value: boolean);
  111786. /**
  111787. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  111788. */
  111789. disableVertexArrayObjects: boolean;
  111790. /** @hidden */
  111791. protected _colorWrite: boolean;
  111792. /** @hidden */
  111793. protected _colorWriteChanged: boolean;
  111794. /** @hidden */
  111795. protected _depthCullingState: DepthCullingState;
  111796. /** @hidden */
  111797. protected _stencilState: StencilState;
  111798. /** @hidden */
  111799. _alphaState: AlphaState;
  111800. /** @hidden */
  111801. _alphaMode: number;
  111802. /** @hidden */
  111803. _alphaEquation: number;
  111804. /** @hidden */
  111805. _internalTexturesCache: InternalTexture[];
  111806. /** @hidden */
  111807. protected _activeChannel: number;
  111808. private _currentTextureChannel;
  111809. /** @hidden */
  111810. protected _boundTexturesCache: {
  111811. [key: string]: Nullable<InternalTexture>;
  111812. };
  111813. /** @hidden */
  111814. protected _currentEffect: Nullable<Effect>;
  111815. /** @hidden */
  111816. protected _currentProgram: Nullable<WebGLProgram>;
  111817. private _compiledEffects;
  111818. private _vertexAttribArraysEnabled;
  111819. /** @hidden */
  111820. protected _cachedViewport: Nullable<IViewportLike>;
  111821. private _cachedVertexArrayObject;
  111822. /** @hidden */
  111823. protected _cachedVertexBuffers: any;
  111824. /** @hidden */
  111825. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  111826. /** @hidden */
  111827. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  111828. /** @hidden */
  111829. _currentRenderTarget: Nullable<InternalTexture>;
  111830. private _uintIndicesCurrentlySet;
  111831. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  111832. /** @hidden */
  111833. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  111834. /** @hidden */
  111835. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  111836. private _currentBufferPointers;
  111837. private _currentInstanceLocations;
  111838. private _currentInstanceBuffers;
  111839. private _textureUnits;
  111840. /** @hidden */
  111841. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  111842. /** @hidden */
  111843. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  111844. /** @hidden */
  111845. _boundRenderFunction: any;
  111846. private _vaoRecordInProgress;
  111847. private _mustWipeVertexAttributes;
  111848. private _emptyTexture;
  111849. private _emptyCubeTexture;
  111850. private _emptyTexture3D;
  111851. private _emptyTexture2DArray;
  111852. /** @hidden */
  111853. _frameHandler: number;
  111854. private _nextFreeTextureSlots;
  111855. private _maxSimultaneousTextures;
  111856. private _activeRequests;
  111857. /** @hidden */
  111858. _transformTextureUrl: Nullable<(url: string) => string>;
  111859. protected get _supportsHardwareTextureRescaling(): boolean;
  111860. private _framebufferDimensionsObject;
  111861. /**
  111862. * sets the object from which width and height will be taken from when getting render width and height
  111863. * Will fallback to the gl object
  111864. * @param dimensions the framebuffer width and height that will be used.
  111865. */
  111866. set framebufferDimensionsObject(dimensions: Nullable<{
  111867. framebufferWidth: number;
  111868. framebufferHeight: number;
  111869. }>);
  111870. /**
  111871. * Gets the current viewport
  111872. */
  111873. get currentViewport(): Nullable<IViewportLike>;
  111874. /**
  111875. * Gets the default empty texture
  111876. */
  111877. get emptyTexture(): InternalTexture;
  111878. /**
  111879. * Gets the default empty 3D texture
  111880. */
  111881. get emptyTexture3D(): InternalTexture;
  111882. /**
  111883. * Gets the default empty 2D array texture
  111884. */
  111885. get emptyTexture2DArray(): InternalTexture;
  111886. /**
  111887. * Gets the default empty cube texture
  111888. */
  111889. get emptyCubeTexture(): InternalTexture;
  111890. /**
  111891. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  111892. */
  111893. readonly premultipliedAlpha: boolean;
  111894. /**
  111895. * Observable event triggered before each texture is initialized
  111896. */
  111897. onBeforeTextureInitObservable: Observable<Texture>;
  111898. /**
  111899. * Creates a new engine
  111900. * @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
  111901. * @param antialias defines enable antialiasing (default: false)
  111902. * @param options defines further options to be sent to the getContext() function
  111903. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  111904. */
  111905. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  111906. private _rebuildInternalTextures;
  111907. private _rebuildEffects;
  111908. /**
  111909. * Gets a boolean indicating if all created effects are ready
  111910. * @returns true if all effects are ready
  111911. */
  111912. areAllEffectsReady(): boolean;
  111913. protected _rebuildBuffers(): void;
  111914. protected _initGLContext(): void;
  111915. /**
  111916. * Gets version of the current webGL context
  111917. */
  111918. get webGLVersion(): number;
  111919. /**
  111920. * Gets a string idenfifying the name of the class
  111921. * @returns "Engine" string
  111922. */
  111923. getClassName(): string;
  111924. /**
  111925. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  111926. */
  111927. get isStencilEnable(): boolean;
  111928. /** @hidden */
  111929. _prepareWorkingCanvas(): void;
  111930. /**
  111931. * Reset the texture cache to empty state
  111932. */
  111933. resetTextureCache(): void;
  111934. /**
  111935. * Gets an object containing information about the current webGL context
  111936. * @returns an object containing the vender, the renderer and the version of the current webGL context
  111937. */
  111938. getGlInfo(): {
  111939. vendor: string;
  111940. renderer: string;
  111941. version: string;
  111942. };
  111943. /**
  111944. * Defines the hardware scaling level.
  111945. * By default the hardware scaling level is computed from the window device ratio.
  111946. * 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.
  111947. * @param level defines the level to use
  111948. */
  111949. setHardwareScalingLevel(level: number): void;
  111950. /**
  111951. * Gets the current hardware scaling level.
  111952. * By default the hardware scaling level is computed from the window device ratio.
  111953. * 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.
  111954. * @returns a number indicating the current hardware scaling level
  111955. */
  111956. getHardwareScalingLevel(): number;
  111957. /**
  111958. * Gets the list of loaded textures
  111959. * @returns an array containing all loaded textures
  111960. */
  111961. getLoadedTexturesCache(): InternalTexture[];
  111962. /**
  111963. * Gets the object containing all engine capabilities
  111964. * @returns the EngineCapabilities object
  111965. */
  111966. getCaps(): EngineCapabilities;
  111967. /**
  111968. * stop executing a render loop function and remove it from the execution array
  111969. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  111970. */
  111971. stopRenderLoop(renderFunction?: () => void): void;
  111972. /** @hidden */
  111973. _renderLoop(): void;
  111974. /**
  111975. * Gets the HTML canvas attached with the current webGL context
  111976. * @returns a HTML canvas
  111977. */
  111978. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  111979. /**
  111980. * Gets host window
  111981. * @returns the host window object
  111982. */
  111983. getHostWindow(): Nullable<Window>;
  111984. /**
  111985. * Gets the current render width
  111986. * @param useScreen defines if screen size must be used (or the current render target if any)
  111987. * @returns a number defining the current render width
  111988. */
  111989. getRenderWidth(useScreen?: boolean): number;
  111990. /**
  111991. * Gets the current render height
  111992. * @param useScreen defines if screen size must be used (or the current render target if any)
  111993. * @returns a number defining the current render height
  111994. */
  111995. getRenderHeight(useScreen?: boolean): number;
  111996. /**
  111997. * Can be used to override the current requestAnimationFrame requester.
  111998. * @hidden
  111999. */
  112000. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112001. /**
  112002. * Register and execute a render loop. The engine can have more than one render function
  112003. * @param renderFunction defines the function to continuously execute
  112004. */
  112005. runRenderLoop(renderFunction: () => void): void;
  112006. /**
  112007. * Clear the current render buffer or the current render target (if any is set up)
  112008. * @param color defines the color to use
  112009. * @param backBuffer defines if the back buffer must be cleared
  112010. * @param depth defines if the depth buffer must be cleared
  112011. * @param stencil defines if the stencil buffer must be cleared
  112012. */
  112013. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112014. private _viewportCached;
  112015. /** @hidden */
  112016. _viewport(x: number, y: number, width: number, height: number): void;
  112017. /**
  112018. * Set the WebGL's viewport
  112019. * @param viewport defines the viewport element to be used
  112020. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112021. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112022. */
  112023. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112024. /**
  112025. * Begin a new frame
  112026. */
  112027. beginFrame(): void;
  112028. /**
  112029. * Enf the current frame
  112030. */
  112031. endFrame(): void;
  112032. /**
  112033. * Resize the view according to the canvas' size
  112034. */
  112035. resize(): void;
  112036. /**
  112037. * Force a specific size of the canvas
  112038. * @param width defines the new canvas' width
  112039. * @param height defines the new canvas' height
  112040. */
  112041. setSize(width: number, height: number): void;
  112042. /**
  112043. * Binds the frame buffer to the specified texture.
  112044. * @param texture The texture to render to or null for the default canvas
  112045. * @param faceIndex The face of the texture to render to in case of cube texture
  112046. * @param requiredWidth The width of the target to render to
  112047. * @param requiredHeight The height of the target to render to
  112048. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112049. * @param lodLevel defines the lod level to bind to the frame buffer
  112050. * @param layer defines the 2d array index to bind to frame buffer to
  112051. */
  112052. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112053. /** @hidden */
  112054. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112055. /**
  112056. * Unbind the current render target texture from the webGL context
  112057. * @param texture defines the render target texture to unbind
  112058. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112059. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112060. */
  112061. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112062. /**
  112063. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112064. */
  112065. flushFramebuffer(): void;
  112066. /**
  112067. * Unbind the current render target and bind the default framebuffer
  112068. */
  112069. restoreDefaultFramebuffer(): void;
  112070. /** @hidden */
  112071. protected _resetVertexBufferBinding(): void;
  112072. /**
  112073. * Creates a vertex buffer
  112074. * @param data the data for the vertex buffer
  112075. * @returns the new WebGL static buffer
  112076. */
  112077. createVertexBuffer(data: DataArray): DataBuffer;
  112078. private _createVertexBuffer;
  112079. /**
  112080. * Creates a dynamic vertex buffer
  112081. * @param data the data for the dynamic vertex buffer
  112082. * @returns the new WebGL dynamic buffer
  112083. */
  112084. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112085. protected _resetIndexBufferBinding(): void;
  112086. /**
  112087. * Creates a new index buffer
  112088. * @param indices defines the content of the index buffer
  112089. * @param updatable defines if the index buffer must be updatable
  112090. * @returns a new webGL buffer
  112091. */
  112092. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112093. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112094. /**
  112095. * Bind a webGL buffer to the webGL context
  112096. * @param buffer defines the buffer to bind
  112097. */
  112098. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112099. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112100. private bindBuffer;
  112101. /**
  112102. * update the bound buffer with the given data
  112103. * @param data defines the data to update
  112104. */
  112105. updateArrayBuffer(data: Float32Array): void;
  112106. private _vertexAttribPointer;
  112107. /** @hidden */
  112108. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112109. private _bindVertexBuffersAttributes;
  112110. /**
  112111. * Records a vertex array object
  112112. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112113. * @param vertexBuffers defines the list of vertex buffers to store
  112114. * @param indexBuffer defines the index buffer to store
  112115. * @param effect defines the effect to store
  112116. * @returns the new vertex array object
  112117. */
  112118. recordVertexArrayObject(vertexBuffers: {
  112119. [key: string]: VertexBuffer;
  112120. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112121. /**
  112122. * Bind a specific vertex array object
  112123. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112124. * @param vertexArrayObject defines the vertex array object to bind
  112125. * @param indexBuffer defines the index buffer to bind
  112126. */
  112127. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112128. /**
  112129. * Bind webGl buffers directly to the webGL context
  112130. * @param vertexBuffer defines the vertex buffer to bind
  112131. * @param indexBuffer defines the index buffer to bind
  112132. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112133. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112134. * @param effect defines the effect associated with the vertex buffer
  112135. */
  112136. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112137. private _unbindVertexArrayObject;
  112138. /**
  112139. * Bind a list of vertex buffers to the webGL context
  112140. * @param vertexBuffers defines the list of vertex buffers to bind
  112141. * @param indexBuffer defines the index buffer to bind
  112142. * @param effect defines the effect associated with the vertex buffers
  112143. */
  112144. bindBuffers(vertexBuffers: {
  112145. [key: string]: Nullable<VertexBuffer>;
  112146. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112147. /**
  112148. * Unbind all instance attributes
  112149. */
  112150. unbindInstanceAttributes(): void;
  112151. /**
  112152. * Release and free the memory of a vertex array object
  112153. * @param vao defines the vertex array object to delete
  112154. */
  112155. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112156. /** @hidden */
  112157. _releaseBuffer(buffer: DataBuffer): boolean;
  112158. protected _deleteBuffer(buffer: DataBuffer): void;
  112159. /**
  112160. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112161. * @param instancesBuffer defines the webGL buffer to update and bind
  112162. * @param data defines the data to store in the buffer
  112163. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112164. */
  112165. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112166. /**
  112167. * Bind the content of a webGL buffer used with instantiation
  112168. * @param instancesBuffer defines the webGL buffer to bind
  112169. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112170. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112171. */
  112172. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112173. /**
  112174. * Disable the instance attribute corresponding to the name in parameter
  112175. * @param name defines the name of the attribute to disable
  112176. */
  112177. disableInstanceAttributeByName(name: string): void;
  112178. /**
  112179. * Disable the instance attribute corresponding to the location in parameter
  112180. * @param attributeLocation defines the attribute location of the attribute to disable
  112181. */
  112182. disableInstanceAttribute(attributeLocation: number): void;
  112183. /**
  112184. * Disable the attribute corresponding to the location in parameter
  112185. * @param attributeLocation defines the attribute location of the attribute to disable
  112186. */
  112187. disableAttributeByIndex(attributeLocation: number): void;
  112188. /**
  112189. * Send a draw order
  112190. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112191. * @param indexStart defines the starting index
  112192. * @param indexCount defines the number of index to draw
  112193. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112194. */
  112195. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112196. /**
  112197. * Draw a list of points
  112198. * @param verticesStart defines the index of first vertex to draw
  112199. * @param verticesCount defines the count of vertices to draw
  112200. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112201. */
  112202. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112203. /**
  112204. * Draw a list of unindexed primitives
  112205. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112206. * @param verticesStart defines the index of first vertex to draw
  112207. * @param verticesCount defines the count of vertices to draw
  112208. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112209. */
  112210. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112211. /**
  112212. * Draw a list of indexed primitives
  112213. * @param fillMode defines the primitive to use
  112214. * @param indexStart defines the starting index
  112215. * @param indexCount defines the number of index to draw
  112216. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112217. */
  112218. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112219. /**
  112220. * Draw a list of unindexed primitives
  112221. * @param fillMode defines the primitive to use
  112222. * @param verticesStart defines the index of first vertex to draw
  112223. * @param verticesCount defines the count of vertices to draw
  112224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112225. */
  112226. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112227. private _drawMode;
  112228. /** @hidden */
  112229. protected _reportDrawCall(): void;
  112230. /** @hidden */
  112231. _releaseEffect(effect: Effect): void;
  112232. /** @hidden */
  112233. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112234. /**
  112235. * Create a new effect (used to store vertex/fragment shaders)
  112236. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  112237. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  112238. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  112239. * @param samplers defines an array of string used to represent textures
  112240. * @param defines defines the string containing the defines to use to compile the shaders
  112241. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  112242. * @param onCompiled defines a function to call when the effect creation is successful
  112243. * @param onError defines a function to call when the effect creation has failed
  112244. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  112245. * @returns the new Effect
  112246. */
  112247. 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;
  112248. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  112249. private _compileShader;
  112250. private _compileRawShader;
  112251. /** @hidden */
  112252. _getShaderSource(shader: WebGLShader): Nullable<string>;
  112253. /**
  112254. * Directly creates a webGL program
  112255. * @param pipelineContext defines the pipeline context to attach to
  112256. * @param vertexCode defines the vertex shader code to use
  112257. * @param fragmentCode defines the fragment shader code to use
  112258. * @param context defines the webGL context to use (if not set, the current one will be used)
  112259. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112260. * @returns the new webGL program
  112261. */
  112262. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112263. /**
  112264. * Creates a webGL program
  112265. * @param pipelineContext defines the pipeline context to attach to
  112266. * @param vertexCode defines the vertex shader code to use
  112267. * @param fragmentCode defines the fragment shader code to use
  112268. * @param defines defines the string containing the defines to use to compile the shaders
  112269. * @param context defines the webGL context to use (if not set, the current one will be used)
  112270. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112271. * @returns the new webGL program
  112272. */
  112273. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112274. /**
  112275. * Creates a new pipeline context
  112276. * @returns the new pipeline
  112277. */
  112278. createPipelineContext(): IPipelineContext;
  112279. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112280. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  112281. /** @hidden */
  112282. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112283. /** @hidden */
  112284. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112285. /** @hidden */
  112286. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112287. /**
  112288. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112289. * @param pipelineContext defines the pipeline context to use
  112290. * @param uniformsNames defines the list of uniform names
  112291. * @returns an array of webGL uniform locations
  112292. */
  112293. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112294. /**
  112295. * Gets the lsit of active attributes for a given webGL program
  112296. * @param pipelineContext defines the pipeline context to use
  112297. * @param attributesNames defines the list of attribute names to get
  112298. * @returns an array of indices indicating the offset of each attribute
  112299. */
  112300. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112301. /**
  112302. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112303. * @param effect defines the effect to activate
  112304. */
  112305. enableEffect(effect: Nullable<Effect>): void;
  112306. /**
  112307. * Set the value of an uniform to a number (int)
  112308. * @param uniform defines the webGL uniform location where to store the value
  112309. * @param value defines the int number to store
  112310. */
  112311. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112312. /**
  112313. * Set the value of an uniform to an array of int32
  112314. * @param uniform defines the webGL uniform location where to store the value
  112315. * @param array defines the array of int32 to store
  112316. */
  112317. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112318. /**
  112319. * Set the value of an uniform to an array of int32 (stored as vec2)
  112320. * @param uniform defines the webGL uniform location where to store the value
  112321. * @param array defines the array of int32 to store
  112322. */
  112323. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112324. /**
  112325. * Set the value of an uniform to an array of int32 (stored as vec3)
  112326. * @param uniform defines the webGL uniform location where to store the value
  112327. * @param array defines the array of int32 to store
  112328. */
  112329. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112330. /**
  112331. * Set the value of an uniform to an array of int32 (stored as vec4)
  112332. * @param uniform defines the webGL uniform location where to store the value
  112333. * @param array defines the array of int32 to store
  112334. */
  112335. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112336. /**
  112337. * Set the value of an uniform to an array of number
  112338. * @param uniform defines the webGL uniform location where to store the value
  112339. * @param array defines the array of number to store
  112340. */
  112341. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112342. /**
  112343. * Set the value of an uniform to an array of number (stored as vec2)
  112344. * @param uniform defines the webGL uniform location where to store the value
  112345. * @param array defines the array of number to store
  112346. */
  112347. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112348. /**
  112349. * Set the value of an uniform to an array of number (stored as vec3)
  112350. * @param uniform defines the webGL uniform location where to store the value
  112351. * @param array defines the array of number to store
  112352. */
  112353. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112354. /**
  112355. * Set the value of an uniform to an array of number (stored as vec4)
  112356. * @param uniform defines the webGL uniform location where to store the value
  112357. * @param array defines the array of number to store
  112358. */
  112359. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112360. /**
  112361. * Set the value of an uniform to an array of float32 (stored as matrices)
  112362. * @param uniform defines the webGL uniform location where to store the value
  112363. * @param matrices defines the array of float32 to store
  112364. */
  112365. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112366. /**
  112367. * Set the value of an uniform to a matrix (3x3)
  112368. * @param uniform defines the webGL uniform location where to store the value
  112369. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112370. */
  112371. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112372. /**
  112373. * Set the value of an uniform to a matrix (2x2)
  112374. * @param uniform defines the webGL uniform location where to store the value
  112375. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112376. */
  112377. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112378. /**
  112379. * Set the value of an uniform to a number (float)
  112380. * @param uniform defines the webGL uniform location where to store the value
  112381. * @param value defines the float number to store
  112382. */
  112383. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112384. /**
  112385. * Set the value of an uniform to a vec2
  112386. * @param uniform defines the webGL uniform location where to store the value
  112387. * @param x defines the 1st component of the value
  112388. * @param y defines the 2nd component of the value
  112389. */
  112390. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112391. /**
  112392. * Set the value of an uniform to a vec3
  112393. * @param uniform defines the webGL uniform location where to store the value
  112394. * @param x defines the 1st component of the value
  112395. * @param y defines the 2nd component of the value
  112396. * @param z defines the 3rd component of the value
  112397. */
  112398. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112399. /**
  112400. * Set the value of an uniform to a vec4
  112401. * @param uniform defines the webGL uniform location where to store the value
  112402. * @param x defines the 1st component of the value
  112403. * @param y defines the 2nd component of the value
  112404. * @param z defines the 3rd component of the value
  112405. * @param w defines the 4th component of the value
  112406. */
  112407. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112408. /**
  112409. * Apply all cached states (depth, culling, stencil and alpha)
  112410. */
  112411. applyStates(): void;
  112412. /**
  112413. * Enable or disable color writing
  112414. * @param enable defines the state to set
  112415. */
  112416. setColorWrite(enable: boolean): void;
  112417. /**
  112418. * Gets a boolean indicating if color writing is enabled
  112419. * @returns the current color writing state
  112420. */
  112421. getColorWrite(): boolean;
  112422. /**
  112423. * Gets the depth culling state manager
  112424. */
  112425. get depthCullingState(): DepthCullingState;
  112426. /**
  112427. * Gets the alpha state manager
  112428. */
  112429. get alphaState(): AlphaState;
  112430. /**
  112431. * Gets the stencil state manager
  112432. */
  112433. get stencilState(): StencilState;
  112434. /**
  112435. * Clears the list of texture accessible through engine.
  112436. * This can help preventing texture load conflict due to name collision.
  112437. */
  112438. clearInternalTexturesCache(): void;
  112439. /**
  112440. * Force the entire cache to be cleared
  112441. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112442. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112443. */
  112444. wipeCaches(bruteForce?: boolean): void;
  112445. /** @hidden */
  112446. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112447. min: number;
  112448. mag: number;
  112449. };
  112450. /** @hidden */
  112451. _createTexture(): WebGLTexture;
  112452. /**
  112453. * Usually called from Texture.ts.
  112454. * Passed information to create a WebGLTexture
  112455. * @param url defines a value which contains one of the following:
  112456. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112457. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112458. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112459. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112460. * @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)
  112461. * @param scene needed for loading to the correct scene
  112462. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112463. * @param onLoad optional callback to be called upon successful completion
  112464. * @param onError optional callback to be called upon failure
  112465. * @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
  112466. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112467. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112468. * @param forcedExtension defines the extension to use to pick the right loader
  112469. * @param mimeType defines an optional mime type
  112470. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112471. */
  112472. 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;
  112473. /**
  112474. * Loads an image as an HTMLImageElement.
  112475. * @param input url string, ArrayBuffer, or Blob to load
  112476. * @param onLoad callback called when the image successfully loads
  112477. * @param onError callback called when the image fails to load
  112478. * @param offlineProvider offline provider for caching
  112479. * @param mimeType optional mime type
  112480. * @returns the HTMLImageElement of the loaded image
  112481. * @hidden
  112482. */
  112483. 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>;
  112484. /**
  112485. * @hidden
  112486. */
  112487. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112488. private _unpackFlipYCached;
  112489. /**
  112490. * In case you are sharing the context with other applications, it might
  112491. * be interested to not cache the unpack flip y state to ensure a consistent
  112492. * value would be set.
  112493. */
  112494. enableUnpackFlipYCached: boolean;
  112495. /** @hidden */
  112496. _unpackFlipY(value: boolean): void;
  112497. /** @hidden */
  112498. _getUnpackAlignement(): number;
  112499. private _getTextureTarget;
  112500. /**
  112501. * Update the sampling mode of a given texture
  112502. * @param samplingMode defines the required sampling mode
  112503. * @param texture defines the texture to update
  112504. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112505. */
  112506. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112507. /**
  112508. * Update the sampling mode of a given texture
  112509. * @param texture defines the texture to update
  112510. * @param wrapU defines the texture wrap mode of the u coordinates
  112511. * @param wrapV defines the texture wrap mode of the v coordinates
  112512. * @param wrapR defines the texture wrap mode of the r coordinates
  112513. */
  112514. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112515. /** @hidden */
  112516. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112517. width: number;
  112518. height: number;
  112519. layers?: number;
  112520. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112521. /** @hidden */
  112522. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112523. /** @hidden */
  112524. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112525. /**
  112526. * Update a portion of an internal texture
  112527. * @param texture defines the texture to update
  112528. * @param imageData defines the data to store into the texture
  112529. * @param xOffset defines the x coordinates of the update rectangle
  112530. * @param yOffset defines the y coordinates of the update rectangle
  112531. * @param width defines the width of the update rectangle
  112532. * @param height defines the height of the update rectangle
  112533. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112534. * @param lod defines the lod level to update (0 by default)
  112535. */
  112536. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112537. /** @hidden */
  112538. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112539. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112540. private _prepareWebGLTexture;
  112541. /** @hidden */
  112542. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112543. private _getDepthStencilBuffer;
  112544. /** @hidden */
  112545. _releaseFramebufferObjects(texture: InternalTexture): void;
  112546. /** @hidden */
  112547. _releaseTexture(texture: InternalTexture): void;
  112548. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112549. protected _setProgram(program: WebGLProgram): void;
  112550. protected _boundUniforms: {
  112551. [key: number]: WebGLUniformLocation;
  112552. };
  112553. /**
  112554. * Binds an effect to the webGL context
  112555. * @param effect defines the effect to bind
  112556. */
  112557. bindSamplers(effect: Effect): void;
  112558. private _activateCurrentTexture;
  112559. /** @hidden */
  112560. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112561. /** @hidden */
  112562. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112563. /**
  112564. * Unbind all textures from the webGL context
  112565. */
  112566. unbindAllTextures(): void;
  112567. /**
  112568. * Sets a texture to the according uniform.
  112569. * @param channel The texture channel
  112570. * @param uniform The uniform to set
  112571. * @param texture The texture to apply
  112572. */
  112573. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112574. private _bindSamplerUniformToChannel;
  112575. private _getTextureWrapMode;
  112576. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112577. /**
  112578. * Sets an array of texture to the webGL context
  112579. * @param channel defines the channel where the texture array must be set
  112580. * @param uniform defines the associated uniform location
  112581. * @param textures defines the array of textures to bind
  112582. */
  112583. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112584. /** @hidden */
  112585. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112586. private _setTextureParameterFloat;
  112587. private _setTextureParameterInteger;
  112588. /**
  112589. * Unbind all vertex attributes from the webGL context
  112590. */
  112591. unbindAllAttributes(): void;
  112592. /**
  112593. * 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
  112594. */
  112595. releaseEffects(): void;
  112596. /**
  112597. * Dispose and release all associated resources
  112598. */
  112599. dispose(): void;
  112600. /**
  112601. * Attach a new callback raised when context lost event is fired
  112602. * @param callback defines the callback to call
  112603. */
  112604. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112605. /**
  112606. * Attach a new callback raised when context restored event is fired
  112607. * @param callback defines the callback to call
  112608. */
  112609. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112610. /**
  112611. * Get the current error code of the webGL context
  112612. * @returns the error code
  112613. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112614. */
  112615. getError(): number;
  112616. private _canRenderToFloatFramebuffer;
  112617. private _canRenderToHalfFloatFramebuffer;
  112618. private _canRenderToFramebuffer;
  112619. /** @hidden */
  112620. _getWebGLTextureType(type: number): number;
  112621. /** @hidden */
  112622. _getInternalFormat(format: number): number;
  112623. /** @hidden */
  112624. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112625. /** @hidden */
  112626. _getRGBAMultiSampleBufferFormat(type: number): number;
  112627. /** @hidden */
  112628. _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;
  112629. /**
  112630. * Loads a file from a url
  112631. * @param url url to load
  112632. * @param onSuccess callback called when the file successfully loads
  112633. * @param onProgress callback called while file is loading (if the server supports this mode)
  112634. * @param offlineProvider defines the offline provider for caching
  112635. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112636. * @param onError callback called when the file fails to load
  112637. * @returns a file request object
  112638. * @hidden
  112639. */
  112640. 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;
  112641. /**
  112642. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112643. * @param x defines the x coordinate of the rectangle where pixels must be read
  112644. * @param y defines the y coordinate of the rectangle where pixels must be read
  112645. * @param width defines the width of the rectangle where pixels must be read
  112646. * @param height defines the height of the rectangle where pixels must be read
  112647. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  112648. * @returns a Uint8Array containing RGBA colors
  112649. */
  112650. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  112651. private static _isSupported;
  112652. /**
  112653. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  112654. * @returns true if the engine can be created
  112655. * @ignorenaming
  112656. */
  112657. static isSupported(): boolean;
  112658. /**
  112659. * Find the next highest power of two.
  112660. * @param x Number to start search from.
  112661. * @return Next highest power of two.
  112662. */
  112663. static CeilingPOT(x: number): number;
  112664. /**
  112665. * Find the next lowest power of two.
  112666. * @param x Number to start search from.
  112667. * @return Next lowest power of two.
  112668. */
  112669. static FloorPOT(x: number): number;
  112670. /**
  112671. * Find the nearest power of two.
  112672. * @param x Number to start search from.
  112673. * @return Next nearest power of two.
  112674. */
  112675. static NearestPOT(x: number): number;
  112676. /**
  112677. * Get the closest exponent of two
  112678. * @param value defines the value to approximate
  112679. * @param max defines the maximum value to return
  112680. * @param mode defines how to define the closest value
  112681. * @returns closest exponent of two of the given value
  112682. */
  112683. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112684. /**
  112685. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112686. * @param func - the function to be called
  112687. * @param requester - the object that will request the next frame. Falls back to window.
  112688. * @returns frame number
  112689. */
  112690. static QueueNewFrame(func: () => void, requester?: any): number;
  112691. /**
  112692. * Gets host document
  112693. * @returns the host document object
  112694. */
  112695. getHostDocument(): Nullable<Document>;
  112696. }
  112697. }
  112698. declare module BABYLON {
  112699. /**
  112700. * Class representing spherical harmonics coefficients to the 3rd degree
  112701. */
  112702. export class SphericalHarmonics {
  112703. /**
  112704. * Defines whether or not the harmonics have been prescaled for rendering.
  112705. */
  112706. preScaled: boolean;
  112707. /**
  112708. * The l0,0 coefficients of the spherical harmonics
  112709. */
  112710. l00: Vector3;
  112711. /**
  112712. * The l1,-1 coefficients of the spherical harmonics
  112713. */
  112714. l1_1: Vector3;
  112715. /**
  112716. * The l1,0 coefficients of the spherical harmonics
  112717. */
  112718. l10: Vector3;
  112719. /**
  112720. * The l1,1 coefficients of the spherical harmonics
  112721. */
  112722. l11: Vector3;
  112723. /**
  112724. * The l2,-2 coefficients of the spherical harmonics
  112725. */
  112726. l2_2: Vector3;
  112727. /**
  112728. * The l2,-1 coefficients of the spherical harmonics
  112729. */
  112730. l2_1: Vector3;
  112731. /**
  112732. * The l2,0 coefficients of the spherical harmonics
  112733. */
  112734. l20: Vector3;
  112735. /**
  112736. * The l2,1 coefficients of the spherical harmonics
  112737. */
  112738. l21: Vector3;
  112739. /**
  112740. * The l2,2 coefficients of the spherical harmonics
  112741. */
  112742. l22: Vector3;
  112743. /**
  112744. * Adds a light to the spherical harmonics
  112745. * @param direction the direction of the light
  112746. * @param color the color of the light
  112747. * @param deltaSolidAngle the delta solid angle of the light
  112748. */
  112749. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  112750. /**
  112751. * Scales the spherical harmonics by the given amount
  112752. * @param scale the amount to scale
  112753. */
  112754. scaleInPlace(scale: number): void;
  112755. /**
  112756. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  112757. *
  112758. * ```
  112759. * E_lm = A_l * L_lm
  112760. * ```
  112761. *
  112762. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  112763. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  112764. * the scaling factors are given in equation 9.
  112765. */
  112766. convertIncidentRadianceToIrradiance(): void;
  112767. /**
  112768. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  112769. *
  112770. * ```
  112771. * L = (1/pi) * E * rho
  112772. * ```
  112773. *
  112774. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  112775. */
  112776. convertIrradianceToLambertianRadiance(): void;
  112777. /**
  112778. * Integrates the reconstruction coefficients directly in to the SH preventing further
  112779. * required operations at run time.
  112780. *
  112781. * This is simply done by scaling back the SH with Ylm constants parameter.
  112782. * The trigonometric part being applied by the shader at run time.
  112783. */
  112784. preScaleForRendering(): void;
  112785. /**
  112786. * Constructs a spherical harmonics from an array.
  112787. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  112788. * @returns the spherical harmonics
  112789. */
  112790. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  112791. /**
  112792. * Gets the spherical harmonics from polynomial
  112793. * @param polynomial the spherical polynomial
  112794. * @returns the spherical harmonics
  112795. */
  112796. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  112797. }
  112798. /**
  112799. * Class representing spherical polynomial coefficients to the 3rd degree
  112800. */
  112801. export class SphericalPolynomial {
  112802. private _harmonics;
  112803. /**
  112804. * The spherical harmonics used to create the polynomials.
  112805. */
  112806. get preScaledHarmonics(): SphericalHarmonics;
  112807. /**
  112808. * The x coefficients of the spherical polynomial
  112809. */
  112810. x: Vector3;
  112811. /**
  112812. * The y coefficients of the spherical polynomial
  112813. */
  112814. y: Vector3;
  112815. /**
  112816. * The z coefficients of the spherical polynomial
  112817. */
  112818. z: Vector3;
  112819. /**
  112820. * The xx coefficients of the spherical polynomial
  112821. */
  112822. xx: Vector3;
  112823. /**
  112824. * The yy coefficients of the spherical polynomial
  112825. */
  112826. yy: Vector3;
  112827. /**
  112828. * The zz coefficients of the spherical polynomial
  112829. */
  112830. zz: Vector3;
  112831. /**
  112832. * The xy coefficients of the spherical polynomial
  112833. */
  112834. xy: Vector3;
  112835. /**
  112836. * The yz coefficients of the spherical polynomial
  112837. */
  112838. yz: Vector3;
  112839. /**
  112840. * The zx coefficients of the spherical polynomial
  112841. */
  112842. zx: Vector3;
  112843. /**
  112844. * Adds an ambient color to the spherical polynomial
  112845. * @param color the color to add
  112846. */
  112847. addAmbient(color: Color3): void;
  112848. /**
  112849. * Scales the spherical polynomial by the given amount
  112850. * @param scale the amount to scale
  112851. */
  112852. scaleInPlace(scale: number): void;
  112853. /**
  112854. * Gets the spherical polynomial from harmonics
  112855. * @param harmonics the spherical harmonics
  112856. * @returns the spherical polynomial
  112857. */
  112858. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  112859. /**
  112860. * Constructs a spherical polynomial from an array.
  112861. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  112862. * @returns the spherical polynomial
  112863. */
  112864. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  112865. }
  112866. }
  112867. declare module BABYLON {
  112868. /**
  112869. * Defines the source of the internal texture
  112870. */
  112871. export enum InternalTextureSource {
  112872. /**
  112873. * The source of the texture data is unknown
  112874. */
  112875. Unknown = 0,
  112876. /**
  112877. * Texture data comes from an URL
  112878. */
  112879. Url = 1,
  112880. /**
  112881. * Texture data is only used for temporary storage
  112882. */
  112883. Temp = 2,
  112884. /**
  112885. * Texture data comes from raw data (ArrayBuffer)
  112886. */
  112887. Raw = 3,
  112888. /**
  112889. * Texture content is dynamic (video or dynamic texture)
  112890. */
  112891. Dynamic = 4,
  112892. /**
  112893. * Texture content is generated by rendering to it
  112894. */
  112895. RenderTarget = 5,
  112896. /**
  112897. * Texture content is part of a multi render target process
  112898. */
  112899. MultiRenderTarget = 6,
  112900. /**
  112901. * Texture data comes from a cube data file
  112902. */
  112903. Cube = 7,
  112904. /**
  112905. * Texture data comes from a raw cube data
  112906. */
  112907. CubeRaw = 8,
  112908. /**
  112909. * Texture data come from a prefiltered cube data file
  112910. */
  112911. CubePrefiltered = 9,
  112912. /**
  112913. * Texture content is raw 3D data
  112914. */
  112915. Raw3D = 10,
  112916. /**
  112917. * Texture content is raw 2D array data
  112918. */
  112919. Raw2DArray = 11,
  112920. /**
  112921. * Texture content is a depth texture
  112922. */
  112923. Depth = 12,
  112924. /**
  112925. * Texture data comes from a raw cube data encoded with RGBD
  112926. */
  112927. CubeRawRGBD = 13
  112928. }
  112929. /**
  112930. * Class used to store data associated with WebGL texture data for the engine
  112931. * This class should not be used directly
  112932. */
  112933. export class InternalTexture {
  112934. /** @hidden */
  112935. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  112936. /**
  112937. * Defines if the texture is ready
  112938. */
  112939. isReady: boolean;
  112940. /**
  112941. * Defines if the texture is a cube texture
  112942. */
  112943. isCube: boolean;
  112944. /**
  112945. * Defines if the texture contains 3D data
  112946. */
  112947. is3D: boolean;
  112948. /**
  112949. * Defines if the texture contains 2D array data
  112950. */
  112951. is2DArray: boolean;
  112952. /**
  112953. * Defines if the texture contains multiview data
  112954. */
  112955. isMultiview: boolean;
  112956. /**
  112957. * Gets the URL used to load this texture
  112958. */
  112959. url: string;
  112960. /**
  112961. * Gets the sampling mode of the texture
  112962. */
  112963. samplingMode: number;
  112964. /**
  112965. * Gets a boolean indicating if the texture needs mipmaps generation
  112966. */
  112967. generateMipMaps: boolean;
  112968. /**
  112969. * Gets the number of samples used by the texture (WebGL2+ only)
  112970. */
  112971. samples: number;
  112972. /**
  112973. * Gets the type of the texture (int, float...)
  112974. */
  112975. type: number;
  112976. /**
  112977. * Gets the format of the texture (RGB, RGBA...)
  112978. */
  112979. format: number;
  112980. /**
  112981. * Observable called when the texture is loaded
  112982. */
  112983. onLoadedObservable: Observable<InternalTexture>;
  112984. /**
  112985. * Gets the width of the texture
  112986. */
  112987. width: number;
  112988. /**
  112989. * Gets the height of the texture
  112990. */
  112991. height: number;
  112992. /**
  112993. * Gets the depth of the texture
  112994. */
  112995. depth: number;
  112996. /**
  112997. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  112998. */
  112999. baseWidth: number;
  113000. /**
  113001. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113002. */
  113003. baseHeight: number;
  113004. /**
  113005. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113006. */
  113007. baseDepth: number;
  113008. /**
  113009. * Gets a boolean indicating if the texture is inverted on Y axis
  113010. */
  113011. invertY: boolean;
  113012. /** @hidden */
  113013. _invertVScale: boolean;
  113014. /** @hidden */
  113015. _associatedChannel: number;
  113016. /** @hidden */
  113017. _source: InternalTextureSource;
  113018. /** @hidden */
  113019. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113020. /** @hidden */
  113021. _bufferView: Nullable<ArrayBufferView>;
  113022. /** @hidden */
  113023. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113024. /** @hidden */
  113025. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113026. /** @hidden */
  113027. _size: number;
  113028. /** @hidden */
  113029. _extension: string;
  113030. /** @hidden */
  113031. _files: Nullable<string[]>;
  113032. /** @hidden */
  113033. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113034. /** @hidden */
  113035. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113036. /** @hidden */
  113037. _framebuffer: Nullable<WebGLFramebuffer>;
  113038. /** @hidden */
  113039. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113040. /** @hidden */
  113041. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113042. /** @hidden */
  113043. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113044. /** @hidden */
  113045. _attachments: Nullable<number[]>;
  113046. /** @hidden */
  113047. _cachedCoordinatesMode: Nullable<number>;
  113048. /** @hidden */
  113049. _cachedWrapU: Nullable<number>;
  113050. /** @hidden */
  113051. _cachedWrapV: Nullable<number>;
  113052. /** @hidden */
  113053. _cachedWrapR: Nullable<number>;
  113054. /** @hidden */
  113055. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113056. /** @hidden */
  113057. _isDisabled: boolean;
  113058. /** @hidden */
  113059. _compression: Nullable<string>;
  113060. /** @hidden */
  113061. _generateStencilBuffer: boolean;
  113062. /** @hidden */
  113063. _generateDepthBuffer: boolean;
  113064. /** @hidden */
  113065. _comparisonFunction: number;
  113066. /** @hidden */
  113067. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113068. /** @hidden */
  113069. _lodGenerationScale: number;
  113070. /** @hidden */
  113071. _lodGenerationOffset: number;
  113072. /** @hidden */
  113073. _depthStencilTexture: Nullable<InternalTexture>;
  113074. /** @hidden */
  113075. _colorTextureArray: Nullable<WebGLTexture>;
  113076. /** @hidden */
  113077. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113078. /** @hidden */
  113079. _lodTextureHigh: Nullable<BaseTexture>;
  113080. /** @hidden */
  113081. _lodTextureMid: Nullable<BaseTexture>;
  113082. /** @hidden */
  113083. _lodTextureLow: Nullable<BaseTexture>;
  113084. /** @hidden */
  113085. _isRGBD: boolean;
  113086. /** @hidden */
  113087. _linearSpecularLOD: boolean;
  113088. /** @hidden */
  113089. _irradianceTexture: Nullable<BaseTexture>;
  113090. /** @hidden */
  113091. _webGLTexture: Nullable<WebGLTexture>;
  113092. /** @hidden */
  113093. _references: number;
  113094. private _engine;
  113095. /**
  113096. * Gets the Engine the texture belongs to.
  113097. * @returns The babylon engine
  113098. */
  113099. getEngine(): ThinEngine;
  113100. /**
  113101. * Gets the data source type of the texture
  113102. */
  113103. get source(): InternalTextureSource;
  113104. /**
  113105. * Creates a new InternalTexture
  113106. * @param engine defines the engine to use
  113107. * @param source defines the type of data that will be used
  113108. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113109. */
  113110. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113111. /**
  113112. * Increments the number of references (ie. the number of Texture that point to it)
  113113. */
  113114. incrementReferences(): void;
  113115. /**
  113116. * Change the size of the texture (not the size of the content)
  113117. * @param width defines the new width
  113118. * @param height defines the new height
  113119. * @param depth defines the new depth (1 by default)
  113120. */
  113121. updateSize(width: int, height: int, depth?: int): void;
  113122. /** @hidden */
  113123. _rebuild(): void;
  113124. /** @hidden */
  113125. _swapAndDie(target: InternalTexture): void;
  113126. /**
  113127. * Dispose the current allocated resources
  113128. */
  113129. dispose(): void;
  113130. }
  113131. }
  113132. declare module BABYLON {
  113133. /**
  113134. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113136. */
  113137. export class Analyser {
  113138. /**
  113139. * Gets or sets the smoothing
  113140. * @ignorenaming
  113141. */
  113142. SMOOTHING: number;
  113143. /**
  113144. * Gets or sets the FFT table size
  113145. * @ignorenaming
  113146. */
  113147. FFT_SIZE: number;
  113148. /**
  113149. * Gets or sets the bar graph amplitude
  113150. * @ignorenaming
  113151. */
  113152. BARGRAPHAMPLITUDE: number;
  113153. /**
  113154. * Gets or sets the position of the debug canvas
  113155. * @ignorenaming
  113156. */
  113157. DEBUGCANVASPOS: {
  113158. x: number;
  113159. y: number;
  113160. };
  113161. /**
  113162. * Gets or sets the debug canvas size
  113163. * @ignorenaming
  113164. */
  113165. DEBUGCANVASSIZE: {
  113166. width: number;
  113167. height: number;
  113168. };
  113169. private _byteFreqs;
  113170. private _byteTime;
  113171. private _floatFreqs;
  113172. private _webAudioAnalyser;
  113173. private _debugCanvas;
  113174. private _debugCanvasContext;
  113175. private _scene;
  113176. private _registerFunc;
  113177. private _audioEngine;
  113178. /**
  113179. * Creates a new analyser
  113180. * @param scene defines hosting scene
  113181. */
  113182. constructor(scene: Scene);
  113183. /**
  113184. * Get the number of data values you will have to play with for the visualization
  113185. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  113186. * @returns a number
  113187. */
  113188. getFrequencyBinCount(): number;
  113189. /**
  113190. * Gets the current frequency data as a byte array
  113191. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113192. * @returns a Uint8Array
  113193. */
  113194. getByteFrequencyData(): Uint8Array;
  113195. /**
  113196. * Gets the current waveform as a byte array
  113197. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  113198. * @returns a Uint8Array
  113199. */
  113200. getByteTimeDomainData(): Uint8Array;
  113201. /**
  113202. * Gets the current frequency data as a float array
  113203. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113204. * @returns a Float32Array
  113205. */
  113206. getFloatFrequencyData(): Float32Array;
  113207. /**
  113208. * Renders the debug canvas
  113209. */
  113210. drawDebugCanvas(): void;
  113211. /**
  113212. * Stops rendering the debug canvas and removes it
  113213. */
  113214. stopDebugCanvas(): void;
  113215. /**
  113216. * Connects two audio nodes
  113217. * @param inputAudioNode defines first node to connect
  113218. * @param outputAudioNode defines second node to connect
  113219. */
  113220. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  113221. /**
  113222. * Releases all associated resources
  113223. */
  113224. dispose(): void;
  113225. }
  113226. }
  113227. declare module BABYLON {
  113228. /**
  113229. * This represents an audio engine and it is responsible
  113230. * to play, synchronize and analyse sounds throughout the application.
  113231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113232. */
  113233. export interface IAudioEngine extends IDisposable {
  113234. /**
  113235. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113236. */
  113237. readonly canUseWebAudio: boolean;
  113238. /**
  113239. * Gets the current AudioContext if available.
  113240. */
  113241. readonly audioContext: Nullable<AudioContext>;
  113242. /**
  113243. * The master gain node defines the global audio volume of your audio engine.
  113244. */
  113245. readonly masterGain: GainNode;
  113246. /**
  113247. * Gets whether or not mp3 are supported by your browser.
  113248. */
  113249. readonly isMP3supported: boolean;
  113250. /**
  113251. * Gets whether or not ogg are supported by your browser.
  113252. */
  113253. readonly isOGGsupported: boolean;
  113254. /**
  113255. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113256. * @ignoreNaming
  113257. */
  113258. WarnedWebAudioUnsupported: boolean;
  113259. /**
  113260. * Defines if the audio engine relies on a custom unlocked button.
  113261. * In this case, the embedded button will not be displayed.
  113262. */
  113263. useCustomUnlockedButton: boolean;
  113264. /**
  113265. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  113266. */
  113267. readonly unlocked: boolean;
  113268. /**
  113269. * Event raised when audio has been unlocked on the browser.
  113270. */
  113271. onAudioUnlockedObservable: Observable<AudioEngine>;
  113272. /**
  113273. * Event raised when audio has been locked on the browser.
  113274. */
  113275. onAudioLockedObservable: Observable<AudioEngine>;
  113276. /**
  113277. * Flags the audio engine in Locked state.
  113278. * This happens due to new browser policies preventing audio to autoplay.
  113279. */
  113280. lock(): void;
  113281. /**
  113282. * Unlocks the audio engine once a user action has been done on the dom.
  113283. * This is helpful to resume play once browser policies have been satisfied.
  113284. */
  113285. unlock(): void;
  113286. /**
  113287. * Gets the global volume sets on the master gain.
  113288. * @returns the global volume if set or -1 otherwise
  113289. */
  113290. getGlobalVolume(): number;
  113291. /**
  113292. * Sets the global volume of your experience (sets on the master gain).
  113293. * @param newVolume Defines the new global volume of the application
  113294. */
  113295. setGlobalVolume(newVolume: number): void;
  113296. /**
  113297. * Connect the audio engine to an audio analyser allowing some amazing
  113298. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113300. * @param analyser The analyser to connect to the engine
  113301. */
  113302. connectToAnalyser(analyser: Analyser): void;
  113303. }
  113304. /**
  113305. * This represents the default audio engine used in babylon.
  113306. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113308. */
  113309. export class AudioEngine implements IAudioEngine {
  113310. private _audioContext;
  113311. private _audioContextInitialized;
  113312. private _muteButton;
  113313. private _hostElement;
  113314. /**
  113315. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113316. */
  113317. canUseWebAudio: boolean;
  113318. /**
  113319. * The master gain node defines the global audio volume of your audio engine.
  113320. */
  113321. masterGain: GainNode;
  113322. /**
  113323. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113324. * @ignoreNaming
  113325. */
  113326. WarnedWebAudioUnsupported: boolean;
  113327. /**
  113328. * Gets whether or not mp3 are supported by your browser.
  113329. */
  113330. isMP3supported: boolean;
  113331. /**
  113332. * Gets whether or not ogg are supported by your browser.
  113333. */
  113334. isOGGsupported: boolean;
  113335. /**
  113336. * Gets whether audio has been unlocked on the device.
  113337. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113338. * a user interaction has happened.
  113339. */
  113340. unlocked: boolean;
  113341. /**
  113342. * Defines if the audio engine relies on a custom unlocked button.
  113343. * In this case, the embedded button will not be displayed.
  113344. */
  113345. useCustomUnlockedButton: boolean;
  113346. /**
  113347. * Event raised when audio has been unlocked on the browser.
  113348. */
  113349. onAudioUnlockedObservable: Observable<AudioEngine>;
  113350. /**
  113351. * Event raised when audio has been locked on the browser.
  113352. */
  113353. onAudioLockedObservable: Observable<AudioEngine>;
  113354. /**
  113355. * Gets the current AudioContext if available.
  113356. */
  113357. get audioContext(): Nullable<AudioContext>;
  113358. private _connectedAnalyser;
  113359. /**
  113360. * Instantiates a new audio engine.
  113361. *
  113362. * There should be only one per page as some browsers restrict the number
  113363. * of audio contexts you can create.
  113364. * @param hostElement defines the host element where to display the mute icon if necessary
  113365. */
  113366. constructor(hostElement?: Nullable<HTMLElement>);
  113367. /**
  113368. * Flags the audio engine in Locked state.
  113369. * This happens due to new browser policies preventing audio to autoplay.
  113370. */
  113371. lock(): void;
  113372. /**
  113373. * Unlocks the audio engine once a user action has been done on the dom.
  113374. * This is helpful to resume play once browser policies have been satisfied.
  113375. */
  113376. unlock(): void;
  113377. private _resumeAudioContext;
  113378. private _initializeAudioContext;
  113379. private _tryToRun;
  113380. private _triggerRunningState;
  113381. private _triggerSuspendedState;
  113382. private _displayMuteButton;
  113383. private _moveButtonToTopLeft;
  113384. private _onResize;
  113385. private _hideMuteButton;
  113386. /**
  113387. * Destroy and release the resources associated with the audio ccontext.
  113388. */
  113389. dispose(): void;
  113390. /**
  113391. * Gets the global volume sets on the master gain.
  113392. * @returns the global volume if set or -1 otherwise
  113393. */
  113394. getGlobalVolume(): number;
  113395. /**
  113396. * Sets the global volume of your experience (sets on the master gain).
  113397. * @param newVolume Defines the new global volume of the application
  113398. */
  113399. setGlobalVolume(newVolume: number): void;
  113400. /**
  113401. * Connect the audio engine to an audio analyser allowing some amazing
  113402. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113404. * @param analyser The analyser to connect to the engine
  113405. */
  113406. connectToAnalyser(analyser: Analyser): void;
  113407. }
  113408. }
  113409. declare module BABYLON {
  113410. /**
  113411. * Interface used to present a loading screen while loading a scene
  113412. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113413. */
  113414. export interface ILoadingScreen {
  113415. /**
  113416. * Function called to display the loading screen
  113417. */
  113418. displayLoadingUI: () => void;
  113419. /**
  113420. * Function called to hide the loading screen
  113421. */
  113422. hideLoadingUI: () => void;
  113423. /**
  113424. * Gets or sets the color to use for the background
  113425. */
  113426. loadingUIBackgroundColor: string;
  113427. /**
  113428. * Gets or sets the text to display while loading
  113429. */
  113430. loadingUIText: string;
  113431. }
  113432. /**
  113433. * Class used for the default loading screen
  113434. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113435. */
  113436. export class DefaultLoadingScreen implements ILoadingScreen {
  113437. private _renderingCanvas;
  113438. private _loadingText;
  113439. private _loadingDivBackgroundColor;
  113440. private _loadingDiv;
  113441. private _loadingTextDiv;
  113442. /** Gets or sets the logo url to use for the default loading screen */
  113443. static DefaultLogoUrl: string;
  113444. /** Gets or sets the spinner url to use for the default loading screen */
  113445. static DefaultSpinnerUrl: string;
  113446. /**
  113447. * Creates a new default loading screen
  113448. * @param _renderingCanvas defines the canvas used to render the scene
  113449. * @param _loadingText defines the default text to display
  113450. * @param _loadingDivBackgroundColor defines the default background color
  113451. */
  113452. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113453. /**
  113454. * Function called to display the loading screen
  113455. */
  113456. displayLoadingUI(): void;
  113457. /**
  113458. * Function called to hide the loading screen
  113459. */
  113460. hideLoadingUI(): void;
  113461. /**
  113462. * Gets or sets the text to display while loading
  113463. */
  113464. set loadingUIText(text: string);
  113465. get loadingUIText(): string;
  113466. /**
  113467. * Gets or sets the color to use for the background
  113468. */
  113469. get loadingUIBackgroundColor(): string;
  113470. set loadingUIBackgroundColor(color: string);
  113471. private _resizeLoadingUI;
  113472. }
  113473. }
  113474. declare module BABYLON {
  113475. /**
  113476. * Interface for any object that can request an animation frame
  113477. */
  113478. export interface ICustomAnimationFrameRequester {
  113479. /**
  113480. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113481. */
  113482. renderFunction?: Function;
  113483. /**
  113484. * Called to request the next frame to render to
  113485. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113486. */
  113487. requestAnimationFrame: Function;
  113488. /**
  113489. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113490. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113491. */
  113492. requestID?: number;
  113493. }
  113494. }
  113495. declare module BABYLON {
  113496. /**
  113497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113498. */
  113499. export class PerformanceMonitor {
  113500. private _enabled;
  113501. private _rollingFrameTime;
  113502. private _lastFrameTimeMs;
  113503. /**
  113504. * constructor
  113505. * @param frameSampleSize The number of samples required to saturate the sliding window
  113506. */
  113507. constructor(frameSampleSize?: number);
  113508. /**
  113509. * Samples current frame
  113510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113511. */
  113512. sampleFrame(timeMs?: number): void;
  113513. /**
  113514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113515. */
  113516. get averageFrameTime(): number;
  113517. /**
  113518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113519. */
  113520. get averageFrameTimeVariance(): number;
  113521. /**
  113522. * Returns the frame time of the most recent frame
  113523. */
  113524. get instantaneousFrameTime(): number;
  113525. /**
  113526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113527. */
  113528. get averageFPS(): number;
  113529. /**
  113530. * Returns the average framerate in frames per second using the most recent frame time
  113531. */
  113532. get instantaneousFPS(): number;
  113533. /**
  113534. * Returns true if enough samples have been taken to completely fill the sliding window
  113535. */
  113536. get isSaturated(): boolean;
  113537. /**
  113538. * Enables contributions to the sliding window sample set
  113539. */
  113540. enable(): void;
  113541. /**
  113542. * Disables contributions to the sliding window sample set
  113543. * Samples will not be interpolated over the disabled period
  113544. */
  113545. disable(): void;
  113546. /**
  113547. * Returns true if sampling is enabled
  113548. */
  113549. get isEnabled(): boolean;
  113550. /**
  113551. * Resets performance monitor
  113552. */
  113553. reset(): void;
  113554. }
  113555. /**
  113556. * RollingAverage
  113557. *
  113558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113559. */
  113560. export class RollingAverage {
  113561. /**
  113562. * Current average
  113563. */
  113564. average: number;
  113565. /**
  113566. * Current variance
  113567. */
  113568. variance: number;
  113569. protected _samples: Array<number>;
  113570. protected _sampleCount: number;
  113571. protected _pos: number;
  113572. protected _m2: number;
  113573. /**
  113574. * constructor
  113575. * @param length The number of samples required to saturate the sliding window
  113576. */
  113577. constructor(length: number);
  113578. /**
  113579. * Adds a sample to the sample set
  113580. * @param v The sample value
  113581. */
  113582. add(v: number): void;
  113583. /**
  113584. * Returns previously added values or null if outside of history or outside the sliding window domain
  113585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113586. * @return Value previously recorded with add() or null if outside of range
  113587. */
  113588. history(i: number): number;
  113589. /**
  113590. * Returns true if enough samples have been taken to completely fill the sliding window
  113591. * @return true if sample-set saturated
  113592. */
  113593. isSaturated(): boolean;
  113594. /**
  113595. * Resets the rolling average (equivalent to 0 samples taken so far)
  113596. */
  113597. reset(): void;
  113598. /**
  113599. * Wraps a value around the sample range boundaries
  113600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113601. * @return Wrapped position in sample range
  113602. */
  113603. protected _wrapPosition(i: number): number;
  113604. }
  113605. }
  113606. declare module BABYLON {
  113607. /**
  113608. * This class is used to track a performance counter which is number based.
  113609. * The user has access to many properties which give statistics of different nature.
  113610. *
  113611. * The implementer can track two kinds of Performance Counter: time and count.
  113612. * 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.
  113613. * 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.
  113614. */
  113615. export class PerfCounter {
  113616. /**
  113617. * Gets or sets a global boolean to turn on and off all the counters
  113618. */
  113619. static Enabled: boolean;
  113620. /**
  113621. * Returns the smallest value ever
  113622. */
  113623. get min(): number;
  113624. /**
  113625. * Returns the biggest value ever
  113626. */
  113627. get max(): number;
  113628. /**
  113629. * Returns the average value since the performance counter is running
  113630. */
  113631. get average(): number;
  113632. /**
  113633. * Returns the average value of the last second the counter was monitored
  113634. */
  113635. get lastSecAverage(): number;
  113636. /**
  113637. * Returns the current value
  113638. */
  113639. get current(): number;
  113640. /**
  113641. * Gets the accumulated total
  113642. */
  113643. get total(): number;
  113644. /**
  113645. * Gets the total value count
  113646. */
  113647. get count(): number;
  113648. /**
  113649. * Creates a new counter
  113650. */
  113651. constructor();
  113652. /**
  113653. * Call this method to start monitoring a new frame.
  113654. * 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.
  113655. */
  113656. fetchNewFrame(): void;
  113657. /**
  113658. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  113659. * @param newCount the count value to add to the monitored count
  113660. * @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.
  113661. */
  113662. addCount(newCount: number, fetchResult: boolean): void;
  113663. /**
  113664. * Start monitoring this performance counter
  113665. */
  113666. beginMonitoring(): void;
  113667. /**
  113668. * Compute the time lapsed since the previous beginMonitoring() call.
  113669. * @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
  113670. */
  113671. endMonitoring(newFrame?: boolean): void;
  113672. private _fetchResult;
  113673. private _startMonitoringTime;
  113674. private _min;
  113675. private _max;
  113676. private _average;
  113677. private _current;
  113678. private _totalValueCount;
  113679. private _totalAccumulated;
  113680. private _lastSecAverage;
  113681. private _lastSecAccumulated;
  113682. private _lastSecTime;
  113683. private _lastSecValueCount;
  113684. }
  113685. }
  113686. declare module BABYLON {
  113687. interface ThinEngine {
  113688. /**
  113689. * Sets alpha constants used by some alpha blending modes
  113690. * @param r defines the red component
  113691. * @param g defines the green component
  113692. * @param b defines the blue component
  113693. * @param a defines the alpha component
  113694. */
  113695. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113696. /**
  113697. * Sets the current alpha mode
  113698. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113699. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113701. */
  113702. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113703. /**
  113704. * Gets the current alpha mode
  113705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113706. * @returns the current alpha mode
  113707. */
  113708. getAlphaMode(): number;
  113709. /**
  113710. * Sets the current alpha equation
  113711. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113712. */
  113713. setAlphaEquation(equation: number): void;
  113714. /**
  113715. * Gets the current alpha equation.
  113716. * @returns the current alpha equation
  113717. */
  113718. getAlphaEquation(): number;
  113719. }
  113720. }
  113721. declare module BABYLON {
  113722. interface ThinEngine {
  113723. /** @hidden */
  113724. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  113725. }
  113726. }
  113727. declare module BABYLON {
  113728. /**
  113729. * Defines the interface used by display changed events
  113730. */
  113731. export interface IDisplayChangedEventArgs {
  113732. /** Gets the vrDisplay object (if any) */
  113733. vrDisplay: Nullable<any>;
  113734. /** Gets a boolean indicating if webVR is supported */
  113735. vrSupported: boolean;
  113736. }
  113737. /**
  113738. * Defines the interface used by objects containing a viewport (like a camera)
  113739. */
  113740. interface IViewportOwnerLike {
  113741. /**
  113742. * Gets or sets the viewport
  113743. */
  113744. viewport: IViewportLike;
  113745. }
  113746. /**
  113747. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  113748. */
  113749. export class Engine extends ThinEngine {
  113750. /** Defines that alpha blending is disabled */
  113751. static readonly ALPHA_DISABLE: number;
  113752. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  113753. static readonly ALPHA_ADD: number;
  113754. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  113755. static readonly ALPHA_COMBINE: number;
  113756. /** Defines that alpha blending to DEST - SRC * DEST */
  113757. static readonly ALPHA_SUBTRACT: number;
  113758. /** Defines that alpha blending to SRC * DEST */
  113759. static readonly ALPHA_MULTIPLY: number;
  113760. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  113761. static readonly ALPHA_MAXIMIZED: number;
  113762. /** Defines that alpha blending to SRC + DEST */
  113763. static readonly ALPHA_ONEONE: number;
  113764. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  113765. static readonly ALPHA_PREMULTIPLIED: number;
  113766. /**
  113767. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  113768. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  113769. */
  113770. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  113771. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  113772. static readonly ALPHA_INTERPOLATE: number;
  113773. /**
  113774. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  113775. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  113776. */
  113777. static readonly ALPHA_SCREENMODE: number;
  113778. /** Defines that the ressource is not delayed*/
  113779. static readonly DELAYLOADSTATE_NONE: number;
  113780. /** Defines that the ressource was successfully delay loaded */
  113781. static readonly DELAYLOADSTATE_LOADED: number;
  113782. /** Defines that the ressource is currently delay loading */
  113783. static readonly DELAYLOADSTATE_LOADING: number;
  113784. /** Defines that the ressource is delayed and has not started loading */
  113785. static readonly DELAYLOADSTATE_NOTLOADED: number;
  113786. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  113787. static readonly NEVER: number;
  113788. /** 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 */
  113789. static readonly ALWAYS: number;
  113790. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  113791. static readonly LESS: number;
  113792. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  113793. static readonly EQUAL: number;
  113794. /** 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 */
  113795. static readonly LEQUAL: number;
  113796. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  113797. static readonly GREATER: number;
  113798. /** 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 */
  113799. static readonly GEQUAL: number;
  113800. /** 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 */
  113801. static readonly NOTEQUAL: number;
  113802. /** Passed to stencilOperation to specify that stencil value must be kept */
  113803. static readonly KEEP: number;
  113804. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113805. static readonly REPLACE: number;
  113806. /** Passed to stencilOperation to specify that stencil value must be incremented */
  113807. static readonly INCR: number;
  113808. /** Passed to stencilOperation to specify that stencil value must be decremented */
  113809. static readonly DECR: number;
  113810. /** Passed to stencilOperation to specify that stencil value must be inverted */
  113811. static readonly INVERT: number;
  113812. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  113813. static readonly INCR_WRAP: number;
  113814. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  113815. static readonly DECR_WRAP: number;
  113816. /** Texture is not repeating outside of 0..1 UVs */
  113817. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  113818. /** Texture is repeating outside of 0..1 UVs */
  113819. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  113820. /** Texture is repeating and mirrored */
  113821. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  113822. /** ALPHA */
  113823. static readonly TEXTUREFORMAT_ALPHA: number;
  113824. /** LUMINANCE */
  113825. static readonly TEXTUREFORMAT_LUMINANCE: number;
  113826. /** LUMINANCE_ALPHA */
  113827. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  113828. /** RGB */
  113829. static readonly TEXTUREFORMAT_RGB: number;
  113830. /** RGBA */
  113831. static readonly TEXTUREFORMAT_RGBA: number;
  113832. /** RED */
  113833. static readonly TEXTUREFORMAT_RED: number;
  113834. /** RED (2nd reference) */
  113835. static readonly TEXTUREFORMAT_R: number;
  113836. /** RG */
  113837. static readonly TEXTUREFORMAT_RG: number;
  113838. /** RED_INTEGER */
  113839. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  113840. /** RED_INTEGER (2nd reference) */
  113841. static readonly TEXTUREFORMAT_R_INTEGER: number;
  113842. /** RG_INTEGER */
  113843. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  113844. /** RGB_INTEGER */
  113845. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  113846. /** RGBA_INTEGER */
  113847. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  113848. /** UNSIGNED_BYTE */
  113849. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  113850. /** UNSIGNED_BYTE (2nd reference) */
  113851. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  113852. /** FLOAT */
  113853. static readonly TEXTURETYPE_FLOAT: number;
  113854. /** HALF_FLOAT */
  113855. static readonly TEXTURETYPE_HALF_FLOAT: number;
  113856. /** BYTE */
  113857. static readonly TEXTURETYPE_BYTE: number;
  113858. /** SHORT */
  113859. static readonly TEXTURETYPE_SHORT: number;
  113860. /** UNSIGNED_SHORT */
  113861. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  113862. /** INT */
  113863. static readonly TEXTURETYPE_INT: number;
  113864. /** UNSIGNED_INT */
  113865. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  113866. /** UNSIGNED_SHORT_4_4_4_4 */
  113867. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  113868. /** UNSIGNED_SHORT_5_5_5_1 */
  113869. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  113870. /** UNSIGNED_SHORT_5_6_5 */
  113871. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  113872. /** UNSIGNED_INT_2_10_10_10_REV */
  113873. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  113874. /** UNSIGNED_INT_24_8 */
  113875. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  113876. /** UNSIGNED_INT_10F_11F_11F_REV */
  113877. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  113878. /** UNSIGNED_INT_5_9_9_9_REV */
  113879. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  113880. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  113881. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113882. /** nearest is mag = nearest and min = nearest and mip = linear */
  113883. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  113884. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113885. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  113886. /** Trilinear is mag = linear and min = linear and mip = linear */
  113887. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  113888. /** nearest is mag = nearest and min = nearest and mip = linear */
  113889. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  113890. /** Bilinear is mag = linear and min = linear and mip = nearest */
  113891. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  113892. /** Trilinear is mag = linear and min = linear and mip = linear */
  113893. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  113894. /** mag = nearest and min = nearest and mip = nearest */
  113895. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  113896. /** mag = nearest and min = linear and mip = nearest */
  113897. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  113898. /** mag = nearest and min = linear and mip = linear */
  113899. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  113900. /** mag = nearest and min = linear and mip = none */
  113901. static readonly TEXTURE_NEAREST_LINEAR: number;
  113902. /** mag = nearest and min = nearest and mip = none */
  113903. static readonly TEXTURE_NEAREST_NEAREST: number;
  113904. /** mag = linear and min = nearest and mip = nearest */
  113905. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  113906. /** mag = linear and min = nearest and mip = linear */
  113907. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  113908. /** mag = linear and min = linear and mip = none */
  113909. static readonly TEXTURE_LINEAR_LINEAR: number;
  113910. /** mag = linear and min = nearest and mip = none */
  113911. static readonly TEXTURE_LINEAR_NEAREST: number;
  113912. /** Explicit coordinates mode */
  113913. static readonly TEXTURE_EXPLICIT_MODE: number;
  113914. /** Spherical coordinates mode */
  113915. static readonly TEXTURE_SPHERICAL_MODE: number;
  113916. /** Planar coordinates mode */
  113917. static readonly TEXTURE_PLANAR_MODE: number;
  113918. /** Cubic coordinates mode */
  113919. static readonly TEXTURE_CUBIC_MODE: number;
  113920. /** Projection coordinates mode */
  113921. static readonly TEXTURE_PROJECTION_MODE: number;
  113922. /** Skybox coordinates mode */
  113923. static readonly TEXTURE_SKYBOX_MODE: number;
  113924. /** Inverse Cubic coordinates mode */
  113925. static readonly TEXTURE_INVCUBIC_MODE: number;
  113926. /** Equirectangular coordinates mode */
  113927. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  113928. /** Equirectangular Fixed coordinates mode */
  113929. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  113930. /** Equirectangular Fixed Mirrored coordinates mode */
  113931. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  113932. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  113933. static readonly SCALEMODE_FLOOR: number;
  113934. /** Defines that texture rescaling will look for the nearest power of 2 size */
  113935. static readonly SCALEMODE_NEAREST: number;
  113936. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  113937. static readonly SCALEMODE_CEILING: number;
  113938. /**
  113939. * Returns the current npm package of the sdk
  113940. */
  113941. static get NpmPackage(): string;
  113942. /**
  113943. * Returns the current version of the framework
  113944. */
  113945. static get Version(): string;
  113946. /** Gets the list of created engines */
  113947. static get Instances(): Engine[];
  113948. /**
  113949. * Gets the latest created engine
  113950. */
  113951. static get LastCreatedEngine(): Nullable<Engine>;
  113952. /**
  113953. * Gets the latest created scene
  113954. */
  113955. static get LastCreatedScene(): Nullable<Scene>;
  113956. /**
  113957. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  113958. * @param flag defines which part of the materials must be marked as dirty
  113959. * @param predicate defines a predicate used to filter which materials should be affected
  113960. */
  113961. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  113962. /**
  113963. * Method called to create the default loading screen.
  113964. * This can be overriden in your own app.
  113965. * @param canvas The rendering canvas element
  113966. * @returns The loading screen
  113967. */
  113968. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  113969. /**
  113970. * Method called to create the default rescale post process on each engine.
  113971. */
  113972. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  113973. /**
  113974. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  113975. **/
  113976. enableOfflineSupport: boolean;
  113977. /**
  113978. * 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)
  113979. **/
  113980. disableManifestCheck: boolean;
  113981. /**
  113982. * Gets the list of created scenes
  113983. */
  113984. scenes: Scene[];
  113985. /**
  113986. * Event raised when a new scene is created
  113987. */
  113988. onNewSceneAddedObservable: Observable<Scene>;
  113989. /**
  113990. * Gets the list of created postprocesses
  113991. */
  113992. postProcesses: PostProcess[];
  113993. /**
  113994. * Gets a boolean indicating if the pointer is currently locked
  113995. */
  113996. isPointerLock: boolean;
  113997. /**
  113998. * Observable event triggered each time the rendering canvas is resized
  113999. */
  114000. onResizeObservable: Observable<Engine>;
  114001. /**
  114002. * Observable event triggered each time the canvas loses focus
  114003. */
  114004. onCanvasBlurObservable: Observable<Engine>;
  114005. /**
  114006. * Observable event triggered each time the canvas gains focus
  114007. */
  114008. onCanvasFocusObservable: Observable<Engine>;
  114009. /**
  114010. * Observable event triggered each time the canvas receives pointerout event
  114011. */
  114012. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114013. /**
  114014. * Observable raised when the engine begins a new frame
  114015. */
  114016. onBeginFrameObservable: Observable<Engine>;
  114017. /**
  114018. * If set, will be used to request the next animation frame for the render loop
  114019. */
  114020. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114021. /**
  114022. * Observable raised when the engine ends the current frame
  114023. */
  114024. onEndFrameObservable: Observable<Engine>;
  114025. /**
  114026. * Observable raised when the engine is about to compile a shader
  114027. */
  114028. onBeforeShaderCompilationObservable: Observable<Engine>;
  114029. /**
  114030. * Observable raised when the engine has jsut compiled a shader
  114031. */
  114032. onAfterShaderCompilationObservable: Observable<Engine>;
  114033. /**
  114034. * Gets the audio engine
  114035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114036. * @ignorenaming
  114037. */
  114038. static audioEngine: IAudioEngine;
  114039. /**
  114040. * Default AudioEngine factory responsible of creating the Audio Engine.
  114041. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114042. */
  114043. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114044. /**
  114045. * Default offline support factory responsible of creating a tool used to store data locally.
  114046. * By default, this will create a Database object if the workload has been embedded.
  114047. */
  114048. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114049. private _loadingScreen;
  114050. private _pointerLockRequested;
  114051. private _rescalePostProcess;
  114052. private _deterministicLockstep;
  114053. private _lockstepMaxSteps;
  114054. private _timeStep;
  114055. protected get _supportsHardwareTextureRescaling(): boolean;
  114056. private _fps;
  114057. private _deltaTime;
  114058. /** @hidden */
  114059. _drawCalls: PerfCounter;
  114060. /** 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 */
  114061. canvasTabIndex: number;
  114062. /**
  114063. * Turn this value on if you want to pause FPS computation when in background
  114064. */
  114065. disablePerformanceMonitorInBackground: boolean;
  114066. private _performanceMonitor;
  114067. /**
  114068. * Gets the performance monitor attached to this engine
  114069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114070. */
  114071. get performanceMonitor(): PerformanceMonitor;
  114072. private _onFocus;
  114073. private _onBlur;
  114074. private _onCanvasPointerOut;
  114075. private _onCanvasBlur;
  114076. private _onCanvasFocus;
  114077. private _onFullscreenChange;
  114078. private _onPointerLockChange;
  114079. /**
  114080. * Gets the HTML element used to attach event listeners
  114081. * @returns a HTML element
  114082. */
  114083. getInputElement(): Nullable<HTMLElement>;
  114084. /**
  114085. * Creates a new engine
  114086. * @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
  114087. * @param antialias defines enable antialiasing (default: false)
  114088. * @param options defines further options to be sent to the getContext() function
  114089. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114090. */
  114091. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114092. /**
  114093. * Gets current aspect ratio
  114094. * @param viewportOwner defines the camera to use to get the aspect ratio
  114095. * @param useScreen defines if screen size must be used (or the current render target if any)
  114096. * @returns a number defining the aspect ratio
  114097. */
  114098. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114099. /**
  114100. * Gets current screen aspect ratio
  114101. * @returns a number defining the aspect ratio
  114102. */
  114103. getScreenAspectRatio(): number;
  114104. /**
  114105. * Gets the client rect of the HTML canvas attached with the current webGL context
  114106. * @returns a client rectanglee
  114107. */
  114108. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114109. /**
  114110. * Gets the client rect of the HTML element used for events
  114111. * @returns a client rectanglee
  114112. */
  114113. getInputElementClientRect(): Nullable<ClientRect>;
  114114. /**
  114115. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114117. * @returns true if engine is in deterministic lock step mode
  114118. */
  114119. isDeterministicLockStep(): boolean;
  114120. /**
  114121. * Gets the max steps when engine is running in deterministic lock step
  114122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114123. * @returns the max steps
  114124. */
  114125. getLockstepMaxSteps(): number;
  114126. /**
  114127. * Returns the time in ms between steps when using deterministic lock step.
  114128. * @returns time step in (ms)
  114129. */
  114130. getTimeStep(): number;
  114131. /**
  114132. * Force the mipmap generation for the given render target texture
  114133. * @param texture defines the render target texture to use
  114134. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114135. */
  114136. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114137. /** States */
  114138. /**
  114139. * Set various states to the webGL context
  114140. * @param culling defines backface culling state
  114141. * @param zOffset defines the value to apply to zOffset (0 by default)
  114142. * @param force defines if states must be applied even if cache is up to date
  114143. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114144. */
  114145. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114146. /**
  114147. * Set the z offset to apply to current rendering
  114148. * @param value defines the offset to apply
  114149. */
  114150. setZOffset(value: number): void;
  114151. /**
  114152. * Gets the current value of the zOffset
  114153. * @returns the current zOffset state
  114154. */
  114155. getZOffset(): number;
  114156. /**
  114157. * Enable or disable depth buffering
  114158. * @param enable defines the state to set
  114159. */
  114160. setDepthBuffer(enable: boolean): void;
  114161. /**
  114162. * Gets a boolean indicating if depth writing is enabled
  114163. * @returns the current depth writing state
  114164. */
  114165. getDepthWrite(): boolean;
  114166. /**
  114167. * Enable or disable depth writing
  114168. * @param enable defines the state to set
  114169. */
  114170. setDepthWrite(enable: boolean): void;
  114171. /**
  114172. * Gets a boolean indicating if stencil buffer is enabled
  114173. * @returns the current stencil buffer state
  114174. */
  114175. getStencilBuffer(): boolean;
  114176. /**
  114177. * Enable or disable the stencil buffer
  114178. * @param enable defines if the stencil buffer must be enabled or disabled
  114179. */
  114180. setStencilBuffer(enable: boolean): void;
  114181. /**
  114182. * Gets the current stencil mask
  114183. * @returns a number defining the new stencil mask to use
  114184. */
  114185. getStencilMask(): number;
  114186. /**
  114187. * Sets the current stencil mask
  114188. * @param mask defines the new stencil mask to use
  114189. */
  114190. setStencilMask(mask: number): void;
  114191. /**
  114192. * Gets the current stencil function
  114193. * @returns a number defining the stencil function to use
  114194. */
  114195. getStencilFunction(): number;
  114196. /**
  114197. * Gets the current stencil reference value
  114198. * @returns a number defining the stencil reference value to use
  114199. */
  114200. getStencilFunctionReference(): number;
  114201. /**
  114202. * Gets the current stencil mask
  114203. * @returns a number defining the stencil mask to use
  114204. */
  114205. getStencilFunctionMask(): number;
  114206. /**
  114207. * Sets the current stencil function
  114208. * @param stencilFunc defines the new stencil function to use
  114209. */
  114210. setStencilFunction(stencilFunc: number): void;
  114211. /**
  114212. * Sets the current stencil reference
  114213. * @param reference defines the new stencil reference to use
  114214. */
  114215. setStencilFunctionReference(reference: number): void;
  114216. /**
  114217. * Sets the current stencil mask
  114218. * @param mask defines the new stencil mask to use
  114219. */
  114220. setStencilFunctionMask(mask: number): void;
  114221. /**
  114222. * Gets the current stencil operation when stencil fails
  114223. * @returns a number defining stencil operation to use when stencil fails
  114224. */
  114225. getStencilOperationFail(): number;
  114226. /**
  114227. * Gets the current stencil operation when depth fails
  114228. * @returns a number defining stencil operation to use when depth fails
  114229. */
  114230. getStencilOperationDepthFail(): number;
  114231. /**
  114232. * Gets the current stencil operation when stencil passes
  114233. * @returns a number defining stencil operation to use when stencil passes
  114234. */
  114235. getStencilOperationPass(): number;
  114236. /**
  114237. * Sets the stencil operation to use when stencil fails
  114238. * @param operation defines the stencil operation to use when stencil fails
  114239. */
  114240. setStencilOperationFail(operation: number): void;
  114241. /**
  114242. * Sets the stencil operation to use when depth fails
  114243. * @param operation defines the stencil operation to use when depth fails
  114244. */
  114245. setStencilOperationDepthFail(operation: number): void;
  114246. /**
  114247. * Sets the stencil operation to use when stencil passes
  114248. * @param operation defines the stencil operation to use when stencil passes
  114249. */
  114250. setStencilOperationPass(operation: number): void;
  114251. /**
  114252. * Sets a boolean indicating if the dithering state is enabled or disabled
  114253. * @param value defines the dithering state
  114254. */
  114255. setDitheringState(value: boolean): void;
  114256. /**
  114257. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  114258. * @param value defines the rasterizer state
  114259. */
  114260. setRasterizerState(value: boolean): void;
  114261. /**
  114262. * Gets the current depth function
  114263. * @returns a number defining the depth function
  114264. */
  114265. getDepthFunction(): Nullable<number>;
  114266. /**
  114267. * Sets the current depth function
  114268. * @param depthFunc defines the function to use
  114269. */
  114270. setDepthFunction(depthFunc: number): void;
  114271. /**
  114272. * Sets the current depth function to GREATER
  114273. */
  114274. setDepthFunctionToGreater(): void;
  114275. /**
  114276. * Sets the current depth function to GEQUAL
  114277. */
  114278. setDepthFunctionToGreaterOrEqual(): void;
  114279. /**
  114280. * Sets the current depth function to LESS
  114281. */
  114282. setDepthFunctionToLess(): void;
  114283. /**
  114284. * Sets the current depth function to LEQUAL
  114285. */
  114286. setDepthFunctionToLessOrEqual(): void;
  114287. private _cachedStencilBuffer;
  114288. private _cachedStencilFunction;
  114289. private _cachedStencilMask;
  114290. private _cachedStencilOperationPass;
  114291. private _cachedStencilOperationFail;
  114292. private _cachedStencilOperationDepthFail;
  114293. private _cachedStencilReference;
  114294. /**
  114295. * Caches the the state of the stencil buffer
  114296. */
  114297. cacheStencilState(): void;
  114298. /**
  114299. * Restores the state of the stencil buffer
  114300. */
  114301. restoreStencilState(): void;
  114302. /**
  114303. * Directly set the WebGL Viewport
  114304. * @param x defines the x coordinate of the viewport (in screen space)
  114305. * @param y defines the y coordinate of the viewport (in screen space)
  114306. * @param width defines the width of the viewport (in screen space)
  114307. * @param height defines the height of the viewport (in screen space)
  114308. * @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
  114309. */
  114310. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114311. /**
  114312. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114313. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114314. * @param y defines the y-coordinate of the corner of the clear rectangle
  114315. * @param width defines the width of the clear rectangle
  114316. * @param height defines the height of the clear rectangle
  114317. * @param clearColor defines the clear color
  114318. */
  114319. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114320. /**
  114321. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114322. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114323. * @param y defines the y-coordinate of the corner of the clear rectangle
  114324. * @param width defines the width of the clear rectangle
  114325. * @param height defines the height of the clear rectangle
  114326. */
  114327. enableScissor(x: number, y: number, width: number, height: number): void;
  114328. /**
  114329. * Disable previously set scissor test rectangle
  114330. */
  114331. disableScissor(): void;
  114332. protected _reportDrawCall(): void;
  114333. /**
  114334. * Initializes a webVR display and starts listening to display change events
  114335. * The onVRDisplayChangedObservable will be notified upon these changes
  114336. * @returns The onVRDisplayChangedObservable
  114337. */
  114338. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114339. /** @hidden */
  114340. _prepareVRComponent(): void;
  114341. /** @hidden */
  114342. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114343. /** @hidden */
  114344. _submitVRFrame(): void;
  114345. /**
  114346. * Call this function to leave webVR mode
  114347. * Will do nothing if webVR is not supported or if there is no webVR device
  114348. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114349. */
  114350. disableVR(): void;
  114351. /**
  114352. * Gets a boolean indicating that the system is in VR mode and is presenting
  114353. * @returns true if VR mode is engaged
  114354. */
  114355. isVRPresenting(): boolean;
  114356. /** @hidden */
  114357. _requestVRFrame(): void;
  114358. /** @hidden */
  114359. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114360. /**
  114361. * Gets the source code of the vertex shader associated with a specific webGL program
  114362. * @param program defines the program to use
  114363. * @returns a string containing the source code of the vertex shader associated with the program
  114364. */
  114365. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114366. /**
  114367. * Gets the source code of the fragment shader associated with a specific webGL program
  114368. * @param program defines the program to use
  114369. * @returns a string containing the source code of the fragment shader associated with the program
  114370. */
  114371. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114372. /**
  114373. * Sets a depth stencil texture from a render target to the according uniform.
  114374. * @param channel The texture channel
  114375. * @param uniform The uniform to set
  114376. * @param texture The render target texture containing the depth stencil texture to apply
  114377. */
  114378. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114379. /**
  114380. * Sets a texture to the webGL context from a postprocess
  114381. * @param channel defines the channel to use
  114382. * @param postProcess defines the source postprocess
  114383. */
  114384. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114385. /**
  114386. * Binds the output of the passed in post process to the texture channel specified
  114387. * @param channel The channel the texture should be bound to
  114388. * @param postProcess The post process which's output should be bound
  114389. */
  114390. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114391. protected _rebuildBuffers(): void;
  114392. /** @hidden */
  114393. _renderFrame(): void;
  114394. _renderLoop(): void;
  114395. /** @hidden */
  114396. _renderViews(): boolean;
  114397. /**
  114398. * Toggle full screen mode
  114399. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114400. */
  114401. switchFullscreen(requestPointerLock: boolean): void;
  114402. /**
  114403. * Enters full screen mode
  114404. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114405. */
  114406. enterFullscreen(requestPointerLock: boolean): void;
  114407. /**
  114408. * Exits full screen mode
  114409. */
  114410. exitFullscreen(): void;
  114411. /**
  114412. * Enters Pointerlock mode
  114413. */
  114414. enterPointerlock(): void;
  114415. /**
  114416. * Exits Pointerlock mode
  114417. */
  114418. exitPointerlock(): void;
  114419. /**
  114420. * Begin a new frame
  114421. */
  114422. beginFrame(): void;
  114423. /**
  114424. * Enf the current frame
  114425. */
  114426. endFrame(): void;
  114427. resize(): void;
  114428. /**
  114429. * Force a specific size of the canvas
  114430. * @param width defines the new canvas' width
  114431. * @param height defines the new canvas' height
  114432. */
  114433. setSize(width: number, height: number): void;
  114434. /**
  114435. * Updates a dynamic vertex buffer.
  114436. * @param vertexBuffer the vertex buffer to update
  114437. * @param data the data used to update the vertex buffer
  114438. * @param byteOffset the byte offset of the data
  114439. * @param byteLength the byte length of the data
  114440. */
  114441. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114442. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114443. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114444. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114445. _releaseTexture(texture: InternalTexture): void;
  114446. /**
  114447. * @hidden
  114448. * Rescales a texture
  114449. * @param source input texutre
  114450. * @param destination destination texture
  114451. * @param scene scene to use to render the resize
  114452. * @param internalFormat format to use when resizing
  114453. * @param onComplete callback to be called when resize has completed
  114454. */
  114455. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114456. /**
  114457. * Gets the current framerate
  114458. * @returns a number representing the framerate
  114459. */
  114460. getFps(): number;
  114461. /**
  114462. * Gets the time spent between current and previous frame
  114463. * @returns a number representing the delta time in ms
  114464. */
  114465. getDeltaTime(): number;
  114466. private _measureFps;
  114467. /** @hidden */
  114468. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114469. /**
  114470. * Update a dynamic index buffer
  114471. * @param indexBuffer defines the target index buffer
  114472. * @param indices defines the data to update
  114473. * @param offset defines the offset in the target index buffer where update should start
  114474. */
  114475. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114476. /**
  114477. * Updates the sample count of a render target texture
  114478. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114479. * @param texture defines the texture to update
  114480. * @param samples defines the sample count to set
  114481. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114482. */
  114483. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114484. /**
  114485. * Updates a depth texture Comparison Mode and Function.
  114486. * If the comparison Function is equal to 0, the mode will be set to none.
  114487. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114488. * @param texture The texture to set the comparison function for
  114489. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114490. */
  114491. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114492. /**
  114493. * Creates a webGL buffer to use with instanciation
  114494. * @param capacity defines the size of the buffer
  114495. * @returns the webGL buffer
  114496. */
  114497. createInstancesBuffer(capacity: number): DataBuffer;
  114498. /**
  114499. * Delete a webGL buffer used with instanciation
  114500. * @param buffer defines the webGL buffer to delete
  114501. */
  114502. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114503. private _clientWaitAsync;
  114504. /** @hidden */
  114505. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114506. dispose(): void;
  114507. private _disableTouchAction;
  114508. /**
  114509. * Display the loading screen
  114510. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114511. */
  114512. displayLoadingUI(): void;
  114513. /**
  114514. * Hide the loading screen
  114515. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114516. */
  114517. hideLoadingUI(): void;
  114518. /**
  114519. * Gets the current loading screen object
  114520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114521. */
  114522. get loadingScreen(): ILoadingScreen;
  114523. /**
  114524. * Sets the current loading screen object
  114525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114526. */
  114527. set loadingScreen(loadingScreen: ILoadingScreen);
  114528. /**
  114529. * Sets the current loading screen text
  114530. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114531. */
  114532. set loadingUIText(text: string);
  114533. /**
  114534. * Sets the current loading screen background color
  114535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114536. */
  114537. set loadingUIBackgroundColor(color: string);
  114538. /** Pointerlock and fullscreen */
  114539. /**
  114540. * Ask the browser to promote the current element to pointerlock mode
  114541. * @param element defines the DOM element to promote
  114542. */
  114543. static _RequestPointerlock(element: HTMLElement): void;
  114544. /**
  114545. * Asks the browser to exit pointerlock mode
  114546. */
  114547. static _ExitPointerlock(): void;
  114548. /**
  114549. * Ask the browser to promote the current element to fullscreen rendering mode
  114550. * @param element defines the DOM element to promote
  114551. */
  114552. static _RequestFullscreen(element: HTMLElement): void;
  114553. /**
  114554. * Asks the browser to exit fullscreen mode
  114555. */
  114556. static _ExitFullscreen(): void;
  114557. }
  114558. }
  114559. declare module BABYLON {
  114560. /**
  114561. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114562. * during the life time of the application.
  114563. */
  114564. export class EngineStore {
  114565. /** Gets the list of created engines */
  114566. static Instances: Engine[];
  114567. /** @hidden */
  114568. static _LastCreatedScene: Nullable<Scene>;
  114569. /**
  114570. * Gets the latest created engine
  114571. */
  114572. static get LastCreatedEngine(): Nullable<Engine>;
  114573. /**
  114574. * Gets the latest created scene
  114575. */
  114576. static get LastCreatedScene(): Nullable<Scene>;
  114577. /**
  114578. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114579. * @ignorenaming
  114580. */
  114581. static UseFallbackTexture: boolean;
  114582. /**
  114583. * Texture content used if a texture cannot loaded
  114584. * @ignorenaming
  114585. */
  114586. static FallbackTexture: string;
  114587. }
  114588. }
  114589. declare module BABYLON {
  114590. /**
  114591. * Helper class that provides a small promise polyfill
  114592. */
  114593. export class PromisePolyfill {
  114594. /**
  114595. * Static function used to check if the polyfill is required
  114596. * If this is the case then the function will inject the polyfill to window.Promise
  114597. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114598. */
  114599. static Apply(force?: boolean): void;
  114600. }
  114601. }
  114602. declare module BABYLON {
  114603. /**
  114604. * Interface for screenshot methods with describe argument called `size` as object with options
  114605. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114606. */
  114607. export interface IScreenshotSize {
  114608. /**
  114609. * number in pixels for canvas height
  114610. */
  114611. height?: number;
  114612. /**
  114613. * multiplier allowing render at a higher or lower resolution
  114614. * If value is defined then height and width will be ignored and taken from camera
  114615. */
  114616. precision?: number;
  114617. /**
  114618. * number in pixels for canvas width
  114619. */
  114620. width?: number;
  114621. }
  114622. }
  114623. declare module BABYLON {
  114624. interface IColor4Like {
  114625. r: float;
  114626. g: float;
  114627. b: float;
  114628. a: float;
  114629. }
  114630. /**
  114631. * Class containing a set of static utilities functions
  114632. */
  114633. export class Tools {
  114634. /**
  114635. * Gets or sets the base URL to use to load assets
  114636. */
  114637. static get BaseUrl(): string;
  114638. static set BaseUrl(value: string);
  114639. /**
  114640. * Enable/Disable Custom HTTP Request Headers globally.
  114641. * default = false
  114642. * @see CustomRequestHeaders
  114643. */
  114644. static UseCustomRequestHeaders: boolean;
  114645. /**
  114646. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114647. * i.e. when loading files, where the server/service expects an Authorization header
  114648. */
  114649. static CustomRequestHeaders: {
  114650. [key: string]: string;
  114651. };
  114652. /**
  114653. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  114654. */
  114655. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  114656. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  114657. /**
  114658. * Default behaviour for cors in the application.
  114659. * It can be a string if the expected behavior is identical in the entire app.
  114660. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  114661. */
  114662. static get CorsBehavior(): string | ((url: string | string[]) => string);
  114663. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  114664. /**
  114665. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114666. * @ignorenaming
  114667. */
  114668. static get UseFallbackTexture(): boolean;
  114669. static set UseFallbackTexture(value: boolean);
  114670. /**
  114671. * Use this object to register external classes like custom textures or material
  114672. * to allow the laoders to instantiate them
  114673. */
  114674. static get RegisteredExternalClasses(): {
  114675. [key: string]: Object;
  114676. };
  114677. static set RegisteredExternalClasses(classes: {
  114678. [key: string]: Object;
  114679. });
  114680. /**
  114681. * Texture content used if a texture cannot loaded
  114682. * @ignorenaming
  114683. */
  114684. static get fallbackTexture(): string;
  114685. static set fallbackTexture(value: string);
  114686. /**
  114687. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114688. * @param u defines the coordinate on X axis
  114689. * @param v defines the coordinate on Y axis
  114690. * @param width defines the width of the source data
  114691. * @param height defines the height of the source data
  114692. * @param pixels defines the source byte array
  114693. * @param color defines the output color
  114694. */
  114695. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114696. /**
  114697. * Interpolates between a and b via alpha
  114698. * @param a The lower value (returned when alpha = 0)
  114699. * @param b The upper value (returned when alpha = 1)
  114700. * @param alpha The interpolation-factor
  114701. * @return The mixed value
  114702. */
  114703. static Mix(a: number, b: number, alpha: number): number;
  114704. /**
  114705. * Tries to instantiate a new object from a given class name
  114706. * @param className defines the class name to instantiate
  114707. * @returns the new object or null if the system was not able to do the instantiation
  114708. */
  114709. static Instantiate(className: string): any;
  114710. /**
  114711. * Provides a slice function that will work even on IE
  114712. * @param data defines the array to slice
  114713. * @param start defines the start of the data (optional)
  114714. * @param end defines the end of the data (optional)
  114715. * @returns the new sliced array
  114716. */
  114717. static Slice<T>(data: T, start?: number, end?: number): T;
  114718. /**
  114719. * Polyfill for setImmediate
  114720. * @param action defines the action to execute after the current execution block
  114721. */
  114722. static SetImmediate(action: () => void): void;
  114723. /**
  114724. * Function indicating if a number is an exponent of 2
  114725. * @param value defines the value to test
  114726. * @returns true if the value is an exponent of 2
  114727. */
  114728. static IsExponentOfTwo(value: number): boolean;
  114729. private static _tmpFloatArray;
  114730. /**
  114731. * Returns the nearest 32-bit single precision float representation of a Number
  114732. * @param value A Number. If the parameter is of a different type, it will get converted
  114733. * to a number or to NaN if it cannot be converted
  114734. * @returns number
  114735. */
  114736. static FloatRound(value: number): number;
  114737. /**
  114738. * Extracts the filename from a path
  114739. * @param path defines the path to use
  114740. * @returns the filename
  114741. */
  114742. static GetFilename(path: string): string;
  114743. /**
  114744. * Extracts the "folder" part of a path (everything before the filename).
  114745. * @param uri The URI to extract the info from
  114746. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  114747. * @returns The "folder" part of the path
  114748. */
  114749. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  114750. /**
  114751. * Extracts text content from a DOM element hierarchy
  114752. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  114753. */
  114754. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  114755. /**
  114756. * Convert an angle in radians to degrees
  114757. * @param angle defines the angle to convert
  114758. * @returns the angle in degrees
  114759. */
  114760. static ToDegrees(angle: number): number;
  114761. /**
  114762. * Convert an angle in degrees to radians
  114763. * @param angle defines the angle to convert
  114764. * @returns the angle in radians
  114765. */
  114766. static ToRadians(angle: number): number;
  114767. /**
  114768. * Returns an array if obj is not an array
  114769. * @param obj defines the object to evaluate as an array
  114770. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  114771. * @returns either obj directly if obj is an array or a new array containing obj
  114772. */
  114773. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  114774. /**
  114775. * Gets the pointer prefix to use
  114776. * @param engine defines the engine we are finding the prefix for
  114777. * @returns "pointer" if touch is enabled. Else returns "mouse"
  114778. */
  114779. static GetPointerPrefix(engine: Engine): string;
  114780. /**
  114781. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  114782. * @param url define the url we are trying
  114783. * @param element define the dom element where to configure the cors policy
  114784. */
  114785. static SetCorsBehavior(url: string | string[], element: {
  114786. crossOrigin: string | null;
  114787. }): void;
  114788. /**
  114789. * Removes unwanted characters from an url
  114790. * @param url defines the url to clean
  114791. * @returns the cleaned url
  114792. */
  114793. static CleanUrl(url: string): string;
  114794. /**
  114795. * Gets or sets a function used to pre-process url before using them to load assets
  114796. */
  114797. static get PreprocessUrl(): (url: string) => string;
  114798. static set PreprocessUrl(processor: (url: string) => string);
  114799. /**
  114800. * Loads an image as an HTMLImageElement.
  114801. * @param input url string, ArrayBuffer, or Blob to load
  114802. * @param onLoad callback called when the image successfully loads
  114803. * @param onError callback called when the image fails to load
  114804. * @param offlineProvider offline provider for caching
  114805. * @param mimeType optional mime type
  114806. * @returns the HTMLImageElement of the loaded image
  114807. */
  114808. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  114809. /**
  114810. * Loads a file from a url
  114811. * @param url url string, ArrayBuffer, or Blob to load
  114812. * @param onSuccess callback called when the file successfully loads
  114813. * @param onProgress callback called while file is loading (if the server supports this mode)
  114814. * @param offlineProvider defines the offline provider for caching
  114815. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114816. * @param onError callback called when the file fails to load
  114817. * @returns a file request object
  114818. */
  114819. 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;
  114820. /**
  114821. * Loads a file from a url
  114822. * @param url the file url to load
  114823. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114824. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  114825. */
  114826. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  114827. /**
  114828. * Load a script (identified by an url). When the url returns, the
  114829. * content of this file is added into a new script element, attached to the DOM (body element)
  114830. * @param scriptUrl defines the url of the script to laod
  114831. * @param onSuccess defines the callback called when the script is loaded
  114832. * @param onError defines the callback to call if an error occurs
  114833. * @param scriptId defines the id of the script element
  114834. */
  114835. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  114836. /**
  114837. * Load an asynchronous script (identified by an url). When the url returns, the
  114838. * content of this file is added into a new script element, attached to the DOM (body element)
  114839. * @param scriptUrl defines the url of the script to laod
  114840. * @param scriptId defines the id of the script element
  114841. * @returns a promise request object
  114842. */
  114843. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  114844. /**
  114845. * Loads a file from a blob
  114846. * @param fileToLoad defines the blob to use
  114847. * @param callback defines the callback to call when data is loaded
  114848. * @param progressCallback defines the callback to call during loading process
  114849. * @returns a file request object
  114850. */
  114851. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  114852. /**
  114853. * Reads a file from a File object
  114854. * @param file defines the file to load
  114855. * @param onSuccess defines the callback to call when data is loaded
  114856. * @param onProgress defines the callback to call during loading process
  114857. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114858. * @param onError defines the callback to call when an error occurs
  114859. * @returns a file request object
  114860. */
  114861. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  114862. /**
  114863. * Creates a data url from a given string content
  114864. * @param content defines the content to convert
  114865. * @returns the new data url link
  114866. */
  114867. static FileAsURL(content: string): string;
  114868. /**
  114869. * Format the given number to a specific decimal format
  114870. * @param value defines the number to format
  114871. * @param decimals defines the number of decimals to use
  114872. * @returns the formatted string
  114873. */
  114874. static Format(value: number, decimals?: number): string;
  114875. /**
  114876. * Tries to copy an object by duplicating every property
  114877. * @param source defines the source object
  114878. * @param destination defines the target object
  114879. * @param doNotCopyList defines a list of properties to avoid
  114880. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  114881. */
  114882. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  114883. /**
  114884. * Gets a boolean indicating if the given object has no own property
  114885. * @param obj defines the object to test
  114886. * @returns true if object has no own property
  114887. */
  114888. static IsEmpty(obj: any): boolean;
  114889. /**
  114890. * Function used to register events at window level
  114891. * @param windowElement defines the Window object to use
  114892. * @param events defines the events to register
  114893. */
  114894. static RegisterTopRootEvents(windowElement: Window, events: {
  114895. name: string;
  114896. handler: Nullable<(e: FocusEvent) => any>;
  114897. }[]): void;
  114898. /**
  114899. * Function used to unregister events from window level
  114900. * @param windowElement defines the Window object to use
  114901. * @param events defines the events to unregister
  114902. */
  114903. static UnregisterTopRootEvents(windowElement: Window, events: {
  114904. name: string;
  114905. handler: Nullable<(e: FocusEvent) => any>;
  114906. }[]): void;
  114907. /**
  114908. * @ignore
  114909. */
  114910. static _ScreenshotCanvas: HTMLCanvasElement;
  114911. /**
  114912. * Dumps the current bound framebuffer
  114913. * @param width defines the rendering width
  114914. * @param height defines the rendering height
  114915. * @param engine defines the hosting engine
  114916. * @param successCallback defines the callback triggered once the data are available
  114917. * @param mimeType defines the mime type of the result
  114918. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  114919. */
  114920. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114921. /**
  114922. * Converts the canvas data to blob.
  114923. * This acts as a polyfill for browsers not supporting the to blob function.
  114924. * @param canvas Defines the canvas to extract the data from
  114925. * @param successCallback Defines the callback triggered once the data are available
  114926. * @param mimeType Defines the mime type of the result
  114927. */
  114928. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  114929. /**
  114930. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  114931. * @param successCallback defines the callback triggered once the data are available
  114932. * @param mimeType defines the mime type of the result
  114933. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  114934. */
  114935. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  114936. /**
  114937. * Downloads a blob in the browser
  114938. * @param blob defines the blob to download
  114939. * @param fileName defines the name of the downloaded file
  114940. */
  114941. static Download(blob: Blob, fileName: string): void;
  114942. /**
  114943. * Captures a screenshot of the current rendering
  114944. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114945. * @param engine defines the rendering engine
  114946. * @param camera defines the source camera
  114947. * @param size This parameter can be set to a single number or to an object with the
  114948. * following (optional) properties: precision, width, height. If a single number is passed,
  114949. * it will be used for both width and height. If an object is passed, the screenshot size
  114950. * will be derived from the parameters. The precision property is a multiplier allowing
  114951. * rendering at a higher or lower resolution
  114952. * @param successCallback defines the callback receives a single parameter which contains the
  114953. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114954. * src parameter of an <img> to display it
  114955. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114956. * Check your browser for supported MIME types
  114957. */
  114958. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  114959. /**
  114960. * Captures a screenshot of the current rendering
  114961. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114962. * @param engine defines the rendering engine
  114963. * @param camera defines the source camera
  114964. * @param size This parameter can be set to a single number or to an object with the
  114965. * following (optional) properties: precision, width, height. If a single number is passed,
  114966. * it will be used for both width and height. If an object is passed, the screenshot size
  114967. * will be derived from the parameters. The precision property is a multiplier allowing
  114968. * rendering at a higher or lower resolution
  114969. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  114970. * Check your browser for supported MIME types
  114971. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  114972. * to the src parameter of an <img> to display it
  114973. */
  114974. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  114975. /**
  114976. * Generates an image screenshot from the specified camera.
  114977. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114978. * @param engine The engine to use for rendering
  114979. * @param camera The camera to use for rendering
  114980. * @param size This parameter can be set to a single number or to an object with the
  114981. * following (optional) properties: precision, width, height. If a single number is passed,
  114982. * it will be used for both width and height. If an object is passed, the screenshot size
  114983. * will be derived from the parameters. The precision property is a multiplier allowing
  114984. * rendering at a higher or lower resolution
  114985. * @param successCallback The callback receives a single parameter which contains the
  114986. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  114987. * src parameter of an <img> to display it
  114988. * @param mimeType The MIME type of the screenshot image (default: image/png).
  114989. * Check your browser for supported MIME types
  114990. * @param samples Texture samples (default: 1)
  114991. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  114992. * @param fileName A name for for the downloaded file.
  114993. */
  114994. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  114995. /**
  114996. * Generates an image screenshot from the specified camera.
  114997. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  114998. * @param engine The engine to use for rendering
  114999. * @param camera The camera to use for rendering
  115000. * @param size This parameter can be set to a single number or to an object with the
  115001. * following (optional) properties: precision, width, height. If a single number is passed,
  115002. * it will be used for both width and height. If an object is passed, the screenshot size
  115003. * will be derived from the parameters. The precision property is a multiplier allowing
  115004. * rendering at a higher or lower resolution
  115005. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115006. * Check your browser for supported MIME types
  115007. * @param samples Texture samples (default: 1)
  115008. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115009. * @param fileName A name for for the downloaded file.
  115010. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115011. * to the src parameter of an <img> to display it
  115012. */
  115013. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115014. /**
  115015. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115016. * Be aware Math.random() could cause collisions, but:
  115017. * "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"
  115018. * @returns a pseudo random id
  115019. */
  115020. static RandomId(): string;
  115021. /**
  115022. * Test if the given uri is a base64 string
  115023. * @param uri The uri to test
  115024. * @return True if the uri is a base64 string or false otherwise
  115025. */
  115026. static IsBase64(uri: string): boolean;
  115027. /**
  115028. * Decode the given base64 uri.
  115029. * @param uri The uri to decode
  115030. * @return The decoded base64 data.
  115031. */
  115032. static DecodeBase64(uri: string): ArrayBuffer;
  115033. /**
  115034. * Gets the absolute url.
  115035. * @param url the input url
  115036. * @return the absolute url
  115037. */
  115038. static GetAbsoluteUrl(url: string): string;
  115039. /**
  115040. * No log
  115041. */
  115042. static readonly NoneLogLevel: number;
  115043. /**
  115044. * Only message logs
  115045. */
  115046. static readonly MessageLogLevel: number;
  115047. /**
  115048. * Only warning logs
  115049. */
  115050. static readonly WarningLogLevel: number;
  115051. /**
  115052. * Only error logs
  115053. */
  115054. static readonly ErrorLogLevel: number;
  115055. /**
  115056. * All logs
  115057. */
  115058. static readonly AllLogLevel: number;
  115059. /**
  115060. * Gets a value indicating the number of loading errors
  115061. * @ignorenaming
  115062. */
  115063. static get errorsCount(): number;
  115064. /**
  115065. * Callback called when a new log is added
  115066. */
  115067. static OnNewCacheEntry: (entry: string) => void;
  115068. /**
  115069. * Log a message to the console
  115070. * @param message defines the message to log
  115071. */
  115072. static Log(message: string): void;
  115073. /**
  115074. * Write a warning message to the console
  115075. * @param message defines the message to log
  115076. */
  115077. static Warn(message: string): void;
  115078. /**
  115079. * Write an error message to the console
  115080. * @param message defines the message to log
  115081. */
  115082. static Error(message: string): void;
  115083. /**
  115084. * Gets current log cache (list of logs)
  115085. */
  115086. static get LogCache(): string;
  115087. /**
  115088. * Clears the log cache
  115089. */
  115090. static ClearLogCache(): void;
  115091. /**
  115092. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115093. */
  115094. static set LogLevels(level: number);
  115095. /**
  115096. * Checks if the window object exists
  115097. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115098. */
  115099. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115100. /**
  115101. * No performance log
  115102. */
  115103. static readonly PerformanceNoneLogLevel: number;
  115104. /**
  115105. * Use user marks to log performance
  115106. */
  115107. static readonly PerformanceUserMarkLogLevel: number;
  115108. /**
  115109. * Log performance to the console
  115110. */
  115111. static readonly PerformanceConsoleLogLevel: number;
  115112. private static _performance;
  115113. /**
  115114. * Sets the current performance log level
  115115. */
  115116. static set PerformanceLogLevel(level: number);
  115117. private static _StartPerformanceCounterDisabled;
  115118. private static _EndPerformanceCounterDisabled;
  115119. private static _StartUserMark;
  115120. private static _EndUserMark;
  115121. private static _StartPerformanceConsole;
  115122. private static _EndPerformanceConsole;
  115123. /**
  115124. * Starts a performance counter
  115125. */
  115126. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115127. /**
  115128. * Ends a specific performance coutner
  115129. */
  115130. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115131. /**
  115132. * Gets either window.performance.now() if supported or Date.now() else
  115133. */
  115134. static get Now(): number;
  115135. /**
  115136. * This method will return the name of the class used to create the instance of the given object.
  115137. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115138. * @param object the object to get the class name from
  115139. * @param isType defines if the object is actually a type
  115140. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115141. */
  115142. static GetClassName(object: any, isType?: boolean): string;
  115143. /**
  115144. * Gets the first element of an array satisfying a given predicate
  115145. * @param array defines the array to browse
  115146. * @param predicate defines the predicate to use
  115147. * @returns null if not found or the element
  115148. */
  115149. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115150. /**
  115151. * This method will return the name of the full name of the class, including its owning module (if any).
  115152. * 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).
  115153. * @param object the object to get the class name from
  115154. * @param isType defines if the object is actually a type
  115155. * @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.
  115156. * @ignorenaming
  115157. */
  115158. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115159. /**
  115160. * Returns a promise that resolves after the given amount of time.
  115161. * @param delay Number of milliseconds to delay
  115162. * @returns Promise that resolves after the given amount of time
  115163. */
  115164. static DelayAsync(delay: number): Promise<void>;
  115165. /**
  115166. * Utility function to detect if the current user agent is Safari
  115167. * @returns whether or not the current user agent is safari
  115168. */
  115169. static IsSafari(): boolean;
  115170. }
  115171. /**
  115172. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  115173. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  115174. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  115175. * @param name The name of the class, case should be preserved
  115176. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  115177. */
  115178. export function className(name: string, module?: string): (target: Object) => void;
  115179. /**
  115180. * An implementation of a loop for asynchronous functions.
  115181. */
  115182. export class AsyncLoop {
  115183. /**
  115184. * Defines the number of iterations for the loop
  115185. */
  115186. iterations: number;
  115187. /**
  115188. * Defines the current index of the loop.
  115189. */
  115190. index: number;
  115191. private _done;
  115192. private _fn;
  115193. private _successCallback;
  115194. /**
  115195. * Constructor.
  115196. * @param iterations the number of iterations.
  115197. * @param func the function to run each iteration
  115198. * @param successCallback the callback that will be called upon succesful execution
  115199. * @param offset starting offset.
  115200. */
  115201. constructor(
  115202. /**
  115203. * Defines the number of iterations for the loop
  115204. */
  115205. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  115206. /**
  115207. * Execute the next iteration. Must be called after the last iteration was finished.
  115208. */
  115209. executeNext(): void;
  115210. /**
  115211. * Break the loop and run the success callback.
  115212. */
  115213. breakLoop(): void;
  115214. /**
  115215. * Create and run an async loop.
  115216. * @param iterations the number of iterations.
  115217. * @param fn the function to run each iteration
  115218. * @param successCallback the callback that will be called upon succesful execution
  115219. * @param offset starting offset.
  115220. * @returns the created async loop object
  115221. */
  115222. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  115223. /**
  115224. * A for-loop that will run a given number of iterations synchronous and the rest async.
  115225. * @param iterations total number of iterations
  115226. * @param syncedIterations number of synchronous iterations in each async iteration.
  115227. * @param fn the function to call each iteration.
  115228. * @param callback a success call back that will be called when iterating stops.
  115229. * @param breakFunction a break condition (optional)
  115230. * @param timeout timeout settings for the setTimeout function. default - 0.
  115231. * @returns the created async loop object
  115232. */
  115233. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  115234. }
  115235. }
  115236. declare module BABYLON {
  115237. /**
  115238. * This class implement a typical dictionary using a string as key and the generic type T as value.
  115239. * The underlying implementation relies on an associative array to ensure the best performances.
  115240. * The value can be anything including 'null' but except 'undefined'
  115241. */
  115242. export class StringDictionary<T> {
  115243. /**
  115244. * This will clear this dictionary and copy the content from the 'source' one.
  115245. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  115246. * @param source the dictionary to take the content from and copy to this dictionary
  115247. */
  115248. copyFrom(source: StringDictionary<T>): void;
  115249. /**
  115250. * Get a value based from its key
  115251. * @param key the given key to get the matching value from
  115252. * @return the value if found, otherwise undefined is returned
  115253. */
  115254. get(key: string): T | undefined;
  115255. /**
  115256. * Get a value from its key or add it if it doesn't exist.
  115257. * This method will ensure you that a given key/data will be present in the dictionary.
  115258. * @param key the given key to get the matching value from
  115259. * @param factory the factory that will create the value if the key is not present in the dictionary.
  115260. * The factory will only be invoked if there's no data for the given key.
  115261. * @return the value corresponding to the key.
  115262. */
  115263. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  115264. /**
  115265. * Get a value from its key if present in the dictionary otherwise add it
  115266. * @param key the key to get the value from
  115267. * @param val if there's no such key/value pair in the dictionary add it with this value
  115268. * @return the value corresponding to the key
  115269. */
  115270. getOrAdd(key: string, val: T): T;
  115271. /**
  115272. * Check if there's a given key in the dictionary
  115273. * @param key the key to check for
  115274. * @return true if the key is present, false otherwise
  115275. */
  115276. contains(key: string): boolean;
  115277. /**
  115278. * Add a new key and its corresponding value
  115279. * @param key the key to add
  115280. * @param value the value corresponding to the key
  115281. * @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
  115282. */
  115283. add(key: string, value: T): boolean;
  115284. /**
  115285. * Update a specific value associated to a key
  115286. * @param key defines the key to use
  115287. * @param value defines the value to store
  115288. * @returns true if the value was updated (or false if the key was not found)
  115289. */
  115290. set(key: string, value: T): boolean;
  115291. /**
  115292. * Get the element of the given key and remove it from the dictionary
  115293. * @param key defines the key to search
  115294. * @returns the value associated with the key or null if not found
  115295. */
  115296. getAndRemove(key: string): Nullable<T>;
  115297. /**
  115298. * Remove a key/value from the dictionary.
  115299. * @param key the key to remove
  115300. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  115301. */
  115302. remove(key: string): boolean;
  115303. /**
  115304. * Clear the whole content of the dictionary
  115305. */
  115306. clear(): void;
  115307. /**
  115308. * Gets the current count
  115309. */
  115310. get count(): number;
  115311. /**
  115312. * Execute a callback on each key/val of the dictionary.
  115313. * Note that you can remove any element in this dictionary in the callback implementation
  115314. * @param callback the callback to execute on a given key/value pair
  115315. */
  115316. forEach(callback: (key: string, val: T) => void): void;
  115317. /**
  115318. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115319. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115320. * Note that you can remove any element in this dictionary in the callback implementation
  115321. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115322. * @returns the first item
  115323. */
  115324. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115325. private _count;
  115326. private _data;
  115327. }
  115328. }
  115329. declare module BABYLON {
  115330. /** @hidden */
  115331. export interface ICollisionCoordinator {
  115332. createCollider(): Collider;
  115333. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115334. init(scene: Scene): void;
  115335. }
  115336. /** @hidden */
  115337. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115338. private _scene;
  115339. private _scaledPosition;
  115340. private _scaledVelocity;
  115341. private _finalPosition;
  115342. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115343. createCollider(): Collider;
  115344. init(scene: Scene): void;
  115345. private _collideWithWorld;
  115346. }
  115347. }
  115348. declare module BABYLON {
  115349. /**
  115350. * Class used to manage all inputs for the scene.
  115351. */
  115352. export class InputManager {
  115353. /** The distance in pixel that you have to move to prevent some events */
  115354. static DragMovementThreshold: number;
  115355. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115356. static LongPressDelay: number;
  115357. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115358. static DoubleClickDelay: number;
  115359. /** If you need to check double click without raising a single click at first click, enable this flag */
  115360. static ExclusiveDoubleClickMode: boolean;
  115361. private _wheelEventName;
  115362. private _onPointerMove;
  115363. private _onPointerDown;
  115364. private _onPointerUp;
  115365. private _initClickEvent;
  115366. private _initActionManager;
  115367. private _delayedSimpleClick;
  115368. private _delayedSimpleClickTimeout;
  115369. private _previousDelayedSimpleClickTimeout;
  115370. private _meshPickProceed;
  115371. private _previousButtonPressed;
  115372. private _currentPickResult;
  115373. private _previousPickResult;
  115374. private _totalPointersPressed;
  115375. private _doubleClickOccured;
  115376. private _pointerOverMesh;
  115377. private _pickedDownMesh;
  115378. private _pickedUpMesh;
  115379. private _pointerX;
  115380. private _pointerY;
  115381. private _unTranslatedPointerX;
  115382. private _unTranslatedPointerY;
  115383. private _startingPointerPosition;
  115384. private _previousStartingPointerPosition;
  115385. private _startingPointerTime;
  115386. private _previousStartingPointerTime;
  115387. private _pointerCaptures;
  115388. private _onKeyDown;
  115389. private _onKeyUp;
  115390. private _onCanvasFocusObserver;
  115391. private _onCanvasBlurObserver;
  115392. private _scene;
  115393. /**
  115394. * Creates a new InputManager
  115395. * @param scene defines the hosting scene
  115396. */
  115397. constructor(scene: Scene);
  115398. /**
  115399. * Gets the mesh that is currently under the pointer
  115400. */
  115401. get meshUnderPointer(): Nullable<AbstractMesh>;
  115402. /**
  115403. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115404. */
  115405. get unTranslatedPointer(): Vector2;
  115406. /**
  115407. * Gets or sets the current on-screen X position of the pointer
  115408. */
  115409. get pointerX(): number;
  115410. set pointerX(value: number);
  115411. /**
  115412. * Gets or sets the current on-screen Y position of the pointer
  115413. */
  115414. get pointerY(): number;
  115415. set pointerY(value: number);
  115416. private _updatePointerPosition;
  115417. private _processPointerMove;
  115418. private _setRayOnPointerInfo;
  115419. private _checkPrePointerObservable;
  115420. /**
  115421. * Use this method to simulate a pointer move on a mesh
  115422. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115423. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115424. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115425. */
  115426. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115427. /**
  115428. * Use this method to simulate a pointer down on a mesh
  115429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115432. */
  115433. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115434. private _processPointerDown;
  115435. /** @hidden */
  115436. _isPointerSwiping(): boolean;
  115437. /**
  115438. * Use this method to simulate a pointer up on a mesh
  115439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115442. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115443. */
  115444. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115445. private _processPointerUp;
  115446. /**
  115447. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115448. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115449. * @returns true if the pointer was captured
  115450. */
  115451. isPointerCaptured(pointerId?: number): boolean;
  115452. /**
  115453. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115454. * @param attachUp defines if you want to attach events to pointerup
  115455. * @param attachDown defines if you want to attach events to pointerdown
  115456. * @param attachMove defines if you want to attach events to pointermove
  115457. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115458. */
  115459. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115460. /**
  115461. * Detaches all event handlers
  115462. */
  115463. detachControl(): void;
  115464. /**
  115465. * Force the value of meshUnderPointer
  115466. * @param mesh defines the mesh to use
  115467. */
  115468. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115469. /**
  115470. * Gets the mesh under the pointer
  115471. * @returns a Mesh or null if no mesh is under the pointer
  115472. */
  115473. getPointerOverMesh(): Nullable<AbstractMesh>;
  115474. }
  115475. }
  115476. declare module BABYLON {
  115477. /**
  115478. * This class defines the direct association between an animation and a target
  115479. */
  115480. export class TargetedAnimation {
  115481. /**
  115482. * Animation to perform
  115483. */
  115484. animation: Animation;
  115485. /**
  115486. * Target to animate
  115487. */
  115488. target: any;
  115489. /**
  115490. * Returns the string "TargetedAnimation"
  115491. * @returns "TargetedAnimation"
  115492. */
  115493. getClassName(): string;
  115494. /**
  115495. * Serialize the object
  115496. * @returns the JSON object representing the current entity
  115497. */
  115498. serialize(): any;
  115499. }
  115500. /**
  115501. * Use this class to create coordinated animations on multiple targets
  115502. */
  115503. export class AnimationGroup implements IDisposable {
  115504. /** The name of the animation group */
  115505. name: string;
  115506. private _scene;
  115507. private _targetedAnimations;
  115508. private _animatables;
  115509. private _from;
  115510. private _to;
  115511. private _isStarted;
  115512. private _isPaused;
  115513. private _speedRatio;
  115514. private _loopAnimation;
  115515. private _isAdditive;
  115516. /**
  115517. * Gets or sets the unique id of the node
  115518. */
  115519. uniqueId: number;
  115520. /**
  115521. * This observable will notify when one animation have ended
  115522. */
  115523. onAnimationEndObservable: Observable<TargetedAnimation>;
  115524. /**
  115525. * Observer raised when one animation loops
  115526. */
  115527. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115528. /**
  115529. * Observer raised when all animations have looped
  115530. */
  115531. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115532. /**
  115533. * This observable will notify when all animations have ended.
  115534. */
  115535. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115536. /**
  115537. * This observable will notify when all animations have paused.
  115538. */
  115539. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115540. /**
  115541. * This observable will notify when all animations are playing.
  115542. */
  115543. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115544. /**
  115545. * Gets the first frame
  115546. */
  115547. get from(): number;
  115548. /**
  115549. * Gets the last frame
  115550. */
  115551. get to(): number;
  115552. /**
  115553. * Define if the animations are started
  115554. */
  115555. get isStarted(): boolean;
  115556. /**
  115557. * Gets a value indicating that the current group is playing
  115558. */
  115559. get isPlaying(): boolean;
  115560. /**
  115561. * Gets or sets the speed ratio to use for all animations
  115562. */
  115563. get speedRatio(): number;
  115564. /**
  115565. * Gets or sets the speed ratio to use for all animations
  115566. */
  115567. set speedRatio(value: number);
  115568. /**
  115569. * Gets or sets if all animations should loop or not
  115570. */
  115571. get loopAnimation(): boolean;
  115572. set loopAnimation(value: boolean);
  115573. /**
  115574. * Gets or sets if all animations should be evaluated additively
  115575. */
  115576. get isAdditive(): boolean;
  115577. set isAdditive(value: boolean);
  115578. /**
  115579. * Gets the targeted animations for this animation group
  115580. */
  115581. get targetedAnimations(): Array<TargetedAnimation>;
  115582. /**
  115583. * returning the list of animatables controlled by this animation group.
  115584. */
  115585. get animatables(): Array<Animatable>;
  115586. /**
  115587. * Gets the list of target animations
  115588. */
  115589. get children(): TargetedAnimation[];
  115590. /**
  115591. * Instantiates a new Animation Group.
  115592. * This helps managing several animations at once.
  115593. * @see http://doc.babylonjs.com/how_to/group
  115594. * @param name Defines the name of the group
  115595. * @param scene Defines the scene the group belongs to
  115596. */
  115597. constructor(
  115598. /** The name of the animation group */
  115599. name: string, scene?: Nullable<Scene>);
  115600. /**
  115601. * Add an animation (with its target) in the group
  115602. * @param animation defines the animation we want to add
  115603. * @param target defines the target of the animation
  115604. * @returns the TargetedAnimation object
  115605. */
  115606. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115607. /**
  115608. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115609. * It can add constant keys at begin or end
  115610. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115611. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115612. * @returns the animation group
  115613. */
  115614. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115615. private _animationLoopCount;
  115616. private _animationLoopFlags;
  115617. private _processLoop;
  115618. /**
  115619. * Start all animations on given targets
  115620. * @param loop defines if animations must loop
  115621. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115622. * @param from defines the from key (optional)
  115623. * @param to defines the to key (optional)
  115624. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115625. * @returns the current animation group
  115626. */
  115627. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115628. /**
  115629. * Pause all animations
  115630. * @returns the animation group
  115631. */
  115632. pause(): AnimationGroup;
  115633. /**
  115634. * Play all animations to initial state
  115635. * This function will start() the animations if they were not started or will restart() them if they were paused
  115636. * @param loop defines if animations must loop
  115637. * @returns the animation group
  115638. */
  115639. play(loop?: boolean): AnimationGroup;
  115640. /**
  115641. * Reset all animations to initial state
  115642. * @returns the animation group
  115643. */
  115644. reset(): AnimationGroup;
  115645. /**
  115646. * Restart animations from key 0
  115647. * @returns the animation group
  115648. */
  115649. restart(): AnimationGroup;
  115650. /**
  115651. * Stop all animations
  115652. * @returns the animation group
  115653. */
  115654. stop(): AnimationGroup;
  115655. /**
  115656. * Set animation weight for all animatables
  115657. * @param weight defines the weight to use
  115658. * @return the animationGroup
  115659. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115660. */
  115661. setWeightForAllAnimatables(weight: number): AnimationGroup;
  115662. /**
  115663. * Synchronize and normalize all animatables with a source animatable
  115664. * @param root defines the root animatable to synchronize with
  115665. * @return the animationGroup
  115666. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115667. */
  115668. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  115669. /**
  115670. * Goes to a specific frame in this animation group
  115671. * @param frame the frame number to go to
  115672. * @return the animationGroup
  115673. */
  115674. goToFrame(frame: number): AnimationGroup;
  115675. /**
  115676. * Dispose all associated resources
  115677. */
  115678. dispose(): void;
  115679. private _checkAnimationGroupEnded;
  115680. /**
  115681. * Clone the current animation group and returns a copy
  115682. * @param newName defines the name of the new group
  115683. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  115684. * @returns the new aniamtion group
  115685. */
  115686. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115687. /**
  115688. * Serializes the animationGroup to an object
  115689. * @returns Serialized object
  115690. */
  115691. serialize(): any;
  115692. /**
  115693. * Returns a new AnimationGroup object parsed from the source provided.
  115694. * @param parsedAnimationGroup defines the source
  115695. * @param scene defines the scene that will receive the animationGroup
  115696. * @returns a new AnimationGroup
  115697. */
  115698. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115699. /**
  115700. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115701. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115702. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115703. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115704. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115705. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115706. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115707. */
  115708. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115709. /**
  115710. * Returns the string "AnimationGroup"
  115711. * @returns "AnimationGroup"
  115712. */
  115713. getClassName(): string;
  115714. /**
  115715. * Creates a detailled string about the object
  115716. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115717. * @returns a string representing the object
  115718. */
  115719. toString(fullDetails?: boolean): string;
  115720. }
  115721. }
  115722. declare module BABYLON {
  115723. /**
  115724. * Define an interface for all classes that will hold resources
  115725. */
  115726. export interface IDisposable {
  115727. /**
  115728. * Releases all held resources
  115729. */
  115730. dispose(): void;
  115731. }
  115732. /** Interface defining initialization parameters for Scene class */
  115733. export interface SceneOptions {
  115734. /**
  115735. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  115736. * It will improve performance when the number of geometries becomes important.
  115737. */
  115738. useGeometryUniqueIdsMap?: boolean;
  115739. /**
  115740. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  115741. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115742. */
  115743. useMaterialMeshMap?: boolean;
  115744. /**
  115745. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  115746. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  115747. */
  115748. useClonedMeshMap?: boolean;
  115749. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  115750. virtual?: boolean;
  115751. }
  115752. /**
  115753. * Represents a scene to be rendered by the engine.
  115754. * @see http://doc.babylonjs.com/features/scene
  115755. */
  115756. export class Scene extends AbstractScene implements IAnimatable {
  115757. /** The fog is deactivated */
  115758. static readonly FOGMODE_NONE: number;
  115759. /** The fog density is following an exponential function */
  115760. static readonly FOGMODE_EXP: number;
  115761. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  115762. static readonly FOGMODE_EXP2: number;
  115763. /** The fog density is following a linear function. */
  115764. static readonly FOGMODE_LINEAR: number;
  115765. /**
  115766. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  115767. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115768. */
  115769. static MinDeltaTime: number;
  115770. /**
  115771. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  115772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115773. */
  115774. static MaxDeltaTime: number;
  115775. /**
  115776. * Factory used to create the default material.
  115777. * @param name The name of the material to create
  115778. * @param scene The scene to create the material for
  115779. * @returns The default material
  115780. */
  115781. static DefaultMaterialFactory(scene: Scene): Material;
  115782. /**
  115783. * Factory used to create the a collision coordinator.
  115784. * @returns The collision coordinator
  115785. */
  115786. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  115787. /** @hidden */
  115788. _inputManager: InputManager;
  115789. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  115790. cameraToUseForPointers: Nullable<Camera>;
  115791. /** @hidden */
  115792. readonly _isScene: boolean;
  115793. /** @hidden */
  115794. _blockEntityCollection: boolean;
  115795. /**
  115796. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  115797. */
  115798. autoClear: boolean;
  115799. /**
  115800. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  115801. */
  115802. autoClearDepthAndStencil: boolean;
  115803. /**
  115804. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  115805. */
  115806. clearColor: Color4;
  115807. /**
  115808. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  115809. */
  115810. ambientColor: Color3;
  115811. /**
  115812. * This is use to store the default BRDF lookup for PBR materials in your scene.
  115813. * It should only be one of the following (if not the default embedded one):
  115814. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115815. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  115816. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115817. * The material properties need to be setup according to the type of texture in use.
  115818. */
  115819. environmentBRDFTexture: BaseTexture;
  115820. /** @hidden */
  115821. protected _environmentTexture: Nullable<BaseTexture>;
  115822. /**
  115823. * Texture used in all pbr material as the reflection texture.
  115824. * As in the majority of the scene they are the same (exception for multi room and so on),
  115825. * this is easier to reference from here than from all the materials.
  115826. */
  115827. get environmentTexture(): Nullable<BaseTexture>;
  115828. /**
  115829. * Texture used in all pbr material as the reflection texture.
  115830. * As in the majority of the scene they are the same (exception for multi room and so on),
  115831. * this is easier to set here than in all the materials.
  115832. */
  115833. set environmentTexture(value: Nullable<BaseTexture>);
  115834. /** @hidden */
  115835. protected _environmentIntensity: number;
  115836. /**
  115837. * Intensity of the environment in all pbr material.
  115838. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115839. * As in the majority of the scene they are the same (exception for multi room and so on),
  115840. * this is easier to reference from here than from all the materials.
  115841. */
  115842. get environmentIntensity(): number;
  115843. /**
  115844. * Intensity of the environment in all pbr material.
  115845. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  115846. * As in the majority of the scene they are the same (exception for multi room and so on),
  115847. * this is easier to set here than in all the materials.
  115848. */
  115849. set environmentIntensity(value: number);
  115850. /** @hidden */
  115851. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115852. /**
  115853. * Default image processing configuration used either in the rendering
  115854. * Forward main pass or through the imageProcessingPostProcess if present.
  115855. * As in the majority of the scene they are the same (exception for multi camera),
  115856. * this is easier to reference from here than from all the materials and post process.
  115857. *
  115858. * No setter as we it is a shared configuration, you can set the values instead.
  115859. */
  115860. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115861. private _forceWireframe;
  115862. /**
  115863. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  115864. */
  115865. set forceWireframe(value: boolean);
  115866. get forceWireframe(): boolean;
  115867. private _skipFrustumClipping;
  115868. /**
  115869. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  115870. */
  115871. set skipFrustumClipping(value: boolean);
  115872. get skipFrustumClipping(): boolean;
  115873. private _forcePointsCloud;
  115874. /**
  115875. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  115876. */
  115877. set forcePointsCloud(value: boolean);
  115878. get forcePointsCloud(): boolean;
  115879. /**
  115880. * Gets or sets the active clipplane 1
  115881. */
  115882. clipPlane: Nullable<Plane>;
  115883. /**
  115884. * Gets or sets the active clipplane 2
  115885. */
  115886. clipPlane2: Nullable<Plane>;
  115887. /**
  115888. * Gets or sets the active clipplane 3
  115889. */
  115890. clipPlane3: Nullable<Plane>;
  115891. /**
  115892. * Gets or sets the active clipplane 4
  115893. */
  115894. clipPlane4: Nullable<Plane>;
  115895. /**
  115896. * Gets or sets the active clipplane 5
  115897. */
  115898. clipPlane5: Nullable<Plane>;
  115899. /**
  115900. * Gets or sets the active clipplane 6
  115901. */
  115902. clipPlane6: Nullable<Plane>;
  115903. /**
  115904. * Gets or sets a boolean indicating if animations are enabled
  115905. */
  115906. animationsEnabled: boolean;
  115907. private _animationPropertiesOverride;
  115908. /**
  115909. * Gets or sets the animation properties override
  115910. */
  115911. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  115912. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  115913. /**
  115914. * Gets or sets a boolean indicating if a constant deltatime has to be used
  115915. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  115916. */
  115917. useConstantAnimationDeltaTime: boolean;
  115918. /**
  115919. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  115920. * Please note that it requires to run a ray cast through the scene on every frame
  115921. */
  115922. constantlyUpdateMeshUnderPointer: boolean;
  115923. /**
  115924. * Defines the HTML cursor to use when hovering over interactive elements
  115925. */
  115926. hoverCursor: string;
  115927. /**
  115928. * Defines the HTML default cursor to use (empty by default)
  115929. */
  115930. defaultCursor: string;
  115931. /**
  115932. * Defines whether cursors are handled by the scene.
  115933. */
  115934. doNotHandleCursors: boolean;
  115935. /**
  115936. * This is used to call preventDefault() on pointer down
  115937. * in order to block unwanted artifacts like system double clicks
  115938. */
  115939. preventDefaultOnPointerDown: boolean;
  115940. /**
  115941. * This is used to call preventDefault() on pointer up
  115942. * in order to block unwanted artifacts like system double clicks
  115943. */
  115944. preventDefaultOnPointerUp: boolean;
  115945. /**
  115946. * Gets or sets user defined metadata
  115947. */
  115948. metadata: any;
  115949. /**
  115950. * For internal use only. Please do not use.
  115951. */
  115952. reservedDataStore: any;
  115953. /**
  115954. * Gets the name of the plugin used to load this scene (null by default)
  115955. */
  115956. loadingPluginName: string;
  115957. /**
  115958. * Use this array to add regular expressions used to disable offline support for specific urls
  115959. */
  115960. disableOfflineSupportExceptionRules: RegExp[];
  115961. /**
  115962. * An event triggered when the scene is disposed.
  115963. */
  115964. onDisposeObservable: Observable<Scene>;
  115965. private _onDisposeObserver;
  115966. /** Sets a function to be executed when this scene is disposed. */
  115967. set onDispose(callback: () => void);
  115968. /**
  115969. * An event triggered before rendering the scene (right after animations and physics)
  115970. */
  115971. onBeforeRenderObservable: Observable<Scene>;
  115972. private _onBeforeRenderObserver;
  115973. /** Sets a function to be executed before rendering this scene */
  115974. set beforeRender(callback: Nullable<() => void>);
  115975. /**
  115976. * An event triggered after rendering the scene
  115977. */
  115978. onAfterRenderObservable: Observable<Scene>;
  115979. /**
  115980. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  115981. */
  115982. onAfterRenderCameraObservable: Observable<Camera>;
  115983. private _onAfterRenderObserver;
  115984. /** Sets a function to be executed after rendering this scene */
  115985. set afterRender(callback: Nullable<() => void>);
  115986. /**
  115987. * An event triggered before animating the scene
  115988. */
  115989. onBeforeAnimationsObservable: Observable<Scene>;
  115990. /**
  115991. * An event triggered after animations processing
  115992. */
  115993. onAfterAnimationsObservable: Observable<Scene>;
  115994. /**
  115995. * An event triggered before draw calls are ready to be sent
  115996. */
  115997. onBeforeDrawPhaseObservable: Observable<Scene>;
  115998. /**
  115999. * An event triggered after draw calls have been sent
  116000. */
  116001. onAfterDrawPhaseObservable: Observable<Scene>;
  116002. /**
  116003. * An event triggered when the scene is ready
  116004. */
  116005. onReadyObservable: Observable<Scene>;
  116006. /**
  116007. * An event triggered before rendering a camera
  116008. */
  116009. onBeforeCameraRenderObservable: Observable<Camera>;
  116010. private _onBeforeCameraRenderObserver;
  116011. /** Sets a function to be executed before rendering a camera*/
  116012. set beforeCameraRender(callback: () => void);
  116013. /**
  116014. * An event triggered after rendering a camera
  116015. */
  116016. onAfterCameraRenderObservable: Observable<Camera>;
  116017. private _onAfterCameraRenderObserver;
  116018. /** Sets a function to be executed after rendering a camera*/
  116019. set afterCameraRender(callback: () => void);
  116020. /**
  116021. * An event triggered when active meshes evaluation is about to start
  116022. */
  116023. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116024. /**
  116025. * An event triggered when active meshes evaluation is done
  116026. */
  116027. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116028. /**
  116029. * An event triggered when particles rendering is about to start
  116030. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116031. */
  116032. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116033. /**
  116034. * An event triggered when particles rendering is done
  116035. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116036. */
  116037. onAfterParticlesRenderingObservable: Observable<Scene>;
  116038. /**
  116039. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116040. */
  116041. onDataLoadedObservable: Observable<Scene>;
  116042. /**
  116043. * An event triggered when a camera is created
  116044. */
  116045. onNewCameraAddedObservable: Observable<Camera>;
  116046. /**
  116047. * An event triggered when a camera is removed
  116048. */
  116049. onCameraRemovedObservable: Observable<Camera>;
  116050. /**
  116051. * An event triggered when a light is created
  116052. */
  116053. onNewLightAddedObservable: Observable<Light>;
  116054. /**
  116055. * An event triggered when a light is removed
  116056. */
  116057. onLightRemovedObservable: Observable<Light>;
  116058. /**
  116059. * An event triggered when a geometry is created
  116060. */
  116061. onNewGeometryAddedObservable: Observable<Geometry>;
  116062. /**
  116063. * An event triggered when a geometry is removed
  116064. */
  116065. onGeometryRemovedObservable: Observable<Geometry>;
  116066. /**
  116067. * An event triggered when a transform node is created
  116068. */
  116069. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116070. /**
  116071. * An event triggered when a transform node is removed
  116072. */
  116073. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116074. /**
  116075. * An event triggered when a mesh is created
  116076. */
  116077. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116078. /**
  116079. * An event triggered when a mesh is removed
  116080. */
  116081. onMeshRemovedObservable: Observable<AbstractMesh>;
  116082. /**
  116083. * An event triggered when a skeleton is created
  116084. */
  116085. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116086. /**
  116087. * An event triggered when a skeleton is removed
  116088. */
  116089. onSkeletonRemovedObservable: Observable<Skeleton>;
  116090. /**
  116091. * An event triggered when a material is created
  116092. */
  116093. onNewMaterialAddedObservable: Observable<Material>;
  116094. /**
  116095. * An event triggered when a material is removed
  116096. */
  116097. onMaterialRemovedObservable: Observable<Material>;
  116098. /**
  116099. * An event triggered when a texture is created
  116100. */
  116101. onNewTextureAddedObservable: Observable<BaseTexture>;
  116102. /**
  116103. * An event triggered when a texture is removed
  116104. */
  116105. onTextureRemovedObservable: Observable<BaseTexture>;
  116106. /**
  116107. * An event triggered when render targets are about to be rendered
  116108. * Can happen multiple times per frame.
  116109. */
  116110. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116111. /**
  116112. * An event triggered when render targets were rendered.
  116113. * Can happen multiple times per frame.
  116114. */
  116115. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116116. /**
  116117. * An event triggered before calculating deterministic simulation step
  116118. */
  116119. onBeforeStepObservable: Observable<Scene>;
  116120. /**
  116121. * An event triggered after calculating deterministic simulation step
  116122. */
  116123. onAfterStepObservable: Observable<Scene>;
  116124. /**
  116125. * An event triggered when the activeCamera property is updated
  116126. */
  116127. onActiveCameraChanged: Observable<Scene>;
  116128. /**
  116129. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116130. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116131. * 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)
  116132. */
  116133. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116134. /**
  116135. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116136. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116137. * 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)
  116138. */
  116139. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116140. /**
  116141. * This Observable will when a mesh has been imported into the scene.
  116142. */
  116143. onMeshImportedObservable: Observable<AbstractMesh>;
  116144. /**
  116145. * This Observable will when an animation file has been imported into the scene.
  116146. */
  116147. onAnimationFileImportedObservable: Observable<Scene>;
  116148. /**
  116149. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116150. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116151. */
  116152. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116153. /** @hidden */
  116154. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116155. /**
  116156. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116157. */
  116158. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116159. /**
  116160. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116161. */
  116162. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116163. /**
  116164. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116165. */
  116166. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116167. /** Callback called when a pointer move is detected */
  116168. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116169. /** Callback called when a pointer down is detected */
  116170. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116171. /** Callback called when a pointer up is detected */
  116172. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  116173. /** Callback called when a pointer pick is detected */
  116174. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  116175. /**
  116176. * 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).
  116177. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  116178. */
  116179. onPrePointerObservable: Observable<PointerInfoPre>;
  116180. /**
  116181. * Observable event triggered each time an input event is received from the rendering canvas
  116182. */
  116183. onPointerObservable: Observable<PointerInfo>;
  116184. /**
  116185. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  116186. */
  116187. get unTranslatedPointer(): Vector2;
  116188. /**
  116189. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  116190. */
  116191. static get DragMovementThreshold(): number;
  116192. static set DragMovementThreshold(value: number);
  116193. /**
  116194. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  116195. */
  116196. static get LongPressDelay(): number;
  116197. static set LongPressDelay(value: number);
  116198. /**
  116199. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  116200. */
  116201. static get DoubleClickDelay(): number;
  116202. static set DoubleClickDelay(value: number);
  116203. /** If you need to check double click without raising a single click at first click, enable this flag */
  116204. static get ExclusiveDoubleClickMode(): boolean;
  116205. static set ExclusiveDoubleClickMode(value: boolean);
  116206. /** @hidden */
  116207. _mirroredCameraPosition: Nullable<Vector3>;
  116208. /**
  116209. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  116210. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  116211. */
  116212. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  116213. /**
  116214. * Observable event triggered each time an keyboard event is received from the hosting window
  116215. */
  116216. onKeyboardObservable: Observable<KeyboardInfo>;
  116217. private _useRightHandedSystem;
  116218. /**
  116219. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  116220. */
  116221. set useRightHandedSystem(value: boolean);
  116222. get useRightHandedSystem(): boolean;
  116223. private _timeAccumulator;
  116224. private _currentStepId;
  116225. private _currentInternalStep;
  116226. /**
  116227. * Sets the step Id used by deterministic lock step
  116228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116229. * @param newStepId defines the step Id
  116230. */
  116231. setStepId(newStepId: number): void;
  116232. /**
  116233. * Gets the step Id used by deterministic lock step
  116234. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116235. * @returns the step Id
  116236. */
  116237. getStepId(): number;
  116238. /**
  116239. * Gets the internal step used by deterministic lock step
  116240. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116241. * @returns the internal step
  116242. */
  116243. getInternalStep(): number;
  116244. private _fogEnabled;
  116245. /**
  116246. * Gets or sets a boolean indicating if fog is enabled on this scene
  116247. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116248. * (Default is true)
  116249. */
  116250. set fogEnabled(value: boolean);
  116251. get fogEnabled(): boolean;
  116252. private _fogMode;
  116253. /**
  116254. * Gets or sets the fog mode to use
  116255. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116256. * | mode | value |
  116257. * | --- | --- |
  116258. * | FOGMODE_NONE | 0 |
  116259. * | FOGMODE_EXP | 1 |
  116260. * | FOGMODE_EXP2 | 2 |
  116261. * | FOGMODE_LINEAR | 3 |
  116262. */
  116263. set fogMode(value: number);
  116264. get fogMode(): number;
  116265. /**
  116266. * Gets or sets the fog color to use
  116267. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116268. * (Default is Color3(0.2, 0.2, 0.3))
  116269. */
  116270. fogColor: Color3;
  116271. /**
  116272. * Gets or sets the fog density to use
  116273. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116274. * (Default is 0.1)
  116275. */
  116276. fogDensity: number;
  116277. /**
  116278. * Gets or sets the fog start distance to use
  116279. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116280. * (Default is 0)
  116281. */
  116282. fogStart: number;
  116283. /**
  116284. * Gets or sets the fog end distance to use
  116285. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116286. * (Default is 1000)
  116287. */
  116288. fogEnd: number;
  116289. private _shadowsEnabled;
  116290. /**
  116291. * Gets or sets a boolean indicating if shadows are enabled on this scene
  116292. */
  116293. set shadowsEnabled(value: boolean);
  116294. get shadowsEnabled(): boolean;
  116295. private _lightsEnabled;
  116296. /**
  116297. * Gets or sets a boolean indicating if lights are enabled on this scene
  116298. */
  116299. set lightsEnabled(value: boolean);
  116300. get lightsEnabled(): boolean;
  116301. /** All of the active cameras added to this scene. */
  116302. activeCameras: Camera[];
  116303. /** @hidden */
  116304. _activeCamera: Nullable<Camera>;
  116305. /** Gets or sets the current active camera */
  116306. get activeCamera(): Nullable<Camera>;
  116307. set activeCamera(value: Nullable<Camera>);
  116308. private _defaultMaterial;
  116309. /** The default material used on meshes when no material is affected */
  116310. get defaultMaterial(): Material;
  116311. /** The default material used on meshes when no material is affected */
  116312. set defaultMaterial(value: Material);
  116313. private _texturesEnabled;
  116314. /**
  116315. * Gets or sets a boolean indicating if textures are enabled on this scene
  116316. */
  116317. set texturesEnabled(value: boolean);
  116318. get texturesEnabled(): boolean;
  116319. /**
  116320. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116321. */
  116322. physicsEnabled: boolean;
  116323. /**
  116324. * Gets or sets a boolean indicating if particles are enabled on this scene
  116325. */
  116326. particlesEnabled: boolean;
  116327. /**
  116328. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116329. */
  116330. spritesEnabled: boolean;
  116331. private _skeletonsEnabled;
  116332. /**
  116333. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116334. */
  116335. set skeletonsEnabled(value: boolean);
  116336. get skeletonsEnabled(): boolean;
  116337. /**
  116338. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116339. */
  116340. lensFlaresEnabled: boolean;
  116341. /**
  116342. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116344. */
  116345. collisionsEnabled: boolean;
  116346. private _collisionCoordinator;
  116347. /** @hidden */
  116348. get collisionCoordinator(): ICollisionCoordinator;
  116349. /**
  116350. * Defines the gravity applied to this scene (used only for collisions)
  116351. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116352. */
  116353. gravity: Vector3;
  116354. /**
  116355. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116356. */
  116357. postProcessesEnabled: boolean;
  116358. /**
  116359. * The list of postprocesses added to the scene
  116360. */
  116361. postProcesses: PostProcess[];
  116362. /**
  116363. * Gets the current postprocess manager
  116364. */
  116365. postProcessManager: PostProcessManager;
  116366. /**
  116367. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116368. */
  116369. renderTargetsEnabled: boolean;
  116370. /**
  116371. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116372. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116373. */
  116374. dumpNextRenderTargets: boolean;
  116375. /**
  116376. * The list of user defined render targets added to the scene
  116377. */
  116378. customRenderTargets: RenderTargetTexture[];
  116379. /**
  116380. * Defines if texture loading must be delayed
  116381. * If true, textures will only be loaded when they need to be rendered
  116382. */
  116383. useDelayedTextureLoading: boolean;
  116384. /**
  116385. * Gets the list of meshes imported to the scene through SceneLoader
  116386. */
  116387. importedMeshesFiles: String[];
  116388. /**
  116389. * Gets or sets a boolean indicating if probes are enabled on this scene
  116390. */
  116391. probesEnabled: boolean;
  116392. /**
  116393. * Gets or sets the current offline provider to use to store scene data
  116394. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116395. */
  116396. offlineProvider: IOfflineProvider;
  116397. /**
  116398. * Gets or sets the action manager associated with the scene
  116399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116400. */
  116401. actionManager: AbstractActionManager;
  116402. private _meshesForIntersections;
  116403. /**
  116404. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116405. */
  116406. proceduralTexturesEnabled: boolean;
  116407. private _engine;
  116408. private _totalVertices;
  116409. /** @hidden */
  116410. _activeIndices: PerfCounter;
  116411. /** @hidden */
  116412. _activeParticles: PerfCounter;
  116413. /** @hidden */
  116414. _activeBones: PerfCounter;
  116415. private _animationRatio;
  116416. /** @hidden */
  116417. _animationTimeLast: number;
  116418. /** @hidden */
  116419. _animationTime: number;
  116420. /**
  116421. * Gets or sets a general scale for animation speed
  116422. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116423. */
  116424. animationTimeScale: number;
  116425. /** @hidden */
  116426. _cachedMaterial: Nullable<Material>;
  116427. /** @hidden */
  116428. _cachedEffect: Nullable<Effect>;
  116429. /** @hidden */
  116430. _cachedVisibility: Nullable<number>;
  116431. private _renderId;
  116432. private _frameId;
  116433. private _executeWhenReadyTimeoutId;
  116434. private _intermediateRendering;
  116435. private _viewUpdateFlag;
  116436. private _projectionUpdateFlag;
  116437. /** @hidden */
  116438. _toBeDisposed: Nullable<IDisposable>[];
  116439. private _activeRequests;
  116440. /** @hidden */
  116441. _pendingData: any[];
  116442. private _isDisposed;
  116443. /**
  116444. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116445. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116446. */
  116447. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116448. private _activeMeshes;
  116449. private _processedMaterials;
  116450. private _renderTargets;
  116451. /** @hidden */
  116452. _activeParticleSystems: SmartArray<IParticleSystem>;
  116453. private _activeSkeletons;
  116454. private _softwareSkinnedMeshes;
  116455. private _renderingManager;
  116456. /** @hidden */
  116457. _activeAnimatables: Animatable[];
  116458. private _transformMatrix;
  116459. private _sceneUbo;
  116460. /** @hidden */
  116461. _viewMatrix: Matrix;
  116462. private _projectionMatrix;
  116463. /** @hidden */
  116464. _forcedViewPosition: Nullable<Vector3>;
  116465. /** @hidden */
  116466. _frustumPlanes: Plane[];
  116467. /**
  116468. * Gets the list of frustum planes (built from the active camera)
  116469. */
  116470. get frustumPlanes(): Plane[];
  116471. /**
  116472. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116473. * This is useful if there are more lights that the maximum simulteanous authorized
  116474. */
  116475. requireLightSorting: boolean;
  116476. /** @hidden */
  116477. readonly useMaterialMeshMap: boolean;
  116478. /** @hidden */
  116479. readonly useClonedMeshMap: boolean;
  116480. private _externalData;
  116481. private _uid;
  116482. /**
  116483. * @hidden
  116484. * Backing store of defined scene components.
  116485. */
  116486. _components: ISceneComponent[];
  116487. /**
  116488. * @hidden
  116489. * Backing store of defined scene components.
  116490. */
  116491. _serializableComponents: ISceneSerializableComponent[];
  116492. /**
  116493. * List of components to register on the next registration step.
  116494. */
  116495. private _transientComponents;
  116496. /**
  116497. * Registers the transient components if needed.
  116498. */
  116499. private _registerTransientComponents;
  116500. /**
  116501. * @hidden
  116502. * Add a component to the scene.
  116503. * Note that the ccomponent could be registered on th next frame if this is called after
  116504. * the register component stage.
  116505. * @param component Defines the component to add to the scene
  116506. */
  116507. _addComponent(component: ISceneComponent): void;
  116508. /**
  116509. * @hidden
  116510. * Gets a component from the scene.
  116511. * @param name defines the name of the component to retrieve
  116512. * @returns the component or null if not present
  116513. */
  116514. _getComponent(name: string): Nullable<ISceneComponent>;
  116515. /**
  116516. * @hidden
  116517. * Defines the actions happening before camera updates.
  116518. */
  116519. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116520. /**
  116521. * @hidden
  116522. * Defines the actions happening before clear the canvas.
  116523. */
  116524. _beforeClearStage: Stage<SimpleStageAction>;
  116525. /**
  116526. * @hidden
  116527. * Defines the actions when collecting render targets for the frame.
  116528. */
  116529. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116530. /**
  116531. * @hidden
  116532. * Defines the actions happening for one camera in the frame.
  116533. */
  116534. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116535. /**
  116536. * @hidden
  116537. * Defines the actions happening during the per mesh ready checks.
  116538. */
  116539. _isReadyForMeshStage: Stage<MeshStageAction>;
  116540. /**
  116541. * @hidden
  116542. * Defines the actions happening before evaluate active mesh checks.
  116543. */
  116544. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116545. /**
  116546. * @hidden
  116547. * Defines the actions happening during the evaluate sub mesh checks.
  116548. */
  116549. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116550. /**
  116551. * @hidden
  116552. * Defines the actions happening during the active mesh stage.
  116553. */
  116554. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116555. /**
  116556. * @hidden
  116557. * Defines the actions happening during the per camera render target step.
  116558. */
  116559. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116560. /**
  116561. * @hidden
  116562. * Defines the actions happening just before the active camera is drawing.
  116563. */
  116564. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116565. /**
  116566. * @hidden
  116567. * Defines the actions happening just before a render target is drawing.
  116568. */
  116569. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116570. /**
  116571. * @hidden
  116572. * Defines the actions happening just before a rendering group is drawing.
  116573. */
  116574. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116575. /**
  116576. * @hidden
  116577. * Defines the actions happening just before a mesh is drawing.
  116578. */
  116579. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116580. /**
  116581. * @hidden
  116582. * Defines the actions happening just after a mesh has been drawn.
  116583. */
  116584. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116585. /**
  116586. * @hidden
  116587. * Defines the actions happening just after a rendering group has been drawn.
  116588. */
  116589. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116590. /**
  116591. * @hidden
  116592. * Defines the actions happening just after the active camera has been drawn.
  116593. */
  116594. _afterCameraDrawStage: Stage<CameraStageAction>;
  116595. /**
  116596. * @hidden
  116597. * Defines the actions happening just after a render target has been drawn.
  116598. */
  116599. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116600. /**
  116601. * @hidden
  116602. * Defines the actions happening just after rendering all cameras and computing intersections.
  116603. */
  116604. _afterRenderStage: Stage<SimpleStageAction>;
  116605. /**
  116606. * @hidden
  116607. * Defines the actions happening when a pointer move event happens.
  116608. */
  116609. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116610. /**
  116611. * @hidden
  116612. * Defines the actions happening when a pointer down event happens.
  116613. */
  116614. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116615. /**
  116616. * @hidden
  116617. * Defines the actions happening when a pointer up event happens.
  116618. */
  116619. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116620. /**
  116621. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116622. */
  116623. private geometriesByUniqueId;
  116624. /**
  116625. * Creates a new Scene
  116626. * @param engine defines the engine to use to render this scene
  116627. * @param options defines the scene options
  116628. */
  116629. constructor(engine: Engine, options?: SceneOptions);
  116630. /**
  116631. * Gets a string idenfifying the name of the class
  116632. * @returns "Scene" string
  116633. */
  116634. getClassName(): string;
  116635. private _defaultMeshCandidates;
  116636. /**
  116637. * @hidden
  116638. */
  116639. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116640. private _defaultSubMeshCandidates;
  116641. /**
  116642. * @hidden
  116643. */
  116644. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116645. /**
  116646. * Sets the default candidate providers for the scene.
  116647. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  116648. * and getCollidingSubMeshCandidates to their default function
  116649. */
  116650. setDefaultCandidateProviders(): void;
  116651. /**
  116652. * Gets the mesh that is currently under the pointer
  116653. */
  116654. get meshUnderPointer(): Nullable<AbstractMesh>;
  116655. /**
  116656. * Gets or sets the current on-screen X position of the pointer
  116657. */
  116658. get pointerX(): number;
  116659. set pointerX(value: number);
  116660. /**
  116661. * Gets or sets the current on-screen Y position of the pointer
  116662. */
  116663. get pointerY(): number;
  116664. set pointerY(value: number);
  116665. /**
  116666. * Gets the cached material (ie. the latest rendered one)
  116667. * @returns the cached material
  116668. */
  116669. getCachedMaterial(): Nullable<Material>;
  116670. /**
  116671. * Gets the cached effect (ie. the latest rendered one)
  116672. * @returns the cached effect
  116673. */
  116674. getCachedEffect(): Nullable<Effect>;
  116675. /**
  116676. * Gets the cached visibility state (ie. the latest rendered one)
  116677. * @returns the cached visibility state
  116678. */
  116679. getCachedVisibility(): Nullable<number>;
  116680. /**
  116681. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  116682. * @param material defines the current material
  116683. * @param effect defines the current effect
  116684. * @param visibility defines the current visibility state
  116685. * @returns true if one parameter is not cached
  116686. */
  116687. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116688. /**
  116689. * Gets the engine associated with the scene
  116690. * @returns an Engine
  116691. */
  116692. getEngine(): Engine;
  116693. /**
  116694. * Gets the total number of vertices rendered per frame
  116695. * @returns the total number of vertices rendered per frame
  116696. */
  116697. getTotalVertices(): number;
  116698. /**
  116699. * Gets the performance counter for total vertices
  116700. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116701. */
  116702. get totalVerticesPerfCounter(): PerfCounter;
  116703. /**
  116704. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116705. * @returns the total number of active indices rendered per frame
  116706. */
  116707. getActiveIndices(): number;
  116708. /**
  116709. * Gets the performance counter for active indices
  116710. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116711. */
  116712. get totalActiveIndicesPerfCounter(): PerfCounter;
  116713. /**
  116714. * Gets the total number of active particles rendered per frame
  116715. * @returns the total number of active particles rendered per frame
  116716. */
  116717. getActiveParticles(): number;
  116718. /**
  116719. * Gets the performance counter for active particles
  116720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116721. */
  116722. get activeParticlesPerfCounter(): PerfCounter;
  116723. /**
  116724. * Gets the total number of active bones rendered per frame
  116725. * @returns the total number of active bones rendered per frame
  116726. */
  116727. getActiveBones(): number;
  116728. /**
  116729. * Gets the performance counter for active bones
  116730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116731. */
  116732. get activeBonesPerfCounter(): PerfCounter;
  116733. /**
  116734. * Gets the array of active meshes
  116735. * @returns an array of AbstractMesh
  116736. */
  116737. getActiveMeshes(): SmartArray<AbstractMesh>;
  116738. /**
  116739. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  116740. * @returns a number
  116741. */
  116742. getAnimationRatio(): number;
  116743. /**
  116744. * Gets an unique Id for the current render phase
  116745. * @returns a number
  116746. */
  116747. getRenderId(): number;
  116748. /**
  116749. * Gets an unique Id for the current frame
  116750. * @returns a number
  116751. */
  116752. getFrameId(): number;
  116753. /** Call this function if you want to manually increment the render Id*/
  116754. incrementRenderId(): void;
  116755. private _createUbo;
  116756. /**
  116757. * Use this method to simulate a pointer move on a mesh
  116758. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116759. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116760. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116761. * @returns the current scene
  116762. */
  116763. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116764. /**
  116765. * Use this method to simulate a pointer down on a mesh
  116766. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116767. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116768. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116769. * @returns the current scene
  116770. */
  116771. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  116772. /**
  116773. * Use this method to simulate a pointer up on a mesh
  116774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116777. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116778. * @returns the current scene
  116779. */
  116780. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  116781. /**
  116782. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116783. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116784. * @returns true if the pointer was captured
  116785. */
  116786. isPointerCaptured(pointerId?: number): boolean;
  116787. /**
  116788. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116789. * @param attachUp defines if you want to attach events to pointerup
  116790. * @param attachDown defines if you want to attach events to pointerdown
  116791. * @param attachMove defines if you want to attach events to pointermove
  116792. */
  116793. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  116794. /** Detaches all event handlers*/
  116795. detachControl(): void;
  116796. /**
  116797. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  116798. * Delay loaded resources are not taking in account
  116799. * @return true if all required resources are ready
  116800. */
  116801. isReady(): boolean;
  116802. /** Resets all cached information relative to material (including effect and visibility) */
  116803. resetCachedMaterial(): void;
  116804. /**
  116805. * Registers a function to be called before every frame render
  116806. * @param func defines the function to register
  116807. */
  116808. registerBeforeRender(func: () => void): void;
  116809. /**
  116810. * Unregisters a function called before every frame render
  116811. * @param func defines the function to unregister
  116812. */
  116813. unregisterBeforeRender(func: () => void): void;
  116814. /**
  116815. * Registers a function to be called after every frame render
  116816. * @param func defines the function to register
  116817. */
  116818. registerAfterRender(func: () => void): void;
  116819. /**
  116820. * Unregisters a function called after every frame render
  116821. * @param func defines the function to unregister
  116822. */
  116823. unregisterAfterRender(func: () => void): void;
  116824. private _executeOnceBeforeRender;
  116825. /**
  116826. * The provided function will run before render once and will be disposed afterwards.
  116827. * A timeout delay can be provided so that the function will be executed in N ms.
  116828. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  116829. * @param func The function to be executed.
  116830. * @param timeout optional delay in ms
  116831. */
  116832. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  116833. /** @hidden */
  116834. _addPendingData(data: any): void;
  116835. /** @hidden */
  116836. _removePendingData(data: any): void;
  116837. /**
  116838. * Returns the number of items waiting to be loaded
  116839. * @returns the number of items waiting to be loaded
  116840. */
  116841. getWaitingItemsCount(): number;
  116842. /**
  116843. * Returns a boolean indicating if the scene is still loading data
  116844. */
  116845. get isLoading(): boolean;
  116846. /**
  116847. * Registers a function to be executed when the scene is ready
  116848. * @param {Function} func - the function to be executed
  116849. */
  116850. executeWhenReady(func: () => void): void;
  116851. /**
  116852. * Returns a promise that resolves when the scene is ready
  116853. * @returns A promise that resolves when the scene is ready
  116854. */
  116855. whenReadyAsync(): Promise<void>;
  116856. /** @hidden */
  116857. _checkIsReady(): void;
  116858. /**
  116859. * Gets all animatable attached to the scene
  116860. */
  116861. get animatables(): Animatable[];
  116862. /**
  116863. * Resets the last animation time frame.
  116864. * Useful to override when animations start running when loading a scene for the first time.
  116865. */
  116866. resetLastAnimationTimeFrame(): void;
  116867. /**
  116868. * Gets the current view matrix
  116869. * @returns a Matrix
  116870. */
  116871. getViewMatrix(): Matrix;
  116872. /**
  116873. * Gets the current projection matrix
  116874. * @returns a Matrix
  116875. */
  116876. getProjectionMatrix(): Matrix;
  116877. /**
  116878. * Gets the current transform matrix
  116879. * @returns a Matrix made of View * Projection
  116880. */
  116881. getTransformMatrix(): Matrix;
  116882. /**
  116883. * Sets the current transform matrix
  116884. * @param viewL defines the View matrix to use
  116885. * @param projectionL defines the Projection matrix to use
  116886. * @param viewR defines the right View matrix to use (if provided)
  116887. * @param projectionR defines the right Projection matrix to use (if provided)
  116888. */
  116889. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  116890. /**
  116891. * Gets the uniform buffer used to store scene data
  116892. * @returns a UniformBuffer
  116893. */
  116894. getSceneUniformBuffer(): UniformBuffer;
  116895. /**
  116896. * Gets an unique (relatively to the current scene) Id
  116897. * @returns an unique number for the scene
  116898. */
  116899. getUniqueId(): number;
  116900. /**
  116901. * Add a mesh to the list of scene's meshes
  116902. * @param newMesh defines the mesh to add
  116903. * @param recursive if all child meshes should also be added to the scene
  116904. */
  116905. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  116906. /**
  116907. * Remove a mesh for the list of scene's meshes
  116908. * @param toRemove defines the mesh to remove
  116909. * @param recursive if all child meshes should also be removed from the scene
  116910. * @returns the index where the mesh was in the mesh list
  116911. */
  116912. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  116913. /**
  116914. * Add a transform node to the list of scene's transform nodes
  116915. * @param newTransformNode defines the transform node to add
  116916. */
  116917. addTransformNode(newTransformNode: TransformNode): void;
  116918. /**
  116919. * Remove a transform node for the list of scene's transform nodes
  116920. * @param toRemove defines the transform node to remove
  116921. * @returns the index where the transform node was in the transform node list
  116922. */
  116923. removeTransformNode(toRemove: TransformNode): number;
  116924. /**
  116925. * Remove a skeleton for the list of scene's skeletons
  116926. * @param toRemove defines the skeleton to remove
  116927. * @returns the index where the skeleton was in the skeleton list
  116928. */
  116929. removeSkeleton(toRemove: Skeleton): number;
  116930. /**
  116931. * Remove a morph target for the list of scene's morph targets
  116932. * @param toRemove defines the morph target to remove
  116933. * @returns the index where the morph target was in the morph target list
  116934. */
  116935. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  116936. /**
  116937. * Remove a light for the list of scene's lights
  116938. * @param toRemove defines the light to remove
  116939. * @returns the index where the light was in the light list
  116940. */
  116941. removeLight(toRemove: Light): number;
  116942. /**
  116943. * Remove a camera for the list of scene's cameras
  116944. * @param toRemove defines the camera to remove
  116945. * @returns the index where the camera was in the camera list
  116946. */
  116947. removeCamera(toRemove: Camera): number;
  116948. /**
  116949. * Remove a particle system for the list of scene's particle systems
  116950. * @param toRemove defines the particle system to remove
  116951. * @returns the index where the particle system was in the particle system list
  116952. */
  116953. removeParticleSystem(toRemove: IParticleSystem): number;
  116954. /**
  116955. * Remove a animation for the list of scene's animations
  116956. * @param toRemove defines the animation to remove
  116957. * @returns the index where the animation was in the animation list
  116958. */
  116959. removeAnimation(toRemove: Animation): number;
  116960. /**
  116961. * Will stop the animation of the given target
  116962. * @param target - the target
  116963. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  116964. * @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)
  116965. */
  116966. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  116967. /**
  116968. * Removes the given animation group from this scene.
  116969. * @param toRemove The animation group to remove
  116970. * @returns The index of the removed animation group
  116971. */
  116972. removeAnimationGroup(toRemove: AnimationGroup): number;
  116973. /**
  116974. * Removes the given multi-material from this scene.
  116975. * @param toRemove The multi-material to remove
  116976. * @returns The index of the removed multi-material
  116977. */
  116978. removeMultiMaterial(toRemove: MultiMaterial): number;
  116979. /**
  116980. * Removes the given material from this scene.
  116981. * @param toRemove The material to remove
  116982. * @returns The index of the removed material
  116983. */
  116984. removeMaterial(toRemove: Material): number;
  116985. /**
  116986. * Removes the given action manager from this scene.
  116987. * @param toRemove The action manager to remove
  116988. * @returns The index of the removed action manager
  116989. */
  116990. removeActionManager(toRemove: AbstractActionManager): number;
  116991. /**
  116992. * Removes the given texture from this scene.
  116993. * @param toRemove The texture to remove
  116994. * @returns The index of the removed texture
  116995. */
  116996. removeTexture(toRemove: BaseTexture): number;
  116997. /**
  116998. * Adds the given light to this scene
  116999. * @param newLight The light to add
  117000. */
  117001. addLight(newLight: Light): void;
  117002. /**
  117003. * Sorts the list list based on light priorities
  117004. */
  117005. sortLightsByPriority(): void;
  117006. /**
  117007. * Adds the given camera to this scene
  117008. * @param newCamera The camera to add
  117009. */
  117010. addCamera(newCamera: Camera): void;
  117011. /**
  117012. * Adds the given skeleton to this scene
  117013. * @param newSkeleton The skeleton to add
  117014. */
  117015. addSkeleton(newSkeleton: Skeleton): void;
  117016. /**
  117017. * Adds the given particle system to this scene
  117018. * @param newParticleSystem The particle system to add
  117019. */
  117020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117021. /**
  117022. * Adds the given animation to this scene
  117023. * @param newAnimation The animation to add
  117024. */
  117025. addAnimation(newAnimation: Animation): void;
  117026. /**
  117027. * Adds the given animation group to this scene.
  117028. * @param newAnimationGroup The animation group to add
  117029. */
  117030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117031. /**
  117032. * Adds the given multi-material to this scene
  117033. * @param newMultiMaterial The multi-material to add
  117034. */
  117035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117036. /**
  117037. * Adds the given material to this scene
  117038. * @param newMaterial The material to add
  117039. */
  117040. addMaterial(newMaterial: Material): void;
  117041. /**
  117042. * Adds the given morph target to this scene
  117043. * @param newMorphTargetManager The morph target to add
  117044. */
  117045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117046. /**
  117047. * Adds the given geometry to this scene
  117048. * @param newGeometry The geometry to add
  117049. */
  117050. addGeometry(newGeometry: Geometry): void;
  117051. /**
  117052. * Adds the given action manager to this scene
  117053. * @param newActionManager The action manager to add
  117054. */
  117055. addActionManager(newActionManager: AbstractActionManager): void;
  117056. /**
  117057. * Adds the given texture to this scene.
  117058. * @param newTexture The texture to add
  117059. */
  117060. addTexture(newTexture: BaseTexture): void;
  117061. /**
  117062. * Switch active camera
  117063. * @param newCamera defines the new active camera
  117064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117065. */
  117066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117067. /**
  117068. * sets the active camera of the scene using its ID
  117069. * @param id defines the camera's ID
  117070. * @return the new active camera or null if none found.
  117071. */
  117072. setActiveCameraByID(id: string): Nullable<Camera>;
  117073. /**
  117074. * sets the active camera of the scene using its name
  117075. * @param name defines the camera's name
  117076. * @returns the new active camera or null if none found.
  117077. */
  117078. setActiveCameraByName(name: string): Nullable<Camera>;
  117079. /**
  117080. * get an animation group using its name
  117081. * @param name defines the material's name
  117082. * @return the animation group or null if none found.
  117083. */
  117084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117085. /**
  117086. * Get a material using its unique id
  117087. * @param uniqueId defines the material's unique id
  117088. * @return the material or null if none found.
  117089. */
  117090. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117091. /**
  117092. * get a material using its id
  117093. * @param id defines the material's ID
  117094. * @return the material or null if none found.
  117095. */
  117096. getMaterialByID(id: string): Nullable<Material>;
  117097. /**
  117098. * Gets a the last added material using a given id
  117099. * @param id defines the material's ID
  117100. * @return the last material with the given id or null if none found.
  117101. */
  117102. getLastMaterialByID(id: string): Nullable<Material>;
  117103. /**
  117104. * Gets a material using its name
  117105. * @param name defines the material's name
  117106. * @return the material or null if none found.
  117107. */
  117108. getMaterialByName(name: string): Nullable<Material>;
  117109. /**
  117110. * Get a texture using its unique id
  117111. * @param uniqueId defines the texture's unique id
  117112. * @return the texture or null if none found.
  117113. */
  117114. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117115. /**
  117116. * Gets a camera using its id
  117117. * @param id defines the id to look for
  117118. * @returns the camera or null if not found
  117119. */
  117120. getCameraByID(id: string): Nullable<Camera>;
  117121. /**
  117122. * Gets a camera using its unique id
  117123. * @param uniqueId defines the unique id to look for
  117124. * @returns the camera or null if not found
  117125. */
  117126. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117127. /**
  117128. * Gets a camera using its name
  117129. * @param name defines the camera's name
  117130. * @return the camera or null if none found.
  117131. */
  117132. getCameraByName(name: string): Nullable<Camera>;
  117133. /**
  117134. * Gets a bone using its id
  117135. * @param id defines the bone's id
  117136. * @return the bone or null if not found
  117137. */
  117138. getBoneByID(id: string): Nullable<Bone>;
  117139. /**
  117140. * Gets a bone using its id
  117141. * @param name defines the bone's name
  117142. * @return the bone or null if not found
  117143. */
  117144. getBoneByName(name: string): Nullable<Bone>;
  117145. /**
  117146. * Gets a light node using its name
  117147. * @param name defines the the light's name
  117148. * @return the light or null if none found.
  117149. */
  117150. getLightByName(name: string): Nullable<Light>;
  117151. /**
  117152. * Gets a light node using its id
  117153. * @param id defines the light's id
  117154. * @return the light or null if none found.
  117155. */
  117156. getLightByID(id: string): Nullable<Light>;
  117157. /**
  117158. * Gets a light node using its scene-generated unique ID
  117159. * @param uniqueId defines the light's unique id
  117160. * @return the light or null if none found.
  117161. */
  117162. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117163. /**
  117164. * Gets a particle system by id
  117165. * @param id defines the particle system id
  117166. * @return the corresponding system or null if none found
  117167. */
  117168. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  117169. /**
  117170. * Gets a geometry using its ID
  117171. * @param id defines the geometry's id
  117172. * @return the geometry or null if none found.
  117173. */
  117174. getGeometryByID(id: string): Nullable<Geometry>;
  117175. private _getGeometryByUniqueID;
  117176. /**
  117177. * Add a new geometry to this scene
  117178. * @param geometry defines the geometry to be added to the scene.
  117179. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  117180. * @return a boolean defining if the geometry was added or not
  117181. */
  117182. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  117183. /**
  117184. * Removes an existing geometry
  117185. * @param geometry defines the geometry to be removed from the scene
  117186. * @return a boolean defining if the geometry was removed or not
  117187. */
  117188. removeGeometry(geometry: Geometry): boolean;
  117189. /**
  117190. * Gets the list of geometries attached to the scene
  117191. * @returns an array of Geometry
  117192. */
  117193. getGeometries(): Geometry[];
  117194. /**
  117195. * Gets the first added mesh found of a given ID
  117196. * @param id defines the id to search for
  117197. * @return the mesh found or null if not found at all
  117198. */
  117199. getMeshByID(id: string): Nullable<AbstractMesh>;
  117200. /**
  117201. * Gets a list of meshes using their id
  117202. * @param id defines the id to search for
  117203. * @returns a list of meshes
  117204. */
  117205. getMeshesByID(id: string): Array<AbstractMesh>;
  117206. /**
  117207. * Gets the first added transform node found of a given ID
  117208. * @param id defines the id to search for
  117209. * @return the found transform node or null if not found at all.
  117210. */
  117211. getTransformNodeByID(id: string): Nullable<TransformNode>;
  117212. /**
  117213. * Gets a transform node with its auto-generated unique id
  117214. * @param uniqueId efines the unique id to search for
  117215. * @return the found transform node or null if not found at all.
  117216. */
  117217. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  117218. /**
  117219. * Gets a list of transform nodes using their id
  117220. * @param id defines the id to search for
  117221. * @returns a list of transform nodes
  117222. */
  117223. getTransformNodesByID(id: string): Array<TransformNode>;
  117224. /**
  117225. * Gets a mesh with its auto-generated unique id
  117226. * @param uniqueId defines the unique id to search for
  117227. * @return the found mesh or null if not found at all.
  117228. */
  117229. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  117230. /**
  117231. * Gets a the last added mesh using a given id
  117232. * @param id defines the id to search for
  117233. * @return the found mesh or null if not found at all.
  117234. */
  117235. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  117236. /**
  117237. * Gets a the last added node (Mesh, Camera, Light) using a given id
  117238. * @param id defines the id to search for
  117239. * @return the found node or null if not found at all
  117240. */
  117241. getLastEntryByID(id: string): Nullable<Node>;
  117242. /**
  117243. * Gets a node (Mesh, Camera, Light) using a given id
  117244. * @param id defines the id to search for
  117245. * @return the found node or null if not found at all
  117246. */
  117247. getNodeByID(id: string): Nullable<Node>;
  117248. /**
  117249. * Gets a node (Mesh, Camera, Light) using a given name
  117250. * @param name defines the name to search for
  117251. * @return the found node or null if not found at all.
  117252. */
  117253. getNodeByName(name: string): Nullable<Node>;
  117254. /**
  117255. * Gets a mesh using a given name
  117256. * @param name defines the name to search for
  117257. * @return the found mesh or null if not found at all.
  117258. */
  117259. getMeshByName(name: string): Nullable<AbstractMesh>;
  117260. /**
  117261. * Gets a transform node using a given name
  117262. * @param name defines the name to search for
  117263. * @return the found transform node or null if not found at all.
  117264. */
  117265. getTransformNodeByName(name: string): Nullable<TransformNode>;
  117266. /**
  117267. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  117268. * @param id defines the id to search for
  117269. * @return the found skeleton or null if not found at all.
  117270. */
  117271. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  117272. /**
  117273. * Gets a skeleton using a given auto generated unique id
  117274. * @param uniqueId defines the unique id to search for
  117275. * @return the found skeleton or null if not found at all.
  117276. */
  117277. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  117278. /**
  117279. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  117280. * @param id defines the id to search for
  117281. * @return the found skeleton or null if not found at all.
  117282. */
  117283. getSkeletonById(id: string): Nullable<Skeleton>;
  117284. /**
  117285. * Gets a skeleton using a given name
  117286. * @param name defines the name to search for
  117287. * @return the found skeleton or null if not found at all.
  117288. */
  117289. getSkeletonByName(name: string): Nullable<Skeleton>;
  117290. /**
  117291. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  117292. * @param id defines the id to search for
  117293. * @return the found morph target manager or null if not found at all.
  117294. */
  117295. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  117296. /**
  117297. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  117298. * @param id defines the id to search for
  117299. * @return the found morph target or null if not found at all.
  117300. */
  117301. getMorphTargetById(id: string): Nullable<MorphTarget>;
  117302. /**
  117303. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117304. * @param name defines the name to search for
  117305. * @return the found morph target or null if not found at all.
  117306. */
  117307. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117308. /**
  117309. * Gets a boolean indicating if the given mesh is active
  117310. * @param mesh defines the mesh to look for
  117311. * @returns true if the mesh is in the active list
  117312. */
  117313. isActiveMesh(mesh: AbstractMesh): boolean;
  117314. /**
  117315. * Return a unique id as a string which can serve as an identifier for the scene
  117316. */
  117317. get uid(): string;
  117318. /**
  117319. * Add an externaly attached data from its key.
  117320. * This method call will fail and return false, if such key already exists.
  117321. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117322. * @param key the unique key that identifies the data
  117323. * @param data the data object to associate to the key for this Engine instance
  117324. * @return true if no such key were already present and the data was added successfully, false otherwise
  117325. */
  117326. addExternalData<T>(key: string, data: T): boolean;
  117327. /**
  117328. * Get an externaly attached data from its key
  117329. * @param key the unique key that identifies the data
  117330. * @return the associated data, if present (can be null), or undefined if not present
  117331. */
  117332. getExternalData<T>(key: string): Nullable<T>;
  117333. /**
  117334. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117335. * @param key the unique key that identifies the data
  117336. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117337. * @return the associated data, can be null if the factory returned null.
  117338. */
  117339. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117340. /**
  117341. * Remove an externaly attached data from the Engine instance
  117342. * @param key the unique key that identifies the data
  117343. * @return true if the data was successfully removed, false if it doesn't exist
  117344. */
  117345. removeExternalData(key: string): boolean;
  117346. private _evaluateSubMesh;
  117347. /**
  117348. * Clear the processed materials smart array preventing retention point in material dispose.
  117349. */
  117350. freeProcessedMaterials(): void;
  117351. private _preventFreeActiveMeshesAndRenderingGroups;
  117352. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117353. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117354. * when disposing several meshes in a row or a hierarchy of meshes.
  117355. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117356. */
  117357. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117358. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117359. /**
  117360. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117361. */
  117362. freeActiveMeshes(): void;
  117363. /**
  117364. * Clear the info related to rendering groups preventing retention points during dispose.
  117365. */
  117366. freeRenderingGroups(): void;
  117367. /** @hidden */
  117368. _isInIntermediateRendering(): boolean;
  117369. /**
  117370. * Lambda returning the list of potentially active meshes.
  117371. */
  117372. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117373. /**
  117374. * Lambda returning the list of potentially active sub meshes.
  117375. */
  117376. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117377. /**
  117378. * Lambda returning the list of potentially intersecting sub meshes.
  117379. */
  117380. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117381. /**
  117382. * Lambda returning the list of potentially colliding sub meshes.
  117383. */
  117384. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117385. private _activeMeshesFrozen;
  117386. private _skipEvaluateActiveMeshesCompletely;
  117387. /**
  117388. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117389. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117390. * @returns the current scene
  117391. */
  117392. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117393. /**
  117394. * Use this function to restart evaluating active meshes on every frame
  117395. * @returns the current scene
  117396. */
  117397. unfreezeActiveMeshes(): Scene;
  117398. private _evaluateActiveMeshes;
  117399. private _activeMesh;
  117400. /**
  117401. * Update the transform matrix to update from the current active camera
  117402. * @param force defines a boolean used to force the update even if cache is up to date
  117403. */
  117404. updateTransformMatrix(force?: boolean): void;
  117405. private _bindFrameBuffer;
  117406. /** @hidden */
  117407. _allowPostProcessClearColor: boolean;
  117408. /** @hidden */
  117409. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117410. private _processSubCameras;
  117411. private _checkIntersections;
  117412. /** @hidden */
  117413. _advancePhysicsEngineStep(step: number): void;
  117414. /**
  117415. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117416. */
  117417. getDeterministicFrameTime: () => number;
  117418. /** @hidden */
  117419. _animate(): void;
  117420. /** Execute all animations (for a frame) */
  117421. animate(): void;
  117422. /**
  117423. * Render the scene
  117424. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117425. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117426. */
  117427. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117428. /**
  117429. * Freeze all materials
  117430. * A frozen material will not be updatable but should be faster to render
  117431. */
  117432. freezeMaterials(): void;
  117433. /**
  117434. * Unfreeze all materials
  117435. * A frozen material will not be updatable but should be faster to render
  117436. */
  117437. unfreezeMaterials(): void;
  117438. /**
  117439. * Releases all held ressources
  117440. */
  117441. dispose(): void;
  117442. /**
  117443. * Gets if the scene is already disposed
  117444. */
  117445. get isDisposed(): boolean;
  117446. /**
  117447. * Call this function to reduce memory footprint of the scene.
  117448. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117449. */
  117450. clearCachedVertexData(): void;
  117451. /**
  117452. * This function will remove the local cached buffer data from texture.
  117453. * It will save memory but will prevent the texture from being rebuilt
  117454. */
  117455. cleanCachedTextureBuffer(): void;
  117456. /**
  117457. * Get the world extend vectors with an optional filter
  117458. *
  117459. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117460. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117461. */
  117462. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117463. min: Vector3;
  117464. max: Vector3;
  117465. };
  117466. /**
  117467. * Creates a ray that can be used to pick in the scene
  117468. * @param x defines the x coordinate of the origin (on-screen)
  117469. * @param y defines the y coordinate of the origin (on-screen)
  117470. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117471. * @param camera defines the camera to use for the picking
  117472. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117473. * @returns a Ray
  117474. */
  117475. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117476. /**
  117477. * Creates a ray that can be used to pick in the scene
  117478. * @param x defines the x coordinate of the origin (on-screen)
  117479. * @param y defines the y coordinate of the origin (on-screen)
  117480. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117481. * @param result defines the ray where to store the picking ray
  117482. * @param camera defines the camera to use for the picking
  117483. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117484. * @returns the current scene
  117485. */
  117486. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117487. /**
  117488. * Creates a ray that can be used to pick in the scene
  117489. * @param x defines the x coordinate of the origin (on-screen)
  117490. * @param y defines the y coordinate of the origin (on-screen)
  117491. * @param camera defines the camera to use for the picking
  117492. * @returns a Ray
  117493. */
  117494. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117495. /**
  117496. * Creates a ray that can be used to pick in the scene
  117497. * @param x defines the x coordinate of the origin (on-screen)
  117498. * @param y defines the y coordinate of the origin (on-screen)
  117499. * @param result defines the ray where to store the picking ray
  117500. * @param camera defines the camera to use for the picking
  117501. * @returns the current scene
  117502. */
  117503. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117504. /** Launch a ray to try to pick a mesh in the scene
  117505. * @param x position on screen
  117506. * @param y position on screen
  117507. * @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
  117508. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117509. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117511. * @returns a PickingInfo
  117512. */
  117513. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117514. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117515. * @param x position on screen
  117516. * @param y position on screen
  117517. * @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
  117518. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117519. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117520. * @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)
  117521. */
  117522. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117523. /** Use the given ray to pick a mesh in the scene
  117524. * @param ray The ray to use to pick meshes
  117525. * @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
  117526. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117527. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117528. * @returns a PickingInfo
  117529. */
  117530. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117531. /**
  117532. * Launch a ray to try to pick a mesh in the scene
  117533. * @param x X position on screen
  117534. * @param y Y position on screen
  117535. * @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
  117536. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117537. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117538. * @returns an array of PickingInfo
  117539. */
  117540. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117541. /**
  117542. * Launch a ray to try to pick a mesh in the scene
  117543. * @param ray Ray to use
  117544. * @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
  117545. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117546. * @returns an array of PickingInfo
  117547. */
  117548. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117549. /**
  117550. * Force the value of meshUnderPointer
  117551. * @param mesh defines the mesh to use
  117552. */
  117553. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117554. /**
  117555. * Gets the mesh under the pointer
  117556. * @returns a Mesh or null if no mesh is under the pointer
  117557. */
  117558. getPointerOverMesh(): Nullable<AbstractMesh>;
  117559. /** @hidden */
  117560. _rebuildGeometries(): void;
  117561. /** @hidden */
  117562. _rebuildTextures(): void;
  117563. private _getByTags;
  117564. /**
  117565. * Get a list of meshes by tags
  117566. * @param tagsQuery defines the tags query to use
  117567. * @param forEach defines a predicate used to filter results
  117568. * @returns an array of Mesh
  117569. */
  117570. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117571. /**
  117572. * Get a list of cameras by tags
  117573. * @param tagsQuery defines the tags query to use
  117574. * @param forEach defines a predicate used to filter results
  117575. * @returns an array of Camera
  117576. */
  117577. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117578. /**
  117579. * Get a list of lights by tags
  117580. * @param tagsQuery defines the tags query to use
  117581. * @param forEach defines a predicate used to filter results
  117582. * @returns an array of Light
  117583. */
  117584. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117585. /**
  117586. * Get a list of materials by tags
  117587. * @param tagsQuery defines the tags query to use
  117588. * @param forEach defines a predicate used to filter results
  117589. * @returns an array of Material
  117590. */
  117591. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117592. /**
  117593. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117594. * This allowed control for front to back rendering or reversly depending of the special needs.
  117595. *
  117596. * @param renderingGroupId The rendering group id corresponding to its index
  117597. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117598. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117599. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117600. */
  117601. 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;
  117602. /**
  117603. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117604. *
  117605. * @param renderingGroupId The rendering group id corresponding to its index
  117606. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117607. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117608. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117609. */
  117610. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117611. /**
  117612. * Gets the current auto clear configuration for one rendering group of the rendering
  117613. * manager.
  117614. * @param index the rendering group index to get the information for
  117615. * @returns The auto clear setup for the requested rendering group
  117616. */
  117617. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117618. private _blockMaterialDirtyMechanism;
  117619. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117620. get blockMaterialDirtyMechanism(): boolean;
  117621. set blockMaterialDirtyMechanism(value: boolean);
  117622. /**
  117623. * Will flag all materials as dirty to trigger new shader compilation
  117624. * @param flag defines the flag used to specify which material part must be marked as dirty
  117625. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117626. */
  117627. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117628. /** @hidden */
  117629. _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;
  117630. /** @hidden */
  117631. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117632. /** @hidden */
  117633. _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;
  117634. /** @hidden */
  117635. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117636. /** @hidden */
  117637. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117638. /** @hidden */
  117639. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117640. }
  117641. }
  117642. declare module BABYLON {
  117643. /**
  117644. * Set of assets to keep when moving a scene into an asset container.
  117645. */
  117646. export class KeepAssets extends AbstractScene {
  117647. }
  117648. /**
  117649. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  117650. */
  117651. export class InstantiatedEntries {
  117652. /**
  117653. * List of new root nodes (eg. nodes with no parent)
  117654. */
  117655. rootNodes: TransformNode[];
  117656. /**
  117657. * List of new skeletons
  117658. */
  117659. skeletons: Skeleton[];
  117660. /**
  117661. * List of new animation groups
  117662. */
  117663. animationGroups: AnimationGroup[];
  117664. }
  117665. /**
  117666. * Container with a set of assets that can be added or removed from a scene.
  117667. */
  117668. export class AssetContainer extends AbstractScene {
  117669. private _wasAddedToScene;
  117670. /**
  117671. * The scene the AssetContainer belongs to.
  117672. */
  117673. scene: Scene;
  117674. /**
  117675. * Instantiates an AssetContainer.
  117676. * @param scene The scene the AssetContainer belongs to.
  117677. */
  117678. constructor(scene: Scene);
  117679. /**
  117680. * Instantiate or clone all meshes and add the new ones to the scene.
  117681. * Skeletons and animation groups will all be cloned
  117682. * @param nameFunction defines an optional function used to get new names for clones
  117683. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  117684. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  117685. */
  117686. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117687. /**
  117688. * Adds all the assets from the container to the scene.
  117689. */
  117690. addAllToScene(): void;
  117691. /**
  117692. * Removes all the assets in the container from the scene
  117693. */
  117694. removeAllFromScene(): void;
  117695. /**
  117696. * Disposes all the assets in the container
  117697. */
  117698. dispose(): void;
  117699. private _moveAssets;
  117700. /**
  117701. * Removes all the assets contained in the scene and adds them to the container.
  117702. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117703. */
  117704. moveAllFromScene(keepAssets?: KeepAssets): void;
  117705. /**
  117706. * 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.
  117707. * @returns the root mesh
  117708. */
  117709. createRootMesh(): Mesh;
  117710. /**
  117711. * Merge animations (direct and animation groups) from this asset container into a scene
  117712. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117713. * @param animatables set of animatables to retarget to a node from the scene
  117714. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117715. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117716. */
  117717. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117718. }
  117719. }
  117720. declare module BABYLON {
  117721. /**
  117722. * Defines how the parser contract is defined.
  117723. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117724. */
  117725. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  117726. /**
  117727. * Defines how the individual parser contract is defined.
  117728. * These parser can parse an individual asset
  117729. */
  117730. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  117731. /**
  117732. * Base class of the scene acting as a container for the different elements composing a scene.
  117733. * This class is dynamically extended by the different components of the scene increasing
  117734. * flexibility and reducing coupling
  117735. */
  117736. export abstract class AbstractScene {
  117737. /**
  117738. * Stores the list of available parsers in the application.
  117739. */
  117740. private static _BabylonFileParsers;
  117741. /**
  117742. * Stores the list of available individual parsers in the application.
  117743. */
  117744. private static _IndividualBabylonFileParsers;
  117745. /**
  117746. * Adds a parser in the list of available ones
  117747. * @param name Defines the name of the parser
  117748. * @param parser Defines the parser to add
  117749. */
  117750. static AddParser(name: string, parser: BabylonFileParser): void;
  117751. /**
  117752. * Gets a general parser from the list of avaialble ones
  117753. * @param name Defines the name of the parser
  117754. * @returns the requested parser or null
  117755. */
  117756. static GetParser(name: string): Nullable<BabylonFileParser>;
  117757. /**
  117758. * Adds n individual parser in the list of available ones
  117759. * @param name Defines the name of the parser
  117760. * @param parser Defines the parser to add
  117761. */
  117762. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  117763. /**
  117764. * Gets an individual parser from the list of avaialble ones
  117765. * @param name Defines the name of the parser
  117766. * @returns the requested parser or null
  117767. */
  117768. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  117769. /**
  117770. * Parser json data and populate both a scene and its associated container object
  117771. * @param jsonData Defines the data to parse
  117772. * @param scene Defines the scene to parse the data for
  117773. * @param container Defines the container attached to the parsing sequence
  117774. * @param rootUrl Defines the root url of the data
  117775. */
  117776. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  117777. /**
  117778. * Gets the list of root nodes (ie. nodes with no parent)
  117779. */
  117780. rootNodes: Node[];
  117781. /** All of the cameras added to this scene
  117782. * @see http://doc.babylonjs.com/babylon101/cameras
  117783. */
  117784. cameras: Camera[];
  117785. /**
  117786. * All of the lights added to this scene
  117787. * @see http://doc.babylonjs.com/babylon101/lights
  117788. */
  117789. lights: Light[];
  117790. /**
  117791. * All of the (abstract) meshes added to this scene
  117792. */
  117793. meshes: AbstractMesh[];
  117794. /**
  117795. * The list of skeletons added to the scene
  117796. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117797. */
  117798. skeletons: Skeleton[];
  117799. /**
  117800. * All of the particle systems added to this scene
  117801. * @see http://doc.babylonjs.com/babylon101/particles
  117802. */
  117803. particleSystems: IParticleSystem[];
  117804. /**
  117805. * Gets a list of Animations associated with the scene
  117806. */
  117807. animations: Animation[];
  117808. /**
  117809. * All of the animation groups added to this scene
  117810. * @see http://doc.babylonjs.com/how_to/group
  117811. */
  117812. animationGroups: AnimationGroup[];
  117813. /**
  117814. * All of the multi-materials added to this scene
  117815. * @see http://doc.babylonjs.com/how_to/multi_materials
  117816. */
  117817. multiMaterials: MultiMaterial[];
  117818. /**
  117819. * All of the materials added to this scene
  117820. * In the context of a Scene, it is not supposed to be modified manually.
  117821. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  117822. * Note also that the order of the Material within the array is not significant and might change.
  117823. * @see http://doc.babylonjs.com/babylon101/materials
  117824. */
  117825. materials: Material[];
  117826. /**
  117827. * The list of morph target managers added to the scene
  117828. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  117829. */
  117830. morphTargetManagers: MorphTargetManager[];
  117831. /**
  117832. * The list of geometries used in the scene.
  117833. */
  117834. geometries: Geometry[];
  117835. /**
  117836. * All of the tranform nodes added to this scene
  117837. * In the context of a Scene, it is not supposed to be modified manually.
  117838. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  117839. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  117840. * @see http://doc.babylonjs.com/how_to/transformnode
  117841. */
  117842. transformNodes: TransformNode[];
  117843. /**
  117844. * ActionManagers available on the scene.
  117845. */
  117846. actionManagers: AbstractActionManager[];
  117847. /**
  117848. * Textures to keep.
  117849. */
  117850. textures: BaseTexture[];
  117851. /**
  117852. * Environment texture for the scene
  117853. */
  117854. environmentTexture: Nullable<BaseTexture>;
  117855. /**
  117856. * @returns all meshes, lights, cameras, transformNodes and bones
  117857. */
  117858. getNodes(): Array<Node>;
  117859. }
  117860. }
  117861. declare module BABYLON {
  117862. /**
  117863. * Interface used to define options for Sound class
  117864. */
  117865. export interface ISoundOptions {
  117866. /**
  117867. * Does the sound autoplay once loaded.
  117868. */
  117869. autoplay?: boolean;
  117870. /**
  117871. * Does the sound loop after it finishes playing once.
  117872. */
  117873. loop?: boolean;
  117874. /**
  117875. * Sound's volume
  117876. */
  117877. volume?: number;
  117878. /**
  117879. * Is it a spatial sound?
  117880. */
  117881. spatialSound?: boolean;
  117882. /**
  117883. * Maximum distance to hear that sound
  117884. */
  117885. maxDistance?: number;
  117886. /**
  117887. * Uses user defined attenuation function
  117888. */
  117889. useCustomAttenuation?: boolean;
  117890. /**
  117891. * Define the roll off factor of spatial sounds.
  117892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117893. */
  117894. rolloffFactor?: number;
  117895. /**
  117896. * Define the reference distance the sound should be heard perfectly.
  117897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117898. */
  117899. refDistance?: number;
  117900. /**
  117901. * Define the distance attenuation model the sound will follow.
  117902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117903. */
  117904. distanceModel?: string;
  117905. /**
  117906. * Defines the playback speed (1 by default)
  117907. */
  117908. playbackRate?: number;
  117909. /**
  117910. * Defines if the sound is from a streaming source
  117911. */
  117912. streaming?: boolean;
  117913. /**
  117914. * Defines an optional length (in seconds) inside the sound file
  117915. */
  117916. length?: number;
  117917. /**
  117918. * Defines an optional offset (in seconds) inside the sound file
  117919. */
  117920. offset?: number;
  117921. /**
  117922. * If true, URLs will not be required to state the audio file codec to use.
  117923. */
  117924. skipCodecCheck?: boolean;
  117925. }
  117926. /**
  117927. * Defines a sound that can be played in the application.
  117928. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  117929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  117930. */
  117931. export class Sound {
  117932. /**
  117933. * The name of the sound in the scene.
  117934. */
  117935. name: string;
  117936. /**
  117937. * Does the sound autoplay once loaded.
  117938. */
  117939. autoplay: boolean;
  117940. /**
  117941. * Does the sound loop after it finishes playing once.
  117942. */
  117943. loop: boolean;
  117944. /**
  117945. * Does the sound use a custom attenuation curve to simulate the falloff
  117946. * happening when the source gets further away from the camera.
  117947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  117948. */
  117949. useCustomAttenuation: boolean;
  117950. /**
  117951. * The sound track id this sound belongs to.
  117952. */
  117953. soundTrackId: number;
  117954. /**
  117955. * Is this sound currently played.
  117956. */
  117957. isPlaying: boolean;
  117958. /**
  117959. * Is this sound currently paused.
  117960. */
  117961. isPaused: boolean;
  117962. /**
  117963. * Does this sound enables spatial sound.
  117964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117965. */
  117966. spatialSound: boolean;
  117967. /**
  117968. * Define the reference distance the sound should be heard perfectly.
  117969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117970. */
  117971. refDistance: number;
  117972. /**
  117973. * Define the roll off factor of spatial sounds.
  117974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117975. */
  117976. rolloffFactor: number;
  117977. /**
  117978. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  117979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117980. */
  117981. maxDistance: number;
  117982. /**
  117983. * Define the distance attenuation model the sound will follow.
  117984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  117985. */
  117986. distanceModel: string;
  117987. /**
  117988. * @hidden
  117989. * Back Compat
  117990. **/
  117991. onended: () => any;
  117992. /**
  117993. * Gets or sets an object used to store user defined information for the sound.
  117994. */
  117995. metadata: any;
  117996. /**
  117997. * Observable event when the current playing sound finishes.
  117998. */
  117999. onEndedObservable: Observable<Sound>;
  118000. private _panningModel;
  118001. private _playbackRate;
  118002. private _streaming;
  118003. private _startTime;
  118004. private _startOffset;
  118005. private _position;
  118006. /** @hidden */
  118007. _positionInEmitterSpace: boolean;
  118008. private _localDirection;
  118009. private _volume;
  118010. private _isReadyToPlay;
  118011. private _isDirectional;
  118012. private _readyToPlayCallback;
  118013. private _audioBuffer;
  118014. private _soundSource;
  118015. private _streamingSource;
  118016. private _soundPanner;
  118017. private _soundGain;
  118018. private _inputAudioNode;
  118019. private _outputAudioNode;
  118020. private _coneInnerAngle;
  118021. private _coneOuterAngle;
  118022. private _coneOuterGain;
  118023. private _scene;
  118024. private _connectedTransformNode;
  118025. private _customAttenuationFunction;
  118026. private _registerFunc;
  118027. private _isOutputConnected;
  118028. private _htmlAudioElement;
  118029. private _urlType;
  118030. private _length?;
  118031. private _offset?;
  118032. /** @hidden */
  118033. static _SceneComponentInitialization: (scene: Scene) => void;
  118034. /**
  118035. * Create a sound and attach it to a scene
  118036. * @param name Name of your sound
  118037. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118038. * @param scene defines the scene the sound belongs to
  118039. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118040. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118041. */
  118042. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118043. /**
  118044. * Release the sound and its associated resources
  118045. */
  118046. dispose(): void;
  118047. /**
  118048. * Gets if the sounds is ready to be played or not.
  118049. * @returns true if ready, otherwise false
  118050. */
  118051. isReady(): boolean;
  118052. private _soundLoaded;
  118053. /**
  118054. * Sets the data of the sound from an audiobuffer
  118055. * @param audioBuffer The audioBuffer containing the data
  118056. */
  118057. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118058. /**
  118059. * Updates the current sounds options such as maxdistance, loop...
  118060. * @param options A JSON object containing values named as the object properties
  118061. */
  118062. updateOptions(options: ISoundOptions): void;
  118063. private _createSpatialParameters;
  118064. private _updateSpatialParameters;
  118065. /**
  118066. * Switch the panning model to HRTF:
  118067. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118069. */
  118070. switchPanningModelToHRTF(): void;
  118071. /**
  118072. * Switch the panning model to Equal Power:
  118073. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118075. */
  118076. switchPanningModelToEqualPower(): void;
  118077. private _switchPanningModel;
  118078. /**
  118079. * Connect this sound to a sound track audio node like gain...
  118080. * @param soundTrackAudioNode the sound track audio node to connect to
  118081. */
  118082. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118083. /**
  118084. * Transform this sound into a directional source
  118085. * @param coneInnerAngle Size of the inner cone in degree
  118086. * @param coneOuterAngle Size of the outer cone in degree
  118087. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118088. */
  118089. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118090. /**
  118091. * Gets or sets the inner angle for the directional cone.
  118092. */
  118093. get directionalConeInnerAngle(): number;
  118094. /**
  118095. * Gets or sets the inner angle for the directional cone.
  118096. */
  118097. set directionalConeInnerAngle(value: number);
  118098. /**
  118099. * Gets or sets the outer angle for the directional cone.
  118100. */
  118101. get directionalConeOuterAngle(): number;
  118102. /**
  118103. * Gets or sets the outer angle for the directional cone.
  118104. */
  118105. set directionalConeOuterAngle(value: number);
  118106. /**
  118107. * Sets the position of the emitter if spatial sound is enabled
  118108. * @param newPosition Defines the new posisiton
  118109. */
  118110. setPosition(newPosition: Vector3): void;
  118111. /**
  118112. * Sets the local direction of the emitter if spatial sound is enabled
  118113. * @param newLocalDirection Defines the new local direction
  118114. */
  118115. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118116. private _updateDirection;
  118117. /** @hidden */
  118118. updateDistanceFromListener(): void;
  118119. /**
  118120. * Sets a new custom attenuation function for the sound.
  118121. * @param callback Defines the function used for the attenuation
  118122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118123. */
  118124. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118125. /**
  118126. * Play the sound
  118127. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118128. * @param offset (optional) Start the sound at a specific time in seconds
  118129. * @param length (optional) Sound duration (in seconds)
  118130. */
  118131. play(time?: number, offset?: number, length?: number): void;
  118132. private _onended;
  118133. /**
  118134. * Stop the sound
  118135. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118136. */
  118137. stop(time?: number): void;
  118138. /**
  118139. * Put the sound in pause
  118140. */
  118141. pause(): void;
  118142. /**
  118143. * Sets a dedicated volume for this sounds
  118144. * @param newVolume Define the new volume of the sound
  118145. * @param time Define time for gradual change to new volume
  118146. */
  118147. setVolume(newVolume: number, time?: number): void;
  118148. /**
  118149. * Set the sound play back rate
  118150. * @param newPlaybackRate Define the playback rate the sound should be played at
  118151. */
  118152. setPlaybackRate(newPlaybackRate: number): void;
  118153. /**
  118154. * Gets the volume of the sound.
  118155. * @returns the volume of the sound
  118156. */
  118157. getVolume(): number;
  118158. /**
  118159. * Attach the sound to a dedicated mesh
  118160. * @param transformNode The transform node to connect the sound with
  118161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118162. */
  118163. attachToMesh(transformNode: TransformNode): void;
  118164. /**
  118165. * Detach the sound from the previously attached mesh
  118166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118167. */
  118168. detachFromMesh(): void;
  118169. private _onRegisterAfterWorldMatrixUpdate;
  118170. /**
  118171. * Clone the current sound in the scene.
  118172. * @returns the new sound clone
  118173. */
  118174. clone(): Nullable<Sound>;
  118175. /**
  118176. * Gets the current underlying audio buffer containing the data
  118177. * @returns the audio buffer
  118178. */
  118179. getAudioBuffer(): Nullable<AudioBuffer>;
  118180. /**
  118181. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  118182. * @returns the source node
  118183. */
  118184. getSoundSource(): Nullable<AudioBufferSourceNode>;
  118185. /**
  118186. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  118187. * @returns the gain node
  118188. */
  118189. getSoundGain(): Nullable<GainNode>;
  118190. /**
  118191. * Serializes the Sound in a JSON representation
  118192. * @returns the JSON representation of the sound
  118193. */
  118194. serialize(): any;
  118195. /**
  118196. * Parse a JSON representation of a sound to innstantiate in a given scene
  118197. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  118198. * @param scene Define the scene the new parsed sound should be created in
  118199. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  118200. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  118201. * @returns the newly parsed sound
  118202. */
  118203. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  118204. }
  118205. }
  118206. declare module BABYLON {
  118207. /**
  118208. * This defines an action helpful to play a defined sound on a triggered action.
  118209. */
  118210. export class PlaySoundAction extends Action {
  118211. private _sound;
  118212. /**
  118213. * Instantiate the action
  118214. * @param triggerOptions defines the trigger options
  118215. * @param sound defines the sound to play
  118216. * @param condition defines the trigger related conditions
  118217. */
  118218. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118219. /** @hidden */
  118220. _prepare(): void;
  118221. /**
  118222. * Execute the action and play the sound.
  118223. */
  118224. execute(): void;
  118225. /**
  118226. * Serializes the actions and its related information.
  118227. * @param parent defines the object to serialize in
  118228. * @returns the serialized object
  118229. */
  118230. serialize(parent: any): any;
  118231. }
  118232. /**
  118233. * This defines an action helpful to stop a defined sound on a triggered action.
  118234. */
  118235. export class StopSoundAction extends Action {
  118236. private _sound;
  118237. /**
  118238. * Instantiate the action
  118239. * @param triggerOptions defines the trigger options
  118240. * @param sound defines the sound to stop
  118241. * @param condition defines the trigger related conditions
  118242. */
  118243. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118244. /** @hidden */
  118245. _prepare(): void;
  118246. /**
  118247. * Execute the action and stop the sound.
  118248. */
  118249. execute(): void;
  118250. /**
  118251. * Serializes the actions and its related information.
  118252. * @param parent defines the object to serialize in
  118253. * @returns the serialized object
  118254. */
  118255. serialize(parent: any): any;
  118256. }
  118257. }
  118258. declare module BABYLON {
  118259. /**
  118260. * This defines an action responsible to change the value of a property
  118261. * by interpolating between its current value and the newly set one once triggered.
  118262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  118263. */
  118264. export class InterpolateValueAction extends Action {
  118265. /**
  118266. * Defines the path of the property where the value should be interpolated
  118267. */
  118268. propertyPath: string;
  118269. /**
  118270. * Defines the target value at the end of the interpolation.
  118271. */
  118272. value: any;
  118273. /**
  118274. * Defines the time it will take for the property to interpolate to the value.
  118275. */
  118276. duration: number;
  118277. /**
  118278. * Defines if the other scene animations should be stopped when the action has been triggered
  118279. */
  118280. stopOtherAnimations?: boolean;
  118281. /**
  118282. * Defines a callback raised once the interpolation animation has been done.
  118283. */
  118284. onInterpolationDone?: () => void;
  118285. /**
  118286. * Observable triggered once the interpolation animation has been done.
  118287. */
  118288. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  118289. private _target;
  118290. private _effectiveTarget;
  118291. private _property;
  118292. /**
  118293. * Instantiate the action
  118294. * @param triggerOptions defines the trigger options
  118295. * @param target defines the object containing the value to interpolate
  118296. * @param propertyPath defines the path to the property in the target object
  118297. * @param value defines the target value at the end of the interpolation
  118298. * @param duration deines the time it will take for the property to interpolate to the value.
  118299. * @param condition defines the trigger related conditions
  118300. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  118301. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  118302. */
  118303. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118304. /** @hidden */
  118305. _prepare(): void;
  118306. /**
  118307. * Execute the action starts the value interpolation.
  118308. */
  118309. execute(): void;
  118310. /**
  118311. * Serializes the actions and its related information.
  118312. * @param parent defines the object to serialize in
  118313. * @returns the serialized object
  118314. */
  118315. serialize(parent: any): any;
  118316. }
  118317. }
  118318. declare module BABYLON {
  118319. /**
  118320. * Options allowed during the creation of a sound track.
  118321. */
  118322. export interface ISoundTrackOptions {
  118323. /**
  118324. * The volume the sound track should take during creation
  118325. */
  118326. volume?: number;
  118327. /**
  118328. * Define if the sound track is the main sound track of the scene
  118329. */
  118330. mainTrack?: boolean;
  118331. }
  118332. /**
  118333. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118334. * It will be also used in a future release to apply effects on a specific track.
  118335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118336. */
  118337. export class SoundTrack {
  118338. /**
  118339. * The unique identifier of the sound track in the scene.
  118340. */
  118341. id: number;
  118342. /**
  118343. * The list of sounds included in the sound track.
  118344. */
  118345. soundCollection: Array<Sound>;
  118346. private _outputAudioNode;
  118347. private _scene;
  118348. private _connectedAnalyser;
  118349. private _options;
  118350. private _isInitialized;
  118351. /**
  118352. * Creates a new sound track.
  118353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118354. * @param scene Define the scene the sound track belongs to
  118355. * @param options
  118356. */
  118357. constructor(scene: Scene, options?: ISoundTrackOptions);
  118358. private _initializeSoundTrackAudioGraph;
  118359. /**
  118360. * Release the sound track and its associated resources
  118361. */
  118362. dispose(): void;
  118363. /**
  118364. * Adds a sound to this sound track
  118365. * @param sound define the cound to add
  118366. * @ignoreNaming
  118367. */
  118368. AddSound(sound: Sound): void;
  118369. /**
  118370. * Removes a sound to this sound track
  118371. * @param sound define the cound to remove
  118372. * @ignoreNaming
  118373. */
  118374. RemoveSound(sound: Sound): void;
  118375. /**
  118376. * Set a global volume for the full sound track.
  118377. * @param newVolume Define the new volume of the sound track
  118378. */
  118379. setVolume(newVolume: number): void;
  118380. /**
  118381. * Switch the panning model to HRTF:
  118382. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118384. */
  118385. switchPanningModelToHRTF(): void;
  118386. /**
  118387. * Switch the panning model to Equal Power:
  118388. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118390. */
  118391. switchPanningModelToEqualPower(): void;
  118392. /**
  118393. * Connect the sound track to an audio analyser allowing some amazing
  118394. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118396. * @param analyser The analyser to connect to the engine
  118397. */
  118398. connectToAnalyser(analyser: Analyser): void;
  118399. }
  118400. }
  118401. declare module BABYLON {
  118402. interface AbstractScene {
  118403. /**
  118404. * The list of sounds used in the scene.
  118405. */
  118406. sounds: Nullable<Array<Sound>>;
  118407. }
  118408. interface Scene {
  118409. /**
  118410. * @hidden
  118411. * Backing field
  118412. */
  118413. _mainSoundTrack: SoundTrack;
  118414. /**
  118415. * The main sound track played by the scene.
  118416. * It cotains your primary collection of sounds.
  118417. */
  118418. mainSoundTrack: SoundTrack;
  118419. /**
  118420. * The list of sound tracks added to the scene
  118421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118422. */
  118423. soundTracks: Nullable<Array<SoundTrack>>;
  118424. /**
  118425. * Gets a sound using a given name
  118426. * @param name defines the name to search for
  118427. * @return the found sound or null if not found at all.
  118428. */
  118429. getSoundByName(name: string): Nullable<Sound>;
  118430. /**
  118431. * Gets or sets if audio support is enabled
  118432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118433. */
  118434. audioEnabled: boolean;
  118435. /**
  118436. * Gets or sets if audio will be output to headphones
  118437. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118438. */
  118439. headphone: boolean;
  118440. /**
  118441. * Gets or sets custom audio listener position provider
  118442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118443. */
  118444. audioListenerPositionProvider: Nullable<() => Vector3>;
  118445. /**
  118446. * Gets or sets a refresh rate when using 3D audio positioning
  118447. */
  118448. audioPositioningRefreshRate: number;
  118449. }
  118450. /**
  118451. * Defines the sound scene component responsible to manage any sounds
  118452. * in a given scene.
  118453. */
  118454. export class AudioSceneComponent implements ISceneSerializableComponent {
  118455. /**
  118456. * The component name helpfull to identify the component in the list of scene components.
  118457. */
  118458. readonly name: string;
  118459. /**
  118460. * The scene the component belongs to.
  118461. */
  118462. scene: Scene;
  118463. private _audioEnabled;
  118464. /**
  118465. * Gets whether audio is enabled or not.
  118466. * Please use related enable/disable method to switch state.
  118467. */
  118468. get audioEnabled(): boolean;
  118469. private _headphone;
  118470. /**
  118471. * Gets whether audio is outputing to headphone or not.
  118472. * Please use the according Switch methods to change output.
  118473. */
  118474. get headphone(): boolean;
  118475. /**
  118476. * Gets or sets a refresh rate when using 3D audio positioning
  118477. */
  118478. audioPositioningRefreshRate: number;
  118479. private _audioListenerPositionProvider;
  118480. /**
  118481. * Gets the current audio listener position provider
  118482. */
  118483. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118484. /**
  118485. * Sets a custom listener position for all sounds in the scene
  118486. * By default, this is the position of the first active camera
  118487. */
  118488. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118489. /**
  118490. * Creates a new instance of the component for the given scene
  118491. * @param scene Defines the scene to register the component in
  118492. */
  118493. constructor(scene: Scene);
  118494. /**
  118495. * Registers the component in a given scene
  118496. */
  118497. register(): void;
  118498. /**
  118499. * Rebuilds the elements related to this component in case of
  118500. * context lost for instance.
  118501. */
  118502. rebuild(): void;
  118503. /**
  118504. * Serializes the component data to the specified json object
  118505. * @param serializationObject The object to serialize to
  118506. */
  118507. serialize(serializationObject: any): void;
  118508. /**
  118509. * Adds all the elements from the container to the scene
  118510. * @param container the container holding the elements
  118511. */
  118512. addFromContainer(container: AbstractScene): void;
  118513. /**
  118514. * Removes all the elements in the container from the scene
  118515. * @param container contains the elements to remove
  118516. * @param dispose if the removed element should be disposed (default: false)
  118517. */
  118518. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118519. /**
  118520. * Disposes the component and the associated ressources.
  118521. */
  118522. dispose(): void;
  118523. /**
  118524. * Disables audio in the associated scene.
  118525. */
  118526. disableAudio(): void;
  118527. /**
  118528. * Enables audio in the associated scene.
  118529. */
  118530. enableAudio(): void;
  118531. /**
  118532. * Switch audio to headphone output.
  118533. */
  118534. switchAudioModeForHeadphones(): void;
  118535. /**
  118536. * Switch audio to normal speakers.
  118537. */
  118538. switchAudioModeForNormalSpeakers(): void;
  118539. private _cachedCameraDirection;
  118540. private _cachedCameraPosition;
  118541. private _lastCheck;
  118542. private _afterRender;
  118543. }
  118544. }
  118545. declare module BABYLON {
  118546. /**
  118547. * Wraps one or more Sound objects and selects one with random weight for playback.
  118548. */
  118549. export class WeightedSound {
  118550. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118551. loop: boolean;
  118552. private _coneInnerAngle;
  118553. private _coneOuterAngle;
  118554. private _volume;
  118555. /** A Sound is currently playing. */
  118556. isPlaying: boolean;
  118557. /** A Sound is currently paused. */
  118558. isPaused: boolean;
  118559. private _sounds;
  118560. private _weights;
  118561. private _currentIndex?;
  118562. /**
  118563. * Creates a new WeightedSound from the list of sounds given.
  118564. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118565. * @param sounds Array of Sounds that will be selected from.
  118566. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118567. */
  118568. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118569. /**
  118570. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118571. */
  118572. get directionalConeInnerAngle(): number;
  118573. /**
  118574. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118575. */
  118576. set directionalConeInnerAngle(value: number);
  118577. /**
  118578. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118579. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118580. */
  118581. get directionalConeOuterAngle(): number;
  118582. /**
  118583. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118584. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118585. */
  118586. set directionalConeOuterAngle(value: number);
  118587. /**
  118588. * Playback volume.
  118589. */
  118590. get volume(): number;
  118591. /**
  118592. * Playback volume.
  118593. */
  118594. set volume(value: number);
  118595. private _onended;
  118596. /**
  118597. * Suspend playback
  118598. */
  118599. pause(): void;
  118600. /**
  118601. * Stop playback
  118602. */
  118603. stop(): void;
  118604. /**
  118605. * Start playback.
  118606. * @param startOffset Position the clip head at a specific time in seconds.
  118607. */
  118608. play(startOffset?: number): void;
  118609. }
  118610. }
  118611. declare module BABYLON {
  118612. /**
  118613. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118614. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118615. */
  118616. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118617. /**
  118618. * Gets the name of the behavior.
  118619. */
  118620. get name(): string;
  118621. /**
  118622. * The easing function used by animations
  118623. */
  118624. static EasingFunction: BackEase;
  118625. /**
  118626. * The easing mode used by animations
  118627. */
  118628. static EasingMode: number;
  118629. /**
  118630. * The duration of the animation, in milliseconds
  118631. */
  118632. transitionDuration: number;
  118633. /**
  118634. * Length of the distance animated by the transition when lower radius is reached
  118635. */
  118636. lowerRadiusTransitionRange: number;
  118637. /**
  118638. * Length of the distance animated by the transition when upper radius is reached
  118639. */
  118640. upperRadiusTransitionRange: number;
  118641. private _autoTransitionRange;
  118642. /**
  118643. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118644. */
  118645. get autoTransitionRange(): boolean;
  118646. /**
  118647. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118648. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  118649. */
  118650. set autoTransitionRange(value: boolean);
  118651. private _attachedCamera;
  118652. private _onAfterCheckInputsObserver;
  118653. private _onMeshTargetChangedObserver;
  118654. /**
  118655. * Initializes the behavior.
  118656. */
  118657. init(): void;
  118658. /**
  118659. * Attaches the behavior to its arc rotate camera.
  118660. * @param camera Defines the camera to attach the behavior to
  118661. */
  118662. attach(camera: ArcRotateCamera): void;
  118663. /**
  118664. * Detaches the behavior from its current arc rotate camera.
  118665. */
  118666. detach(): void;
  118667. private _radiusIsAnimating;
  118668. private _radiusBounceTransition;
  118669. private _animatables;
  118670. private _cachedWheelPrecision;
  118671. /**
  118672. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  118673. * @param radiusLimit The limit to check against.
  118674. * @return Bool to indicate if at limit.
  118675. */
  118676. private _isRadiusAtLimit;
  118677. /**
  118678. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  118679. * @param radiusDelta The delta by which to animate to. Can be negative.
  118680. */
  118681. private _applyBoundRadiusAnimation;
  118682. /**
  118683. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  118684. */
  118685. protected _clearAnimationLocks(): void;
  118686. /**
  118687. * Stops and removes all animations that have been applied to the camera
  118688. */
  118689. stopAllAnimations(): void;
  118690. }
  118691. }
  118692. declare module BABYLON {
  118693. /**
  118694. * 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.
  118695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118696. */
  118697. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118698. /**
  118699. * Gets the name of the behavior.
  118700. */
  118701. get name(): string;
  118702. private _mode;
  118703. private _radiusScale;
  118704. private _positionScale;
  118705. private _defaultElevation;
  118706. private _elevationReturnTime;
  118707. private _elevationReturnWaitTime;
  118708. private _zoomStopsAnimation;
  118709. private _framingTime;
  118710. /**
  118711. * The easing function used by animations
  118712. */
  118713. static EasingFunction: ExponentialEase;
  118714. /**
  118715. * The easing mode used by animations
  118716. */
  118717. static EasingMode: number;
  118718. /**
  118719. * Sets the current mode used by the behavior
  118720. */
  118721. set mode(mode: number);
  118722. /**
  118723. * Gets current mode used by the behavior.
  118724. */
  118725. get mode(): number;
  118726. /**
  118727. * Sets the scale applied to the radius (1 by default)
  118728. */
  118729. set radiusScale(radius: number);
  118730. /**
  118731. * Gets the scale applied to the radius
  118732. */
  118733. get radiusScale(): number;
  118734. /**
  118735. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118736. */
  118737. set positionScale(scale: number);
  118738. /**
  118739. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  118740. */
  118741. get positionScale(): number;
  118742. /**
  118743. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118744. * behaviour is triggered, in radians.
  118745. */
  118746. set defaultElevation(elevation: number);
  118747. /**
  118748. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  118749. * behaviour is triggered, in radians.
  118750. */
  118751. get defaultElevation(): number;
  118752. /**
  118753. * Sets the time (in milliseconds) taken to return to the default beta position.
  118754. * Negative value indicates camera should not return to default.
  118755. */
  118756. set elevationReturnTime(speed: number);
  118757. /**
  118758. * Gets the time (in milliseconds) taken to return to the default beta position.
  118759. * Negative value indicates camera should not return to default.
  118760. */
  118761. get elevationReturnTime(): number;
  118762. /**
  118763. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118764. */
  118765. set elevationReturnWaitTime(time: number);
  118766. /**
  118767. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  118768. */
  118769. get elevationReturnWaitTime(): number;
  118770. /**
  118771. * Sets the flag that indicates if user zooming should stop animation.
  118772. */
  118773. set zoomStopsAnimation(flag: boolean);
  118774. /**
  118775. * Gets the flag that indicates if user zooming should stop animation.
  118776. */
  118777. get zoomStopsAnimation(): boolean;
  118778. /**
  118779. * Sets the transition time when framing the mesh, in milliseconds
  118780. */
  118781. set framingTime(time: number);
  118782. /**
  118783. * Gets the transition time when framing the mesh, in milliseconds
  118784. */
  118785. get framingTime(): number;
  118786. /**
  118787. * Define if the behavior should automatically change the configured
  118788. * camera limits and sensibilities.
  118789. */
  118790. autoCorrectCameraLimitsAndSensibility: boolean;
  118791. private _onPrePointerObservableObserver;
  118792. private _onAfterCheckInputsObserver;
  118793. private _onMeshTargetChangedObserver;
  118794. private _attachedCamera;
  118795. private _isPointerDown;
  118796. private _lastInteractionTime;
  118797. /**
  118798. * Initializes the behavior.
  118799. */
  118800. init(): void;
  118801. /**
  118802. * Attaches the behavior to its arc rotate camera.
  118803. * @param camera Defines the camera to attach the behavior to
  118804. */
  118805. attach(camera: ArcRotateCamera): void;
  118806. /**
  118807. * Detaches the behavior from its current arc rotate camera.
  118808. */
  118809. detach(): void;
  118810. private _animatables;
  118811. private _betaIsAnimating;
  118812. private _betaTransition;
  118813. private _radiusTransition;
  118814. private _vectorTransition;
  118815. /**
  118816. * Targets the given mesh and updates zoom level accordingly.
  118817. * @param mesh The mesh to target.
  118818. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118819. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118820. */
  118821. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118822. /**
  118823. * Targets the given mesh with its children and updates zoom level accordingly.
  118824. * @param mesh The mesh to target.
  118825. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118826. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118827. */
  118828. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118829. /**
  118830. * Targets the given meshes with their children and updates zoom level accordingly.
  118831. * @param meshes The mesh to target.
  118832. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118833. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118834. */
  118835. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118836. /**
  118837. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  118838. * @param minimumWorld Determines the smaller position of the bounding box extend
  118839. * @param maximumWorld Determines the bigger position of the bounding box extend
  118840. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  118841. * @param onAnimationEnd Callback triggered at the end of the framing animation
  118842. */
  118843. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  118844. /**
  118845. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  118846. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  118847. * frustum width.
  118848. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  118849. * to fully enclose the mesh in the viewing frustum.
  118850. */
  118851. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  118852. /**
  118853. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  118854. * is automatically returned to its default position (expected to be above ground plane).
  118855. */
  118856. private _maintainCameraAboveGround;
  118857. /**
  118858. * Returns the frustum slope based on the canvas ratio and camera FOV
  118859. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  118860. */
  118861. private _getFrustumSlope;
  118862. /**
  118863. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  118864. */
  118865. private _clearAnimationLocks;
  118866. /**
  118867. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  118868. */
  118869. private _applyUserInteraction;
  118870. /**
  118871. * Stops and removes all animations that have been applied to the camera
  118872. */
  118873. stopAllAnimations(): void;
  118874. /**
  118875. * Gets a value indicating if the user is moving the camera
  118876. */
  118877. get isUserIsMoving(): boolean;
  118878. /**
  118879. * The camera can move all the way towards the mesh.
  118880. */
  118881. static IgnoreBoundsSizeMode: number;
  118882. /**
  118883. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  118884. */
  118885. static FitFrustumSidesMode: number;
  118886. }
  118887. }
  118888. declare module BABYLON {
  118889. /**
  118890. * Base class for Camera Pointer Inputs.
  118891. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  118892. * for example usage.
  118893. */
  118894. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  118895. /**
  118896. * Defines the camera the input is attached to.
  118897. */
  118898. abstract camera: Camera;
  118899. /**
  118900. * Whether keyboard modifier keys are pressed at time of last mouse event.
  118901. */
  118902. protected _altKey: boolean;
  118903. protected _ctrlKey: boolean;
  118904. protected _metaKey: boolean;
  118905. protected _shiftKey: boolean;
  118906. /**
  118907. * Which mouse buttons were pressed at time of last mouse event.
  118908. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  118909. */
  118910. protected _buttonsPressed: number;
  118911. /**
  118912. * Defines the buttons associated with the input to handle camera move.
  118913. */
  118914. buttons: number[];
  118915. /**
  118916. * Attach the input controls to a specific dom element to get the input from.
  118917. * @param element Defines the element the controls should be listened from
  118918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118919. */
  118920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  118921. /**
  118922. * Detach the current controls from the specified dom element.
  118923. * @param element Defines the element to stop listening the inputs from
  118924. */
  118925. detachControl(element: Nullable<HTMLElement>): void;
  118926. /**
  118927. * Gets the class name of the current input.
  118928. * @returns the class name
  118929. */
  118930. getClassName(): string;
  118931. /**
  118932. * Get the friendly name associated with the input class.
  118933. * @returns the input friendly name
  118934. */
  118935. getSimpleName(): string;
  118936. /**
  118937. * Called on pointer POINTERDOUBLETAP event.
  118938. * Override this method to provide functionality on POINTERDOUBLETAP event.
  118939. */
  118940. protected onDoubleTap(type: string): void;
  118941. /**
  118942. * Called on pointer POINTERMOVE event if only a single touch is active.
  118943. * Override this method to provide functionality.
  118944. */
  118945. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  118946. /**
  118947. * Called on pointer POINTERMOVE event if multiple touches are active.
  118948. * Override this method to provide functionality.
  118949. */
  118950. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  118951. /**
  118952. * Called on JS contextmenu event.
  118953. * Override this method to provide functionality.
  118954. */
  118955. protected onContextMenu(evt: PointerEvent): void;
  118956. /**
  118957. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  118958. * press.
  118959. * Override this method to provide functionality.
  118960. */
  118961. protected onButtonDown(evt: PointerEvent): void;
  118962. /**
  118963. * Called each time a new POINTERUP event occurs. Ie, for each button
  118964. * release.
  118965. * Override this method to provide functionality.
  118966. */
  118967. protected onButtonUp(evt: PointerEvent): void;
  118968. /**
  118969. * Called when window becomes inactive.
  118970. * Override this method to provide functionality.
  118971. */
  118972. protected onLostFocus(): void;
  118973. private _pointerInput;
  118974. private _observer;
  118975. private _onLostFocus;
  118976. private pointA;
  118977. private pointB;
  118978. }
  118979. }
  118980. declare module BABYLON {
  118981. /**
  118982. * Manage the pointers inputs to control an arc rotate camera.
  118983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  118984. */
  118985. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  118986. /**
  118987. * Defines the camera the input is attached to.
  118988. */
  118989. camera: ArcRotateCamera;
  118990. /**
  118991. * Gets the class name of the current input.
  118992. * @returns the class name
  118993. */
  118994. getClassName(): string;
  118995. /**
  118996. * Defines the buttons associated with the input to handle camera move.
  118997. */
  118998. buttons: number[];
  118999. /**
  119000. * Defines the pointer angular sensibility along the X axis or how fast is
  119001. * the camera rotating.
  119002. */
  119003. angularSensibilityX: number;
  119004. /**
  119005. * Defines the pointer angular sensibility along the Y axis or how fast is
  119006. * the camera rotating.
  119007. */
  119008. angularSensibilityY: number;
  119009. /**
  119010. * Defines the pointer pinch precision or how fast is the camera zooming.
  119011. */
  119012. pinchPrecision: number;
  119013. /**
  119014. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119015. * from 0.
  119016. * It defines the percentage of current camera.radius to use as delta when
  119017. * pinch zoom is used.
  119018. */
  119019. pinchDeltaPercentage: number;
  119020. /**
  119021. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119022. * that any object in the plane at the camera's target point will scale
  119023. * perfectly with finger motion.
  119024. * Overrides pinchDeltaPercentage and pinchPrecision.
  119025. */
  119026. useNaturalPinchZoom: boolean;
  119027. /**
  119028. * Defines the pointer panning sensibility or how fast is the camera moving.
  119029. */
  119030. panningSensibility: number;
  119031. /**
  119032. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119033. */
  119034. multiTouchPanning: boolean;
  119035. /**
  119036. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119037. * zoom (pinch) through multitouch.
  119038. */
  119039. multiTouchPanAndZoom: boolean;
  119040. /**
  119041. * Revers pinch action direction.
  119042. */
  119043. pinchInwards: boolean;
  119044. private _isPanClick;
  119045. private _twoFingerActivityCount;
  119046. private _isPinching;
  119047. /**
  119048. * Called on pointer POINTERMOVE event if only a single touch is active.
  119049. */
  119050. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119051. /**
  119052. * Called on pointer POINTERDOUBLETAP event.
  119053. */
  119054. protected onDoubleTap(type: string): void;
  119055. /**
  119056. * Called on pointer POINTERMOVE event if multiple touches are active.
  119057. */
  119058. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119059. /**
  119060. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119061. * press.
  119062. */
  119063. protected onButtonDown(evt: PointerEvent): void;
  119064. /**
  119065. * Called each time a new POINTERUP event occurs. Ie, for each button
  119066. * release.
  119067. */
  119068. protected onButtonUp(evt: PointerEvent): void;
  119069. /**
  119070. * Called when window becomes inactive.
  119071. */
  119072. protected onLostFocus(): void;
  119073. }
  119074. }
  119075. declare module BABYLON {
  119076. /**
  119077. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119079. */
  119080. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119081. /**
  119082. * Defines the camera the input is attached to.
  119083. */
  119084. camera: ArcRotateCamera;
  119085. /**
  119086. * Defines the list of key codes associated with the up action (increase alpha)
  119087. */
  119088. keysUp: number[];
  119089. /**
  119090. * Defines the list of key codes associated with the down action (decrease alpha)
  119091. */
  119092. keysDown: number[];
  119093. /**
  119094. * Defines the list of key codes associated with the left action (increase beta)
  119095. */
  119096. keysLeft: number[];
  119097. /**
  119098. * Defines the list of key codes associated with the right action (decrease beta)
  119099. */
  119100. keysRight: number[];
  119101. /**
  119102. * Defines the list of key codes associated with the reset action.
  119103. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119104. */
  119105. keysReset: number[];
  119106. /**
  119107. * Defines the panning sensibility of the inputs.
  119108. * (How fast is the camera panning)
  119109. */
  119110. panningSensibility: number;
  119111. /**
  119112. * Defines the zooming sensibility of the inputs.
  119113. * (How fast is the camera zooming)
  119114. */
  119115. zoomingSensibility: number;
  119116. /**
  119117. * Defines whether maintaining the alt key down switch the movement mode from
  119118. * orientation to zoom.
  119119. */
  119120. useAltToZoom: boolean;
  119121. /**
  119122. * Rotation speed of the camera
  119123. */
  119124. angularSpeed: number;
  119125. private _keys;
  119126. private _ctrlPressed;
  119127. private _altPressed;
  119128. private _onCanvasBlurObserver;
  119129. private _onKeyboardObserver;
  119130. private _engine;
  119131. private _scene;
  119132. /**
  119133. * Attach the input controls to a specific dom element to get the input from.
  119134. * @param element Defines the element the controls should be listened from
  119135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119136. */
  119137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119138. /**
  119139. * Detach the current controls from the specified dom element.
  119140. * @param element Defines the element to stop listening the inputs from
  119141. */
  119142. detachControl(element: Nullable<HTMLElement>): void;
  119143. /**
  119144. * Update the current camera state depending on the inputs that have been used this frame.
  119145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119146. */
  119147. checkInputs(): void;
  119148. /**
  119149. * Gets the class name of the current intput.
  119150. * @returns the class name
  119151. */
  119152. getClassName(): string;
  119153. /**
  119154. * Get the friendly name associated with the input class.
  119155. * @returns the input friendly name
  119156. */
  119157. getSimpleName(): string;
  119158. }
  119159. }
  119160. declare module BABYLON {
  119161. /**
  119162. * Manage the mouse wheel inputs to control an arc rotate camera.
  119163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119164. */
  119165. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119166. /**
  119167. * Defines the camera the input is attached to.
  119168. */
  119169. camera: ArcRotateCamera;
  119170. /**
  119171. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119172. */
  119173. wheelPrecision: number;
  119174. /**
  119175. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  119176. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  119177. */
  119178. wheelDeltaPercentage: number;
  119179. private _wheel;
  119180. private _observer;
  119181. private computeDeltaFromMouseWheelLegacyEvent;
  119182. /**
  119183. * Attach the input controls to a specific dom element to get the input from.
  119184. * @param element Defines the element the controls should be listened from
  119185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119186. */
  119187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119188. /**
  119189. * Detach the current controls from the specified dom element.
  119190. * @param element Defines the element to stop listening the inputs from
  119191. */
  119192. detachControl(element: Nullable<HTMLElement>): void;
  119193. /**
  119194. * Gets the class name of the current intput.
  119195. * @returns the class name
  119196. */
  119197. getClassName(): string;
  119198. /**
  119199. * Get the friendly name associated with the input class.
  119200. * @returns the input friendly name
  119201. */
  119202. getSimpleName(): string;
  119203. }
  119204. }
  119205. declare module BABYLON {
  119206. /**
  119207. * Default Inputs manager for the ArcRotateCamera.
  119208. * It groups all the default supported inputs for ease of use.
  119209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119210. */
  119211. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  119212. /**
  119213. * Instantiates a new ArcRotateCameraInputsManager.
  119214. * @param camera Defines the camera the inputs belong to
  119215. */
  119216. constructor(camera: ArcRotateCamera);
  119217. /**
  119218. * Add mouse wheel input support to the input manager.
  119219. * @returns the current input manager
  119220. */
  119221. addMouseWheel(): ArcRotateCameraInputsManager;
  119222. /**
  119223. * Add pointers input support to the input manager.
  119224. * @returns the current input manager
  119225. */
  119226. addPointers(): ArcRotateCameraInputsManager;
  119227. /**
  119228. * Add keyboard input support to the input manager.
  119229. * @returns the current input manager
  119230. */
  119231. addKeyboard(): ArcRotateCameraInputsManager;
  119232. }
  119233. }
  119234. declare module BABYLON {
  119235. /**
  119236. * This represents an orbital type of camera.
  119237. *
  119238. * 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.
  119239. * 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.
  119240. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  119241. */
  119242. export class ArcRotateCamera extends TargetCamera {
  119243. /**
  119244. * Defines the rotation angle of the camera along the longitudinal axis.
  119245. */
  119246. alpha: number;
  119247. /**
  119248. * Defines the rotation angle of the camera along the latitudinal axis.
  119249. */
  119250. beta: number;
  119251. /**
  119252. * Defines the radius of the camera from it s target point.
  119253. */
  119254. radius: number;
  119255. protected _target: Vector3;
  119256. protected _targetHost: Nullable<AbstractMesh>;
  119257. /**
  119258. * Defines the target point of the camera.
  119259. * The camera looks towards it form the radius distance.
  119260. */
  119261. get target(): Vector3;
  119262. set target(value: Vector3);
  119263. /**
  119264. * Define the current local position of the camera in the scene
  119265. */
  119266. get position(): Vector3;
  119267. set position(newPosition: Vector3);
  119268. protected _upVector: Vector3;
  119269. protected _upToYMatrix: Matrix;
  119270. protected _YToUpMatrix: Matrix;
  119271. /**
  119272. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  119273. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  119274. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  119275. */
  119276. set upVector(vec: Vector3);
  119277. get upVector(): Vector3;
  119278. /**
  119279. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  119280. */
  119281. setMatUp(): void;
  119282. /**
  119283. * Current inertia value on the longitudinal axis.
  119284. * The bigger this number the longer it will take for the camera to stop.
  119285. */
  119286. inertialAlphaOffset: number;
  119287. /**
  119288. * Current inertia value on the latitudinal axis.
  119289. * The bigger this number the longer it will take for the camera to stop.
  119290. */
  119291. inertialBetaOffset: number;
  119292. /**
  119293. * Current inertia value on the radius axis.
  119294. * The bigger this number the longer it will take for the camera to stop.
  119295. */
  119296. inertialRadiusOffset: number;
  119297. /**
  119298. * Minimum allowed angle on the longitudinal axis.
  119299. * This can help limiting how the Camera is able to move in the scene.
  119300. */
  119301. lowerAlphaLimit: Nullable<number>;
  119302. /**
  119303. * Maximum allowed angle on the longitudinal axis.
  119304. * This can help limiting how the Camera is able to move in the scene.
  119305. */
  119306. upperAlphaLimit: Nullable<number>;
  119307. /**
  119308. * Minimum allowed angle on the latitudinal axis.
  119309. * This can help limiting how the Camera is able to move in the scene.
  119310. */
  119311. lowerBetaLimit: number;
  119312. /**
  119313. * Maximum allowed angle on the latitudinal axis.
  119314. * This can help limiting how the Camera is able to move in the scene.
  119315. */
  119316. upperBetaLimit: number;
  119317. /**
  119318. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119319. * This can help limiting how the Camera is able to move in the scene.
  119320. */
  119321. lowerRadiusLimit: Nullable<number>;
  119322. /**
  119323. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119324. * This can help limiting how the Camera is able to move in the scene.
  119325. */
  119326. upperRadiusLimit: Nullable<number>;
  119327. /**
  119328. * Defines the current inertia value used during panning of the camera along the X axis.
  119329. */
  119330. inertialPanningX: number;
  119331. /**
  119332. * Defines the current inertia value used during panning of the camera along the Y axis.
  119333. */
  119334. inertialPanningY: number;
  119335. /**
  119336. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119337. * Basically if your fingers moves away from more than this distance you will be considered
  119338. * in pinch mode.
  119339. */
  119340. pinchToPanMaxDistance: number;
  119341. /**
  119342. * Defines the maximum distance the camera can pan.
  119343. * This could help keeping the cammera always in your scene.
  119344. */
  119345. panningDistanceLimit: Nullable<number>;
  119346. /**
  119347. * Defines the target of the camera before paning.
  119348. */
  119349. panningOriginTarget: Vector3;
  119350. /**
  119351. * Defines the value of the inertia used during panning.
  119352. * 0 would mean stop inertia and one would mean no decelleration at all.
  119353. */
  119354. panningInertia: number;
  119355. /**
  119356. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119357. */
  119358. get angularSensibilityX(): number;
  119359. set angularSensibilityX(value: number);
  119360. /**
  119361. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119362. */
  119363. get angularSensibilityY(): number;
  119364. set angularSensibilityY(value: number);
  119365. /**
  119366. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119367. */
  119368. get pinchPrecision(): number;
  119369. set pinchPrecision(value: number);
  119370. /**
  119371. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119372. * It will be used instead of pinchDeltaPrecision if different from 0.
  119373. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119374. */
  119375. get pinchDeltaPercentage(): number;
  119376. set pinchDeltaPercentage(value: number);
  119377. /**
  119378. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119379. * and pinch delta percentage.
  119380. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119381. * that any object in the plane at the camera's target point will scale
  119382. * perfectly with finger motion.
  119383. */
  119384. get useNaturalPinchZoom(): boolean;
  119385. set useNaturalPinchZoom(value: boolean);
  119386. /**
  119387. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119388. */
  119389. get panningSensibility(): number;
  119390. set panningSensibility(value: number);
  119391. /**
  119392. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119393. */
  119394. get keysUp(): number[];
  119395. set keysUp(value: number[]);
  119396. /**
  119397. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119398. */
  119399. get keysDown(): number[];
  119400. set keysDown(value: number[]);
  119401. /**
  119402. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119403. */
  119404. get keysLeft(): number[];
  119405. set keysLeft(value: number[]);
  119406. /**
  119407. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119408. */
  119409. get keysRight(): number[];
  119410. set keysRight(value: number[]);
  119411. /**
  119412. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119413. */
  119414. get wheelPrecision(): number;
  119415. set wheelPrecision(value: number);
  119416. /**
  119417. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119418. * It will be used instead of pinchDeltaPrecision if different from 0.
  119419. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119420. */
  119421. get wheelDeltaPercentage(): number;
  119422. set wheelDeltaPercentage(value: number);
  119423. /**
  119424. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119425. */
  119426. zoomOnFactor: number;
  119427. /**
  119428. * Defines a screen offset for the camera position.
  119429. */
  119430. targetScreenOffset: Vector2;
  119431. /**
  119432. * Allows the camera to be completely reversed.
  119433. * If false the camera can not arrive upside down.
  119434. */
  119435. allowUpsideDown: boolean;
  119436. /**
  119437. * Define if double tap/click is used to restore the previously saved state of the camera.
  119438. */
  119439. useInputToRestoreState: boolean;
  119440. /** @hidden */
  119441. _viewMatrix: Matrix;
  119442. /** @hidden */
  119443. _useCtrlForPanning: boolean;
  119444. /** @hidden */
  119445. _panningMouseButton: number;
  119446. /**
  119447. * Defines the input associated to the camera.
  119448. */
  119449. inputs: ArcRotateCameraInputsManager;
  119450. /** @hidden */
  119451. _reset: () => void;
  119452. /**
  119453. * Defines the allowed panning axis.
  119454. */
  119455. panningAxis: Vector3;
  119456. protected _localDirection: Vector3;
  119457. protected _transformedDirection: Vector3;
  119458. private _bouncingBehavior;
  119459. /**
  119460. * Gets the bouncing behavior of the camera if it has been enabled.
  119461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119462. */
  119463. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119464. /**
  119465. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119467. */
  119468. get useBouncingBehavior(): boolean;
  119469. set useBouncingBehavior(value: boolean);
  119470. private _framingBehavior;
  119471. /**
  119472. * Gets the framing behavior of the camera if it has been enabled.
  119473. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119474. */
  119475. get framingBehavior(): Nullable<FramingBehavior>;
  119476. /**
  119477. * Defines if the framing behavior of the camera is enabled on the camera.
  119478. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119479. */
  119480. get useFramingBehavior(): boolean;
  119481. set useFramingBehavior(value: boolean);
  119482. private _autoRotationBehavior;
  119483. /**
  119484. * Gets the auto rotation behavior of the camera if it has been enabled.
  119485. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119486. */
  119487. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119488. /**
  119489. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119490. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119491. */
  119492. get useAutoRotationBehavior(): boolean;
  119493. set useAutoRotationBehavior(value: boolean);
  119494. /**
  119495. * Observable triggered when the mesh target has been changed on the camera.
  119496. */
  119497. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119498. /**
  119499. * Event raised when the camera is colliding with a mesh.
  119500. */
  119501. onCollide: (collidedMesh: AbstractMesh) => void;
  119502. /**
  119503. * Defines whether the camera should check collision with the objects oh the scene.
  119504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119505. */
  119506. checkCollisions: boolean;
  119507. /**
  119508. * Defines the collision radius of the camera.
  119509. * This simulates a sphere around the camera.
  119510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119511. */
  119512. collisionRadius: Vector3;
  119513. protected _collider: Collider;
  119514. protected _previousPosition: Vector3;
  119515. protected _collisionVelocity: Vector3;
  119516. protected _newPosition: Vector3;
  119517. protected _previousAlpha: number;
  119518. protected _previousBeta: number;
  119519. protected _previousRadius: number;
  119520. protected _collisionTriggered: boolean;
  119521. protected _targetBoundingCenter: Nullable<Vector3>;
  119522. private _computationVector;
  119523. /**
  119524. * Instantiates a new ArcRotateCamera in a given scene
  119525. * @param name Defines the name of the camera
  119526. * @param alpha Defines the camera rotation along the logitudinal axis
  119527. * @param beta Defines the camera rotation along the latitudinal axis
  119528. * @param radius Defines the camera distance from its target
  119529. * @param target Defines the camera target
  119530. * @param scene Defines the scene the camera belongs to
  119531. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119532. */
  119533. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119534. /** @hidden */
  119535. _initCache(): void;
  119536. /** @hidden */
  119537. _updateCache(ignoreParentClass?: boolean): void;
  119538. protected _getTargetPosition(): Vector3;
  119539. private _storedAlpha;
  119540. private _storedBeta;
  119541. private _storedRadius;
  119542. private _storedTarget;
  119543. private _storedTargetScreenOffset;
  119544. /**
  119545. * Stores the current state of the camera (alpha, beta, radius and target)
  119546. * @returns the camera itself
  119547. */
  119548. storeState(): Camera;
  119549. /**
  119550. * @hidden
  119551. * Restored camera state. You must call storeState() first
  119552. */
  119553. _restoreStateValues(): boolean;
  119554. /** @hidden */
  119555. _isSynchronizedViewMatrix(): boolean;
  119556. /**
  119557. * Attached controls to the current camera.
  119558. * @param element Defines the element the controls should be listened from
  119559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119560. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119561. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119562. */
  119563. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119564. /**
  119565. * Detach the current controls from the camera.
  119566. * The camera will stop reacting to inputs.
  119567. * @param element Defines the element to stop listening the inputs from
  119568. */
  119569. detachControl(element: HTMLElement): void;
  119570. /** @hidden */
  119571. _checkInputs(): void;
  119572. protected _checkLimits(): void;
  119573. /**
  119574. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119575. */
  119576. rebuildAnglesAndRadius(): void;
  119577. /**
  119578. * Use a position to define the current camera related information like alpha, beta and radius
  119579. * @param position Defines the position to set the camera at
  119580. */
  119581. setPosition(position: Vector3): void;
  119582. /**
  119583. * Defines the target the camera should look at.
  119584. * This will automatically adapt alpha beta and radius to fit within the new target.
  119585. * @param target Defines the new target as a Vector or a mesh
  119586. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119587. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119588. */
  119589. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119590. /** @hidden */
  119591. _getViewMatrix(): Matrix;
  119592. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119593. /**
  119594. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119595. * @param meshes Defines the mesh to zoom on
  119596. * @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)
  119597. */
  119598. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119599. /**
  119600. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119601. * The target will be changed but the radius
  119602. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119603. * @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)
  119604. */
  119605. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119606. min: Vector3;
  119607. max: Vector3;
  119608. distance: number;
  119609. }, doNotUpdateMaxZ?: boolean): void;
  119610. /**
  119611. * @override
  119612. * Override Camera.createRigCamera
  119613. */
  119614. createRigCamera(name: string, cameraIndex: number): Camera;
  119615. /**
  119616. * @hidden
  119617. * @override
  119618. * Override Camera._updateRigCameras
  119619. */
  119620. _updateRigCameras(): void;
  119621. /**
  119622. * Destroy the camera and release the current resources hold by it.
  119623. */
  119624. dispose(): void;
  119625. /**
  119626. * Gets the current object class name.
  119627. * @return the class name
  119628. */
  119629. getClassName(): string;
  119630. }
  119631. }
  119632. declare module BABYLON {
  119633. /**
  119634. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119636. */
  119637. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119638. /**
  119639. * Gets the name of the behavior.
  119640. */
  119641. get name(): string;
  119642. private _zoomStopsAnimation;
  119643. private _idleRotationSpeed;
  119644. private _idleRotationWaitTime;
  119645. private _idleRotationSpinupTime;
  119646. /**
  119647. * Sets the flag that indicates if user zooming should stop animation.
  119648. */
  119649. set zoomStopsAnimation(flag: boolean);
  119650. /**
  119651. * Gets the flag that indicates if user zooming should stop animation.
  119652. */
  119653. get zoomStopsAnimation(): boolean;
  119654. /**
  119655. * Sets the default speed at which the camera rotates around the model.
  119656. */
  119657. set idleRotationSpeed(speed: number);
  119658. /**
  119659. * Gets the default speed at which the camera rotates around the model.
  119660. */
  119661. get idleRotationSpeed(): number;
  119662. /**
  119663. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  119664. */
  119665. set idleRotationWaitTime(time: number);
  119666. /**
  119667. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  119668. */
  119669. get idleRotationWaitTime(): number;
  119670. /**
  119671. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119672. */
  119673. set idleRotationSpinupTime(time: number);
  119674. /**
  119675. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119676. */
  119677. get idleRotationSpinupTime(): number;
  119678. /**
  119679. * Gets a value indicating if the camera is currently rotating because of this behavior
  119680. */
  119681. get rotationInProgress(): boolean;
  119682. private _onPrePointerObservableObserver;
  119683. private _onAfterCheckInputsObserver;
  119684. private _attachedCamera;
  119685. private _isPointerDown;
  119686. private _lastFrameTime;
  119687. private _lastInteractionTime;
  119688. private _cameraRotationSpeed;
  119689. /**
  119690. * Initializes the behavior.
  119691. */
  119692. init(): void;
  119693. /**
  119694. * Attaches the behavior to its arc rotate camera.
  119695. * @param camera Defines the camera to attach the behavior to
  119696. */
  119697. attach(camera: ArcRotateCamera): void;
  119698. /**
  119699. * Detaches the behavior from its current arc rotate camera.
  119700. */
  119701. detach(): void;
  119702. /**
  119703. * Returns true if user is scrolling.
  119704. * @return true if user is scrolling.
  119705. */
  119706. private _userIsZooming;
  119707. private _lastFrameRadius;
  119708. private _shouldAnimationStopForInteraction;
  119709. /**
  119710. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119711. */
  119712. private _applyUserInteraction;
  119713. private _userIsMoving;
  119714. }
  119715. }
  119716. declare module BABYLON {
  119717. /**
  119718. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119719. */
  119720. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119721. private ui;
  119722. /**
  119723. * The name of the behavior
  119724. */
  119725. name: string;
  119726. /**
  119727. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  119728. */
  119729. distanceAwayFromFace: number;
  119730. /**
  119731. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  119732. */
  119733. distanceAwayFromBottomOfFace: number;
  119734. private _faceVectors;
  119735. private _target;
  119736. private _scene;
  119737. private _onRenderObserver;
  119738. private _tmpMatrix;
  119739. private _tmpVector;
  119740. /**
  119741. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  119742. * @param ui The transform node that should be attched to the mesh
  119743. */
  119744. constructor(ui: TransformNode);
  119745. /**
  119746. * Initializes the behavior
  119747. */
  119748. init(): void;
  119749. private _closestFace;
  119750. private _zeroVector;
  119751. private _lookAtTmpMatrix;
  119752. private _lookAtToRef;
  119753. /**
  119754. * Attaches the AttachToBoxBehavior to the passed in mesh
  119755. * @param target The mesh that the specified node will be attached to
  119756. */
  119757. attach(target: Mesh): void;
  119758. /**
  119759. * Detaches the behavior from the mesh
  119760. */
  119761. detach(): void;
  119762. }
  119763. }
  119764. declare module BABYLON {
  119765. /**
  119766. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  119767. */
  119768. export class FadeInOutBehavior implements Behavior<Mesh> {
  119769. /**
  119770. * Time in milliseconds to delay before fading in (Default: 0)
  119771. */
  119772. delay: number;
  119773. /**
  119774. * Time in milliseconds for the mesh to fade in (Default: 300)
  119775. */
  119776. fadeInTime: number;
  119777. private _millisecondsPerFrame;
  119778. private _hovered;
  119779. private _hoverValue;
  119780. private _ownerNode;
  119781. /**
  119782. * Instatiates the FadeInOutBehavior
  119783. */
  119784. constructor();
  119785. /**
  119786. * The name of the behavior
  119787. */
  119788. get name(): string;
  119789. /**
  119790. * Initializes the behavior
  119791. */
  119792. init(): void;
  119793. /**
  119794. * Attaches the fade behavior on the passed in mesh
  119795. * @param ownerNode The mesh that will be faded in/out once attached
  119796. */
  119797. attach(ownerNode: Mesh): void;
  119798. /**
  119799. * Detaches the behavior from the mesh
  119800. */
  119801. detach(): void;
  119802. /**
  119803. * Triggers the mesh to begin fading in or out
  119804. * @param value if the object should fade in or out (true to fade in)
  119805. */
  119806. fadeIn(value: boolean): void;
  119807. private _update;
  119808. private _setAllVisibility;
  119809. }
  119810. }
  119811. declare module BABYLON {
  119812. /**
  119813. * Class containing a set of static utilities functions for managing Pivots
  119814. * @hidden
  119815. */
  119816. export class PivotTools {
  119817. private static _PivotCached;
  119818. private static _OldPivotPoint;
  119819. private static _PivotTranslation;
  119820. private static _PivotTmpVector;
  119821. /** @hidden */
  119822. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  119823. /** @hidden */
  119824. static _RestorePivotPoint(mesh: AbstractMesh): void;
  119825. }
  119826. }
  119827. declare module BABYLON {
  119828. /**
  119829. * Class containing static functions to help procedurally build meshes
  119830. */
  119831. export class PlaneBuilder {
  119832. /**
  119833. * Creates a plane mesh
  119834. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  119835. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  119836. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  119837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119840. * @param name defines the name of the mesh
  119841. * @param options defines the options used to create the mesh
  119842. * @param scene defines the hosting scene
  119843. * @returns the plane mesh
  119844. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  119845. */
  119846. static CreatePlane(name: string, options: {
  119847. size?: number;
  119848. width?: number;
  119849. height?: number;
  119850. sideOrientation?: number;
  119851. frontUVs?: Vector4;
  119852. backUVs?: Vector4;
  119853. updatable?: boolean;
  119854. sourcePlane?: Plane;
  119855. }, scene?: Nullable<Scene>): Mesh;
  119856. }
  119857. }
  119858. declare module BABYLON {
  119859. /**
  119860. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  119861. */
  119862. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  119863. private static _AnyMouseID;
  119864. /**
  119865. * Abstract mesh the behavior is set on
  119866. */
  119867. attachedNode: AbstractMesh;
  119868. private _dragPlane;
  119869. private _scene;
  119870. private _pointerObserver;
  119871. private _beforeRenderObserver;
  119872. private static _planeScene;
  119873. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  119874. /**
  119875. * 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)
  119876. */
  119877. maxDragAngle: number;
  119878. /**
  119879. * @hidden
  119880. */
  119881. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  119882. /**
  119883. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  119884. */
  119885. currentDraggingPointerID: number;
  119886. /**
  119887. * The last position where the pointer hit the drag plane in world space
  119888. */
  119889. lastDragPosition: Vector3;
  119890. /**
  119891. * If the behavior is currently in a dragging state
  119892. */
  119893. dragging: boolean;
  119894. /**
  119895. * 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)
  119896. */
  119897. dragDeltaRatio: number;
  119898. /**
  119899. * If the drag plane orientation should be updated during the dragging (Default: true)
  119900. */
  119901. updateDragPlane: boolean;
  119902. private _debugMode;
  119903. private _moving;
  119904. /**
  119905. * Fires each time the attached mesh is dragged with the pointer
  119906. * * delta between last drag position and current drag position in world space
  119907. * * dragDistance along the drag axis
  119908. * * dragPlaneNormal normal of the current drag plane used during the drag
  119909. * * dragPlanePoint in world space where the drag intersects the drag plane
  119910. */
  119911. onDragObservable: Observable<{
  119912. delta: Vector3;
  119913. dragPlanePoint: Vector3;
  119914. dragPlaneNormal: Vector3;
  119915. dragDistance: number;
  119916. pointerId: number;
  119917. }>;
  119918. /**
  119919. * Fires each time a drag begins (eg. mouse down on mesh)
  119920. */
  119921. onDragStartObservable: Observable<{
  119922. dragPlanePoint: Vector3;
  119923. pointerId: number;
  119924. }>;
  119925. /**
  119926. * Fires each time a drag ends (eg. mouse release after drag)
  119927. */
  119928. onDragEndObservable: Observable<{
  119929. dragPlanePoint: Vector3;
  119930. pointerId: number;
  119931. }>;
  119932. /**
  119933. * If the attached mesh should be moved when dragged
  119934. */
  119935. moveAttached: boolean;
  119936. /**
  119937. * If the drag behavior will react to drag events (Default: true)
  119938. */
  119939. enabled: boolean;
  119940. /**
  119941. * If pointer events should start and release the drag (Default: true)
  119942. */
  119943. startAndReleaseDragOnPointerEvents: boolean;
  119944. /**
  119945. * If camera controls should be detached during the drag
  119946. */
  119947. detachCameraControls: boolean;
  119948. /**
  119949. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  119950. */
  119951. useObjectOrientationForDragging: boolean;
  119952. private _options;
  119953. /**
  119954. * Gets the options used by the behavior
  119955. */
  119956. get options(): {
  119957. dragAxis?: Vector3;
  119958. dragPlaneNormal?: Vector3;
  119959. };
  119960. /**
  119961. * Sets the options used by the behavior
  119962. */
  119963. set options(options: {
  119964. dragAxis?: Vector3;
  119965. dragPlaneNormal?: Vector3;
  119966. });
  119967. /**
  119968. * Creates a pointer drag behavior that can be attached to a mesh
  119969. * @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)
  119970. */
  119971. constructor(options?: {
  119972. dragAxis?: Vector3;
  119973. dragPlaneNormal?: Vector3;
  119974. });
  119975. /**
  119976. * Predicate to determine if it is valid to move the object to a new position when it is moved
  119977. */
  119978. validateDrag: (targetPosition: Vector3) => boolean;
  119979. /**
  119980. * The name of the behavior
  119981. */
  119982. get name(): string;
  119983. /**
  119984. * Initializes the behavior
  119985. */
  119986. init(): void;
  119987. private _tmpVector;
  119988. private _alternatePickedPoint;
  119989. private _worldDragAxis;
  119990. private _targetPosition;
  119991. private _attachedElement;
  119992. /**
  119993. * Attaches the drag behavior the passed in mesh
  119994. * @param ownerNode The mesh that will be dragged around once attached
  119995. * @param predicate Predicate to use for pick filtering
  119996. */
  119997. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  119998. /**
  119999. * Force relase the drag action by code.
  120000. */
  120001. releaseDrag(): void;
  120002. private _startDragRay;
  120003. private _lastPointerRay;
  120004. /**
  120005. * Simulates the start of a pointer drag event on the behavior
  120006. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120007. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120008. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120009. */
  120010. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120011. private _startDrag;
  120012. private _dragDelta;
  120013. private _moveDrag;
  120014. private _pickWithRayOnDragPlane;
  120015. private _pointA;
  120016. private _pointB;
  120017. private _pointC;
  120018. private _lineA;
  120019. private _lineB;
  120020. private _localAxis;
  120021. private _lookAt;
  120022. private _updateDragPlanePosition;
  120023. /**
  120024. * Detaches the behavior from the mesh
  120025. */
  120026. detach(): void;
  120027. }
  120028. }
  120029. declare module BABYLON {
  120030. /**
  120031. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120032. */
  120033. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120034. private _dragBehaviorA;
  120035. private _dragBehaviorB;
  120036. private _startDistance;
  120037. private _initialScale;
  120038. private _targetScale;
  120039. private _ownerNode;
  120040. private _sceneRenderObserver;
  120041. /**
  120042. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120043. */
  120044. constructor();
  120045. /**
  120046. * The name of the behavior
  120047. */
  120048. get name(): string;
  120049. /**
  120050. * Initializes the behavior
  120051. */
  120052. init(): void;
  120053. private _getCurrentDistance;
  120054. /**
  120055. * Attaches the scale behavior the passed in mesh
  120056. * @param ownerNode The mesh that will be scaled around once attached
  120057. */
  120058. attach(ownerNode: Mesh): void;
  120059. /**
  120060. * Detaches the behavior from the mesh
  120061. */
  120062. detach(): void;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /**
  120067. * 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
  120068. */
  120069. export class SixDofDragBehavior implements Behavior<Mesh> {
  120070. private static _virtualScene;
  120071. private _ownerNode;
  120072. private _sceneRenderObserver;
  120073. private _scene;
  120074. private _targetPosition;
  120075. private _virtualOriginMesh;
  120076. private _virtualDragMesh;
  120077. private _pointerObserver;
  120078. private _moving;
  120079. private _startingOrientation;
  120080. private _attachedElement;
  120081. /**
  120082. * 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)
  120083. */
  120084. private zDragFactor;
  120085. /**
  120086. * If the object should rotate to face the drag origin
  120087. */
  120088. rotateDraggedObject: boolean;
  120089. /**
  120090. * If the behavior is currently in a dragging state
  120091. */
  120092. dragging: boolean;
  120093. /**
  120094. * 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)
  120095. */
  120096. dragDeltaRatio: number;
  120097. /**
  120098. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120099. */
  120100. currentDraggingPointerID: number;
  120101. /**
  120102. * If camera controls should be detached during the drag
  120103. */
  120104. detachCameraControls: boolean;
  120105. /**
  120106. * Fires each time a drag starts
  120107. */
  120108. onDragStartObservable: Observable<{}>;
  120109. /**
  120110. * Fires each time a drag ends (eg. mouse release after drag)
  120111. */
  120112. onDragEndObservable: Observable<{}>;
  120113. /**
  120114. * 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
  120115. */
  120116. constructor();
  120117. /**
  120118. * The name of the behavior
  120119. */
  120120. get name(): string;
  120121. /**
  120122. * Initializes the behavior
  120123. */
  120124. init(): void;
  120125. /**
  120126. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120127. */
  120128. private get _pointerCamera();
  120129. /**
  120130. * Attaches the scale behavior the passed in mesh
  120131. * @param ownerNode The mesh that will be scaled around once attached
  120132. */
  120133. attach(ownerNode: Mesh): void;
  120134. /**
  120135. * Detaches the behavior from the mesh
  120136. */
  120137. detach(): void;
  120138. }
  120139. }
  120140. declare module BABYLON {
  120141. /**
  120142. * Class used to apply inverse kinematics to bones
  120143. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120144. */
  120145. export class BoneIKController {
  120146. private static _tmpVecs;
  120147. private static _tmpQuat;
  120148. private static _tmpMats;
  120149. /**
  120150. * Gets or sets the target mesh
  120151. */
  120152. targetMesh: AbstractMesh;
  120153. /** Gets or sets the mesh used as pole */
  120154. poleTargetMesh: AbstractMesh;
  120155. /**
  120156. * Gets or sets the bone used as pole
  120157. */
  120158. poleTargetBone: Nullable<Bone>;
  120159. /**
  120160. * Gets or sets the target position
  120161. */
  120162. targetPosition: Vector3;
  120163. /**
  120164. * Gets or sets the pole target position
  120165. */
  120166. poleTargetPosition: Vector3;
  120167. /**
  120168. * Gets or sets the pole target local offset
  120169. */
  120170. poleTargetLocalOffset: Vector3;
  120171. /**
  120172. * Gets or sets the pole angle
  120173. */
  120174. poleAngle: number;
  120175. /**
  120176. * Gets or sets the mesh associated with the controller
  120177. */
  120178. mesh: AbstractMesh;
  120179. /**
  120180. * 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)
  120181. */
  120182. slerpAmount: number;
  120183. private _bone1Quat;
  120184. private _bone1Mat;
  120185. private _bone2Ang;
  120186. private _bone1;
  120187. private _bone2;
  120188. private _bone1Length;
  120189. private _bone2Length;
  120190. private _maxAngle;
  120191. private _maxReach;
  120192. private _rightHandedSystem;
  120193. private _bendAxis;
  120194. private _slerping;
  120195. private _adjustRoll;
  120196. /**
  120197. * Gets or sets maximum allowed angle
  120198. */
  120199. get maxAngle(): number;
  120200. set maxAngle(value: number);
  120201. /**
  120202. * Creates a new BoneIKController
  120203. * @param mesh defines the mesh to control
  120204. * @param bone defines the bone to control
  120205. * @param options defines options to set up the controller
  120206. */
  120207. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  120208. targetMesh?: AbstractMesh;
  120209. poleTargetMesh?: AbstractMesh;
  120210. poleTargetBone?: Bone;
  120211. poleTargetLocalOffset?: Vector3;
  120212. poleAngle?: number;
  120213. bendAxis?: Vector3;
  120214. maxAngle?: number;
  120215. slerpAmount?: number;
  120216. });
  120217. private _setMaxAngle;
  120218. /**
  120219. * Force the controller to update the bones
  120220. */
  120221. update(): void;
  120222. }
  120223. }
  120224. declare module BABYLON {
  120225. /**
  120226. * Class used to make a bone look toward a point in space
  120227. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  120228. */
  120229. export class BoneLookController {
  120230. private static _tmpVecs;
  120231. private static _tmpQuat;
  120232. private static _tmpMats;
  120233. /**
  120234. * The target Vector3 that the bone will look at
  120235. */
  120236. target: Vector3;
  120237. /**
  120238. * The mesh that the bone is attached to
  120239. */
  120240. mesh: AbstractMesh;
  120241. /**
  120242. * The bone that will be looking to the target
  120243. */
  120244. bone: Bone;
  120245. /**
  120246. * The up axis of the coordinate system that is used when the bone is rotated
  120247. */
  120248. upAxis: Vector3;
  120249. /**
  120250. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  120251. */
  120252. upAxisSpace: Space;
  120253. /**
  120254. * Used to make an adjustment to the yaw of the bone
  120255. */
  120256. adjustYaw: number;
  120257. /**
  120258. * Used to make an adjustment to the pitch of the bone
  120259. */
  120260. adjustPitch: number;
  120261. /**
  120262. * Used to make an adjustment to the roll of the bone
  120263. */
  120264. adjustRoll: number;
  120265. /**
  120266. * 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)
  120267. */
  120268. slerpAmount: number;
  120269. private _minYaw;
  120270. private _maxYaw;
  120271. private _minPitch;
  120272. private _maxPitch;
  120273. private _minYawSin;
  120274. private _minYawCos;
  120275. private _maxYawSin;
  120276. private _maxYawCos;
  120277. private _midYawConstraint;
  120278. private _minPitchTan;
  120279. private _maxPitchTan;
  120280. private _boneQuat;
  120281. private _slerping;
  120282. private _transformYawPitch;
  120283. private _transformYawPitchInv;
  120284. private _firstFrameSkipped;
  120285. private _yawRange;
  120286. private _fowardAxis;
  120287. /**
  120288. * Gets or sets the minimum yaw angle that the bone can look to
  120289. */
  120290. get minYaw(): number;
  120291. set minYaw(value: number);
  120292. /**
  120293. * Gets or sets the maximum yaw angle that the bone can look to
  120294. */
  120295. get maxYaw(): number;
  120296. set maxYaw(value: number);
  120297. /**
  120298. * Gets or sets the minimum pitch angle that the bone can look to
  120299. */
  120300. get minPitch(): number;
  120301. set minPitch(value: number);
  120302. /**
  120303. * Gets or sets the maximum pitch angle that the bone can look to
  120304. */
  120305. get maxPitch(): number;
  120306. set maxPitch(value: number);
  120307. /**
  120308. * Create a BoneLookController
  120309. * @param mesh the mesh that the bone belongs to
  120310. * @param bone the bone that will be looking to the target
  120311. * @param target the target Vector3 to look at
  120312. * @param options optional settings:
  120313. * * maxYaw: the maximum angle the bone will yaw to
  120314. * * minYaw: the minimum angle the bone will yaw to
  120315. * * maxPitch: the maximum angle the bone will pitch to
  120316. * * minPitch: the minimum angle the bone will yaw to
  120317. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120318. * * upAxis: the up axis of the coordinate system
  120319. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120320. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120321. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120322. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120323. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120324. * * adjustRoll: used to make an adjustment to the roll of the bone
  120325. **/
  120326. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120327. maxYaw?: number;
  120328. minYaw?: number;
  120329. maxPitch?: number;
  120330. minPitch?: number;
  120331. slerpAmount?: number;
  120332. upAxis?: Vector3;
  120333. upAxisSpace?: Space;
  120334. yawAxis?: Vector3;
  120335. pitchAxis?: Vector3;
  120336. adjustYaw?: number;
  120337. adjustPitch?: number;
  120338. adjustRoll?: number;
  120339. });
  120340. /**
  120341. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120342. */
  120343. update(): void;
  120344. private _getAngleDiff;
  120345. private _getAngleBetween;
  120346. private _isAngleBetween;
  120347. }
  120348. }
  120349. declare module BABYLON {
  120350. /**
  120351. * Manage the gamepad inputs to control an arc rotate camera.
  120352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120353. */
  120354. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120355. /**
  120356. * Defines the camera the input is attached to.
  120357. */
  120358. camera: ArcRotateCamera;
  120359. /**
  120360. * Defines the gamepad the input is gathering event from.
  120361. */
  120362. gamepad: Nullable<Gamepad>;
  120363. /**
  120364. * Defines the gamepad rotation sensiblity.
  120365. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120366. */
  120367. gamepadRotationSensibility: number;
  120368. /**
  120369. * Defines the gamepad move sensiblity.
  120370. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120371. */
  120372. gamepadMoveSensibility: number;
  120373. private _yAxisScale;
  120374. /**
  120375. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120376. */
  120377. get invertYAxis(): boolean;
  120378. set invertYAxis(value: boolean);
  120379. private _onGamepadConnectedObserver;
  120380. private _onGamepadDisconnectedObserver;
  120381. /**
  120382. * Attach the input controls to a specific dom element to get the input from.
  120383. * @param element Defines the element the controls should be listened from
  120384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120385. */
  120386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120387. /**
  120388. * Detach the current controls from the specified dom element.
  120389. * @param element Defines the element to stop listening the inputs from
  120390. */
  120391. detachControl(element: Nullable<HTMLElement>): void;
  120392. /**
  120393. * Update the current camera state depending on the inputs that have been used this frame.
  120394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120395. */
  120396. checkInputs(): void;
  120397. /**
  120398. * Gets the class name of the current intput.
  120399. * @returns the class name
  120400. */
  120401. getClassName(): string;
  120402. /**
  120403. * Get the friendly name associated with the input class.
  120404. * @returns the input friendly name
  120405. */
  120406. getSimpleName(): string;
  120407. }
  120408. }
  120409. declare module BABYLON {
  120410. interface ArcRotateCameraInputsManager {
  120411. /**
  120412. * Add orientation input support to the input manager.
  120413. * @returns the current input manager
  120414. */
  120415. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120416. }
  120417. /**
  120418. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120420. */
  120421. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120422. /**
  120423. * Defines the camera the input is attached to.
  120424. */
  120425. camera: ArcRotateCamera;
  120426. /**
  120427. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120428. */
  120429. alphaCorrection: number;
  120430. /**
  120431. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120432. */
  120433. gammaCorrection: number;
  120434. private _alpha;
  120435. private _gamma;
  120436. private _dirty;
  120437. private _deviceOrientationHandler;
  120438. /**
  120439. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120440. */
  120441. constructor();
  120442. /**
  120443. * Attach the input controls to a specific dom element to get the input from.
  120444. * @param element Defines the element the controls should be listened from
  120445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120446. */
  120447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120448. /** @hidden */
  120449. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120450. /**
  120451. * Update the current camera state depending on the inputs that have been used this frame.
  120452. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120453. */
  120454. checkInputs(): void;
  120455. /**
  120456. * Detach the current controls from the specified dom element.
  120457. * @param element Defines the element to stop listening the inputs from
  120458. */
  120459. detachControl(element: Nullable<HTMLElement>): void;
  120460. /**
  120461. * Gets the class name of the current intput.
  120462. * @returns the class name
  120463. */
  120464. getClassName(): string;
  120465. /**
  120466. * Get the friendly name associated with the input class.
  120467. * @returns the input friendly name
  120468. */
  120469. getSimpleName(): string;
  120470. }
  120471. }
  120472. declare module BABYLON {
  120473. /**
  120474. * Listen to mouse events to control the camera.
  120475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120476. */
  120477. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120478. /**
  120479. * Defines the camera the input is attached to.
  120480. */
  120481. camera: FlyCamera;
  120482. /**
  120483. * Defines if touch is enabled. (Default is true.)
  120484. */
  120485. touchEnabled: boolean;
  120486. /**
  120487. * Defines the buttons associated with the input to handle camera rotation.
  120488. */
  120489. buttons: number[];
  120490. /**
  120491. * Assign buttons for Yaw control.
  120492. */
  120493. buttonsYaw: number[];
  120494. /**
  120495. * Assign buttons for Pitch control.
  120496. */
  120497. buttonsPitch: number[];
  120498. /**
  120499. * Assign buttons for Roll control.
  120500. */
  120501. buttonsRoll: number[];
  120502. /**
  120503. * Detect if any button is being pressed while mouse is moved.
  120504. * -1 = Mouse locked.
  120505. * 0 = Left button.
  120506. * 1 = Middle Button.
  120507. * 2 = Right Button.
  120508. */
  120509. activeButton: number;
  120510. /**
  120511. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120512. * Higher values reduce its sensitivity.
  120513. */
  120514. angularSensibility: number;
  120515. private _mousemoveCallback;
  120516. private _observer;
  120517. private _rollObserver;
  120518. private previousPosition;
  120519. private noPreventDefault;
  120520. private element;
  120521. /**
  120522. * Listen to mouse events to control the camera.
  120523. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120525. */
  120526. constructor(touchEnabled?: boolean);
  120527. /**
  120528. * Attach the mouse control to the HTML DOM element.
  120529. * @param element Defines the element that listens to the input events.
  120530. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120531. */
  120532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120533. /**
  120534. * Detach the current controls from the specified dom element.
  120535. * @param element Defines the element to stop listening the inputs from
  120536. */
  120537. detachControl(element: Nullable<HTMLElement>): void;
  120538. /**
  120539. * Gets the class name of the current input.
  120540. * @returns the class name.
  120541. */
  120542. getClassName(): string;
  120543. /**
  120544. * Get the friendly name associated with the input class.
  120545. * @returns the input's friendly name.
  120546. */
  120547. getSimpleName(): string;
  120548. private _pointerInput;
  120549. private _onMouseMove;
  120550. /**
  120551. * Rotate camera by mouse offset.
  120552. */
  120553. private rotateCamera;
  120554. }
  120555. }
  120556. declare module BABYLON {
  120557. /**
  120558. * Default Inputs manager for the FlyCamera.
  120559. * It groups all the default supported inputs for ease of use.
  120560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120561. */
  120562. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120563. /**
  120564. * Instantiates a new FlyCameraInputsManager.
  120565. * @param camera Defines the camera the inputs belong to.
  120566. */
  120567. constructor(camera: FlyCamera);
  120568. /**
  120569. * Add keyboard input support to the input manager.
  120570. * @returns the new FlyCameraKeyboardMoveInput().
  120571. */
  120572. addKeyboard(): FlyCameraInputsManager;
  120573. /**
  120574. * Add mouse input support to the input manager.
  120575. * @param touchEnabled Enable touch screen support.
  120576. * @returns the new FlyCameraMouseInput().
  120577. */
  120578. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120579. }
  120580. }
  120581. declare module BABYLON {
  120582. /**
  120583. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120584. * such as in a 3D Space Shooter or a Flight Simulator.
  120585. */
  120586. export class FlyCamera extends TargetCamera {
  120587. /**
  120588. * Define the collision ellipsoid of the camera.
  120589. * This is helpful for simulating a camera body, like a player's body.
  120590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120591. */
  120592. ellipsoid: Vector3;
  120593. /**
  120594. * Define an offset for the position of the ellipsoid around the camera.
  120595. * This can be helpful if the camera is attached away from the player's body center,
  120596. * such as at its head.
  120597. */
  120598. ellipsoidOffset: Vector3;
  120599. /**
  120600. * Enable or disable collisions of the camera with the rest of the scene objects.
  120601. */
  120602. checkCollisions: boolean;
  120603. /**
  120604. * Enable or disable gravity on the camera.
  120605. */
  120606. applyGravity: boolean;
  120607. /**
  120608. * Define the current direction the camera is moving to.
  120609. */
  120610. cameraDirection: Vector3;
  120611. /**
  120612. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120613. * This overrides and empties cameraRotation.
  120614. */
  120615. rotationQuaternion: Quaternion;
  120616. /**
  120617. * Track Roll to maintain the wanted Rolling when looking around.
  120618. */
  120619. _trackRoll: number;
  120620. /**
  120621. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120622. */
  120623. rollCorrect: number;
  120624. /**
  120625. * Mimic a banked turn, Rolling the camera when Yawing.
  120626. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120627. */
  120628. bankedTurn: boolean;
  120629. /**
  120630. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120631. */
  120632. bankedTurnLimit: number;
  120633. /**
  120634. * Value of 0 disables the banked Roll.
  120635. * Value of 1 is equal to the Yaw angle in radians.
  120636. */
  120637. bankedTurnMultiplier: number;
  120638. /**
  120639. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120640. */
  120641. inputs: FlyCameraInputsManager;
  120642. /**
  120643. * Gets the input sensibility for mouse input.
  120644. * Higher values reduce sensitivity.
  120645. */
  120646. get angularSensibility(): number;
  120647. /**
  120648. * Sets the input sensibility for a mouse input.
  120649. * Higher values reduce sensitivity.
  120650. */
  120651. set angularSensibility(value: number);
  120652. /**
  120653. * Get the keys for camera movement forward.
  120654. */
  120655. get keysForward(): number[];
  120656. /**
  120657. * Set the keys for camera movement forward.
  120658. */
  120659. set keysForward(value: number[]);
  120660. /**
  120661. * Get the keys for camera movement backward.
  120662. */
  120663. get keysBackward(): number[];
  120664. set keysBackward(value: number[]);
  120665. /**
  120666. * Get the keys for camera movement up.
  120667. */
  120668. get keysUp(): number[];
  120669. /**
  120670. * Set the keys for camera movement up.
  120671. */
  120672. set keysUp(value: number[]);
  120673. /**
  120674. * Get the keys for camera movement down.
  120675. */
  120676. get keysDown(): number[];
  120677. /**
  120678. * Set the keys for camera movement down.
  120679. */
  120680. set keysDown(value: number[]);
  120681. /**
  120682. * Get the keys for camera movement left.
  120683. */
  120684. get keysLeft(): number[];
  120685. /**
  120686. * Set the keys for camera movement left.
  120687. */
  120688. set keysLeft(value: number[]);
  120689. /**
  120690. * Set the keys for camera movement right.
  120691. */
  120692. get keysRight(): number[];
  120693. /**
  120694. * Set the keys for camera movement right.
  120695. */
  120696. set keysRight(value: number[]);
  120697. /**
  120698. * Event raised when the camera collides with a mesh in the scene.
  120699. */
  120700. onCollide: (collidedMesh: AbstractMesh) => void;
  120701. private _collider;
  120702. private _needMoveForGravity;
  120703. private _oldPosition;
  120704. private _diffPosition;
  120705. private _newPosition;
  120706. /** @hidden */
  120707. _localDirection: Vector3;
  120708. /** @hidden */
  120709. _transformedDirection: Vector3;
  120710. /**
  120711. * Instantiates a FlyCamera.
  120712. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120713. * such as in a 3D Space Shooter or a Flight Simulator.
  120714. * @param name Define the name of the camera in the scene.
  120715. * @param position Define the starting position of the camera in the scene.
  120716. * @param scene Define the scene the camera belongs to.
  120717. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120718. */
  120719. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120720. /**
  120721. * Attach a control to the HTML DOM element.
  120722. * @param element Defines the element that listens to the input events.
  120723. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120724. */
  120725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120726. /**
  120727. * Detach a control from the HTML DOM element.
  120728. * The camera will stop reacting to that input.
  120729. * @param element Defines the element that listens to the input events.
  120730. */
  120731. detachControl(element: HTMLElement): void;
  120732. private _collisionMask;
  120733. /**
  120734. * Get the mask that the camera ignores in collision events.
  120735. */
  120736. get collisionMask(): number;
  120737. /**
  120738. * Set the mask that the camera ignores in collision events.
  120739. */
  120740. set collisionMask(mask: number);
  120741. /** @hidden */
  120742. _collideWithWorld(displacement: Vector3): void;
  120743. /** @hidden */
  120744. private _onCollisionPositionChange;
  120745. /** @hidden */
  120746. _checkInputs(): void;
  120747. /** @hidden */
  120748. _decideIfNeedsToMove(): boolean;
  120749. /** @hidden */
  120750. _updatePosition(): void;
  120751. /**
  120752. * Restore the Roll to its target value at the rate specified.
  120753. * @param rate - Higher means slower restoring.
  120754. * @hidden
  120755. */
  120756. restoreRoll(rate: number): void;
  120757. /**
  120758. * Destroy the camera and release the current resources held by it.
  120759. */
  120760. dispose(): void;
  120761. /**
  120762. * Get the current object class name.
  120763. * @returns the class name.
  120764. */
  120765. getClassName(): string;
  120766. }
  120767. }
  120768. declare module BABYLON {
  120769. /**
  120770. * Listen to keyboard events to control the camera.
  120771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120772. */
  120773. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  120774. /**
  120775. * Defines the camera the input is attached to.
  120776. */
  120777. camera: FlyCamera;
  120778. /**
  120779. * The list of keyboard keys used to control the forward move of the camera.
  120780. */
  120781. keysForward: number[];
  120782. /**
  120783. * The list of keyboard keys used to control the backward move of the camera.
  120784. */
  120785. keysBackward: number[];
  120786. /**
  120787. * The list of keyboard keys used to control the forward move of the camera.
  120788. */
  120789. keysUp: number[];
  120790. /**
  120791. * The list of keyboard keys used to control the backward move of the camera.
  120792. */
  120793. keysDown: number[];
  120794. /**
  120795. * The list of keyboard keys used to control the right strafe move of the camera.
  120796. */
  120797. keysRight: number[];
  120798. /**
  120799. * The list of keyboard keys used to control the left strafe move of the camera.
  120800. */
  120801. keysLeft: number[];
  120802. private _keys;
  120803. private _onCanvasBlurObserver;
  120804. private _onKeyboardObserver;
  120805. private _engine;
  120806. private _scene;
  120807. /**
  120808. * Attach the input controls to a specific dom element to get the input from.
  120809. * @param element Defines the element the controls should be listened from
  120810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120811. */
  120812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120813. /**
  120814. * Detach the current controls from the specified dom element.
  120815. * @param element Defines the element to stop listening the inputs from
  120816. */
  120817. detachControl(element: Nullable<HTMLElement>): void;
  120818. /**
  120819. * Gets the class name of the current intput.
  120820. * @returns the class name
  120821. */
  120822. getClassName(): string;
  120823. /** @hidden */
  120824. _onLostFocus(e: FocusEvent): void;
  120825. /**
  120826. * Get the friendly name associated with the input class.
  120827. * @returns the input friendly name
  120828. */
  120829. getSimpleName(): string;
  120830. /**
  120831. * Update the current camera state depending on the inputs that have been used this frame.
  120832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120833. */
  120834. checkInputs(): void;
  120835. }
  120836. }
  120837. declare module BABYLON {
  120838. /**
  120839. * Manage the mouse wheel inputs to control a follow camera.
  120840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120841. */
  120842. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  120843. /**
  120844. * Defines the camera the input is attached to.
  120845. */
  120846. camera: FollowCamera;
  120847. /**
  120848. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  120849. */
  120850. axisControlRadius: boolean;
  120851. /**
  120852. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  120853. */
  120854. axisControlHeight: boolean;
  120855. /**
  120856. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  120857. */
  120858. axisControlRotation: boolean;
  120859. /**
  120860. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  120861. * relation to mouseWheel events.
  120862. */
  120863. wheelPrecision: number;
  120864. /**
  120865. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120866. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120867. */
  120868. wheelDeltaPercentage: number;
  120869. private _wheel;
  120870. private _observer;
  120871. /**
  120872. * Attach the input controls to a specific dom element to get the input from.
  120873. * @param element Defines the element the controls should be listened from
  120874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120875. */
  120876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120877. /**
  120878. * Detach the current controls from the specified dom element.
  120879. * @param element Defines the element to stop listening the inputs from
  120880. */
  120881. detachControl(element: Nullable<HTMLElement>): void;
  120882. /**
  120883. * Gets the class name of the current intput.
  120884. * @returns the class name
  120885. */
  120886. getClassName(): string;
  120887. /**
  120888. * Get the friendly name associated with the input class.
  120889. * @returns the input friendly name
  120890. */
  120891. getSimpleName(): string;
  120892. }
  120893. }
  120894. declare module BABYLON {
  120895. /**
  120896. * Manage the pointers inputs to control an follow camera.
  120897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120898. */
  120899. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  120900. /**
  120901. * Defines the camera the input is attached to.
  120902. */
  120903. camera: FollowCamera;
  120904. /**
  120905. * Gets the class name of the current input.
  120906. * @returns the class name
  120907. */
  120908. getClassName(): string;
  120909. /**
  120910. * Defines the pointer angular sensibility along the X axis or how fast is
  120911. * the camera rotating.
  120912. * A negative number will reverse the axis direction.
  120913. */
  120914. angularSensibilityX: number;
  120915. /**
  120916. * Defines the pointer angular sensibility along the Y axis or how fast is
  120917. * the camera rotating.
  120918. * A negative number will reverse the axis direction.
  120919. */
  120920. angularSensibilityY: number;
  120921. /**
  120922. * Defines the pointer pinch precision or how fast is the camera zooming.
  120923. * A negative number will reverse the axis direction.
  120924. */
  120925. pinchPrecision: number;
  120926. /**
  120927. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120928. * from 0.
  120929. * It defines the percentage of current camera.radius to use as delta when
  120930. * pinch zoom is used.
  120931. */
  120932. pinchDeltaPercentage: number;
  120933. /**
  120934. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  120935. */
  120936. axisXControlRadius: boolean;
  120937. /**
  120938. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  120939. */
  120940. axisXControlHeight: boolean;
  120941. /**
  120942. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  120943. */
  120944. axisXControlRotation: boolean;
  120945. /**
  120946. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  120947. */
  120948. axisYControlRadius: boolean;
  120949. /**
  120950. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  120951. */
  120952. axisYControlHeight: boolean;
  120953. /**
  120954. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  120955. */
  120956. axisYControlRotation: boolean;
  120957. /**
  120958. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  120959. */
  120960. axisPinchControlRadius: boolean;
  120961. /**
  120962. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  120963. */
  120964. axisPinchControlHeight: boolean;
  120965. /**
  120966. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  120967. */
  120968. axisPinchControlRotation: boolean;
  120969. /**
  120970. * Log error messages if basic misconfiguration has occurred.
  120971. */
  120972. warningEnable: boolean;
  120973. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120974. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120975. private _warningCounter;
  120976. private _warning;
  120977. }
  120978. }
  120979. declare module BABYLON {
  120980. /**
  120981. * Default Inputs manager for the FollowCamera.
  120982. * It groups all the default supported inputs for ease of use.
  120983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120984. */
  120985. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  120986. /**
  120987. * Instantiates a new FollowCameraInputsManager.
  120988. * @param camera Defines the camera the inputs belong to
  120989. */
  120990. constructor(camera: FollowCamera);
  120991. /**
  120992. * Add keyboard input support to the input manager.
  120993. * @returns the current input manager
  120994. */
  120995. addKeyboard(): FollowCameraInputsManager;
  120996. /**
  120997. * Add mouse wheel input support to the input manager.
  120998. * @returns the current input manager
  120999. */
  121000. addMouseWheel(): FollowCameraInputsManager;
  121001. /**
  121002. * Add pointers input support to the input manager.
  121003. * @returns the current input manager
  121004. */
  121005. addPointers(): FollowCameraInputsManager;
  121006. /**
  121007. * Add orientation input support to the input manager.
  121008. * @returns the current input manager
  121009. */
  121010. addVRDeviceOrientation(): FollowCameraInputsManager;
  121011. }
  121012. }
  121013. declare module BABYLON {
  121014. /**
  121015. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121016. * an arc rotate version arcFollowCamera are available.
  121017. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121018. */
  121019. export class FollowCamera extends TargetCamera {
  121020. /**
  121021. * Distance the follow camera should follow an object at
  121022. */
  121023. radius: number;
  121024. /**
  121025. * Minimum allowed distance of the camera to the axis of rotation
  121026. * (The camera can not get closer).
  121027. * This can help limiting how the Camera is able to move in the scene.
  121028. */
  121029. lowerRadiusLimit: Nullable<number>;
  121030. /**
  121031. * Maximum allowed distance of the camera to the axis of rotation
  121032. * (The camera can not get further).
  121033. * This can help limiting how the Camera is able to move in the scene.
  121034. */
  121035. upperRadiusLimit: Nullable<number>;
  121036. /**
  121037. * Define a rotation offset between the camera and the object it follows
  121038. */
  121039. rotationOffset: number;
  121040. /**
  121041. * Minimum allowed angle to camera position relative to target object.
  121042. * This can help limiting how the Camera is able to move in the scene.
  121043. */
  121044. lowerRotationOffsetLimit: Nullable<number>;
  121045. /**
  121046. * Maximum allowed angle to camera position relative to target object.
  121047. * This can help limiting how the Camera is able to move in the scene.
  121048. */
  121049. upperRotationOffsetLimit: Nullable<number>;
  121050. /**
  121051. * Define a height offset between the camera and the object it follows.
  121052. * It can help following an object from the top (like a car chaing a plane)
  121053. */
  121054. heightOffset: number;
  121055. /**
  121056. * Minimum allowed height of camera position relative to target object.
  121057. * This can help limiting how the Camera is able to move in the scene.
  121058. */
  121059. lowerHeightOffsetLimit: Nullable<number>;
  121060. /**
  121061. * Maximum allowed height of camera position relative to target object.
  121062. * This can help limiting how the Camera is able to move in the scene.
  121063. */
  121064. upperHeightOffsetLimit: Nullable<number>;
  121065. /**
  121066. * Define how fast the camera can accelerate to follow it s target.
  121067. */
  121068. cameraAcceleration: number;
  121069. /**
  121070. * Define the speed limit of the camera following an object.
  121071. */
  121072. maxCameraSpeed: number;
  121073. /**
  121074. * Define the target of the camera.
  121075. */
  121076. lockedTarget: Nullable<AbstractMesh>;
  121077. /**
  121078. * Defines the input associated with the camera.
  121079. */
  121080. inputs: FollowCameraInputsManager;
  121081. /**
  121082. * Instantiates the follow camera.
  121083. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121084. * @param name Define the name of the camera in the scene
  121085. * @param position Define the position of the camera
  121086. * @param scene Define the scene the camera belong to
  121087. * @param lockedTarget Define the target of the camera
  121088. */
  121089. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121090. private _follow;
  121091. /**
  121092. * Attached controls to the current camera.
  121093. * @param element Defines the element the controls should be listened from
  121094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121095. */
  121096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121097. /**
  121098. * Detach the current controls from the camera.
  121099. * The camera will stop reacting to inputs.
  121100. * @param element Defines the element to stop listening the inputs from
  121101. */
  121102. detachControl(element: HTMLElement): void;
  121103. /** @hidden */
  121104. _checkInputs(): void;
  121105. private _checkLimits;
  121106. /**
  121107. * Gets the camera class name.
  121108. * @returns the class name
  121109. */
  121110. getClassName(): string;
  121111. }
  121112. /**
  121113. * Arc Rotate version of the follow camera.
  121114. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121115. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121116. */
  121117. export class ArcFollowCamera extends TargetCamera {
  121118. /** The longitudinal angle of the camera */
  121119. alpha: number;
  121120. /** The latitudinal angle of the camera */
  121121. beta: number;
  121122. /** The radius of the camera from its target */
  121123. radius: number;
  121124. /** Define the camera target (the mesh it should follow) */
  121125. target: Nullable<AbstractMesh>;
  121126. private _cartesianCoordinates;
  121127. /**
  121128. * Instantiates a new ArcFollowCamera
  121129. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121130. * @param name Define the name of the camera
  121131. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121132. * @param beta Define the rotation angle of the camera around the elevation axis
  121133. * @param radius Define the radius of the camera from its target point
  121134. * @param target Define the target of the camera
  121135. * @param scene Define the scene the camera belongs to
  121136. */
  121137. constructor(name: string,
  121138. /** The longitudinal angle of the camera */
  121139. alpha: number,
  121140. /** The latitudinal angle of the camera */
  121141. beta: number,
  121142. /** The radius of the camera from its target */
  121143. radius: number,
  121144. /** Define the camera target (the mesh it should follow) */
  121145. target: Nullable<AbstractMesh>, scene: Scene);
  121146. private _follow;
  121147. /** @hidden */
  121148. _checkInputs(): void;
  121149. /**
  121150. * Returns the class name of the object.
  121151. * It is mostly used internally for serialization purposes.
  121152. */
  121153. getClassName(): string;
  121154. }
  121155. }
  121156. declare module BABYLON {
  121157. /**
  121158. * Manage the keyboard inputs to control the movement of a follow camera.
  121159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121160. */
  121161. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121162. /**
  121163. * Defines the camera the input is attached to.
  121164. */
  121165. camera: FollowCamera;
  121166. /**
  121167. * Defines the list of key codes associated with the up action (increase heightOffset)
  121168. */
  121169. keysHeightOffsetIncr: number[];
  121170. /**
  121171. * Defines the list of key codes associated with the down action (decrease heightOffset)
  121172. */
  121173. keysHeightOffsetDecr: number[];
  121174. /**
  121175. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  121176. */
  121177. keysHeightOffsetModifierAlt: boolean;
  121178. /**
  121179. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  121180. */
  121181. keysHeightOffsetModifierCtrl: boolean;
  121182. /**
  121183. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  121184. */
  121185. keysHeightOffsetModifierShift: boolean;
  121186. /**
  121187. * Defines the list of key codes associated with the left action (increase rotationOffset)
  121188. */
  121189. keysRotationOffsetIncr: number[];
  121190. /**
  121191. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  121192. */
  121193. keysRotationOffsetDecr: number[];
  121194. /**
  121195. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  121196. */
  121197. keysRotationOffsetModifierAlt: boolean;
  121198. /**
  121199. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  121200. */
  121201. keysRotationOffsetModifierCtrl: boolean;
  121202. /**
  121203. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  121204. */
  121205. keysRotationOffsetModifierShift: boolean;
  121206. /**
  121207. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  121208. */
  121209. keysRadiusIncr: number[];
  121210. /**
  121211. * Defines the list of key codes associated with the zoom-out action (increase radius)
  121212. */
  121213. keysRadiusDecr: number[];
  121214. /**
  121215. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  121216. */
  121217. keysRadiusModifierAlt: boolean;
  121218. /**
  121219. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  121220. */
  121221. keysRadiusModifierCtrl: boolean;
  121222. /**
  121223. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  121224. */
  121225. keysRadiusModifierShift: boolean;
  121226. /**
  121227. * Defines the rate of change of heightOffset.
  121228. */
  121229. heightSensibility: number;
  121230. /**
  121231. * Defines the rate of change of rotationOffset.
  121232. */
  121233. rotationSensibility: number;
  121234. /**
  121235. * Defines the rate of change of radius.
  121236. */
  121237. radiusSensibility: number;
  121238. private _keys;
  121239. private _ctrlPressed;
  121240. private _altPressed;
  121241. private _shiftPressed;
  121242. private _onCanvasBlurObserver;
  121243. private _onKeyboardObserver;
  121244. private _engine;
  121245. private _scene;
  121246. /**
  121247. * Attach the input controls to a specific dom element to get the input from.
  121248. * @param element Defines the element the controls should be listened from
  121249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121250. */
  121251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121252. /**
  121253. * Detach the current controls from the specified dom element.
  121254. * @param element Defines the element to stop listening the inputs from
  121255. */
  121256. detachControl(element: Nullable<HTMLElement>): void;
  121257. /**
  121258. * Update the current camera state depending on the inputs that have been used this frame.
  121259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121260. */
  121261. checkInputs(): void;
  121262. /**
  121263. * Gets the class name of the current input.
  121264. * @returns the class name
  121265. */
  121266. getClassName(): string;
  121267. /**
  121268. * Get the friendly name associated with the input class.
  121269. * @returns the input friendly name
  121270. */
  121271. getSimpleName(): string;
  121272. /**
  121273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121274. * allow modification of the heightOffset value.
  121275. */
  121276. private _modifierHeightOffset;
  121277. /**
  121278. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121279. * allow modification of the rotationOffset value.
  121280. */
  121281. private _modifierRotationOffset;
  121282. /**
  121283. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121284. * allow modification of the radius value.
  121285. */
  121286. private _modifierRadius;
  121287. }
  121288. }
  121289. declare module BABYLON {
  121290. interface FreeCameraInputsManager {
  121291. /**
  121292. * @hidden
  121293. */
  121294. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  121295. /**
  121296. * Add orientation input support to the input manager.
  121297. * @returns the current input manager
  121298. */
  121299. addDeviceOrientation(): FreeCameraInputsManager;
  121300. }
  121301. /**
  121302. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121303. * Screen rotation is taken into account.
  121304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121305. */
  121306. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121307. private _camera;
  121308. private _screenOrientationAngle;
  121309. private _constantTranform;
  121310. private _screenQuaternion;
  121311. private _alpha;
  121312. private _beta;
  121313. private _gamma;
  121314. /**
  121315. * Can be used to detect if a device orientation sensor is available on a device
  121316. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121317. * @returns a promise that will resolve on orientation change
  121318. */
  121319. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121320. /**
  121321. * @hidden
  121322. */
  121323. _onDeviceOrientationChangedObservable: Observable<void>;
  121324. /**
  121325. * Instantiates a new input
  121326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121327. */
  121328. constructor();
  121329. /**
  121330. * Define the camera controlled by the input.
  121331. */
  121332. get camera(): FreeCamera;
  121333. set camera(camera: FreeCamera);
  121334. /**
  121335. * Attach the input controls to a specific dom element to get the input from.
  121336. * @param element Defines the element the controls should be listened from
  121337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121338. */
  121339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121340. private _orientationChanged;
  121341. private _deviceOrientation;
  121342. /**
  121343. * Detach the current controls from the specified dom element.
  121344. * @param element Defines the element to stop listening the inputs from
  121345. */
  121346. detachControl(element: Nullable<HTMLElement>): void;
  121347. /**
  121348. * Update the current camera state depending on the inputs that have been used this frame.
  121349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121350. */
  121351. checkInputs(): void;
  121352. /**
  121353. * Gets the class name of the current intput.
  121354. * @returns the class name
  121355. */
  121356. getClassName(): string;
  121357. /**
  121358. * Get the friendly name associated with the input class.
  121359. * @returns the input friendly name
  121360. */
  121361. getSimpleName(): string;
  121362. }
  121363. }
  121364. declare module BABYLON {
  121365. /**
  121366. * Manage the gamepad inputs to control a free camera.
  121367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121368. */
  121369. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121370. /**
  121371. * Define the camera the input is attached to.
  121372. */
  121373. camera: FreeCamera;
  121374. /**
  121375. * Define the Gamepad controlling the input
  121376. */
  121377. gamepad: Nullable<Gamepad>;
  121378. /**
  121379. * Defines the gamepad rotation sensiblity.
  121380. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121381. */
  121382. gamepadAngularSensibility: number;
  121383. /**
  121384. * Defines the gamepad move sensiblity.
  121385. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121386. */
  121387. gamepadMoveSensibility: number;
  121388. private _yAxisScale;
  121389. /**
  121390. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121391. */
  121392. get invertYAxis(): boolean;
  121393. set invertYAxis(value: boolean);
  121394. private _onGamepadConnectedObserver;
  121395. private _onGamepadDisconnectedObserver;
  121396. private _cameraTransform;
  121397. private _deltaTransform;
  121398. private _vector3;
  121399. private _vector2;
  121400. /**
  121401. * Attach the input controls to a specific dom element to get the input from.
  121402. * @param element Defines the element the controls should be listened from
  121403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121404. */
  121405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121406. /**
  121407. * Detach the current controls from the specified dom element.
  121408. * @param element Defines the element to stop listening the inputs from
  121409. */
  121410. detachControl(element: Nullable<HTMLElement>): void;
  121411. /**
  121412. * Update the current camera state depending on the inputs that have been used this frame.
  121413. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121414. */
  121415. checkInputs(): void;
  121416. /**
  121417. * Gets the class name of the current intput.
  121418. * @returns the class name
  121419. */
  121420. getClassName(): string;
  121421. /**
  121422. * Get the friendly name associated with the input class.
  121423. * @returns the input friendly name
  121424. */
  121425. getSimpleName(): string;
  121426. }
  121427. }
  121428. declare module BABYLON {
  121429. /**
  121430. * Defines the potential axis of a Joystick
  121431. */
  121432. export enum JoystickAxis {
  121433. /** X axis */
  121434. X = 0,
  121435. /** Y axis */
  121436. Y = 1,
  121437. /** Z axis */
  121438. Z = 2
  121439. }
  121440. /**
  121441. * Class used to define virtual joystick (used in touch mode)
  121442. */
  121443. export class VirtualJoystick {
  121444. /**
  121445. * Gets or sets a boolean indicating that left and right values must be inverted
  121446. */
  121447. reverseLeftRight: boolean;
  121448. /**
  121449. * Gets or sets a boolean indicating that up and down values must be inverted
  121450. */
  121451. reverseUpDown: boolean;
  121452. /**
  121453. * Gets the offset value for the position (ie. the change of the position value)
  121454. */
  121455. deltaPosition: Vector3;
  121456. /**
  121457. * Gets a boolean indicating if the virtual joystick was pressed
  121458. */
  121459. pressed: boolean;
  121460. /**
  121461. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121462. */
  121463. static Canvas: Nullable<HTMLCanvasElement>;
  121464. private static _globalJoystickIndex;
  121465. private static vjCanvasContext;
  121466. private static vjCanvasWidth;
  121467. private static vjCanvasHeight;
  121468. private static halfWidth;
  121469. private _action;
  121470. private _axisTargetedByLeftAndRight;
  121471. private _axisTargetedByUpAndDown;
  121472. private _joystickSensibility;
  121473. private _inversedSensibility;
  121474. private _joystickPointerID;
  121475. private _joystickColor;
  121476. private _joystickPointerPos;
  121477. private _joystickPreviousPointerPos;
  121478. private _joystickPointerStartPos;
  121479. private _deltaJoystickVector;
  121480. private _leftJoystick;
  121481. private _touches;
  121482. private _onPointerDownHandlerRef;
  121483. private _onPointerMoveHandlerRef;
  121484. private _onPointerUpHandlerRef;
  121485. private _onResize;
  121486. /**
  121487. * Creates a new virtual joystick
  121488. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121489. */
  121490. constructor(leftJoystick?: boolean);
  121491. /**
  121492. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121493. * @param newJoystickSensibility defines the new sensibility
  121494. */
  121495. setJoystickSensibility(newJoystickSensibility: number): void;
  121496. private _onPointerDown;
  121497. private _onPointerMove;
  121498. private _onPointerUp;
  121499. /**
  121500. * Change the color of the virtual joystick
  121501. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121502. */
  121503. setJoystickColor(newColor: string): void;
  121504. /**
  121505. * Defines a callback to call when the joystick is touched
  121506. * @param action defines the callback
  121507. */
  121508. setActionOnTouch(action: () => any): void;
  121509. /**
  121510. * Defines which axis you'd like to control for left & right
  121511. * @param axis defines the axis to use
  121512. */
  121513. setAxisForLeftRight(axis: JoystickAxis): void;
  121514. /**
  121515. * Defines which axis you'd like to control for up & down
  121516. * @param axis defines the axis to use
  121517. */
  121518. setAxisForUpDown(axis: JoystickAxis): void;
  121519. private _drawVirtualJoystick;
  121520. /**
  121521. * Release internal HTML canvas
  121522. */
  121523. releaseCanvas(): void;
  121524. }
  121525. }
  121526. declare module BABYLON {
  121527. interface FreeCameraInputsManager {
  121528. /**
  121529. * Add virtual joystick input support to the input manager.
  121530. * @returns the current input manager
  121531. */
  121532. addVirtualJoystick(): FreeCameraInputsManager;
  121533. }
  121534. /**
  121535. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121537. */
  121538. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121539. /**
  121540. * Defines the camera the input is attached to.
  121541. */
  121542. camera: FreeCamera;
  121543. private _leftjoystick;
  121544. private _rightjoystick;
  121545. /**
  121546. * Gets the left stick of the virtual joystick.
  121547. * @returns The virtual Joystick
  121548. */
  121549. getLeftJoystick(): VirtualJoystick;
  121550. /**
  121551. * Gets the right stick of the virtual joystick.
  121552. * @returns The virtual Joystick
  121553. */
  121554. getRightJoystick(): VirtualJoystick;
  121555. /**
  121556. * Update the current camera state depending on the inputs that have been used this frame.
  121557. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121558. */
  121559. checkInputs(): void;
  121560. /**
  121561. * Attach the input controls to a specific dom element to get the input from.
  121562. * @param element Defines the element the controls should be listened from
  121563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121564. */
  121565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121566. /**
  121567. * Detach the current controls from the specified dom element.
  121568. * @param element Defines the element to stop listening the inputs from
  121569. */
  121570. detachControl(element: Nullable<HTMLElement>): void;
  121571. /**
  121572. * Gets the class name of the current intput.
  121573. * @returns the class name
  121574. */
  121575. getClassName(): string;
  121576. /**
  121577. * Get the friendly name associated with the input class.
  121578. * @returns the input friendly name
  121579. */
  121580. getSimpleName(): string;
  121581. }
  121582. }
  121583. declare module BABYLON {
  121584. /**
  121585. * This represents a FPS type of camera controlled by touch.
  121586. * This is like a universal camera minus the Gamepad controls.
  121587. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121588. */
  121589. export class TouchCamera extends FreeCamera {
  121590. /**
  121591. * Defines the touch sensibility for rotation.
  121592. * The higher the faster.
  121593. */
  121594. get touchAngularSensibility(): number;
  121595. set touchAngularSensibility(value: number);
  121596. /**
  121597. * Defines the touch sensibility for move.
  121598. * The higher the faster.
  121599. */
  121600. get touchMoveSensibility(): number;
  121601. set touchMoveSensibility(value: number);
  121602. /**
  121603. * Instantiates a new touch camera.
  121604. * This represents a FPS type of camera controlled by touch.
  121605. * This is like a universal camera minus the Gamepad controls.
  121606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121607. * @param name Define the name of the camera in the scene
  121608. * @param position Define the start position of the camera in the scene
  121609. * @param scene Define the scene the camera belongs to
  121610. */
  121611. constructor(name: string, position: Vector3, scene: Scene);
  121612. /**
  121613. * Gets the current object class name.
  121614. * @return the class name
  121615. */
  121616. getClassName(): string;
  121617. /** @hidden */
  121618. _setupInputs(): void;
  121619. }
  121620. }
  121621. declare module BABYLON {
  121622. /**
  121623. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121624. * being tilted forward or back and left or right.
  121625. */
  121626. export class DeviceOrientationCamera extends FreeCamera {
  121627. private _initialQuaternion;
  121628. private _quaternionCache;
  121629. private _tmpDragQuaternion;
  121630. private _disablePointerInputWhenUsingDeviceOrientation;
  121631. /**
  121632. * Creates a new device orientation camera
  121633. * @param name The name of the camera
  121634. * @param position The start position camera
  121635. * @param scene The scene the camera belongs to
  121636. */
  121637. constructor(name: string, position: Vector3, scene: Scene);
  121638. /**
  121639. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121640. */
  121641. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121642. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121643. private _dragFactor;
  121644. /**
  121645. * Enabled turning on the y axis when the orientation sensor is active
  121646. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121647. */
  121648. enableHorizontalDragging(dragFactor?: number): void;
  121649. /**
  121650. * Gets the current instance class name ("DeviceOrientationCamera").
  121651. * This helps avoiding instanceof at run time.
  121652. * @returns the class name
  121653. */
  121654. getClassName(): string;
  121655. /**
  121656. * @hidden
  121657. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  121658. */
  121659. _checkInputs(): void;
  121660. /**
  121661. * Reset the camera to its default orientation on the specified axis only.
  121662. * @param axis The axis to reset
  121663. */
  121664. resetToCurrentRotation(axis?: Axis): void;
  121665. }
  121666. }
  121667. declare module BABYLON {
  121668. /**
  121669. * Defines supported buttons for XBox360 compatible gamepads
  121670. */
  121671. export enum Xbox360Button {
  121672. /** A */
  121673. A = 0,
  121674. /** B */
  121675. B = 1,
  121676. /** X */
  121677. X = 2,
  121678. /** Y */
  121679. Y = 3,
  121680. /** Left button */
  121681. LB = 4,
  121682. /** Right button */
  121683. RB = 5,
  121684. /** Back */
  121685. Back = 8,
  121686. /** Start */
  121687. Start = 9,
  121688. /** Left stick */
  121689. LeftStick = 10,
  121690. /** Right stick */
  121691. RightStick = 11
  121692. }
  121693. /** Defines values for XBox360 DPad */
  121694. export enum Xbox360Dpad {
  121695. /** Up */
  121696. Up = 12,
  121697. /** Down */
  121698. Down = 13,
  121699. /** Left */
  121700. Left = 14,
  121701. /** Right */
  121702. Right = 15
  121703. }
  121704. /**
  121705. * Defines a XBox360 gamepad
  121706. */
  121707. export class Xbox360Pad extends Gamepad {
  121708. private _leftTrigger;
  121709. private _rightTrigger;
  121710. private _onlefttriggerchanged;
  121711. private _onrighttriggerchanged;
  121712. private _onbuttondown;
  121713. private _onbuttonup;
  121714. private _ondpaddown;
  121715. private _ondpadup;
  121716. /** Observable raised when a button is pressed */
  121717. onButtonDownObservable: Observable<Xbox360Button>;
  121718. /** Observable raised when a button is released */
  121719. onButtonUpObservable: Observable<Xbox360Button>;
  121720. /** Observable raised when a pad is pressed */
  121721. onPadDownObservable: Observable<Xbox360Dpad>;
  121722. /** Observable raised when a pad is released */
  121723. onPadUpObservable: Observable<Xbox360Dpad>;
  121724. private _buttonA;
  121725. private _buttonB;
  121726. private _buttonX;
  121727. private _buttonY;
  121728. private _buttonBack;
  121729. private _buttonStart;
  121730. private _buttonLB;
  121731. private _buttonRB;
  121732. private _buttonLeftStick;
  121733. private _buttonRightStick;
  121734. private _dPadUp;
  121735. private _dPadDown;
  121736. private _dPadLeft;
  121737. private _dPadRight;
  121738. private _isXboxOnePad;
  121739. /**
  121740. * Creates a new XBox360 gamepad object
  121741. * @param id defines the id of this gamepad
  121742. * @param index defines its index
  121743. * @param gamepad defines the internal HTML gamepad object
  121744. * @param xboxOne defines if it is a XBox One gamepad
  121745. */
  121746. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  121747. /**
  121748. * Defines the callback to call when left trigger is pressed
  121749. * @param callback defines the callback to use
  121750. */
  121751. onlefttriggerchanged(callback: (value: number) => void): void;
  121752. /**
  121753. * Defines the callback to call when right trigger is pressed
  121754. * @param callback defines the callback to use
  121755. */
  121756. onrighttriggerchanged(callback: (value: number) => void): void;
  121757. /**
  121758. * Gets the left trigger value
  121759. */
  121760. get leftTrigger(): number;
  121761. /**
  121762. * Sets the left trigger value
  121763. */
  121764. set leftTrigger(newValue: number);
  121765. /**
  121766. * Gets the right trigger value
  121767. */
  121768. get rightTrigger(): number;
  121769. /**
  121770. * Sets the right trigger value
  121771. */
  121772. set rightTrigger(newValue: number);
  121773. /**
  121774. * Defines the callback to call when a button is pressed
  121775. * @param callback defines the callback to use
  121776. */
  121777. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  121778. /**
  121779. * Defines the callback to call when a button is released
  121780. * @param callback defines the callback to use
  121781. */
  121782. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  121783. /**
  121784. * Defines the callback to call when a pad is pressed
  121785. * @param callback defines the callback to use
  121786. */
  121787. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  121788. /**
  121789. * Defines the callback to call when a pad is released
  121790. * @param callback defines the callback to use
  121791. */
  121792. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  121793. private _setButtonValue;
  121794. private _setDPadValue;
  121795. /**
  121796. * Gets the value of the `A` button
  121797. */
  121798. get buttonA(): number;
  121799. /**
  121800. * Sets the value of the `A` button
  121801. */
  121802. set buttonA(value: number);
  121803. /**
  121804. * Gets the value of the `B` button
  121805. */
  121806. get buttonB(): number;
  121807. /**
  121808. * Sets the value of the `B` button
  121809. */
  121810. set buttonB(value: number);
  121811. /**
  121812. * Gets the value of the `X` button
  121813. */
  121814. get buttonX(): number;
  121815. /**
  121816. * Sets the value of the `X` button
  121817. */
  121818. set buttonX(value: number);
  121819. /**
  121820. * Gets the value of the `Y` button
  121821. */
  121822. get buttonY(): number;
  121823. /**
  121824. * Sets the value of the `Y` button
  121825. */
  121826. set buttonY(value: number);
  121827. /**
  121828. * Gets the value of the `Start` button
  121829. */
  121830. get buttonStart(): number;
  121831. /**
  121832. * Sets the value of the `Start` button
  121833. */
  121834. set buttonStart(value: number);
  121835. /**
  121836. * Gets the value of the `Back` button
  121837. */
  121838. get buttonBack(): number;
  121839. /**
  121840. * Sets the value of the `Back` button
  121841. */
  121842. set buttonBack(value: number);
  121843. /**
  121844. * Gets the value of the `Left` button
  121845. */
  121846. get buttonLB(): number;
  121847. /**
  121848. * Sets the value of the `Left` button
  121849. */
  121850. set buttonLB(value: number);
  121851. /**
  121852. * Gets the value of the `Right` button
  121853. */
  121854. get buttonRB(): number;
  121855. /**
  121856. * Sets the value of the `Right` button
  121857. */
  121858. set buttonRB(value: number);
  121859. /**
  121860. * Gets the value of the Left joystick
  121861. */
  121862. get buttonLeftStick(): number;
  121863. /**
  121864. * Sets the value of the Left joystick
  121865. */
  121866. set buttonLeftStick(value: number);
  121867. /**
  121868. * Gets the value of the Right joystick
  121869. */
  121870. get buttonRightStick(): number;
  121871. /**
  121872. * Sets the value of the Right joystick
  121873. */
  121874. set buttonRightStick(value: number);
  121875. /**
  121876. * Gets the value of D-pad up
  121877. */
  121878. get dPadUp(): number;
  121879. /**
  121880. * Sets the value of D-pad up
  121881. */
  121882. set dPadUp(value: number);
  121883. /**
  121884. * Gets the value of D-pad down
  121885. */
  121886. get dPadDown(): number;
  121887. /**
  121888. * Sets the value of D-pad down
  121889. */
  121890. set dPadDown(value: number);
  121891. /**
  121892. * Gets the value of D-pad left
  121893. */
  121894. get dPadLeft(): number;
  121895. /**
  121896. * Sets the value of D-pad left
  121897. */
  121898. set dPadLeft(value: number);
  121899. /**
  121900. * Gets the value of D-pad right
  121901. */
  121902. get dPadRight(): number;
  121903. /**
  121904. * Sets the value of D-pad right
  121905. */
  121906. set dPadRight(value: number);
  121907. /**
  121908. * Force the gamepad to synchronize with device values
  121909. */
  121910. update(): void;
  121911. /**
  121912. * Disposes the gamepad
  121913. */
  121914. dispose(): void;
  121915. }
  121916. }
  121917. declare module BABYLON {
  121918. /**
  121919. * Defines supported buttons for DualShock compatible gamepads
  121920. */
  121921. export enum DualShockButton {
  121922. /** Cross */
  121923. Cross = 0,
  121924. /** Circle */
  121925. Circle = 1,
  121926. /** Square */
  121927. Square = 2,
  121928. /** Triangle */
  121929. Triangle = 3,
  121930. /** L1 */
  121931. L1 = 4,
  121932. /** R1 */
  121933. R1 = 5,
  121934. /** Share */
  121935. Share = 8,
  121936. /** Options */
  121937. Options = 9,
  121938. /** Left stick */
  121939. LeftStick = 10,
  121940. /** Right stick */
  121941. RightStick = 11
  121942. }
  121943. /** Defines values for DualShock DPad */
  121944. export enum DualShockDpad {
  121945. /** Up */
  121946. Up = 12,
  121947. /** Down */
  121948. Down = 13,
  121949. /** Left */
  121950. Left = 14,
  121951. /** Right */
  121952. Right = 15
  121953. }
  121954. /**
  121955. * Defines a DualShock gamepad
  121956. */
  121957. export class DualShockPad extends Gamepad {
  121958. private _leftTrigger;
  121959. private _rightTrigger;
  121960. private _onlefttriggerchanged;
  121961. private _onrighttriggerchanged;
  121962. private _onbuttondown;
  121963. private _onbuttonup;
  121964. private _ondpaddown;
  121965. private _ondpadup;
  121966. /** Observable raised when a button is pressed */
  121967. onButtonDownObservable: Observable<DualShockButton>;
  121968. /** Observable raised when a button is released */
  121969. onButtonUpObservable: Observable<DualShockButton>;
  121970. /** Observable raised when a pad is pressed */
  121971. onPadDownObservable: Observable<DualShockDpad>;
  121972. /** Observable raised when a pad is released */
  121973. onPadUpObservable: Observable<DualShockDpad>;
  121974. private _buttonCross;
  121975. private _buttonCircle;
  121976. private _buttonSquare;
  121977. private _buttonTriangle;
  121978. private _buttonShare;
  121979. private _buttonOptions;
  121980. private _buttonL1;
  121981. private _buttonR1;
  121982. private _buttonLeftStick;
  121983. private _buttonRightStick;
  121984. private _dPadUp;
  121985. private _dPadDown;
  121986. private _dPadLeft;
  121987. private _dPadRight;
  121988. /**
  121989. * Creates a new DualShock gamepad object
  121990. * @param id defines the id of this gamepad
  121991. * @param index defines its index
  121992. * @param gamepad defines the internal HTML gamepad object
  121993. */
  121994. constructor(id: string, index: number, gamepad: any);
  121995. /**
  121996. * Defines the callback to call when left trigger is pressed
  121997. * @param callback defines the callback to use
  121998. */
  121999. onlefttriggerchanged(callback: (value: number) => void): void;
  122000. /**
  122001. * Defines the callback to call when right trigger is pressed
  122002. * @param callback defines the callback to use
  122003. */
  122004. onrighttriggerchanged(callback: (value: number) => void): void;
  122005. /**
  122006. * Gets the left trigger value
  122007. */
  122008. get leftTrigger(): number;
  122009. /**
  122010. * Sets the left trigger value
  122011. */
  122012. set leftTrigger(newValue: number);
  122013. /**
  122014. * Gets the right trigger value
  122015. */
  122016. get rightTrigger(): number;
  122017. /**
  122018. * Sets the right trigger value
  122019. */
  122020. set rightTrigger(newValue: number);
  122021. /**
  122022. * Defines the callback to call when a button is pressed
  122023. * @param callback defines the callback to use
  122024. */
  122025. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122026. /**
  122027. * Defines the callback to call when a button is released
  122028. * @param callback defines the callback to use
  122029. */
  122030. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122031. /**
  122032. * Defines the callback to call when a pad is pressed
  122033. * @param callback defines the callback to use
  122034. */
  122035. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122036. /**
  122037. * Defines the callback to call when a pad is released
  122038. * @param callback defines the callback to use
  122039. */
  122040. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122041. private _setButtonValue;
  122042. private _setDPadValue;
  122043. /**
  122044. * Gets the value of the `Cross` button
  122045. */
  122046. get buttonCross(): number;
  122047. /**
  122048. * Sets the value of the `Cross` button
  122049. */
  122050. set buttonCross(value: number);
  122051. /**
  122052. * Gets the value of the `Circle` button
  122053. */
  122054. get buttonCircle(): number;
  122055. /**
  122056. * Sets the value of the `Circle` button
  122057. */
  122058. set buttonCircle(value: number);
  122059. /**
  122060. * Gets the value of the `Square` button
  122061. */
  122062. get buttonSquare(): number;
  122063. /**
  122064. * Sets the value of the `Square` button
  122065. */
  122066. set buttonSquare(value: number);
  122067. /**
  122068. * Gets the value of the `Triangle` button
  122069. */
  122070. get buttonTriangle(): number;
  122071. /**
  122072. * Sets the value of the `Triangle` button
  122073. */
  122074. set buttonTriangle(value: number);
  122075. /**
  122076. * Gets the value of the `Options` button
  122077. */
  122078. get buttonOptions(): number;
  122079. /**
  122080. * Sets the value of the `Options` button
  122081. */
  122082. set buttonOptions(value: number);
  122083. /**
  122084. * Gets the value of the `Share` button
  122085. */
  122086. get buttonShare(): number;
  122087. /**
  122088. * Sets the value of the `Share` button
  122089. */
  122090. set buttonShare(value: number);
  122091. /**
  122092. * Gets the value of the `L1` button
  122093. */
  122094. get buttonL1(): number;
  122095. /**
  122096. * Sets the value of the `L1` button
  122097. */
  122098. set buttonL1(value: number);
  122099. /**
  122100. * Gets the value of the `R1` button
  122101. */
  122102. get buttonR1(): number;
  122103. /**
  122104. * Sets the value of the `R1` button
  122105. */
  122106. set buttonR1(value: number);
  122107. /**
  122108. * Gets the value of the Left joystick
  122109. */
  122110. get buttonLeftStick(): number;
  122111. /**
  122112. * Sets the value of the Left joystick
  122113. */
  122114. set buttonLeftStick(value: number);
  122115. /**
  122116. * Gets the value of the Right joystick
  122117. */
  122118. get buttonRightStick(): number;
  122119. /**
  122120. * Sets the value of the Right joystick
  122121. */
  122122. set buttonRightStick(value: number);
  122123. /**
  122124. * Gets the value of D-pad up
  122125. */
  122126. get dPadUp(): number;
  122127. /**
  122128. * Sets the value of D-pad up
  122129. */
  122130. set dPadUp(value: number);
  122131. /**
  122132. * Gets the value of D-pad down
  122133. */
  122134. get dPadDown(): number;
  122135. /**
  122136. * Sets the value of D-pad down
  122137. */
  122138. set dPadDown(value: number);
  122139. /**
  122140. * Gets the value of D-pad left
  122141. */
  122142. get dPadLeft(): number;
  122143. /**
  122144. * Sets the value of D-pad left
  122145. */
  122146. set dPadLeft(value: number);
  122147. /**
  122148. * Gets the value of D-pad right
  122149. */
  122150. get dPadRight(): number;
  122151. /**
  122152. * Sets the value of D-pad right
  122153. */
  122154. set dPadRight(value: number);
  122155. /**
  122156. * Force the gamepad to synchronize with device values
  122157. */
  122158. update(): void;
  122159. /**
  122160. * Disposes the gamepad
  122161. */
  122162. dispose(): void;
  122163. }
  122164. }
  122165. declare module BABYLON {
  122166. /**
  122167. * Manager for handling gamepads
  122168. */
  122169. export class GamepadManager {
  122170. private _scene?;
  122171. private _babylonGamepads;
  122172. private _oneGamepadConnected;
  122173. /** @hidden */
  122174. _isMonitoring: boolean;
  122175. private _gamepadEventSupported;
  122176. private _gamepadSupport?;
  122177. /**
  122178. * observable to be triggered when the gamepad controller has been connected
  122179. */
  122180. onGamepadConnectedObservable: Observable<Gamepad>;
  122181. /**
  122182. * observable to be triggered when the gamepad controller has been disconnected
  122183. */
  122184. onGamepadDisconnectedObservable: Observable<Gamepad>;
  122185. private _onGamepadConnectedEvent;
  122186. private _onGamepadDisconnectedEvent;
  122187. /**
  122188. * Initializes the gamepad manager
  122189. * @param _scene BabylonJS scene
  122190. */
  122191. constructor(_scene?: Scene | undefined);
  122192. /**
  122193. * The gamepads in the game pad manager
  122194. */
  122195. get gamepads(): Gamepad[];
  122196. /**
  122197. * Get the gamepad controllers based on type
  122198. * @param type The type of gamepad controller
  122199. * @returns Nullable gamepad
  122200. */
  122201. getGamepadByType(type?: number): Nullable<Gamepad>;
  122202. /**
  122203. * Disposes the gamepad manager
  122204. */
  122205. dispose(): void;
  122206. private _addNewGamepad;
  122207. private _startMonitoringGamepads;
  122208. private _stopMonitoringGamepads;
  122209. /** @hidden */
  122210. _checkGamepadsStatus(): void;
  122211. private _updateGamepadObjects;
  122212. }
  122213. }
  122214. declare module BABYLON {
  122215. interface Scene {
  122216. /** @hidden */
  122217. _gamepadManager: Nullable<GamepadManager>;
  122218. /**
  122219. * Gets the gamepad manager associated with the scene
  122220. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  122221. */
  122222. gamepadManager: GamepadManager;
  122223. }
  122224. /**
  122225. * Interface representing a free camera inputs manager
  122226. */
  122227. interface FreeCameraInputsManager {
  122228. /**
  122229. * Adds gamepad input support to the FreeCameraInputsManager.
  122230. * @returns the FreeCameraInputsManager
  122231. */
  122232. addGamepad(): FreeCameraInputsManager;
  122233. }
  122234. /**
  122235. * Interface representing an arc rotate camera inputs manager
  122236. */
  122237. interface ArcRotateCameraInputsManager {
  122238. /**
  122239. * Adds gamepad input support to the ArcRotateCamera InputManager.
  122240. * @returns the camera inputs manager
  122241. */
  122242. addGamepad(): ArcRotateCameraInputsManager;
  122243. }
  122244. /**
  122245. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  122246. */
  122247. export class GamepadSystemSceneComponent implements ISceneComponent {
  122248. /**
  122249. * The component name helpfull to identify the component in the list of scene components.
  122250. */
  122251. readonly name: string;
  122252. /**
  122253. * The scene the component belongs to.
  122254. */
  122255. scene: Scene;
  122256. /**
  122257. * Creates a new instance of the component for the given scene
  122258. * @param scene Defines the scene to register the component in
  122259. */
  122260. constructor(scene: Scene);
  122261. /**
  122262. * Registers the component in a given scene
  122263. */
  122264. register(): void;
  122265. /**
  122266. * Rebuilds the elements related to this component in case of
  122267. * context lost for instance.
  122268. */
  122269. rebuild(): void;
  122270. /**
  122271. * Disposes the component and the associated ressources
  122272. */
  122273. dispose(): void;
  122274. private _beforeCameraUpdate;
  122275. }
  122276. }
  122277. declare module BABYLON {
  122278. /**
  122279. * 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,
  122280. * which still works and will still be found in many Playgrounds.
  122281. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122282. */
  122283. export class UniversalCamera extends TouchCamera {
  122284. /**
  122285. * Defines the gamepad rotation sensiblity.
  122286. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122287. */
  122288. get gamepadAngularSensibility(): number;
  122289. set gamepadAngularSensibility(value: number);
  122290. /**
  122291. * Defines the gamepad move sensiblity.
  122292. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122293. */
  122294. get gamepadMoveSensibility(): number;
  122295. set gamepadMoveSensibility(value: number);
  122296. /**
  122297. * 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,
  122298. * which still works and will still be found in many Playgrounds.
  122299. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122300. * @param name Define the name of the camera in the scene
  122301. * @param position Define the start position of the camera in the scene
  122302. * @param scene Define the scene the camera belongs to
  122303. */
  122304. constructor(name: string, position: Vector3, scene: Scene);
  122305. /**
  122306. * Gets the current object class name.
  122307. * @return the class name
  122308. */
  122309. getClassName(): string;
  122310. }
  122311. }
  122312. declare module BABYLON {
  122313. /**
  122314. * This represents a FPS type of camera. This is only here for back compat purpose.
  122315. * Please use the UniversalCamera instead as both are identical.
  122316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122317. */
  122318. export class GamepadCamera extends UniversalCamera {
  122319. /**
  122320. * Instantiates a new Gamepad Camera
  122321. * This represents a FPS type of camera. This is only here for back compat purpose.
  122322. * Please use the UniversalCamera instead as both are identical.
  122323. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122324. * @param name Define the name of the camera in the scene
  122325. * @param position Define the start position of the camera in the scene
  122326. * @param scene Define the scene the camera belongs to
  122327. */
  122328. constructor(name: string, position: Vector3, scene: Scene);
  122329. /**
  122330. * Gets the current object class name.
  122331. * @return the class name
  122332. */
  122333. getClassName(): string;
  122334. }
  122335. }
  122336. declare module BABYLON {
  122337. /** @hidden */
  122338. export var passPixelShader: {
  122339. name: string;
  122340. shader: string;
  122341. };
  122342. }
  122343. declare module BABYLON {
  122344. /** @hidden */
  122345. export var passCubePixelShader: {
  122346. name: string;
  122347. shader: string;
  122348. };
  122349. }
  122350. declare module BABYLON {
  122351. /**
  122352. * PassPostProcess which produces an output the same as it's input
  122353. */
  122354. export class PassPostProcess extends PostProcess {
  122355. /**
  122356. * Creates the PassPostProcess
  122357. * @param name The name of the effect.
  122358. * @param options The required width/height ratio to downsize to before computing the render pass.
  122359. * @param camera The camera to apply the render pass to.
  122360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122361. * @param engine The engine which the post process will be applied. (default: current engine)
  122362. * @param reusable If the post process can be reused on the same frame. (default: false)
  122363. * @param textureType The type of texture to be used when performing the post processing.
  122364. * @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)
  122365. */
  122366. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122367. }
  122368. /**
  122369. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122370. */
  122371. export class PassCubePostProcess extends PostProcess {
  122372. private _face;
  122373. /**
  122374. * Gets or sets the cube face to display.
  122375. * * 0 is +X
  122376. * * 1 is -X
  122377. * * 2 is +Y
  122378. * * 3 is -Y
  122379. * * 4 is +Z
  122380. * * 5 is -Z
  122381. */
  122382. get face(): number;
  122383. set face(value: number);
  122384. /**
  122385. * Creates the PassCubePostProcess
  122386. * @param name The name of the effect.
  122387. * @param options The required width/height ratio to downsize to before computing the render pass.
  122388. * @param camera The camera to apply the render pass to.
  122389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122390. * @param engine The engine which the post process will be applied. (default: current engine)
  122391. * @param reusable If the post process can be reused on the same frame. (default: false)
  122392. * @param textureType The type of texture to be used when performing the post processing.
  122393. * @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)
  122394. */
  122395. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122396. }
  122397. }
  122398. declare module BABYLON {
  122399. /** @hidden */
  122400. export var anaglyphPixelShader: {
  122401. name: string;
  122402. shader: string;
  122403. };
  122404. }
  122405. declare module BABYLON {
  122406. /**
  122407. * Postprocess used to generate anaglyphic rendering
  122408. */
  122409. export class AnaglyphPostProcess extends PostProcess {
  122410. private _passedProcess;
  122411. /**
  122412. * Creates a new AnaglyphPostProcess
  122413. * @param name defines postprocess name
  122414. * @param options defines creation options or target ratio scale
  122415. * @param rigCameras defines cameras using this postprocess
  122416. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122417. * @param engine defines hosting engine
  122418. * @param reusable defines if the postprocess will be reused multiple times per frame
  122419. */
  122420. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122421. }
  122422. }
  122423. declare module BABYLON {
  122424. /**
  122425. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122426. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122427. */
  122428. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122429. /**
  122430. * Creates a new AnaglyphArcRotateCamera
  122431. * @param name defines camera name
  122432. * @param alpha defines alpha angle (in radians)
  122433. * @param beta defines beta angle (in radians)
  122434. * @param radius defines radius
  122435. * @param target defines camera target
  122436. * @param interaxialDistance defines distance between each color axis
  122437. * @param scene defines the hosting scene
  122438. */
  122439. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122440. /**
  122441. * Gets camera class name
  122442. * @returns AnaglyphArcRotateCamera
  122443. */
  122444. getClassName(): string;
  122445. }
  122446. }
  122447. declare module BABYLON {
  122448. /**
  122449. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122450. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122451. */
  122452. export class AnaglyphFreeCamera extends FreeCamera {
  122453. /**
  122454. * Creates a new AnaglyphFreeCamera
  122455. * @param name defines camera name
  122456. * @param position defines initial position
  122457. * @param interaxialDistance defines distance between each color axis
  122458. * @param scene defines the hosting scene
  122459. */
  122460. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122461. /**
  122462. * Gets camera class name
  122463. * @returns AnaglyphFreeCamera
  122464. */
  122465. getClassName(): string;
  122466. }
  122467. }
  122468. declare module BABYLON {
  122469. /**
  122470. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122471. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122472. */
  122473. export class AnaglyphGamepadCamera extends GamepadCamera {
  122474. /**
  122475. * Creates a new AnaglyphGamepadCamera
  122476. * @param name defines camera name
  122477. * @param position defines initial position
  122478. * @param interaxialDistance defines distance between each color axis
  122479. * @param scene defines the hosting scene
  122480. */
  122481. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122482. /**
  122483. * Gets camera class name
  122484. * @returns AnaglyphGamepadCamera
  122485. */
  122486. getClassName(): string;
  122487. }
  122488. }
  122489. declare module BABYLON {
  122490. /**
  122491. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122492. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122493. */
  122494. export class AnaglyphUniversalCamera extends UniversalCamera {
  122495. /**
  122496. * Creates a new AnaglyphUniversalCamera
  122497. * @param name defines camera name
  122498. * @param position defines initial position
  122499. * @param interaxialDistance defines distance between each color axis
  122500. * @param scene defines the hosting scene
  122501. */
  122502. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122503. /**
  122504. * Gets camera class name
  122505. * @returns AnaglyphUniversalCamera
  122506. */
  122507. getClassName(): string;
  122508. }
  122509. }
  122510. declare module BABYLON {
  122511. /**
  122512. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122513. * @see http://doc.babylonjs.com/features/cameras
  122514. */
  122515. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122516. /**
  122517. * Creates a new StereoscopicArcRotateCamera
  122518. * @param name defines camera name
  122519. * @param alpha defines alpha angle (in radians)
  122520. * @param beta defines beta angle (in radians)
  122521. * @param radius defines radius
  122522. * @param target defines camera target
  122523. * @param interaxialDistance defines distance between each color axis
  122524. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122525. * @param scene defines the hosting scene
  122526. */
  122527. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122528. /**
  122529. * Gets camera class name
  122530. * @returns StereoscopicArcRotateCamera
  122531. */
  122532. getClassName(): string;
  122533. }
  122534. }
  122535. declare module BABYLON {
  122536. /**
  122537. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122538. * @see http://doc.babylonjs.com/features/cameras
  122539. */
  122540. export class StereoscopicFreeCamera extends FreeCamera {
  122541. /**
  122542. * Creates a new StereoscopicFreeCamera
  122543. * @param name defines camera name
  122544. * @param position defines initial position
  122545. * @param interaxialDistance defines distance between each color axis
  122546. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122547. * @param scene defines the hosting scene
  122548. */
  122549. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122550. /**
  122551. * Gets camera class name
  122552. * @returns StereoscopicFreeCamera
  122553. */
  122554. getClassName(): string;
  122555. }
  122556. }
  122557. declare module BABYLON {
  122558. /**
  122559. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122560. * @see http://doc.babylonjs.com/features/cameras
  122561. */
  122562. export class StereoscopicGamepadCamera extends GamepadCamera {
  122563. /**
  122564. * Creates a new StereoscopicGamepadCamera
  122565. * @param name defines camera name
  122566. * @param position defines initial position
  122567. * @param interaxialDistance defines distance between each color axis
  122568. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122569. * @param scene defines the hosting scene
  122570. */
  122571. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122572. /**
  122573. * Gets camera class name
  122574. * @returns StereoscopicGamepadCamera
  122575. */
  122576. getClassName(): string;
  122577. }
  122578. }
  122579. declare module BABYLON {
  122580. /**
  122581. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122582. * @see http://doc.babylonjs.com/features/cameras
  122583. */
  122584. export class StereoscopicUniversalCamera extends UniversalCamera {
  122585. /**
  122586. * Creates a new StereoscopicUniversalCamera
  122587. * @param name defines camera name
  122588. * @param position defines initial position
  122589. * @param interaxialDistance defines distance between each color axis
  122590. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122591. * @param scene defines the hosting scene
  122592. */
  122593. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122594. /**
  122595. * Gets camera class name
  122596. * @returns StereoscopicUniversalCamera
  122597. */
  122598. getClassName(): string;
  122599. }
  122600. }
  122601. declare module BABYLON {
  122602. /**
  122603. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122604. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122605. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122606. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122607. */
  122608. export class VirtualJoysticksCamera extends FreeCamera {
  122609. /**
  122610. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122611. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122612. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122613. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122614. * @param name Define the name of the camera in the scene
  122615. * @param position Define the start position of the camera in the scene
  122616. * @param scene Define the scene the camera belongs to
  122617. */
  122618. constructor(name: string, position: Vector3, scene: Scene);
  122619. /**
  122620. * Gets the current object class name.
  122621. * @return the class name
  122622. */
  122623. getClassName(): string;
  122624. }
  122625. }
  122626. declare module BABYLON {
  122627. /**
  122628. * This represents all the required metrics to create a VR camera.
  122629. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122630. */
  122631. export class VRCameraMetrics {
  122632. /**
  122633. * Define the horizontal resolution off the screen.
  122634. */
  122635. hResolution: number;
  122636. /**
  122637. * Define the vertical resolution off the screen.
  122638. */
  122639. vResolution: number;
  122640. /**
  122641. * Define the horizontal screen size.
  122642. */
  122643. hScreenSize: number;
  122644. /**
  122645. * Define the vertical screen size.
  122646. */
  122647. vScreenSize: number;
  122648. /**
  122649. * Define the vertical screen center position.
  122650. */
  122651. vScreenCenter: number;
  122652. /**
  122653. * Define the distance of the eyes to the screen.
  122654. */
  122655. eyeToScreenDistance: number;
  122656. /**
  122657. * Define the distance between both lenses
  122658. */
  122659. lensSeparationDistance: number;
  122660. /**
  122661. * Define the distance between both viewer's eyes.
  122662. */
  122663. interpupillaryDistance: number;
  122664. /**
  122665. * Define the distortion factor of the VR postprocess.
  122666. * Please, touch with care.
  122667. */
  122668. distortionK: number[];
  122669. /**
  122670. * Define the chromatic aberration correction factors for the VR post process.
  122671. */
  122672. chromaAbCorrection: number[];
  122673. /**
  122674. * Define the scale factor of the post process.
  122675. * The smaller the better but the slower.
  122676. */
  122677. postProcessScaleFactor: number;
  122678. /**
  122679. * Define an offset for the lens center.
  122680. */
  122681. lensCenterOffset: number;
  122682. /**
  122683. * Define if the current vr camera should compensate the distortion of the lense or not.
  122684. */
  122685. compensateDistortion: boolean;
  122686. /**
  122687. * Defines if multiview should be enabled when rendering (Default: false)
  122688. */
  122689. multiviewEnabled: boolean;
  122690. /**
  122691. * Gets the rendering aspect ratio based on the provided resolutions.
  122692. */
  122693. get aspectRatio(): number;
  122694. /**
  122695. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122696. */
  122697. get aspectRatioFov(): number;
  122698. /**
  122699. * @hidden
  122700. */
  122701. get leftHMatrix(): Matrix;
  122702. /**
  122703. * @hidden
  122704. */
  122705. get rightHMatrix(): Matrix;
  122706. /**
  122707. * @hidden
  122708. */
  122709. get leftPreViewMatrix(): Matrix;
  122710. /**
  122711. * @hidden
  122712. */
  122713. get rightPreViewMatrix(): Matrix;
  122714. /**
  122715. * Get the default VRMetrics based on the most generic setup.
  122716. * @returns the default vr metrics
  122717. */
  122718. static GetDefault(): VRCameraMetrics;
  122719. }
  122720. }
  122721. declare module BABYLON {
  122722. /** @hidden */
  122723. export var vrDistortionCorrectionPixelShader: {
  122724. name: string;
  122725. shader: string;
  122726. };
  122727. }
  122728. declare module BABYLON {
  122729. /**
  122730. * VRDistortionCorrectionPostProcess used for mobile VR
  122731. */
  122732. export class VRDistortionCorrectionPostProcess extends PostProcess {
  122733. private _isRightEye;
  122734. private _distortionFactors;
  122735. private _postProcessScaleFactor;
  122736. private _lensCenterOffset;
  122737. private _scaleIn;
  122738. private _scaleFactor;
  122739. private _lensCenter;
  122740. /**
  122741. * Initializes the VRDistortionCorrectionPostProcess
  122742. * @param name The name of the effect.
  122743. * @param camera The camera to apply the render pass to.
  122744. * @param isRightEye If this is for the right eye distortion
  122745. * @param vrMetrics All the required metrics for the VR camera
  122746. */
  122747. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  122748. }
  122749. }
  122750. declare module BABYLON {
  122751. /**
  122752. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  122753. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122754. */
  122755. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  122756. /**
  122757. * Creates a new VRDeviceOrientationArcRotateCamera
  122758. * @param name defines camera name
  122759. * @param alpha defines the camera rotation along the logitudinal axis
  122760. * @param beta defines the camera rotation along the latitudinal axis
  122761. * @param radius defines the camera distance from its target
  122762. * @param target defines the camera target
  122763. * @param scene defines the scene the camera belongs to
  122764. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122765. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122766. */
  122767. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122768. /**
  122769. * Gets camera class name
  122770. * @returns VRDeviceOrientationArcRotateCamera
  122771. */
  122772. getClassName(): string;
  122773. }
  122774. }
  122775. declare module BABYLON {
  122776. /**
  122777. * Camera used to simulate VR rendering (based on FreeCamera)
  122778. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122779. */
  122780. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  122781. /**
  122782. * Creates a new VRDeviceOrientationFreeCamera
  122783. * @param name defines camera name
  122784. * @param position defines the start position of the camera
  122785. * @param scene defines the scene the camera belongs to
  122786. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122787. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122788. */
  122789. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122790. /**
  122791. * Gets camera class name
  122792. * @returns VRDeviceOrientationFreeCamera
  122793. */
  122794. getClassName(): string;
  122795. }
  122796. }
  122797. declare module BABYLON {
  122798. /**
  122799. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  122800. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  122801. */
  122802. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  122803. /**
  122804. * Creates a new VRDeviceOrientationGamepadCamera
  122805. * @param name defines camera name
  122806. * @param position defines the start position of the camera
  122807. * @param scene defines the scene the camera belongs to
  122808. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  122809. * @param vrCameraMetrics defines the vr metrics associated to the camera
  122810. */
  122811. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  122812. /**
  122813. * Gets camera class name
  122814. * @returns VRDeviceOrientationGamepadCamera
  122815. */
  122816. getClassName(): string;
  122817. }
  122818. }
  122819. declare module BABYLON {
  122820. /** @hidden */
  122821. export var imageProcessingPixelShader: {
  122822. name: string;
  122823. shader: string;
  122824. };
  122825. }
  122826. declare module BABYLON {
  122827. /**
  122828. * ImageProcessingPostProcess
  122829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  122830. */
  122831. export class ImageProcessingPostProcess extends PostProcess {
  122832. /**
  122833. * Default configuration related to image processing available in the PBR Material.
  122834. */
  122835. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122836. /**
  122837. * Gets the image processing configuration used either in this material.
  122838. */
  122839. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122840. /**
  122841. * Sets the Default image processing configuration used either in the this material.
  122842. *
  122843. * If sets to null, the scene one is in use.
  122844. */
  122845. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122846. /**
  122847. * Keep track of the image processing observer to allow dispose and replace.
  122848. */
  122849. private _imageProcessingObserver;
  122850. /**
  122851. * Attaches a new image processing configuration to the PBR Material.
  122852. * @param configuration
  122853. */
  122854. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  122855. /**
  122856. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122857. */
  122858. get colorCurves(): Nullable<ColorCurves>;
  122859. /**
  122860. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  122861. */
  122862. set colorCurves(value: Nullable<ColorCurves>);
  122863. /**
  122864. * Gets wether the color curves effect is enabled.
  122865. */
  122866. get colorCurvesEnabled(): boolean;
  122867. /**
  122868. * Sets wether the color curves effect is enabled.
  122869. */
  122870. set colorCurvesEnabled(value: boolean);
  122871. /**
  122872. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122873. */
  122874. get colorGradingTexture(): Nullable<BaseTexture>;
  122875. /**
  122876. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  122877. */
  122878. set colorGradingTexture(value: Nullable<BaseTexture>);
  122879. /**
  122880. * Gets wether the color grading effect is enabled.
  122881. */
  122882. get colorGradingEnabled(): boolean;
  122883. /**
  122884. * Gets wether the color grading effect is enabled.
  122885. */
  122886. set colorGradingEnabled(value: boolean);
  122887. /**
  122888. * Gets exposure used in the effect.
  122889. */
  122890. get exposure(): number;
  122891. /**
  122892. * Sets exposure used in the effect.
  122893. */
  122894. set exposure(value: number);
  122895. /**
  122896. * Gets wether tonemapping is enabled or not.
  122897. */
  122898. get toneMappingEnabled(): boolean;
  122899. /**
  122900. * Sets wether tonemapping is enabled or not
  122901. */
  122902. set toneMappingEnabled(value: boolean);
  122903. /**
  122904. * Gets the type of tone mapping effect.
  122905. */
  122906. get toneMappingType(): number;
  122907. /**
  122908. * Sets the type of tone mapping effect.
  122909. */
  122910. set toneMappingType(value: number);
  122911. /**
  122912. * Gets contrast used in the effect.
  122913. */
  122914. get contrast(): number;
  122915. /**
  122916. * Sets contrast used in the effect.
  122917. */
  122918. set contrast(value: number);
  122919. /**
  122920. * Gets Vignette stretch size.
  122921. */
  122922. get vignetteStretch(): number;
  122923. /**
  122924. * Sets Vignette stretch size.
  122925. */
  122926. set vignetteStretch(value: number);
  122927. /**
  122928. * Gets Vignette centre X Offset.
  122929. */
  122930. get vignetteCentreX(): number;
  122931. /**
  122932. * Sets Vignette centre X Offset.
  122933. */
  122934. set vignetteCentreX(value: number);
  122935. /**
  122936. * Gets Vignette centre Y Offset.
  122937. */
  122938. get vignetteCentreY(): number;
  122939. /**
  122940. * Sets Vignette centre Y Offset.
  122941. */
  122942. set vignetteCentreY(value: number);
  122943. /**
  122944. * Gets Vignette weight or intensity of the vignette effect.
  122945. */
  122946. get vignetteWeight(): number;
  122947. /**
  122948. * Sets Vignette weight or intensity of the vignette effect.
  122949. */
  122950. set vignetteWeight(value: number);
  122951. /**
  122952. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122953. * if vignetteEnabled is set to true.
  122954. */
  122955. get vignetteColor(): Color4;
  122956. /**
  122957. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  122958. * if vignetteEnabled is set to true.
  122959. */
  122960. set vignetteColor(value: Color4);
  122961. /**
  122962. * Gets Camera field of view used by the Vignette effect.
  122963. */
  122964. get vignetteCameraFov(): number;
  122965. /**
  122966. * Sets Camera field of view used by the Vignette effect.
  122967. */
  122968. set vignetteCameraFov(value: number);
  122969. /**
  122970. * Gets the vignette blend mode allowing different kind of effect.
  122971. */
  122972. get vignetteBlendMode(): number;
  122973. /**
  122974. * Sets the vignette blend mode allowing different kind of effect.
  122975. */
  122976. set vignetteBlendMode(value: number);
  122977. /**
  122978. * Gets wether the vignette effect is enabled.
  122979. */
  122980. get vignetteEnabled(): boolean;
  122981. /**
  122982. * Sets wether the vignette effect is enabled.
  122983. */
  122984. set vignetteEnabled(value: boolean);
  122985. private _fromLinearSpace;
  122986. /**
  122987. * Gets wether the input of the processing is in Gamma or Linear Space.
  122988. */
  122989. get fromLinearSpace(): boolean;
  122990. /**
  122991. * Sets wether the input of the processing is in Gamma or Linear Space.
  122992. */
  122993. set fromLinearSpace(value: boolean);
  122994. /**
  122995. * Defines cache preventing GC.
  122996. */
  122997. private _defines;
  122998. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  122999. /**
  123000. * "ImageProcessingPostProcess"
  123001. * @returns "ImageProcessingPostProcess"
  123002. */
  123003. getClassName(): string;
  123004. protected _updateParameters(): void;
  123005. dispose(camera?: Camera): void;
  123006. }
  123007. }
  123008. declare module BABYLON {
  123009. /**
  123010. * Class containing static functions to help procedurally build meshes
  123011. */
  123012. export class GroundBuilder {
  123013. /**
  123014. * Creates a ground mesh
  123015. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123016. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123018. * @param name defines the name of the mesh
  123019. * @param options defines the options used to create the mesh
  123020. * @param scene defines the hosting scene
  123021. * @returns the ground mesh
  123022. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123023. */
  123024. static CreateGround(name: string, options: {
  123025. width?: number;
  123026. height?: number;
  123027. subdivisions?: number;
  123028. subdivisionsX?: number;
  123029. subdivisionsY?: number;
  123030. updatable?: boolean;
  123031. }, scene: any): Mesh;
  123032. /**
  123033. * Creates a tiled ground mesh
  123034. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123035. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123036. * * 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
  123037. * * 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
  123038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123039. * @param name defines the name of the mesh
  123040. * @param options defines the options used to create the mesh
  123041. * @param scene defines the hosting scene
  123042. * @returns the tiled ground mesh
  123043. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123044. */
  123045. static CreateTiledGround(name: string, options: {
  123046. xmin: number;
  123047. zmin: number;
  123048. xmax: number;
  123049. zmax: number;
  123050. subdivisions?: {
  123051. w: number;
  123052. h: number;
  123053. };
  123054. precision?: {
  123055. w: number;
  123056. h: number;
  123057. };
  123058. updatable?: boolean;
  123059. }, scene?: Nullable<Scene>): Mesh;
  123060. /**
  123061. * Creates a ground mesh from a height map
  123062. * * The parameter `url` sets the URL of the height map image resource.
  123063. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123064. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123065. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123066. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123067. * * 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.
  123068. * * 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).
  123069. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123071. * @param name defines the name of the mesh
  123072. * @param url defines the url to the height map
  123073. * @param options defines the options used to create the mesh
  123074. * @param scene defines the hosting scene
  123075. * @returns the ground mesh
  123076. * @see https://doc.babylonjs.com/babylon101/height_map
  123077. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123078. */
  123079. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123080. width?: number;
  123081. height?: number;
  123082. subdivisions?: number;
  123083. minHeight?: number;
  123084. maxHeight?: number;
  123085. colorFilter?: Color3;
  123086. alphaFilter?: number;
  123087. updatable?: boolean;
  123088. onReady?: (mesh: GroundMesh) => void;
  123089. }, scene?: Nullable<Scene>): GroundMesh;
  123090. }
  123091. }
  123092. declare module BABYLON {
  123093. /**
  123094. * Class containing static functions to help procedurally build meshes
  123095. */
  123096. export class TorusBuilder {
  123097. /**
  123098. * Creates a torus mesh
  123099. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123100. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123101. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123105. * @param name defines the name of the mesh
  123106. * @param options defines the options used to create the mesh
  123107. * @param scene defines the hosting scene
  123108. * @returns the torus mesh
  123109. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123110. */
  123111. static CreateTorus(name: string, options: {
  123112. diameter?: number;
  123113. thickness?: number;
  123114. tessellation?: number;
  123115. updatable?: boolean;
  123116. sideOrientation?: number;
  123117. frontUVs?: Vector4;
  123118. backUVs?: Vector4;
  123119. }, scene: any): Mesh;
  123120. }
  123121. }
  123122. declare module BABYLON {
  123123. /**
  123124. * Class containing static functions to help procedurally build meshes
  123125. */
  123126. export class CylinderBuilder {
  123127. /**
  123128. * Creates a cylinder or a cone mesh
  123129. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123130. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123131. * * 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.
  123132. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123133. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123134. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123135. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123136. * * 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).
  123137. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123138. * * 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).
  123139. * * 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
  123140. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123141. * * 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
  123142. * * 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.
  123143. * * If `enclose` is false, a ring surface is one element.
  123144. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123145. * * 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
  123146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123149. * @param name defines the name of the mesh
  123150. * @param options defines the options used to create the mesh
  123151. * @param scene defines the hosting scene
  123152. * @returns the cylinder mesh
  123153. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123154. */
  123155. static CreateCylinder(name: string, options: {
  123156. height?: number;
  123157. diameterTop?: number;
  123158. diameterBottom?: number;
  123159. diameter?: number;
  123160. tessellation?: number;
  123161. subdivisions?: number;
  123162. arc?: number;
  123163. faceColors?: Color4[];
  123164. faceUV?: Vector4[];
  123165. updatable?: boolean;
  123166. hasRings?: boolean;
  123167. enclose?: boolean;
  123168. cap?: number;
  123169. sideOrientation?: number;
  123170. frontUVs?: Vector4;
  123171. backUVs?: Vector4;
  123172. }, scene: any): Mesh;
  123173. }
  123174. }
  123175. declare module BABYLON {
  123176. /**
  123177. * States of the webXR experience
  123178. */
  123179. export enum WebXRState {
  123180. /**
  123181. * Transitioning to being in XR mode
  123182. */
  123183. ENTERING_XR = 0,
  123184. /**
  123185. * Transitioning to non XR mode
  123186. */
  123187. EXITING_XR = 1,
  123188. /**
  123189. * In XR mode and presenting
  123190. */
  123191. IN_XR = 2,
  123192. /**
  123193. * Not entered XR mode
  123194. */
  123195. NOT_IN_XR = 3
  123196. }
  123197. /**
  123198. * Abstraction of the XR render target
  123199. */
  123200. export interface WebXRRenderTarget extends IDisposable {
  123201. /**
  123202. * xrpresent context of the canvas which can be used to display/mirror xr content
  123203. */
  123204. canvasContext: WebGLRenderingContext;
  123205. /**
  123206. * xr layer for the canvas
  123207. */
  123208. xrLayer: Nullable<XRWebGLLayer>;
  123209. /**
  123210. * Initializes the xr layer for the session
  123211. * @param xrSession xr session
  123212. * @returns a promise that will resolve once the XR Layer has been created
  123213. */
  123214. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123215. }
  123216. }
  123217. declare module BABYLON {
  123218. /**
  123219. * COnfiguration object for WebXR output canvas
  123220. */
  123221. export class WebXRManagedOutputCanvasOptions {
  123222. /**
  123223. * An optional canvas in case you wish to create it yourself and provide it here.
  123224. * If not provided, a new canvas will be created
  123225. */
  123226. canvasElement?: HTMLCanvasElement;
  123227. /**
  123228. * Options for this XR Layer output
  123229. */
  123230. canvasOptions?: XRWebGLLayerOptions;
  123231. /**
  123232. * CSS styling for a newly created canvas (if not provided)
  123233. */
  123234. newCanvasCssStyle?: string;
  123235. /**
  123236. * Get the default values of the configuration object
  123237. * @returns default values of this configuration object
  123238. */
  123239. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  123240. }
  123241. /**
  123242. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  123243. */
  123244. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  123245. private _options;
  123246. private _canvas;
  123247. private _engine;
  123248. /**
  123249. * Rendering context of the canvas which can be used to display/mirror xr content
  123250. */
  123251. canvasContext: WebGLRenderingContext;
  123252. /**
  123253. * xr layer for the canvas
  123254. */
  123255. xrLayer: Nullable<XRWebGLLayer>;
  123256. /**
  123257. * Initializes the canvas to be added/removed upon entering/exiting xr
  123258. * @param _xrSessionManager The XR Session manager
  123259. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  123260. */
  123261. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  123262. /**
  123263. * Disposes of the object
  123264. */
  123265. dispose(): void;
  123266. /**
  123267. * Initializes the xr layer for the session
  123268. * @param xrSession xr session
  123269. * @returns a promise that will resolve once the XR Layer has been created
  123270. */
  123271. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123272. private _addCanvas;
  123273. private _removeCanvas;
  123274. private _setManagedOutputCanvas;
  123275. }
  123276. }
  123277. declare module BABYLON {
  123278. /**
  123279. * Manages an XRSession to work with Babylon's engine
  123280. * @see https://doc.babylonjs.com/how_to/webxr
  123281. */
  123282. export class WebXRSessionManager implements IDisposable {
  123283. /** The scene which the session should be created for */
  123284. scene: Scene;
  123285. private _referenceSpace;
  123286. private _rttProvider;
  123287. private _sessionEnded;
  123288. private _xrNavigator;
  123289. private baseLayer;
  123290. /**
  123291. * The base reference space from which the session started. good if you want to reset your
  123292. * reference space
  123293. */
  123294. baseReferenceSpace: XRReferenceSpace;
  123295. /**
  123296. * Current XR frame
  123297. */
  123298. currentFrame: Nullable<XRFrame>;
  123299. /** WebXR timestamp updated every frame */
  123300. currentTimestamp: number;
  123301. /**
  123302. * Used just in case of a failure to initialize an immersive session.
  123303. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123304. */
  123305. defaultHeightCompensation: number;
  123306. /**
  123307. * Fires every time a new xrFrame arrives which can be used to update the camera
  123308. */
  123309. onXRFrameObservable: Observable<XRFrame>;
  123310. /**
  123311. * Fires when the reference space changed
  123312. */
  123313. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123314. /**
  123315. * Fires when the xr session is ended either by the device or manually done
  123316. */
  123317. onXRSessionEnded: Observable<any>;
  123318. /**
  123319. * Fires when the xr session is ended either by the device or manually done
  123320. */
  123321. onXRSessionInit: Observable<XRSession>;
  123322. /**
  123323. * Underlying xr session
  123324. */
  123325. session: XRSession;
  123326. /**
  123327. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123328. * or get the offset the player is currently at.
  123329. */
  123330. viewerReferenceSpace: XRReferenceSpace;
  123331. /**
  123332. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123333. * @param scene The scene which the session should be created for
  123334. */
  123335. constructor(
  123336. /** The scene which the session should be created for */
  123337. scene: Scene);
  123338. /**
  123339. * The current reference space used in this session. This reference space can constantly change!
  123340. * It is mainly used to offset the camera's position.
  123341. */
  123342. get referenceSpace(): XRReferenceSpace;
  123343. /**
  123344. * Set a new reference space and triggers the observable
  123345. */
  123346. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123347. /**
  123348. * Disposes of the session manager
  123349. */
  123350. dispose(): void;
  123351. /**
  123352. * Stops the xrSession and restores the render loop
  123353. * @returns Promise which resolves after it exits XR
  123354. */
  123355. exitXRAsync(): Promise<void>;
  123356. /**
  123357. * Gets the correct render target texture to be rendered this frame for this eye
  123358. * @param eye the eye for which to get the render target
  123359. * @returns the render target for the specified eye
  123360. */
  123361. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123362. /**
  123363. * Creates a WebXRRenderTarget object for the XR session
  123364. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123365. * @param options optional options to provide when creating a new render target
  123366. * @returns a WebXR render target to which the session can render
  123367. */
  123368. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123369. /**
  123370. * Initializes the manager
  123371. * After initialization enterXR can be called to start an XR session
  123372. * @returns Promise which resolves after it is initialized
  123373. */
  123374. initializeAsync(): Promise<void>;
  123375. /**
  123376. * Initializes an xr session
  123377. * @param xrSessionMode mode to initialize
  123378. * @param xrSessionInit defines optional and required values to pass to the session builder
  123379. * @returns a promise which will resolve once the session has been initialized
  123380. */
  123381. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123382. /**
  123383. * Checks if a session would be supported for the creation options specified
  123384. * @param sessionMode session mode to check if supported eg. immersive-vr
  123385. * @returns A Promise that resolves to true if supported and false if not
  123386. */
  123387. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123388. /**
  123389. * Resets the reference space to the one started the session
  123390. */
  123391. resetReferenceSpace(): void;
  123392. /**
  123393. * Starts rendering to the xr layer
  123394. */
  123395. runXRRenderLoop(): void;
  123396. /**
  123397. * Sets the reference space on the xr session
  123398. * @param referenceSpaceType space to set
  123399. * @returns a promise that will resolve once the reference space has been set
  123400. */
  123401. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123402. /**
  123403. * Updates the render state of the session
  123404. * @param state state to set
  123405. * @returns a promise that resolves once the render state has been updated
  123406. */
  123407. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  123408. /**
  123409. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  123410. * @param sessionMode defines the session to test
  123411. * @returns a promise with boolean as final value
  123412. */
  123413. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123414. private _createRenderTargetTexture;
  123415. }
  123416. }
  123417. declare module BABYLON {
  123418. /**
  123419. * WebXR Camera which holds the views for the xrSession
  123420. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123421. */
  123422. export class WebXRCamera extends FreeCamera {
  123423. private _xrSessionManager;
  123424. private _firstFrame;
  123425. private _referenceQuaternion;
  123426. private _referencedPosition;
  123427. private _xrInvPositionCache;
  123428. private _xrInvQuaternionCache;
  123429. /**
  123430. * Should position compensation execute on first frame.
  123431. * This is used when copying the position from a native (non XR) camera
  123432. */
  123433. compensateOnFirstFrame: boolean;
  123434. /**
  123435. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123436. * @param name the name of the camera
  123437. * @param scene the scene to add the camera to
  123438. * @param _xrSessionManager a constructed xr session manager
  123439. */
  123440. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123441. /**
  123442. * Return the user's height, unrelated to the current ground.
  123443. * This will be the y position of this camera, when ground level is 0.
  123444. */
  123445. get realWorldHeight(): number;
  123446. /** @hidden */
  123447. _updateForDualEyeDebugging(): void;
  123448. /**
  123449. * Sets this camera's transformation based on a non-vr camera
  123450. * @param otherCamera the non-vr camera to copy the transformation from
  123451. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123452. */
  123453. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123454. /**
  123455. * Gets the current instance class name ("WebXRCamera").
  123456. * @returns the class name
  123457. */
  123458. getClassName(): string;
  123459. /**
  123460. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123461. */
  123462. _getViewMatrix(): Matrix;
  123463. private _updateFromXRSession;
  123464. private _updateNumberOfRigCameras;
  123465. private _updateReferenceSpace;
  123466. private _updateReferenceSpaceOffset;
  123467. }
  123468. }
  123469. declare module BABYLON {
  123470. /**
  123471. * Defining the interface required for a (webxr) feature
  123472. */
  123473. export interface IWebXRFeature extends IDisposable {
  123474. /**
  123475. * Is this feature attached
  123476. */
  123477. attached: boolean;
  123478. /**
  123479. * Should auto-attach be disabled?
  123480. */
  123481. disableAutoAttach: boolean;
  123482. /**
  123483. * Attach the feature to the session
  123484. * Will usually be called by the features manager
  123485. *
  123486. * @param force should attachment be forced (even when already attached)
  123487. * @returns true if successful.
  123488. */
  123489. attach(force?: boolean): boolean;
  123490. /**
  123491. * Detach the feature from the session
  123492. * Will usually be called by the features manager
  123493. *
  123494. * @returns true if successful.
  123495. */
  123496. detach(): boolean;
  123497. }
  123498. /**
  123499. * A list of the currently available features without referencing them
  123500. */
  123501. export class WebXRFeatureName {
  123502. /**
  123503. * The name of the anchor system feature
  123504. */
  123505. static ANCHOR_SYSTEM: string;
  123506. /**
  123507. * The name of the background remover feature
  123508. */
  123509. static BACKGROUND_REMOVER: string;
  123510. /**
  123511. * The name of the hit test feature
  123512. */
  123513. static HIT_TEST: string;
  123514. /**
  123515. * physics impostors for xr controllers feature
  123516. */
  123517. static PHYSICS_CONTROLLERS: string;
  123518. /**
  123519. * The name of the plane detection feature
  123520. */
  123521. static PLANE_DETECTION: string;
  123522. /**
  123523. * The name of the pointer selection feature
  123524. */
  123525. static POINTER_SELECTION: string;
  123526. /**
  123527. * The name of the teleportation feature
  123528. */
  123529. static TELEPORTATION: string;
  123530. }
  123531. /**
  123532. * Defining the constructor of a feature. Used to register the modules.
  123533. */
  123534. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123535. /**
  123536. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123537. * It is mainly used in AR sessions.
  123538. *
  123539. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123540. */
  123541. export class WebXRFeaturesManager implements IDisposable {
  123542. private _xrSessionManager;
  123543. private static readonly _AvailableFeatures;
  123544. private _features;
  123545. /**
  123546. * constructs a new features manages.
  123547. *
  123548. * @param _xrSessionManager an instance of WebXRSessionManager
  123549. */
  123550. constructor(_xrSessionManager: WebXRSessionManager);
  123551. /**
  123552. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123553. * Mainly used internally.
  123554. *
  123555. * @param featureName the name of the feature to register
  123556. * @param constructorFunction the function used to construct the module
  123557. * @param version the (babylon) version of the module
  123558. * @param stable is that a stable version of this module
  123559. */
  123560. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123561. /**
  123562. * Returns a constructor of a specific feature.
  123563. *
  123564. * @param featureName the name of the feature to construct
  123565. * @param version the version of the feature to load
  123566. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123567. * @param options optional options provided to the module.
  123568. * @returns a function that, when called, will return a new instance of this feature
  123569. */
  123570. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123571. /**
  123572. * Can be used to return the list of features currently registered
  123573. *
  123574. * @returns an Array of available features
  123575. */
  123576. static GetAvailableFeatures(): string[];
  123577. /**
  123578. * Gets the versions available for a specific feature
  123579. * @param featureName the name of the feature
  123580. * @returns an array with the available versions
  123581. */
  123582. static GetAvailableVersions(featureName: string): string[];
  123583. /**
  123584. * Return the latest unstable version of this feature
  123585. * @param featureName the name of the feature to search
  123586. * @returns the version number. if not found will return -1
  123587. */
  123588. static GetLatestVersionOfFeature(featureName: string): number;
  123589. /**
  123590. * Return the latest stable version of this feature
  123591. * @param featureName the name of the feature to search
  123592. * @returns the version number. if not found will return -1
  123593. */
  123594. static GetStableVersionOfFeature(featureName: string): number;
  123595. /**
  123596. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123597. * Can be used during a session to start a feature
  123598. * @param featureName the name of feature to attach
  123599. */
  123600. attachFeature(featureName: string): void;
  123601. /**
  123602. * Can be used inside a session or when the session ends to detach a specific feature
  123603. * @param featureName the name of the feature to detach
  123604. */
  123605. detachFeature(featureName: string): void;
  123606. /**
  123607. * Used to disable an already-enabled feature
  123608. * The feature will be disposed and will be recreated once enabled.
  123609. * @param featureName the feature to disable
  123610. * @returns true if disable was successful
  123611. */
  123612. disableFeature(featureName: string | {
  123613. Name: string;
  123614. }): boolean;
  123615. /**
  123616. * dispose this features manager
  123617. */
  123618. dispose(): void;
  123619. /**
  123620. * 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.
  123621. * 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.
  123622. *
  123623. * @param featureName the name of the feature to load or the class of the feature
  123624. * @param version optional version to load. if not provided the latest version will be enabled
  123625. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123626. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123627. * @returns a new constructed feature or throws an error if feature not found.
  123628. */
  123629. enableFeature(featureName: string | {
  123630. Name: string;
  123631. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123632. /**
  123633. * get the implementation of an enabled feature.
  123634. * @param featureName the name of the feature to load
  123635. * @returns the feature class, if found
  123636. */
  123637. getEnabledFeature(featureName: string): IWebXRFeature;
  123638. /**
  123639. * Get the list of enabled features
  123640. * @returns an array of enabled features
  123641. */
  123642. getEnabledFeatures(): string[];
  123643. }
  123644. }
  123645. declare module BABYLON {
  123646. /**
  123647. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  123648. * @see https://doc.babylonjs.com/how_to/webxr
  123649. */
  123650. export class WebXRExperienceHelper implements IDisposable {
  123651. private scene;
  123652. private _nonVRCamera;
  123653. private _originalSceneAutoClear;
  123654. private _supported;
  123655. /**
  123656. * Camera used to render xr content
  123657. */
  123658. camera: WebXRCamera;
  123659. /** A features manager for this xr session */
  123660. featuresManager: WebXRFeaturesManager;
  123661. /**
  123662. * Observers registered here will be triggered after the camera's initial transformation is set
  123663. * This can be used to set a different ground level or an extra rotation.
  123664. *
  123665. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  123666. * to the position set after this observable is done executing.
  123667. */
  123668. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  123669. /**
  123670. * Fires when the state of the experience helper has changed
  123671. */
  123672. onStateChangedObservable: Observable<WebXRState>;
  123673. /** Session manager used to keep track of xr session */
  123674. sessionManager: WebXRSessionManager;
  123675. /**
  123676. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  123677. */
  123678. state: WebXRState;
  123679. /**
  123680. * Creates a WebXRExperienceHelper
  123681. * @param scene The scene the helper should be created in
  123682. */
  123683. private constructor();
  123684. /**
  123685. * Creates the experience helper
  123686. * @param scene the scene to attach the experience helper to
  123687. * @returns a promise for the experience helper
  123688. */
  123689. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  123690. /**
  123691. * Disposes of the experience helper
  123692. */
  123693. dispose(): void;
  123694. /**
  123695. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  123696. * @param sessionMode options for the XR session
  123697. * @param referenceSpaceType frame of reference of the XR session
  123698. * @param renderTarget the output canvas that will be used to enter XR mode
  123699. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  123700. * @returns promise that resolves after xr mode has entered
  123701. */
  123702. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  123703. /**
  123704. * Exits XR mode and returns the scene to its original state
  123705. * @returns promise that resolves after xr mode has exited
  123706. */
  123707. exitXRAsync(): Promise<void>;
  123708. private _nonXRToXRCamera;
  123709. private _setState;
  123710. }
  123711. }
  123712. declare module BABYLON {
  123713. /**
  123714. * X-Y values for axes in WebXR
  123715. */
  123716. export interface IWebXRMotionControllerAxesValue {
  123717. /**
  123718. * The value of the x axis
  123719. */
  123720. x: number;
  123721. /**
  123722. * The value of the y-axis
  123723. */
  123724. y: number;
  123725. }
  123726. /**
  123727. * changed / previous values for the values of this component
  123728. */
  123729. export interface IWebXRMotionControllerComponentChangesValues<T> {
  123730. /**
  123731. * current (this frame) value
  123732. */
  123733. current: T;
  123734. /**
  123735. * previous (last change) value
  123736. */
  123737. previous: T;
  123738. }
  123739. /**
  123740. * Represents changes in the component between current frame and last values recorded
  123741. */
  123742. export interface IWebXRMotionControllerComponentChanges {
  123743. /**
  123744. * will be populated with previous and current values if axes changed
  123745. */
  123746. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  123747. /**
  123748. * will be populated with previous and current values if pressed changed
  123749. */
  123750. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123751. /**
  123752. * will be populated with previous and current values if touched changed
  123753. */
  123754. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  123755. /**
  123756. * will be populated with previous and current values if value changed
  123757. */
  123758. value?: IWebXRMotionControllerComponentChangesValues<number>;
  123759. }
  123760. /**
  123761. * This class represents a single component (for example button or thumbstick) of a motion controller
  123762. */
  123763. export class WebXRControllerComponent implements IDisposable {
  123764. /**
  123765. * the id of this component
  123766. */
  123767. id: string;
  123768. /**
  123769. * the type of the component
  123770. */
  123771. type: MotionControllerComponentType;
  123772. private _buttonIndex;
  123773. private _axesIndices;
  123774. private _axes;
  123775. private _changes;
  123776. private _currentValue;
  123777. private _hasChanges;
  123778. private _pressed;
  123779. private _touched;
  123780. /**
  123781. * button component type
  123782. */
  123783. static BUTTON_TYPE: MotionControllerComponentType;
  123784. /**
  123785. * squeeze component type
  123786. */
  123787. static SQUEEZE_TYPE: MotionControllerComponentType;
  123788. /**
  123789. * Thumbstick component type
  123790. */
  123791. static THUMBSTICK_TYPE: MotionControllerComponentType;
  123792. /**
  123793. * Touchpad component type
  123794. */
  123795. static TOUCHPAD_TYPE: MotionControllerComponentType;
  123796. /**
  123797. * trigger component type
  123798. */
  123799. static TRIGGER_TYPE: MotionControllerComponentType;
  123800. /**
  123801. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  123802. * the axes data changes
  123803. */
  123804. onAxisValueChangedObservable: Observable<{
  123805. x: number;
  123806. y: number;
  123807. }>;
  123808. /**
  123809. * Observers registered here will be triggered when the state of a button changes
  123810. * State change is either pressed / touched / value
  123811. */
  123812. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  123813. /**
  123814. * Creates a new component for a motion controller.
  123815. * It is created by the motion controller itself
  123816. *
  123817. * @param id the id of this component
  123818. * @param type the type of the component
  123819. * @param _buttonIndex index in the buttons array of the gamepad
  123820. * @param _axesIndices indices of the values in the axes array of the gamepad
  123821. */
  123822. constructor(
  123823. /**
  123824. * the id of this component
  123825. */
  123826. id: string,
  123827. /**
  123828. * the type of the component
  123829. */
  123830. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  123831. /**
  123832. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  123833. */
  123834. get axes(): IWebXRMotionControllerAxesValue;
  123835. /**
  123836. * Get the changes. Elements will be populated only if they changed with their previous and current value
  123837. */
  123838. get changes(): IWebXRMotionControllerComponentChanges;
  123839. /**
  123840. * Return whether or not the component changed the last frame
  123841. */
  123842. get hasChanges(): boolean;
  123843. /**
  123844. * is the button currently pressed
  123845. */
  123846. get pressed(): boolean;
  123847. /**
  123848. * is the button currently touched
  123849. */
  123850. get touched(): boolean;
  123851. /**
  123852. * Get the current value of this component
  123853. */
  123854. get value(): number;
  123855. /**
  123856. * Dispose this component
  123857. */
  123858. dispose(): void;
  123859. /**
  123860. * Are there axes correlating to this component
  123861. * @return true is axes data is available
  123862. */
  123863. isAxes(): boolean;
  123864. /**
  123865. * Is this component a button (hence - pressable)
  123866. * @returns true if can be pressed
  123867. */
  123868. isButton(): boolean;
  123869. /**
  123870. * update this component using the gamepad object it is in. Called on every frame
  123871. * @param nativeController the native gamepad controller object
  123872. */
  123873. update(nativeController: IMinimalMotionControllerObject): void;
  123874. }
  123875. }
  123876. declare module BABYLON {
  123877. /**
  123878. * Class used to represent data loading progression
  123879. */
  123880. export class SceneLoaderProgressEvent {
  123881. /** defines if data length to load can be evaluated */
  123882. readonly lengthComputable: boolean;
  123883. /** defines the loaded data length */
  123884. readonly loaded: number;
  123885. /** defines the data length to load */
  123886. readonly total: number;
  123887. /**
  123888. * Create a new progress event
  123889. * @param lengthComputable defines if data length to load can be evaluated
  123890. * @param loaded defines the loaded data length
  123891. * @param total defines the data length to load
  123892. */
  123893. constructor(
  123894. /** defines if data length to load can be evaluated */
  123895. lengthComputable: boolean,
  123896. /** defines the loaded data length */
  123897. loaded: number,
  123898. /** defines the data length to load */
  123899. total: number);
  123900. /**
  123901. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  123902. * @param event defines the source event
  123903. * @returns a new SceneLoaderProgressEvent
  123904. */
  123905. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  123906. }
  123907. /**
  123908. * Interface used by SceneLoader plugins to define supported file extensions
  123909. */
  123910. export interface ISceneLoaderPluginExtensions {
  123911. /**
  123912. * Defines the list of supported extensions
  123913. */
  123914. [extension: string]: {
  123915. isBinary: boolean;
  123916. };
  123917. }
  123918. /**
  123919. * Interface used by SceneLoader plugin factory
  123920. */
  123921. export interface ISceneLoaderPluginFactory {
  123922. /**
  123923. * Defines the name of the factory
  123924. */
  123925. name: string;
  123926. /**
  123927. * Function called to create a new plugin
  123928. * @return the new plugin
  123929. */
  123930. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  123931. /**
  123932. * The callback that returns true if the data can be directly loaded.
  123933. * @param data string containing the file data
  123934. * @returns if the data can be loaded directly
  123935. */
  123936. canDirectLoad?(data: string): boolean;
  123937. }
  123938. /**
  123939. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  123940. */
  123941. export interface ISceneLoaderPluginBase {
  123942. /**
  123943. * The friendly name of this plugin.
  123944. */
  123945. name: string;
  123946. /**
  123947. * The file extensions supported by this plugin.
  123948. */
  123949. extensions: string | ISceneLoaderPluginExtensions;
  123950. /**
  123951. * The callback called when loading from a url.
  123952. * @param scene scene loading this url
  123953. * @param url url to load
  123954. * @param onSuccess callback called when the file successfully loads
  123955. * @param onProgress callback called while file is loading (if the server supports this mode)
  123956. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123957. * @param onError callback called when the file fails to load
  123958. * @returns a file request object
  123959. */
  123960. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123961. /**
  123962. * The callback called when loading from a file object.
  123963. * @param scene scene loading this file
  123964. * @param file defines the file to load
  123965. * @param onSuccess defines the callback to call when data is loaded
  123966. * @param onProgress defines the callback to call during loading process
  123967. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123968. * @param onError defines the callback to call when an error occurs
  123969. * @returns a file request object
  123970. */
  123971. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  123972. /**
  123973. * The callback that returns true if the data can be directly loaded.
  123974. * @param data string containing the file data
  123975. * @returns if the data can be loaded directly
  123976. */
  123977. canDirectLoad?(data: string): boolean;
  123978. /**
  123979. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  123980. * @param scene scene loading this data
  123981. * @param data string containing the data
  123982. * @returns data to pass to the plugin
  123983. */
  123984. directLoad?(scene: Scene, data: string): any;
  123985. /**
  123986. * The callback that allows custom handling of the root url based on the response url.
  123987. * @param rootUrl the original root url
  123988. * @param responseURL the response url if available
  123989. * @returns the new root url
  123990. */
  123991. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  123992. }
  123993. /**
  123994. * Interface used to define a SceneLoader plugin
  123995. */
  123996. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  123997. /**
  123998. * Import meshes into a scene.
  123999. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124000. * @param scene The scene to import into
  124001. * @param data The data to import
  124002. * @param rootUrl The root url for scene and resources
  124003. * @param meshes The meshes array to import into
  124004. * @param particleSystems The particle systems array to import into
  124005. * @param skeletons The skeletons array to import into
  124006. * @param onError The callback when import fails
  124007. * @returns True if successful or false otherwise
  124008. */
  124009. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  124010. /**
  124011. * Load into a scene.
  124012. * @param scene The scene to load into
  124013. * @param data The data to import
  124014. * @param rootUrl The root url for scene and resources
  124015. * @param onError The callback when import fails
  124016. * @returns True if successful or false otherwise
  124017. */
  124018. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  124019. /**
  124020. * Load into an asset container.
  124021. * @param scene The scene to load into
  124022. * @param data The data to import
  124023. * @param rootUrl The root url for scene and resources
  124024. * @param onError The callback when import fails
  124025. * @returns The loaded asset container
  124026. */
  124027. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  124028. }
  124029. /**
  124030. * Interface used to define an async SceneLoader plugin
  124031. */
  124032. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  124033. /**
  124034. * Import meshes into a scene.
  124035. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124036. * @param scene The scene to import into
  124037. * @param data The data to import
  124038. * @param rootUrl The root url for scene and resources
  124039. * @param onProgress The callback when the load progresses
  124040. * @param fileName Defines the name of the file to load
  124041. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  124042. */
  124043. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  124044. meshes: AbstractMesh[];
  124045. particleSystems: IParticleSystem[];
  124046. skeletons: Skeleton[];
  124047. animationGroups: AnimationGroup[];
  124048. }>;
  124049. /**
  124050. * Load into a scene.
  124051. * @param scene The scene to load into
  124052. * @param data The data to import
  124053. * @param rootUrl The root url for scene and resources
  124054. * @param onProgress The callback when the load progresses
  124055. * @param fileName Defines the name of the file to load
  124056. * @returns Nothing
  124057. */
  124058. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  124059. /**
  124060. * Load into an asset container.
  124061. * @param scene The scene to load into
  124062. * @param data The data to import
  124063. * @param rootUrl The root url for scene and resources
  124064. * @param onProgress The callback when the load progresses
  124065. * @param fileName Defines the name of the file to load
  124066. * @returns The loaded asset container
  124067. */
  124068. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124069. }
  124070. /**
  124071. * Mode that determines how to handle old animation groups before loading new ones.
  124072. */
  124073. export enum SceneLoaderAnimationGroupLoadingMode {
  124074. /**
  124075. * Reset all old animations to initial state then dispose them.
  124076. */
  124077. Clean = 0,
  124078. /**
  124079. * Stop all old animations.
  124080. */
  124081. Stop = 1,
  124082. /**
  124083. * Restart old animations from first frame.
  124084. */
  124085. Sync = 2,
  124086. /**
  124087. * Old animations remains untouched.
  124088. */
  124089. NoSync = 3
  124090. }
  124091. /**
  124092. * Class used to load scene from various file formats using registered plugins
  124093. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  124094. */
  124095. export class SceneLoader {
  124096. /**
  124097. * No logging while loading
  124098. */
  124099. static readonly NO_LOGGING: number;
  124100. /**
  124101. * Minimal logging while loading
  124102. */
  124103. static readonly MINIMAL_LOGGING: number;
  124104. /**
  124105. * Summary logging while loading
  124106. */
  124107. static readonly SUMMARY_LOGGING: number;
  124108. /**
  124109. * Detailled logging while loading
  124110. */
  124111. static readonly DETAILED_LOGGING: number;
  124112. /**
  124113. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  124114. */
  124115. static get ForceFullSceneLoadingForIncremental(): boolean;
  124116. static set ForceFullSceneLoadingForIncremental(value: boolean);
  124117. /**
  124118. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  124119. */
  124120. static get ShowLoadingScreen(): boolean;
  124121. static set ShowLoadingScreen(value: boolean);
  124122. /**
  124123. * Defines the current logging level (while loading the scene)
  124124. * @ignorenaming
  124125. */
  124126. static get loggingLevel(): number;
  124127. static set loggingLevel(value: number);
  124128. /**
  124129. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  124130. */
  124131. static get CleanBoneMatrixWeights(): boolean;
  124132. static set CleanBoneMatrixWeights(value: boolean);
  124133. /**
  124134. * Event raised when a plugin is used to load a scene
  124135. */
  124136. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124137. private static _registeredPlugins;
  124138. private static _getDefaultPlugin;
  124139. private static _getPluginForExtension;
  124140. private static _getPluginForDirectLoad;
  124141. private static _getPluginForFilename;
  124142. private static _getDirectLoad;
  124143. private static _loadData;
  124144. private static _getFileInfo;
  124145. /**
  124146. * Gets a plugin that can load the given extension
  124147. * @param extension defines the extension to load
  124148. * @returns a plugin or null if none works
  124149. */
  124150. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  124151. /**
  124152. * Gets a boolean indicating that the given extension can be loaded
  124153. * @param extension defines the extension to load
  124154. * @returns true if the extension is supported
  124155. */
  124156. static IsPluginForExtensionAvailable(extension: string): boolean;
  124157. /**
  124158. * Adds a new plugin to the list of registered plugins
  124159. * @param plugin defines the plugin to add
  124160. */
  124161. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  124162. /**
  124163. * Import meshes into a scene
  124164. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124165. * @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)
  124166. * @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)
  124167. * @param scene the instance of BABYLON.Scene to append to
  124168. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  124169. * @param onProgress a callback with a progress event for each file being loaded
  124170. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124171. * @param pluginExtension the extension used to determine the plugin
  124172. * @returns The loaded plugin
  124173. */
  124174. 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>;
  124175. /**
  124176. * Import meshes into a scene
  124177. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124178. * @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)
  124179. * @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)
  124180. * @param scene the instance of BABYLON.Scene to append to
  124181. * @param onProgress a callback with a progress event for each file being loaded
  124182. * @param pluginExtension the extension used to determine the plugin
  124183. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  124184. */
  124185. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  124186. meshes: AbstractMesh[];
  124187. particleSystems: IParticleSystem[];
  124188. skeletons: Skeleton[];
  124189. animationGroups: AnimationGroup[];
  124190. }>;
  124191. /**
  124192. * Load a scene
  124193. * @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)
  124194. * @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)
  124195. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124196. * @param onSuccess a callback with the scene when import succeeds
  124197. * @param onProgress a callback with a progress event for each file being loaded
  124198. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124199. * @param pluginExtension the extension used to determine the plugin
  124200. * @returns The loaded plugin
  124201. */
  124202. 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>;
  124203. /**
  124204. * Load a scene
  124205. * @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)
  124206. * @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)
  124207. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124208. * @param onProgress a callback with a progress event for each file being loaded
  124209. * @param pluginExtension the extension used to determine the plugin
  124210. * @returns The loaded scene
  124211. */
  124212. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124213. /**
  124214. * Append a scene
  124215. * @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)
  124216. * @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)
  124217. * @param scene is the instance of BABYLON.Scene to append to
  124218. * @param onSuccess a callback with the scene when import succeeds
  124219. * @param onProgress a callback with a progress event for each file being loaded
  124220. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124221. * @param pluginExtension the extension used to determine the plugin
  124222. * @returns The loaded plugin
  124223. */
  124224. 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>;
  124225. /**
  124226. * Append a scene
  124227. * @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)
  124228. * @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)
  124229. * @param scene is the instance of BABYLON.Scene to append to
  124230. * @param onProgress a callback with a progress event for each file being loaded
  124231. * @param pluginExtension the extension used to determine the plugin
  124232. * @returns The given scene
  124233. */
  124234. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124235. /**
  124236. * Load a scene into an asset container
  124237. * @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)
  124238. * @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)
  124239. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124240. * @param onSuccess a callback with the scene when import succeeds
  124241. * @param onProgress a callback with a progress event for each file being loaded
  124242. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124243. * @param pluginExtension the extension used to determine the plugin
  124244. * @returns The loaded plugin
  124245. */
  124246. 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>;
  124247. /**
  124248. * Load a scene into an asset container
  124249. * @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)
  124250. * @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)
  124251. * @param scene is the instance of Scene to append to
  124252. * @param onProgress a callback with a progress event for each file being loaded
  124253. * @param pluginExtension the extension used to determine the plugin
  124254. * @returns The loaded asset container
  124255. */
  124256. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  124257. /**
  124258. * Import animations from a file into a scene
  124259. * @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)
  124260. * @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)
  124261. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124262. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124263. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124264. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124265. * @param onSuccess a callback with the scene when import succeeds
  124266. * @param onProgress a callback with a progress event for each file being loaded
  124267. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124268. */
  124269. 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;
  124270. /**
  124271. * Import animations from a file into a scene
  124272. * @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)
  124273. * @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)
  124274. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124275. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124276. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124277. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124278. * @param onSuccess a callback with the scene when import succeeds
  124279. * @param onProgress a callback with a progress event for each file being loaded
  124280. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124281. * @returns the updated scene with imported animations
  124282. */
  124283. 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>;
  124284. }
  124285. }
  124286. declare module BABYLON {
  124287. /**
  124288. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  124289. */
  124290. export type MotionControllerHandedness = "none" | "left" | "right";
  124291. /**
  124292. * The type of components available in motion controllers.
  124293. * This is not the name of the component.
  124294. */
  124295. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  124296. /**
  124297. * The state of a controller component
  124298. */
  124299. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  124300. /**
  124301. * The schema of motion controller layout.
  124302. * No object will be initialized using this interface
  124303. * This is used just to define the profile.
  124304. */
  124305. export interface IMotionControllerLayout {
  124306. /**
  124307. * Path to load the assets. Usually relative to the base path
  124308. */
  124309. assetPath: string;
  124310. /**
  124311. * Available components (unsorted)
  124312. */
  124313. components: {
  124314. /**
  124315. * A map of component Ids
  124316. */
  124317. [componentId: string]: {
  124318. /**
  124319. * The type of input the component outputs
  124320. */
  124321. type: MotionControllerComponentType;
  124322. /**
  124323. * The indices of this component in the gamepad object
  124324. */
  124325. gamepadIndices: {
  124326. /**
  124327. * Index of button
  124328. */
  124329. button?: number;
  124330. /**
  124331. * If available, index of x-axis
  124332. */
  124333. xAxis?: number;
  124334. /**
  124335. * If available, index of y-axis
  124336. */
  124337. yAxis?: number;
  124338. };
  124339. /**
  124340. * The mesh's root node name
  124341. */
  124342. rootNodeName: string;
  124343. /**
  124344. * Animation definitions for this model
  124345. */
  124346. visualResponses: {
  124347. [stateKey: string]: {
  124348. /**
  124349. * What property will be animated
  124350. */
  124351. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124352. /**
  124353. * What states influence this visual response
  124354. */
  124355. states: MotionControllerComponentStateType[];
  124356. /**
  124357. * Type of animation - movement or visibility
  124358. */
  124359. valueNodeProperty: "transform" | "visibility";
  124360. /**
  124361. * Base node name to move. Its position will be calculated according to the min and max nodes
  124362. */
  124363. valueNodeName?: string;
  124364. /**
  124365. * Minimum movement node
  124366. */
  124367. minNodeName?: string;
  124368. /**
  124369. * Max movement node
  124370. */
  124371. maxNodeName?: string;
  124372. };
  124373. };
  124374. /**
  124375. * If touch enabled, what is the name of node to display user feedback
  124376. */
  124377. touchPointNodeName?: string;
  124378. };
  124379. };
  124380. /**
  124381. * Is it xr standard mapping or not
  124382. */
  124383. gamepadMapping: "" | "xr-standard";
  124384. /**
  124385. * Base root node of this entire model
  124386. */
  124387. rootNodeName: string;
  124388. /**
  124389. * Defines the main button component id
  124390. */
  124391. selectComponentId: string;
  124392. }
  124393. /**
  124394. * A definition for the layout map in the input profile
  124395. */
  124396. export interface IMotionControllerLayoutMap {
  124397. /**
  124398. * Layouts with handedness type as a key
  124399. */
  124400. [handedness: string]: IMotionControllerLayout;
  124401. }
  124402. /**
  124403. * The XR Input profile schema
  124404. * Profiles can be found here:
  124405. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  124406. */
  124407. export interface IMotionControllerProfile {
  124408. /**
  124409. * fallback profiles for this profileId
  124410. */
  124411. fallbackProfileIds: string[];
  124412. /**
  124413. * The layout map, with handedness as key
  124414. */
  124415. layouts: IMotionControllerLayoutMap;
  124416. /**
  124417. * The id of this profile
  124418. * correlates to the profile(s) in the xrInput.profiles array
  124419. */
  124420. profileId: string;
  124421. }
  124422. /**
  124423. * A helper-interface for the 3 meshes needed for controller button animation
  124424. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124425. */
  124426. export interface IMotionControllerButtonMeshMap {
  124427. /**
  124428. * the mesh that defines the pressed value mesh position.
  124429. * This is used to find the max-position of this button
  124430. */
  124431. pressedMesh: AbstractMesh;
  124432. /**
  124433. * the mesh that defines the unpressed value mesh position.
  124434. * This is used to find the min (or initial) position of this button
  124435. */
  124436. unpressedMesh: AbstractMesh;
  124437. /**
  124438. * The mesh that will be changed when value changes
  124439. */
  124440. valueMesh: AbstractMesh;
  124441. }
  124442. /**
  124443. * A helper-interface for the 3 meshes needed for controller axis animation.
  124444. * This will be expanded when touchpad animations are fully supported
  124445. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124446. */
  124447. export interface IMotionControllerMeshMap {
  124448. /**
  124449. * the mesh that defines the maximum value mesh position.
  124450. */
  124451. maxMesh?: AbstractMesh;
  124452. /**
  124453. * the mesh that defines the minimum value mesh position.
  124454. */
  124455. minMesh?: AbstractMesh;
  124456. /**
  124457. * The mesh that will be changed when axis value changes
  124458. */
  124459. valueMesh: AbstractMesh;
  124460. }
  124461. /**
  124462. * The elements needed for change-detection of the gamepad objects in motion controllers
  124463. */
  124464. export interface IMinimalMotionControllerObject {
  124465. /**
  124466. * Available axes of this controller
  124467. */
  124468. axes: number[];
  124469. /**
  124470. * An array of available buttons
  124471. */
  124472. buttons: Array<{
  124473. /**
  124474. * Value of the button/trigger
  124475. */
  124476. value: number;
  124477. /**
  124478. * If the button/trigger is currently touched
  124479. */
  124480. touched: boolean;
  124481. /**
  124482. * If the button/trigger is currently pressed
  124483. */
  124484. pressed: boolean;
  124485. }>;
  124486. /**
  124487. * EXPERIMENTAL haptic support.
  124488. */
  124489. hapticActuators?: Array<{
  124490. pulse: (value: number, duration: number) => Promise<boolean>;
  124491. }>;
  124492. }
  124493. /**
  124494. * An Abstract Motion controller
  124495. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124496. * Each component has an observable to check for changes in value and state
  124497. */
  124498. export abstract class WebXRAbstractMotionController implements IDisposable {
  124499. protected scene: Scene;
  124500. protected layout: IMotionControllerLayout;
  124501. /**
  124502. * The gamepad object correlating to this controller
  124503. */
  124504. gamepadObject: IMinimalMotionControllerObject;
  124505. /**
  124506. * handedness (left/right/none) of this controller
  124507. */
  124508. handedness: MotionControllerHandedness;
  124509. private _initComponent;
  124510. private _modelReady;
  124511. /**
  124512. * A map of components (WebXRControllerComponent) in this motion controller
  124513. * Components have a ComponentType and can also have both button and axis definitions
  124514. */
  124515. readonly components: {
  124516. [id: string]: WebXRControllerComponent;
  124517. };
  124518. /**
  124519. * Disable the model's animation. Can be set at any time.
  124520. */
  124521. disableAnimation: boolean;
  124522. /**
  124523. * Observers registered here will be triggered when the model of this controller is done loading
  124524. */
  124525. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124526. /**
  124527. * The profile id of this motion controller
  124528. */
  124529. abstract profileId: string;
  124530. /**
  124531. * The root mesh of the model. It is null if the model was not yet initialized
  124532. */
  124533. rootMesh: Nullable<AbstractMesh>;
  124534. /**
  124535. * constructs a new abstract motion controller
  124536. * @param scene the scene to which the model of the controller will be added
  124537. * @param layout The profile layout to load
  124538. * @param gamepadObject The gamepad object correlating to this controller
  124539. * @param handedness handedness (left/right/none) of this controller
  124540. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124541. */
  124542. constructor(scene: Scene, layout: IMotionControllerLayout,
  124543. /**
  124544. * The gamepad object correlating to this controller
  124545. */
  124546. gamepadObject: IMinimalMotionControllerObject,
  124547. /**
  124548. * handedness (left/right/none) of this controller
  124549. */
  124550. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124551. /**
  124552. * Dispose this controller, the model mesh and all its components
  124553. */
  124554. dispose(): void;
  124555. /**
  124556. * Returns all components of specific type
  124557. * @param type the type to search for
  124558. * @return an array of components with this type
  124559. */
  124560. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124561. /**
  124562. * get a component based an its component id as defined in layout.components
  124563. * @param id the id of the component
  124564. * @returns the component correlates to the id or undefined if not found
  124565. */
  124566. getComponent(id: string): WebXRControllerComponent;
  124567. /**
  124568. * Get the list of components available in this motion controller
  124569. * @returns an array of strings correlating to available components
  124570. */
  124571. getComponentIds(): string[];
  124572. /**
  124573. * Get the first component of specific type
  124574. * @param type type of component to find
  124575. * @return a controller component or null if not found
  124576. */
  124577. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124578. /**
  124579. * Get the main (Select) component of this controller as defined in the layout
  124580. * @returns the main component of this controller
  124581. */
  124582. getMainComponent(): WebXRControllerComponent;
  124583. /**
  124584. * Loads the model correlating to this controller
  124585. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124586. * @returns A promise fulfilled with the result of the model loading
  124587. */
  124588. loadModel(): Promise<boolean>;
  124589. /**
  124590. * Update this model using the current XRFrame
  124591. * @param xrFrame the current xr frame to use and update the model
  124592. */
  124593. updateFromXRFrame(xrFrame: XRFrame): void;
  124594. /**
  124595. * Backwards compatibility due to a deeply-integrated typo
  124596. */
  124597. get handness(): XREye;
  124598. /**
  124599. * Pulse (vibrate) this controller
  124600. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124601. * Consecutive calls to this function will cancel the last pulse call
  124602. *
  124603. * @param value the strength of the pulse in 0.0...1.0 range
  124604. * @param duration Duration of the pulse in milliseconds
  124605. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124606. * @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
  124607. */
  124608. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124609. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124610. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124611. /**
  124612. * Moves the axis on the controller mesh based on its current state
  124613. * @param axis the index of the axis
  124614. * @param axisValue the value of the axis which determines the meshes new position
  124615. * @hidden
  124616. */
  124617. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124618. /**
  124619. * Update the model itself with the current frame data
  124620. * @param xrFrame the frame to use for updating the model mesh
  124621. */
  124622. protected updateModel(xrFrame: XRFrame): void;
  124623. /**
  124624. * Get the filename and path for this controller's model
  124625. * @returns a map of filename and path
  124626. */
  124627. protected abstract _getFilenameAndPath(): {
  124628. filename: string;
  124629. path: string;
  124630. };
  124631. /**
  124632. * This function is called before the mesh is loaded. It checks for loading constraints.
  124633. * For example, this function can check if the GLB loader is available
  124634. * If this function returns false, the generic controller will be loaded instead
  124635. * @returns Is the client ready to load the mesh
  124636. */
  124637. protected abstract _getModelLoadingConstraints(): boolean;
  124638. /**
  124639. * This function will be called after the model was successfully loaded and can be used
  124640. * for mesh transformations before it is available for the user
  124641. * @param meshes the loaded meshes
  124642. */
  124643. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124644. /**
  124645. * Set the root mesh for this controller. Important for the WebXR controller class
  124646. * @param meshes the loaded meshes
  124647. */
  124648. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  124649. /**
  124650. * A function executed each frame that updates the mesh (if needed)
  124651. * @param xrFrame the current xrFrame
  124652. */
  124653. protected abstract _updateModel(xrFrame: XRFrame): void;
  124654. private _getGenericFilenameAndPath;
  124655. private _getGenericParentMesh;
  124656. }
  124657. }
  124658. declare module BABYLON {
  124659. /**
  124660. * A generic trigger-only motion controller for WebXR
  124661. */
  124662. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  124663. /**
  124664. * Static version of the profile id of this controller
  124665. */
  124666. static ProfileId: string;
  124667. profileId: string;
  124668. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  124669. protected _getFilenameAndPath(): {
  124670. filename: string;
  124671. path: string;
  124672. };
  124673. protected _getModelLoadingConstraints(): boolean;
  124674. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  124675. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124676. protected _updateModel(): void;
  124677. }
  124678. }
  124679. declare module BABYLON {
  124680. /**
  124681. * Class containing static functions to help procedurally build meshes
  124682. */
  124683. export class SphereBuilder {
  124684. /**
  124685. * Creates a sphere mesh
  124686. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124687. * * 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`)
  124688. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124689. * * 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
  124690. * * 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)
  124691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124694. * @param name defines the name of the mesh
  124695. * @param options defines the options used to create the mesh
  124696. * @param scene defines the hosting scene
  124697. * @returns the sphere mesh
  124698. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124699. */
  124700. static CreateSphere(name: string, options: {
  124701. segments?: number;
  124702. diameter?: number;
  124703. diameterX?: number;
  124704. diameterY?: number;
  124705. diameterZ?: number;
  124706. arc?: number;
  124707. slice?: number;
  124708. sideOrientation?: number;
  124709. frontUVs?: Vector4;
  124710. backUVs?: Vector4;
  124711. updatable?: boolean;
  124712. }, scene?: Nullable<Scene>): Mesh;
  124713. }
  124714. }
  124715. declare module BABYLON {
  124716. /**
  124717. * A profiled motion controller has its profile loaded from an online repository.
  124718. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  124719. */
  124720. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  124721. private _repositoryUrl;
  124722. private _buttonMeshMapping;
  124723. private _touchDots;
  124724. /**
  124725. * The profile ID of this controller. Will be populated when the controller initializes.
  124726. */
  124727. profileId: string;
  124728. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  124729. dispose(): void;
  124730. protected _getFilenameAndPath(): {
  124731. filename: string;
  124732. path: string;
  124733. };
  124734. protected _getModelLoadingConstraints(): boolean;
  124735. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  124736. protected _setRootMesh(meshes: AbstractMesh[]): void;
  124737. protected _updateModel(_xrFrame: XRFrame): void;
  124738. }
  124739. }
  124740. declare module BABYLON {
  124741. /**
  124742. * A construction function type to create a new controller based on an xrInput object
  124743. */
  124744. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  124745. /**
  124746. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  124747. *
  124748. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  124749. * it should be replaced with auto-loaded controllers.
  124750. *
  124751. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  124752. */
  124753. export class WebXRMotionControllerManager {
  124754. private static _AvailableControllers;
  124755. private static _Fallbacks;
  124756. private static _ProfileLoadingPromises;
  124757. private static _ProfilesList;
  124758. /**
  124759. * The base URL of the online controller repository. Can be changed at any time.
  124760. */
  124761. static BaseRepositoryUrl: string;
  124762. /**
  124763. * Which repository gets priority - local or online
  124764. */
  124765. static PrioritizeOnlineRepository: boolean;
  124766. /**
  124767. * Use the online repository, or use only locally-defined controllers
  124768. */
  124769. static UseOnlineRepository: boolean;
  124770. /**
  124771. * Clear the cache used for profile loading and reload when requested again
  124772. */
  124773. static ClearProfilesCache(): void;
  124774. /**
  124775. * Register the default fallbacks.
  124776. * This function is called automatically when this file is imported.
  124777. */
  124778. static DefaultFallbacks(): void;
  124779. /**
  124780. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  124781. * @param profileId the profile to which a fallback needs to be found
  124782. * @return an array with corresponding fallback profiles
  124783. */
  124784. static FindFallbackWithProfileId(profileId: string): string[];
  124785. /**
  124786. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  124787. * The order of search:
  124788. *
  124789. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  124790. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  124791. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  124792. * 4) return the generic trigger controller if none were found
  124793. *
  124794. * @param xrInput the xrInput to which a new controller is initialized
  124795. * @param scene the scene to which the model will be added
  124796. * @param forceProfile force a certain profile for this controller
  124797. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  124798. */
  124799. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  124800. /**
  124801. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  124802. *
  124803. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  124804. *
  124805. * @param type the profile type to register
  124806. * @param constructFunction the function to be called when loading this profile
  124807. */
  124808. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  124809. /**
  124810. * Register a fallback to a specific profile.
  124811. * @param profileId the profileId that will receive the fallbacks
  124812. * @param fallbacks A list of fallback profiles
  124813. */
  124814. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  124815. /**
  124816. * Will update the list of profiles available in the repository
  124817. * @return a promise that resolves to a map of profiles available online
  124818. */
  124819. static UpdateProfilesList(): Promise<{
  124820. [profile: string]: string;
  124821. }>;
  124822. private static _LoadProfileFromRepository;
  124823. private static _LoadProfilesFromAvailableControllers;
  124824. }
  124825. }
  124826. declare module BABYLON {
  124827. /**
  124828. * Configuration options for the WebXR controller creation
  124829. */
  124830. export interface IWebXRControllerOptions {
  124831. /**
  124832. * Should the controller mesh be animated when a user interacts with it
  124833. * The pressed buttons / thumbstick and touchpad animations will be disabled
  124834. */
  124835. disableMotionControllerAnimation?: boolean;
  124836. /**
  124837. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  124838. */
  124839. doNotLoadControllerMesh?: boolean;
  124840. /**
  124841. * Force a specific controller type for this controller.
  124842. * This can be used when creating your own profile or when testing different controllers
  124843. */
  124844. forceControllerProfile?: string;
  124845. /**
  124846. * Defines a rendering group ID for meshes that will be loaded.
  124847. * This is for the default controllers only.
  124848. */
  124849. renderingGroupId?: number;
  124850. }
  124851. /**
  124852. * Represents an XR controller
  124853. */
  124854. export class WebXRInputSource {
  124855. private _scene;
  124856. /** The underlying input source for the controller */
  124857. inputSource: XRInputSource;
  124858. private _options;
  124859. private _tmpVector;
  124860. private _uniqueId;
  124861. /**
  124862. * 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
  124863. */
  124864. grip?: AbstractMesh;
  124865. /**
  124866. * If available, this is the gamepad object related to this controller.
  124867. * Using this object it is possible to get click events and trackpad changes of the
  124868. * webxr controller that is currently being used.
  124869. */
  124870. motionController?: WebXRAbstractMotionController;
  124871. /**
  124872. * Event that fires when the controller is removed/disposed.
  124873. * The object provided as event data is this controller, after associated assets were disposed.
  124874. * uniqueId is still available.
  124875. */
  124876. onDisposeObservable: Observable<WebXRInputSource>;
  124877. /**
  124878. * Will be triggered when the mesh associated with the motion controller is done loading.
  124879. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  124880. * A shortened version of controller -> motion controller -> on mesh loaded.
  124881. */
  124882. onMeshLoadedObservable: Observable<AbstractMesh>;
  124883. /**
  124884. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  124885. */
  124886. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  124887. /**
  124888. * Pointer which can be used to select objects or attach a visible laser to
  124889. */
  124890. pointer: AbstractMesh;
  124891. /**
  124892. * Creates the controller
  124893. * @see https://doc.babylonjs.com/how_to/webxr
  124894. * @param _scene the scene which the controller should be associated to
  124895. * @param inputSource the underlying input source for the controller
  124896. * @param _options options for this controller creation
  124897. */
  124898. constructor(_scene: Scene,
  124899. /** The underlying input source for the controller */
  124900. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  124901. /**
  124902. * Get this controllers unique id
  124903. */
  124904. get uniqueId(): string;
  124905. /**
  124906. * Disposes of the object
  124907. */
  124908. dispose(): void;
  124909. /**
  124910. * Gets a world space ray coming from the pointer or grip
  124911. * @param result the resulting ray
  124912. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  124913. */
  124914. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  124915. /**
  124916. * Updates the controller pose based on the given XRFrame
  124917. * @param xrFrame xr frame to update the pose with
  124918. * @param referenceSpace reference space to use
  124919. */
  124920. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  124921. }
  124922. }
  124923. declare module BABYLON {
  124924. /**
  124925. * The schema for initialization options of the XR Input class
  124926. */
  124927. export interface IWebXRInputOptions {
  124928. /**
  124929. * If set to true no model will be automatically loaded
  124930. */
  124931. doNotLoadControllerMeshes?: boolean;
  124932. /**
  124933. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  124934. * If not found, the xr input profile data will be used.
  124935. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  124936. */
  124937. forceInputProfile?: string;
  124938. /**
  124939. * Do not send a request to the controller repository to load the profile.
  124940. *
  124941. * Instead, use the controllers available in babylon itself.
  124942. */
  124943. disableOnlineControllerRepository?: boolean;
  124944. /**
  124945. * A custom URL for the controllers repository
  124946. */
  124947. customControllersRepositoryURL?: string;
  124948. /**
  124949. * Should the controller model's components not move according to the user input
  124950. */
  124951. disableControllerAnimation?: boolean;
  124952. /**
  124953. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  124954. */
  124955. controllerOptions?: IWebXRControllerOptions;
  124956. }
  124957. /**
  124958. * XR input used to track XR inputs such as controllers/rays
  124959. */
  124960. export class WebXRInput implements IDisposable {
  124961. /**
  124962. * the xr session manager for this session
  124963. */
  124964. xrSessionManager: WebXRSessionManager;
  124965. /**
  124966. * the WebXR camera for this session. Mainly used for teleportation
  124967. */
  124968. xrCamera: WebXRCamera;
  124969. private readonly options;
  124970. /**
  124971. * XR controllers being tracked
  124972. */
  124973. controllers: Array<WebXRInputSource>;
  124974. private _frameObserver;
  124975. private _sessionEndedObserver;
  124976. private _sessionInitObserver;
  124977. /**
  124978. * Event when a controller has been connected/added
  124979. */
  124980. onControllerAddedObservable: Observable<WebXRInputSource>;
  124981. /**
  124982. * Event when a controller has been removed/disconnected
  124983. */
  124984. onControllerRemovedObservable: Observable<WebXRInputSource>;
  124985. /**
  124986. * Initializes the WebXRInput
  124987. * @param xrSessionManager the xr session manager for this session
  124988. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  124989. * @param options = initialization options for this xr input
  124990. */
  124991. constructor(
  124992. /**
  124993. * the xr session manager for this session
  124994. */
  124995. xrSessionManager: WebXRSessionManager,
  124996. /**
  124997. * the WebXR camera for this session. Mainly used for teleportation
  124998. */
  124999. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  125000. private _onInputSourcesChange;
  125001. private _addAndRemoveControllers;
  125002. /**
  125003. * Disposes of the object
  125004. */
  125005. dispose(): void;
  125006. }
  125007. }
  125008. declare module BABYLON {
  125009. /**
  125010. * This is the base class for all WebXR features.
  125011. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  125012. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  125013. */
  125014. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  125015. protected _xrSessionManager: WebXRSessionManager;
  125016. private _attached;
  125017. private _removeOnDetach;
  125018. /**
  125019. * Should auto-attach be disabled?
  125020. */
  125021. disableAutoAttach: boolean;
  125022. /**
  125023. * Construct a new (abstract) WebXR feature
  125024. * @param _xrSessionManager the xr session manager for this feature
  125025. */
  125026. constructor(_xrSessionManager: WebXRSessionManager);
  125027. /**
  125028. * Is this feature attached
  125029. */
  125030. get attached(): boolean;
  125031. /**
  125032. * attach this feature
  125033. *
  125034. * @param force should attachment be forced (even when already attached)
  125035. * @returns true if successful, false is failed or already attached
  125036. */
  125037. attach(force?: boolean): boolean;
  125038. /**
  125039. * detach this feature.
  125040. *
  125041. * @returns true if successful, false if failed or already detached
  125042. */
  125043. detach(): boolean;
  125044. /**
  125045. * Dispose this feature and all of the resources attached
  125046. */
  125047. dispose(): void;
  125048. /**
  125049. * This is used to register callbacks that will automatically be removed when detach is called.
  125050. * @param observable the observable to which the observer will be attached
  125051. * @param callback the callback to register
  125052. */
  125053. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  125054. /**
  125055. * Code in this function will be executed on each xrFrame received from the browser.
  125056. * This function will not execute after the feature is detached.
  125057. * @param _xrFrame the current frame
  125058. */
  125059. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  125060. }
  125061. }
  125062. declare module BABYLON {
  125063. /**
  125064. * Renders a layer on top of an existing scene
  125065. */
  125066. export class UtilityLayerRenderer implements IDisposable {
  125067. /** the original scene that will be rendered on top of */
  125068. originalScene: Scene;
  125069. private _pointerCaptures;
  125070. private _lastPointerEvents;
  125071. private static _DefaultUtilityLayer;
  125072. private static _DefaultKeepDepthUtilityLayer;
  125073. private _sharedGizmoLight;
  125074. private _renderCamera;
  125075. /**
  125076. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  125077. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  125078. * @returns the camera that is used when rendering the utility layer
  125079. */
  125080. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  125081. /**
  125082. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  125083. * @param cam the camera that should be used when rendering the utility layer
  125084. */
  125085. setRenderCamera(cam: Nullable<Camera>): void;
  125086. /**
  125087. * @hidden
  125088. * Light which used by gizmos to get light shading
  125089. */
  125090. _getSharedGizmoLight(): HemisphericLight;
  125091. /**
  125092. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  125093. */
  125094. pickUtilitySceneFirst: boolean;
  125095. /**
  125096. * 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)
  125097. */
  125098. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  125099. /**
  125100. * 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)
  125101. */
  125102. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  125103. /**
  125104. * The scene that is rendered on top of the original scene
  125105. */
  125106. utilityLayerScene: Scene;
  125107. /**
  125108. * If the utility layer should automatically be rendered on top of existing scene
  125109. */
  125110. shouldRender: boolean;
  125111. /**
  125112. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  125113. */
  125114. onlyCheckPointerDownEvents: boolean;
  125115. /**
  125116. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  125117. */
  125118. processAllEvents: boolean;
  125119. /**
  125120. * Observable raised when the pointer move from the utility layer scene to the main scene
  125121. */
  125122. onPointerOutObservable: Observable<number>;
  125123. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  125124. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  125125. private _afterRenderObserver;
  125126. private _sceneDisposeObserver;
  125127. private _originalPointerObserver;
  125128. /**
  125129. * Instantiates a UtilityLayerRenderer
  125130. * @param originalScene the original scene that will be rendered on top of
  125131. * @param handleEvents boolean indicating if the utility layer should handle events
  125132. */
  125133. constructor(
  125134. /** the original scene that will be rendered on top of */
  125135. originalScene: Scene, handleEvents?: boolean);
  125136. private _notifyObservers;
  125137. /**
  125138. * Renders the utility layers scene on top of the original scene
  125139. */
  125140. render(): void;
  125141. /**
  125142. * Disposes of the renderer
  125143. */
  125144. dispose(): void;
  125145. private _updateCamera;
  125146. }
  125147. }
  125148. declare module BABYLON {
  125149. /**
  125150. * Options interface for the pointer selection module
  125151. */
  125152. export interface IWebXRControllerPointerSelectionOptions {
  125153. /**
  125154. * if provided, this scene will be used to render meshes.
  125155. */
  125156. customUtilityLayerScene?: Scene;
  125157. /**
  125158. * 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)
  125159. * If not disabled, the last picked point will be used to execute a pointer up event
  125160. * If disabled, pointer up event will be triggered right after the pointer down event.
  125161. * Used in screen and gaze target ray mode only
  125162. */
  125163. disablePointerUpOnTouchOut: boolean;
  125164. /**
  125165. * For gaze mode (time to select instead of press)
  125166. */
  125167. forceGazeMode: boolean;
  125168. /**
  125169. * 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
  125170. * to start a new countdown to the pointer down event.
  125171. * Defaults to 1.
  125172. */
  125173. gazeModePointerMovedFactor?: number;
  125174. /**
  125175. * Different button type to use instead of the main component
  125176. */
  125177. overrideButtonId?: string;
  125178. /**
  125179. * use this rendering group id for the meshes (optional)
  125180. */
  125181. renderingGroupId?: number;
  125182. /**
  125183. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  125184. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  125185. * 3000 means 3 seconds between pointing at something and selecting it
  125186. */
  125187. timeToSelect?: number;
  125188. /**
  125189. * Should meshes created here be added to a utility layer or the main scene
  125190. */
  125191. useUtilityLayer?: boolean;
  125192. /**
  125193. * the xr input to use with this pointer selection
  125194. */
  125195. xrInput: WebXRInput;
  125196. }
  125197. /**
  125198. * A module that will enable pointer selection for motion controllers of XR Input Sources
  125199. */
  125200. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  125201. private readonly _options;
  125202. private static _idCounter;
  125203. private _attachController;
  125204. private _controllers;
  125205. private _scene;
  125206. private _tmpVectorForPickCompare;
  125207. /**
  125208. * The module's name
  125209. */
  125210. static readonly Name: string;
  125211. /**
  125212. * The (Babylon) version of this module.
  125213. * This is an integer representing the implementation version.
  125214. * This number does not correspond to the WebXR specs version
  125215. */
  125216. static readonly Version: number;
  125217. /**
  125218. * Disable lighting on the laser pointer (so it will always be visible)
  125219. */
  125220. disablePointerLighting: boolean;
  125221. /**
  125222. * Disable lighting on the selection mesh (so it will always be visible)
  125223. */
  125224. disableSelectionMeshLighting: boolean;
  125225. /**
  125226. * Should the laser pointer be displayed
  125227. */
  125228. displayLaserPointer: boolean;
  125229. /**
  125230. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  125231. */
  125232. displaySelectionMesh: boolean;
  125233. /**
  125234. * This color will be set to the laser pointer when selection is triggered
  125235. */
  125236. laserPointerPickedColor: Color3;
  125237. /**
  125238. * Default color of the laser pointer
  125239. */
  125240. laserPointerDefaultColor: Color3;
  125241. /**
  125242. * default color of the selection ring
  125243. */
  125244. selectionMeshDefaultColor: Color3;
  125245. /**
  125246. * This color will be applied to the selection ring when selection is triggered
  125247. */
  125248. selectionMeshPickedColor: Color3;
  125249. /**
  125250. * Optional filter to be used for ray selection. This predicate shares behavior with
  125251. * scene.pointerMovePredicate which takes priority if it is also assigned.
  125252. */
  125253. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125254. /**
  125255. * constructs a new background remover module
  125256. * @param _xrSessionManager the session manager for this module
  125257. * @param _options read-only options to be used in this module
  125258. */
  125259. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  125260. /**
  125261. * attach this feature
  125262. * Will usually be called by the features manager
  125263. *
  125264. * @returns true if successful.
  125265. */
  125266. attach(): boolean;
  125267. /**
  125268. * detach this feature.
  125269. * Will usually be called by the features manager
  125270. *
  125271. * @returns true if successful.
  125272. */
  125273. detach(): boolean;
  125274. /**
  125275. * Will get the mesh under a specific pointer.
  125276. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  125277. * @param controllerId the controllerId to check
  125278. * @returns The mesh under pointer or null if no mesh is under the pointer
  125279. */
  125280. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  125281. /**
  125282. * Get the xr controller that correlates to the pointer id in the pointer event
  125283. *
  125284. * @param id the pointer id to search for
  125285. * @returns the controller that correlates to this id or null if not found
  125286. */
  125287. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  125288. protected _onXRFrame(_xrFrame: XRFrame): void;
  125289. private _attachGazeMode;
  125290. private _attachScreenRayMode;
  125291. private _attachTrackedPointerRayMode;
  125292. private _convertNormalToDirectionOfRay;
  125293. private _detachController;
  125294. private _generateNewMeshPair;
  125295. private _pickingMoved;
  125296. private _updatePointerDistance;
  125297. /** @hidden */
  125298. get lasterPointerDefaultColor(): Color3;
  125299. }
  125300. }
  125301. declare module BABYLON {
  125302. /**
  125303. * Button which can be used to enter a different mode of XR
  125304. */
  125305. export class WebXREnterExitUIButton {
  125306. /** button element */
  125307. element: HTMLElement;
  125308. /** XR initialization options for the button */
  125309. sessionMode: XRSessionMode;
  125310. /** Reference space type */
  125311. referenceSpaceType: XRReferenceSpaceType;
  125312. /**
  125313. * Creates a WebXREnterExitUIButton
  125314. * @param element button element
  125315. * @param sessionMode XR initialization session mode
  125316. * @param referenceSpaceType the type of reference space to be used
  125317. */
  125318. constructor(
  125319. /** button element */
  125320. element: HTMLElement,
  125321. /** XR initialization options for the button */
  125322. sessionMode: XRSessionMode,
  125323. /** Reference space type */
  125324. referenceSpaceType: XRReferenceSpaceType);
  125325. /**
  125326. * Extendable function which can be used to update the button's visuals when the state changes
  125327. * @param activeButton the current active button in the UI
  125328. */
  125329. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125330. }
  125331. /**
  125332. * Options to create the webXR UI
  125333. */
  125334. export class WebXREnterExitUIOptions {
  125335. /**
  125336. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125337. */
  125338. customButtons?: Array<WebXREnterExitUIButton>;
  125339. /**
  125340. * A reference space type to use when creating the default button.
  125341. * Default is local-floor
  125342. */
  125343. referenceSpaceType?: XRReferenceSpaceType;
  125344. /**
  125345. * Context to enter xr with
  125346. */
  125347. renderTarget?: Nullable<WebXRRenderTarget>;
  125348. /**
  125349. * A session mode to use when creating the default button.
  125350. * Default is immersive-vr
  125351. */
  125352. sessionMode?: XRSessionMode;
  125353. /**
  125354. * A list of optional features to init the session with
  125355. */
  125356. optionalFeatures?: string[];
  125357. }
  125358. /**
  125359. * UI to allow the user to enter/exit XR mode
  125360. */
  125361. export class WebXREnterExitUI implements IDisposable {
  125362. private scene;
  125363. /** version of the options passed to this UI */
  125364. options: WebXREnterExitUIOptions;
  125365. private _activeButton;
  125366. private _buttons;
  125367. private _overlay;
  125368. /**
  125369. * Fired every time the active button is changed.
  125370. *
  125371. * When xr is entered via a button that launches xr that button will be the callback parameter
  125372. *
  125373. * When exiting xr the callback parameter will be null)
  125374. */
  125375. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125376. /**
  125377. *
  125378. * @param scene babylon scene object to use
  125379. * @param options (read-only) version of the options passed to this UI
  125380. */
  125381. private constructor();
  125382. /**
  125383. * Creates UI to allow the user to enter/exit XR mode
  125384. * @param scene the scene to add the ui to
  125385. * @param helper the xr experience helper to enter/exit xr with
  125386. * @param options options to configure the UI
  125387. * @returns the created ui
  125388. */
  125389. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125390. /**
  125391. * Disposes of the XR UI component
  125392. */
  125393. dispose(): void;
  125394. private _updateButtons;
  125395. }
  125396. }
  125397. declare module BABYLON {
  125398. /**
  125399. * Class containing static functions to help procedurally build meshes
  125400. */
  125401. export class LinesBuilder {
  125402. /**
  125403. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125404. * * 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
  125405. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125406. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125407. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125408. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125409. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125410. * * 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
  125411. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125414. * @param name defines the name of the new line system
  125415. * @param options defines the options used to create the line system
  125416. * @param scene defines the hosting scene
  125417. * @returns a new line system mesh
  125418. */
  125419. static CreateLineSystem(name: string, options: {
  125420. lines: Vector3[][];
  125421. updatable?: boolean;
  125422. instance?: Nullable<LinesMesh>;
  125423. colors?: Nullable<Color4[][]>;
  125424. useVertexAlpha?: boolean;
  125425. }, scene: Nullable<Scene>): LinesMesh;
  125426. /**
  125427. * Creates a line mesh
  125428. * 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
  125429. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125430. * * The parameter `points` is an array successive Vector3
  125431. * * 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
  125432. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125433. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125434. * * When updating an instance, remember that only point positions can change, not the number of points
  125435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125437. * @param name defines the name of the new line system
  125438. * @param options defines the options used to create the line system
  125439. * @param scene defines the hosting scene
  125440. * @returns a new line mesh
  125441. */
  125442. static CreateLines(name: string, options: {
  125443. points: Vector3[];
  125444. updatable?: boolean;
  125445. instance?: Nullable<LinesMesh>;
  125446. colors?: Color4[];
  125447. useVertexAlpha?: boolean;
  125448. }, scene?: Nullable<Scene>): LinesMesh;
  125449. /**
  125450. * Creates a dashed line mesh
  125451. * * 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
  125452. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125453. * * The parameter `points` is an array successive Vector3
  125454. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125455. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125456. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125457. * * 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
  125458. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125459. * * When updating an instance, remember that only point positions can change, not the number of points
  125460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125461. * @param name defines the name of the mesh
  125462. * @param options defines the options used to create the mesh
  125463. * @param scene defines the hosting scene
  125464. * @returns the dashed line mesh
  125465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125466. */
  125467. static CreateDashedLines(name: string, options: {
  125468. points: Vector3[];
  125469. dashSize?: number;
  125470. gapSize?: number;
  125471. dashNb?: number;
  125472. updatable?: boolean;
  125473. instance?: LinesMesh;
  125474. useVertexAlpha?: boolean;
  125475. }, scene?: Nullable<Scene>): LinesMesh;
  125476. }
  125477. }
  125478. declare module BABYLON {
  125479. /**
  125480. * Construction options for a timer
  125481. */
  125482. export interface ITimerOptions<T> {
  125483. /**
  125484. * Time-to-end
  125485. */
  125486. timeout: number;
  125487. /**
  125488. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  125489. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  125490. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  125491. */
  125492. contextObservable: Observable<T>;
  125493. /**
  125494. * Optional parameters when adding an observer to the observable
  125495. */
  125496. observableParameters?: {
  125497. mask?: number;
  125498. insertFirst?: boolean;
  125499. scope?: any;
  125500. };
  125501. /**
  125502. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  125503. */
  125504. breakCondition?: (data?: ITimerData<T>) => boolean;
  125505. /**
  125506. * Will be triggered when the time condition has met
  125507. */
  125508. onEnded?: (data: ITimerData<any>) => void;
  125509. /**
  125510. * Will be triggered when the break condition has met (prematurely ended)
  125511. */
  125512. onAborted?: (data: ITimerData<any>) => void;
  125513. /**
  125514. * Optional function to execute on each tick (or count)
  125515. */
  125516. onTick?: (data: ITimerData<any>) => void;
  125517. }
  125518. /**
  125519. * An interface defining the data sent by the timer
  125520. */
  125521. export interface ITimerData<T> {
  125522. /**
  125523. * When did it start
  125524. */
  125525. startTime: number;
  125526. /**
  125527. * Time now
  125528. */
  125529. currentTime: number;
  125530. /**
  125531. * Time passed since started
  125532. */
  125533. deltaTime: number;
  125534. /**
  125535. * How much is completed, in [0.0...1.0].
  125536. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  125537. */
  125538. completeRate: number;
  125539. /**
  125540. * What the registered observable sent in the last count
  125541. */
  125542. payload: T;
  125543. }
  125544. /**
  125545. * The current state of the timer
  125546. */
  125547. export enum TimerState {
  125548. /**
  125549. * Timer initialized, not yet started
  125550. */
  125551. INIT = 0,
  125552. /**
  125553. * Timer started and counting
  125554. */
  125555. STARTED = 1,
  125556. /**
  125557. * Timer ended (whether aborted or time reached)
  125558. */
  125559. ENDED = 2
  125560. }
  125561. /**
  125562. * A simple version of the timer. Will take options and start the timer immediately after calling it
  125563. *
  125564. * @param options options with which to initialize this timer
  125565. */
  125566. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  125567. /**
  125568. * An advanced implementation of a timer class
  125569. */
  125570. export class AdvancedTimer<T = any> implements IDisposable {
  125571. /**
  125572. * Will notify each time the timer calculates the remaining time
  125573. */
  125574. onEachCountObservable: Observable<ITimerData<T>>;
  125575. /**
  125576. * Will trigger when the timer was aborted due to the break condition
  125577. */
  125578. onTimerAbortedObservable: Observable<ITimerData<T>>;
  125579. /**
  125580. * Will trigger when the timer ended successfully
  125581. */
  125582. onTimerEndedObservable: Observable<ITimerData<T>>;
  125583. /**
  125584. * Will trigger when the timer state has changed
  125585. */
  125586. onStateChangedObservable: Observable<TimerState>;
  125587. private _observer;
  125588. private _contextObservable;
  125589. private _observableParameters;
  125590. private _startTime;
  125591. private _timer;
  125592. private _state;
  125593. private _breakCondition;
  125594. private _timeToEnd;
  125595. private _breakOnNextTick;
  125596. /**
  125597. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  125598. * @param options construction options for this advanced timer
  125599. */
  125600. constructor(options: ITimerOptions<T>);
  125601. /**
  125602. * set a breaking condition for this timer. Default is to never break during count
  125603. * @param predicate the new break condition. Returns true to break, false otherwise
  125604. */
  125605. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  125606. /**
  125607. * Reset ALL associated observables in this advanced timer
  125608. */
  125609. clearObservables(): void;
  125610. /**
  125611. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  125612. *
  125613. * @param timeToEnd how much time to measure until timer ended
  125614. */
  125615. start(timeToEnd?: number): void;
  125616. /**
  125617. * Will force a stop on the next tick.
  125618. */
  125619. stop(): void;
  125620. /**
  125621. * Dispose this timer, clearing all resources
  125622. */
  125623. dispose(): void;
  125624. private _setState;
  125625. private _tick;
  125626. private _stop;
  125627. }
  125628. }
  125629. declare module BABYLON {
  125630. /**
  125631. * The options container for the teleportation module
  125632. */
  125633. export interface IWebXRTeleportationOptions {
  125634. /**
  125635. * if provided, this scene will be used to render meshes.
  125636. */
  125637. customUtilityLayerScene?: Scene;
  125638. /**
  125639. * Values to configure the default target mesh
  125640. */
  125641. defaultTargetMeshOptions?: {
  125642. /**
  125643. * Fill color of the teleportation area
  125644. */
  125645. teleportationFillColor?: string;
  125646. /**
  125647. * Border color for the teleportation area
  125648. */
  125649. teleportationBorderColor?: string;
  125650. /**
  125651. * Disable the mesh's animation sequence
  125652. */
  125653. disableAnimation?: boolean;
  125654. /**
  125655. * Disable lighting on the material or the ring and arrow
  125656. */
  125657. disableLighting?: boolean;
  125658. /**
  125659. * Override the default material of the torus and arrow
  125660. */
  125661. torusArrowMaterial?: Material;
  125662. };
  125663. /**
  125664. * A list of meshes to use as floor meshes.
  125665. * Meshes can be added and removed after initializing the feature using the
  125666. * addFloorMesh and removeFloorMesh functions
  125667. * If empty, rotation will still work
  125668. */
  125669. floorMeshes?: AbstractMesh[];
  125670. /**
  125671. * use this rendering group id for the meshes (optional)
  125672. */
  125673. renderingGroupId?: number;
  125674. /**
  125675. * Should teleportation move only to snap points
  125676. */
  125677. snapPointsOnly?: boolean;
  125678. /**
  125679. * An array of points to which the teleportation will snap to.
  125680. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  125681. */
  125682. snapPositions?: Vector3[];
  125683. /**
  125684. * How close should the teleportation ray be in order to snap to position.
  125685. * Default to 0.8 units (meters)
  125686. */
  125687. snapToPositionRadius?: number;
  125688. /**
  125689. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  125690. * If you want to support rotation, make sure your mesh has a direction indicator.
  125691. *
  125692. * When left untouched, the default mesh will be initialized.
  125693. */
  125694. teleportationTargetMesh?: AbstractMesh;
  125695. /**
  125696. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  125697. */
  125698. timeToTeleport?: number;
  125699. /**
  125700. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  125701. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  125702. */
  125703. useMainComponentOnly?: boolean;
  125704. /**
  125705. * Should meshes created here be added to a utility layer or the main scene
  125706. */
  125707. useUtilityLayer?: boolean;
  125708. /**
  125709. * Babylon XR Input class for controller
  125710. */
  125711. xrInput: WebXRInput;
  125712. }
  125713. /**
  125714. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  125715. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  125716. * the input of the attached controllers.
  125717. */
  125718. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  125719. private _options;
  125720. private _controllers;
  125721. private _currentTeleportationControllerId;
  125722. private _floorMeshes;
  125723. private _quadraticBezierCurve;
  125724. private _selectionFeature;
  125725. private _snapToPositions;
  125726. private _snappedToPoint;
  125727. private _teleportationRingMaterial?;
  125728. private _tmpRay;
  125729. private _tmpVector;
  125730. /**
  125731. * The module's name
  125732. */
  125733. static readonly Name: string;
  125734. /**
  125735. * The (Babylon) version of this module.
  125736. * This is an integer representing the implementation version.
  125737. * This number does not correspond to the webxr specs version
  125738. */
  125739. static readonly Version: number;
  125740. /**
  125741. * Is movement backwards enabled
  125742. */
  125743. backwardsMovementEnabled: boolean;
  125744. /**
  125745. * Distance to travel when moving backwards
  125746. */
  125747. backwardsTeleportationDistance: number;
  125748. /**
  125749. * The distance from the user to the inspection point in the direction of the controller
  125750. * A higher number will allow the user to move further
  125751. * defaults to 5 (meters, in xr units)
  125752. */
  125753. parabolicCheckRadius: number;
  125754. /**
  125755. * Should the module support parabolic ray on top of direct ray
  125756. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  125757. * Very helpful when moving between floors / different heights
  125758. */
  125759. parabolicRayEnabled: boolean;
  125760. /**
  125761. * How much rotation should be applied when rotating right and left
  125762. */
  125763. rotationAngle: number;
  125764. /**
  125765. * Is rotation enabled when moving forward?
  125766. * Disabling this feature will prevent the user from deciding the direction when teleporting
  125767. */
  125768. rotationEnabled: boolean;
  125769. /**
  125770. * constructs a new anchor system
  125771. * @param _xrSessionManager an instance of WebXRSessionManager
  125772. * @param _options configuration object for this feature
  125773. */
  125774. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  125775. /**
  125776. * Get the snapPointsOnly flag
  125777. */
  125778. get snapPointsOnly(): boolean;
  125779. /**
  125780. * Sets the snapPointsOnly flag
  125781. * @param snapToPoints should teleportation be exclusively to snap points
  125782. */
  125783. set snapPointsOnly(snapToPoints: boolean);
  125784. /**
  125785. * Add a new mesh to the floor meshes array
  125786. * @param mesh the mesh to use as floor mesh
  125787. */
  125788. addFloorMesh(mesh: AbstractMesh): void;
  125789. /**
  125790. * Add a new snap-to point to fix teleportation to this position
  125791. * @param newSnapPoint The new Snap-To point
  125792. */
  125793. addSnapPoint(newSnapPoint: Vector3): void;
  125794. attach(): boolean;
  125795. detach(): boolean;
  125796. dispose(): void;
  125797. /**
  125798. * Remove a mesh from the floor meshes array
  125799. * @param mesh the mesh to remove
  125800. */
  125801. removeFloorMesh(mesh: AbstractMesh): void;
  125802. /**
  125803. * Remove a mesh from the floor meshes array using its name
  125804. * @param name the mesh name to remove
  125805. */
  125806. removeFloorMeshByName(name: string): void;
  125807. /**
  125808. * 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
  125809. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  125810. * @returns was the point found and removed or not
  125811. */
  125812. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  125813. /**
  125814. * This function sets a selection feature that will be disabled when
  125815. * the forward ray is shown and will be reattached when hidden.
  125816. * This is used to remove the selection rays when moving.
  125817. * @param selectionFeature the feature to disable when forward movement is enabled
  125818. */
  125819. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  125820. protected _onXRFrame(_xrFrame: XRFrame): void;
  125821. private _attachController;
  125822. private _createDefaultTargetMesh;
  125823. private _detachController;
  125824. private _findClosestSnapPointWithRadius;
  125825. private _setTargetMeshPosition;
  125826. private _setTargetMeshVisibility;
  125827. private _showParabolicPath;
  125828. private _teleportForward;
  125829. }
  125830. }
  125831. declare module BABYLON {
  125832. /**
  125833. * Options for the default xr helper
  125834. */
  125835. export class WebXRDefaultExperienceOptions {
  125836. /**
  125837. * Enable or disable default UI to enter XR
  125838. */
  125839. disableDefaultUI?: boolean;
  125840. /**
  125841. * Should teleportation not initialize. defaults to false.
  125842. */
  125843. disableTeleportation?: boolean;
  125844. /**
  125845. * Floor meshes that will be used for teleport
  125846. */
  125847. floorMeshes?: Array<AbstractMesh>;
  125848. /**
  125849. * If set to true, the first frame will not be used to reset position
  125850. * The first frame is mainly used when copying transformation from the old camera
  125851. * Mainly used in AR
  125852. */
  125853. ignoreNativeCameraTransformation?: boolean;
  125854. /**
  125855. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  125856. */
  125857. inputOptions?: IWebXRInputOptions;
  125858. /**
  125859. * optional configuration for the output canvas
  125860. */
  125861. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  125862. /**
  125863. * optional UI options. This can be used among other to change session mode and reference space type
  125864. */
  125865. uiOptions?: WebXREnterExitUIOptions;
  125866. /**
  125867. * When loading teleportation and pointer select, use stable versions instead of latest.
  125868. */
  125869. useStablePlugins?: boolean;
  125870. /**
  125871. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  125872. */
  125873. renderingGroupId?: number;
  125874. /**
  125875. * A list of optional features to init the session with
  125876. * If set to true, all features we support will be added
  125877. */
  125878. optionalFeatures?: boolean | string[];
  125879. }
  125880. /**
  125881. * Default experience which provides a similar setup to the previous webVRExperience
  125882. */
  125883. export class WebXRDefaultExperience {
  125884. /**
  125885. * Base experience
  125886. */
  125887. baseExperience: WebXRExperienceHelper;
  125888. /**
  125889. * Enables ui for entering/exiting xr
  125890. */
  125891. enterExitUI: WebXREnterExitUI;
  125892. /**
  125893. * Input experience extension
  125894. */
  125895. input: WebXRInput;
  125896. /**
  125897. * Enables laser pointer and selection
  125898. */
  125899. pointerSelection: WebXRControllerPointerSelection;
  125900. /**
  125901. * Default target xr should render to
  125902. */
  125903. renderTarget: WebXRRenderTarget;
  125904. /**
  125905. * Enables teleportation
  125906. */
  125907. teleportation: WebXRMotionControllerTeleportation;
  125908. private constructor();
  125909. /**
  125910. * Creates the default xr experience
  125911. * @param scene scene
  125912. * @param options options for basic configuration
  125913. * @returns resulting WebXRDefaultExperience
  125914. */
  125915. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125916. /**
  125917. * DIsposes of the experience helper
  125918. */
  125919. dispose(): void;
  125920. }
  125921. }
  125922. declare module BABYLON {
  125923. /**
  125924. * Options to modify the vr teleportation behavior.
  125925. */
  125926. export interface VRTeleportationOptions {
  125927. /**
  125928. * The name of the mesh which should be used as the teleportation floor. (default: null)
  125929. */
  125930. floorMeshName?: string;
  125931. /**
  125932. * A list of meshes to be used as the teleportation floor. (default: empty)
  125933. */
  125934. floorMeshes?: Mesh[];
  125935. /**
  125936. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  125937. */
  125938. teleportationMode?: number;
  125939. /**
  125940. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  125941. */
  125942. teleportationTime?: number;
  125943. /**
  125944. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  125945. */
  125946. teleportationSpeed?: number;
  125947. /**
  125948. * The easing function used in the animation or null for Linear. (default CircleEase)
  125949. */
  125950. easingFunction?: EasingFunction;
  125951. }
  125952. /**
  125953. * Options to modify the vr experience helper's behavior.
  125954. */
  125955. export interface VRExperienceHelperOptions extends WebVROptions {
  125956. /**
  125957. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  125958. */
  125959. createDeviceOrientationCamera?: boolean;
  125960. /**
  125961. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  125962. */
  125963. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  125964. /**
  125965. * Uses the main button on the controller to toggle the laser casted. (default: true)
  125966. */
  125967. laserToggle?: boolean;
  125968. /**
  125969. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  125970. */
  125971. floorMeshes?: Mesh[];
  125972. /**
  125973. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  125974. */
  125975. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  125976. /**
  125977. * Defines if WebXR should be used instead of WebVR (if available)
  125978. */
  125979. useXR?: boolean;
  125980. }
  125981. /**
  125982. * Event containing information after VR has been entered
  125983. */
  125984. export class OnAfterEnteringVRObservableEvent {
  125985. /**
  125986. * If entering vr was successful
  125987. */
  125988. success: boolean;
  125989. }
  125990. /**
  125991. * Helps to quickly add VR support to an existing scene.
  125992. * See http://doc.babylonjs.com/how_to/webvr_helper
  125993. */
  125994. export class VRExperienceHelper {
  125995. /** Options to modify the vr experience helper's behavior. */
  125996. webVROptions: VRExperienceHelperOptions;
  125997. private _scene;
  125998. private _position;
  125999. private _btnVR;
  126000. private _btnVRDisplayed;
  126001. private _webVRsupported;
  126002. private _webVRready;
  126003. private _webVRrequesting;
  126004. private _webVRpresenting;
  126005. private _hasEnteredVR;
  126006. private _fullscreenVRpresenting;
  126007. private _inputElement;
  126008. private _webVRCamera;
  126009. private _vrDeviceOrientationCamera;
  126010. private _deviceOrientationCamera;
  126011. private _existingCamera;
  126012. private _onKeyDown;
  126013. private _onVrDisplayPresentChange;
  126014. private _onVRDisplayChanged;
  126015. private _onVRRequestPresentStart;
  126016. private _onVRRequestPresentComplete;
  126017. /**
  126018. * 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)
  126019. */
  126020. enableGazeEvenWhenNoPointerLock: boolean;
  126021. /**
  126022. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  126023. */
  126024. exitVROnDoubleTap: boolean;
  126025. /**
  126026. * Observable raised right before entering VR.
  126027. */
  126028. onEnteringVRObservable: Observable<VRExperienceHelper>;
  126029. /**
  126030. * Observable raised when entering VR has completed.
  126031. */
  126032. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  126033. /**
  126034. * Observable raised when exiting VR.
  126035. */
  126036. onExitingVRObservable: Observable<VRExperienceHelper>;
  126037. /**
  126038. * Observable raised when controller mesh is loaded.
  126039. */
  126040. onControllerMeshLoadedObservable: Observable<WebVRController>;
  126041. /** Return this.onEnteringVRObservable
  126042. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  126043. */
  126044. get onEnteringVR(): Observable<VRExperienceHelper>;
  126045. /** Return this.onExitingVRObservable
  126046. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  126047. */
  126048. get onExitingVR(): Observable<VRExperienceHelper>;
  126049. /** Return this.onControllerMeshLoadedObservable
  126050. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  126051. */
  126052. get onControllerMeshLoaded(): Observable<WebVRController>;
  126053. private _rayLength;
  126054. private _useCustomVRButton;
  126055. private _teleportationRequested;
  126056. private _teleportActive;
  126057. private _floorMeshName;
  126058. private _floorMeshesCollection;
  126059. private _teleportationMode;
  126060. private _teleportationTime;
  126061. private _teleportationSpeed;
  126062. private _teleportationEasing;
  126063. private _rotationAllowed;
  126064. private _teleportBackwardsVector;
  126065. private _teleportationTarget;
  126066. private _isDefaultTeleportationTarget;
  126067. private _postProcessMove;
  126068. private _teleportationFillColor;
  126069. private _teleportationBorderColor;
  126070. private _rotationAngle;
  126071. private _haloCenter;
  126072. private _cameraGazer;
  126073. private _padSensibilityUp;
  126074. private _padSensibilityDown;
  126075. private _leftController;
  126076. private _rightController;
  126077. private _gazeColor;
  126078. private _laserColor;
  126079. private _pickedLaserColor;
  126080. private _pickedGazeColor;
  126081. /**
  126082. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  126083. */
  126084. onNewMeshSelected: Observable<AbstractMesh>;
  126085. /**
  126086. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  126087. * This observable will provide the mesh and the controller used to select the mesh
  126088. */
  126089. onMeshSelectedWithController: Observable<{
  126090. mesh: AbstractMesh;
  126091. controller: WebVRController;
  126092. }>;
  126093. /**
  126094. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  126095. */
  126096. onNewMeshPicked: Observable<PickingInfo>;
  126097. private _circleEase;
  126098. /**
  126099. * Observable raised before camera teleportation
  126100. */
  126101. onBeforeCameraTeleport: Observable<Vector3>;
  126102. /**
  126103. * Observable raised after camera teleportation
  126104. */
  126105. onAfterCameraTeleport: Observable<Vector3>;
  126106. /**
  126107. * Observable raised when current selected mesh gets unselected
  126108. */
  126109. onSelectedMeshUnselected: Observable<AbstractMesh>;
  126110. private _raySelectionPredicate;
  126111. /**
  126112. * To be optionaly changed by user to define custom ray selection
  126113. */
  126114. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126115. /**
  126116. * To be optionaly changed by user to define custom selection logic (after ray selection)
  126117. */
  126118. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126119. /**
  126120. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  126121. */
  126122. teleportationEnabled: boolean;
  126123. private _defaultHeight;
  126124. private _teleportationInitialized;
  126125. private _interactionsEnabled;
  126126. private _interactionsRequested;
  126127. private _displayGaze;
  126128. private _displayLaserPointer;
  126129. /**
  126130. * The mesh used to display where the user is going to teleport.
  126131. */
  126132. get teleportationTarget(): Mesh;
  126133. /**
  126134. * Sets the mesh to be used to display where the user is going to teleport.
  126135. */
  126136. set teleportationTarget(value: Mesh);
  126137. /**
  126138. * 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
  126139. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  126140. * See http://doc.babylonjs.com/resources/baking_transformations
  126141. */
  126142. get gazeTrackerMesh(): Mesh;
  126143. set gazeTrackerMesh(value: Mesh);
  126144. /**
  126145. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  126146. */
  126147. updateGazeTrackerScale: boolean;
  126148. /**
  126149. * If the gaze trackers color should be updated when selecting meshes
  126150. */
  126151. updateGazeTrackerColor: boolean;
  126152. /**
  126153. * If the controller laser color should be updated when selecting meshes
  126154. */
  126155. updateControllerLaserColor: boolean;
  126156. /**
  126157. * The gaze tracking mesh corresponding to the left controller
  126158. */
  126159. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  126160. /**
  126161. * The gaze tracking mesh corresponding to the right controller
  126162. */
  126163. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  126164. /**
  126165. * If the ray of the gaze should be displayed.
  126166. */
  126167. get displayGaze(): boolean;
  126168. /**
  126169. * Sets if the ray of the gaze should be displayed.
  126170. */
  126171. set displayGaze(value: boolean);
  126172. /**
  126173. * If the ray of the LaserPointer should be displayed.
  126174. */
  126175. get displayLaserPointer(): boolean;
  126176. /**
  126177. * Sets if the ray of the LaserPointer should be displayed.
  126178. */
  126179. set displayLaserPointer(value: boolean);
  126180. /**
  126181. * The deviceOrientationCamera used as the camera when not in VR.
  126182. */
  126183. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  126184. /**
  126185. * Based on the current WebVR support, returns the current VR camera used.
  126186. */
  126187. get currentVRCamera(): Nullable<Camera>;
  126188. /**
  126189. * The webVRCamera which is used when in VR.
  126190. */
  126191. get webVRCamera(): WebVRFreeCamera;
  126192. /**
  126193. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  126194. */
  126195. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  126196. /**
  126197. * The html button that is used to trigger entering into VR.
  126198. */
  126199. get vrButton(): Nullable<HTMLButtonElement>;
  126200. private get _teleportationRequestInitiated();
  126201. /**
  126202. * Defines whether or not Pointer lock should be requested when switching to
  126203. * full screen.
  126204. */
  126205. requestPointerLockOnFullScreen: boolean;
  126206. /**
  126207. * If asking to force XR, this will be populated with the default xr experience
  126208. */
  126209. xr: WebXRDefaultExperience;
  126210. /**
  126211. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  126212. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  126213. */
  126214. xrTestDone: boolean;
  126215. /**
  126216. * Instantiates a VRExperienceHelper.
  126217. * Helps to quickly add VR support to an existing scene.
  126218. * @param scene The scene the VRExperienceHelper belongs to.
  126219. * @param webVROptions Options to modify the vr experience helper's behavior.
  126220. */
  126221. constructor(scene: Scene,
  126222. /** Options to modify the vr experience helper's behavior. */
  126223. webVROptions?: VRExperienceHelperOptions);
  126224. private completeVRInit;
  126225. private _onDefaultMeshLoaded;
  126226. private _onResize;
  126227. private _onFullscreenChange;
  126228. /**
  126229. * Gets a value indicating if we are currently in VR mode.
  126230. */
  126231. get isInVRMode(): boolean;
  126232. private onVrDisplayPresentChange;
  126233. private onVRDisplayChanged;
  126234. private moveButtonToBottomRight;
  126235. private displayVRButton;
  126236. private updateButtonVisibility;
  126237. private _cachedAngularSensibility;
  126238. /**
  126239. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  126240. * Otherwise, will use the fullscreen API.
  126241. */
  126242. enterVR(): void;
  126243. /**
  126244. * Attempt to exit VR, or fullscreen.
  126245. */
  126246. exitVR(): void;
  126247. /**
  126248. * The position of the vr experience helper.
  126249. */
  126250. get position(): Vector3;
  126251. /**
  126252. * Sets the position of the vr experience helper.
  126253. */
  126254. set position(value: Vector3);
  126255. /**
  126256. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  126257. */
  126258. enableInteractions(): void;
  126259. private get _noControllerIsActive();
  126260. private beforeRender;
  126261. private _isTeleportationFloor;
  126262. /**
  126263. * Adds a floor mesh to be used for teleportation.
  126264. * @param floorMesh the mesh to be used for teleportation.
  126265. */
  126266. addFloorMesh(floorMesh: Mesh): void;
  126267. /**
  126268. * Removes a floor mesh from being used for teleportation.
  126269. * @param floorMesh the mesh to be removed.
  126270. */
  126271. removeFloorMesh(floorMesh: Mesh): void;
  126272. /**
  126273. * Enables interactions and teleportation using the VR controllers and gaze.
  126274. * @param vrTeleportationOptions options to modify teleportation behavior.
  126275. */
  126276. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  126277. private _onNewGamepadConnected;
  126278. private _tryEnableInteractionOnController;
  126279. private _onNewGamepadDisconnected;
  126280. private _enableInteractionOnController;
  126281. private _checkTeleportWithRay;
  126282. private _checkRotate;
  126283. private _checkTeleportBackwards;
  126284. private _enableTeleportationOnController;
  126285. private _createTeleportationCircles;
  126286. private _displayTeleportationTarget;
  126287. private _hideTeleportationTarget;
  126288. private _rotateCamera;
  126289. private _moveTeleportationSelectorTo;
  126290. private _workingVector;
  126291. private _workingQuaternion;
  126292. private _workingMatrix;
  126293. /**
  126294. * Time Constant Teleportation Mode
  126295. */
  126296. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  126297. /**
  126298. * Speed Constant Teleportation Mode
  126299. */
  126300. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  126301. /**
  126302. * Teleports the users feet to the desired location
  126303. * @param location The location where the user's feet should be placed
  126304. */
  126305. teleportCamera(location: Vector3): void;
  126306. private _convertNormalToDirectionOfRay;
  126307. private _castRayAndSelectObject;
  126308. private _notifySelectedMeshUnselected;
  126309. /**
  126310. * Permanently set new colors for the laser pointer
  126311. * @param color the new laser color
  126312. * @param pickedColor the new laser color when picked mesh detected
  126313. */
  126314. setLaserColor(color: Color3, pickedColor?: Color3): void;
  126315. /**
  126316. * Set lighting enabled / disabled on the laser pointer of both controllers
  126317. * @param enabled should the lighting be enabled on the laser pointer
  126318. */
  126319. setLaserLightingState(enabled?: boolean): void;
  126320. /**
  126321. * Permanently set new colors for the gaze pointer
  126322. * @param color the new gaze color
  126323. * @param pickedColor the new gaze color when picked mesh detected
  126324. */
  126325. setGazeColor(color: Color3, pickedColor?: Color3): void;
  126326. /**
  126327. * Sets the color of the laser ray from the vr controllers.
  126328. * @param color new color for the ray.
  126329. */
  126330. changeLaserColor(color: Color3): void;
  126331. /**
  126332. * Sets the color of the ray from the vr headsets gaze.
  126333. * @param color new color for the ray.
  126334. */
  126335. changeGazeColor(color: Color3): void;
  126336. /**
  126337. * Exits VR and disposes of the vr experience helper
  126338. */
  126339. dispose(): void;
  126340. /**
  126341. * Gets the name of the VRExperienceHelper class
  126342. * @returns "VRExperienceHelper"
  126343. */
  126344. getClassName(): string;
  126345. }
  126346. }
  126347. declare module BABYLON {
  126348. /**
  126349. * Contains an array of blocks representing the octree
  126350. */
  126351. export interface IOctreeContainer<T> {
  126352. /**
  126353. * Blocks within the octree
  126354. */
  126355. blocks: Array<OctreeBlock<T>>;
  126356. }
  126357. /**
  126358. * Class used to store a cell in an octree
  126359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126360. */
  126361. export class OctreeBlock<T> {
  126362. /**
  126363. * Gets the content of the current block
  126364. */
  126365. entries: T[];
  126366. /**
  126367. * Gets the list of block children
  126368. */
  126369. blocks: Array<OctreeBlock<T>>;
  126370. private _depth;
  126371. private _maxDepth;
  126372. private _capacity;
  126373. private _minPoint;
  126374. private _maxPoint;
  126375. private _boundingVectors;
  126376. private _creationFunc;
  126377. /**
  126378. * Creates a new block
  126379. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  126380. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  126381. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126382. * @param depth defines the current depth of this block in the octree
  126383. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  126384. * @param creationFunc defines a callback to call when an element is added to the block
  126385. */
  126386. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  126387. /**
  126388. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126389. */
  126390. get capacity(): number;
  126391. /**
  126392. * Gets the minimum vector (in world space) of the block's bounding box
  126393. */
  126394. get minPoint(): Vector3;
  126395. /**
  126396. * Gets the maximum vector (in world space) of the block's bounding box
  126397. */
  126398. get maxPoint(): Vector3;
  126399. /**
  126400. * Add a new element to this block
  126401. * @param entry defines the element to add
  126402. */
  126403. addEntry(entry: T): void;
  126404. /**
  126405. * Remove an element from this block
  126406. * @param entry defines the element to remove
  126407. */
  126408. removeEntry(entry: T): void;
  126409. /**
  126410. * Add an array of elements to this block
  126411. * @param entries defines the array of elements to add
  126412. */
  126413. addEntries(entries: T[]): void;
  126414. /**
  126415. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  126416. * @param frustumPlanes defines the frustum planes to test
  126417. * @param selection defines the array to store current content if selection is positive
  126418. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126419. */
  126420. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126421. /**
  126422. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  126423. * @param sphereCenter defines the bounding sphere center
  126424. * @param sphereRadius defines the bounding sphere radius
  126425. * @param selection defines the array to store current content if selection is positive
  126426. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126427. */
  126428. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126429. /**
  126430. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  126431. * @param ray defines the ray to test with
  126432. * @param selection defines the array to store current content if selection is positive
  126433. */
  126434. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  126435. /**
  126436. * Subdivide the content into child blocks (this block will then be empty)
  126437. */
  126438. createInnerBlocks(): void;
  126439. /**
  126440. * @hidden
  126441. */
  126442. 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;
  126443. }
  126444. }
  126445. declare module BABYLON {
  126446. /**
  126447. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  126448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126449. */
  126450. export class Octree<T> {
  126451. /** 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.) */
  126452. maxDepth: number;
  126453. /**
  126454. * Blocks within the octree containing objects
  126455. */
  126456. blocks: Array<OctreeBlock<T>>;
  126457. /**
  126458. * Content stored in the octree
  126459. */
  126460. dynamicContent: T[];
  126461. private _maxBlockCapacity;
  126462. private _selectionContent;
  126463. private _creationFunc;
  126464. /**
  126465. * Creates a octree
  126466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126467. * @param creationFunc function to be used to instatiate the octree
  126468. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  126469. * @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.)
  126470. */
  126471. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  126472. /** 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.) */
  126473. maxDepth?: number);
  126474. /**
  126475. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  126476. * @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);
  126477. * @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);
  126478. * @param entries meshes to be added to the octree blocks
  126479. */
  126480. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  126481. /**
  126482. * Adds a mesh to the octree
  126483. * @param entry Mesh to add to the octree
  126484. */
  126485. addMesh(entry: T): void;
  126486. /**
  126487. * Remove an element from the octree
  126488. * @param entry defines the element to remove
  126489. */
  126490. removeMesh(entry: T): void;
  126491. /**
  126492. * Selects an array of meshes within the frustum
  126493. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  126494. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  126495. * @returns array of meshes within the frustum
  126496. */
  126497. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  126498. /**
  126499. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  126500. * @param sphereCenter defines the bounding sphere center
  126501. * @param sphereRadius defines the bounding sphere radius
  126502. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126503. * @returns an array of objects that intersect the sphere
  126504. */
  126505. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  126506. /**
  126507. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  126508. * @param ray defines the ray to test with
  126509. * @returns array of intersected objects
  126510. */
  126511. intersectsRay(ray: Ray): SmartArray<T>;
  126512. /**
  126513. * Adds a mesh into the octree block if it intersects the block
  126514. */
  126515. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  126516. /**
  126517. * Adds a submesh into the octree block if it intersects the block
  126518. */
  126519. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  126520. }
  126521. }
  126522. declare module BABYLON {
  126523. interface Scene {
  126524. /**
  126525. * @hidden
  126526. * Backing Filed
  126527. */
  126528. _selectionOctree: Octree<AbstractMesh>;
  126529. /**
  126530. * Gets the octree used to boost mesh selection (picking)
  126531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126532. */
  126533. selectionOctree: Octree<AbstractMesh>;
  126534. /**
  126535. * Creates or updates the octree used to boost selection (picking)
  126536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126537. * @param maxCapacity defines the maximum capacity per leaf
  126538. * @param maxDepth defines the maximum depth of the octree
  126539. * @returns an octree of AbstractMesh
  126540. */
  126541. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  126542. }
  126543. interface AbstractMesh {
  126544. /**
  126545. * @hidden
  126546. * Backing Field
  126547. */
  126548. _submeshesOctree: Octree<SubMesh>;
  126549. /**
  126550. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  126551. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  126552. * @param maxCapacity defines the maximum size of each block (64 by default)
  126553. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  126554. * @returns the new octree
  126555. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  126556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126557. */
  126558. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  126559. }
  126560. /**
  126561. * Defines the octree scene component responsible to manage any octrees
  126562. * in a given scene.
  126563. */
  126564. export class OctreeSceneComponent {
  126565. /**
  126566. * The component name help to identify the component in the list of scene components.
  126567. */
  126568. readonly name: string;
  126569. /**
  126570. * The scene the component belongs to.
  126571. */
  126572. scene: Scene;
  126573. /**
  126574. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126575. */
  126576. readonly checksIsEnabled: boolean;
  126577. /**
  126578. * Creates a new instance of the component for the given scene
  126579. * @param scene Defines the scene to register the component in
  126580. */
  126581. constructor(scene: Scene);
  126582. /**
  126583. * Registers the component in a given scene
  126584. */
  126585. register(): void;
  126586. /**
  126587. * Return the list of active meshes
  126588. * @returns the list of active meshes
  126589. */
  126590. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126591. /**
  126592. * Return the list of active sub meshes
  126593. * @param mesh The mesh to get the candidates sub meshes from
  126594. * @returns the list of active sub meshes
  126595. */
  126596. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126597. private _tempRay;
  126598. /**
  126599. * Return the list of sub meshes intersecting with a given local ray
  126600. * @param mesh defines the mesh to find the submesh for
  126601. * @param localRay defines the ray in local space
  126602. * @returns the list of intersecting sub meshes
  126603. */
  126604. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126605. /**
  126606. * Return the list of sub meshes colliding with a collider
  126607. * @param mesh defines the mesh to find the submesh for
  126608. * @param collider defines the collider to evaluate the collision against
  126609. * @returns the list of colliding sub meshes
  126610. */
  126611. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126612. /**
  126613. * Rebuilds the elements related to this component in case of
  126614. * context lost for instance.
  126615. */
  126616. rebuild(): void;
  126617. /**
  126618. * Disposes the component and the associated ressources.
  126619. */
  126620. dispose(): void;
  126621. }
  126622. }
  126623. declare module BABYLON {
  126624. /**
  126625. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126626. */
  126627. export class Gizmo implements IDisposable {
  126628. /** The utility layer the gizmo will be added to */
  126629. gizmoLayer: UtilityLayerRenderer;
  126630. /**
  126631. * The root mesh of the gizmo
  126632. */
  126633. _rootMesh: Mesh;
  126634. private _attachedMesh;
  126635. /**
  126636. * Ratio for the scale of the gizmo (Default: 1)
  126637. */
  126638. scaleRatio: number;
  126639. /**
  126640. * If a custom mesh has been set (Default: false)
  126641. */
  126642. protected _customMeshSet: boolean;
  126643. /**
  126644. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126645. * * When set, interactions will be enabled
  126646. */
  126647. get attachedMesh(): Nullable<AbstractMesh>;
  126648. set attachedMesh(value: Nullable<AbstractMesh>);
  126649. /**
  126650. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  126651. * @param mesh The mesh to replace the default mesh of the gizmo
  126652. */
  126653. setCustomMesh(mesh: Mesh): void;
  126654. /**
  126655. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  126656. */
  126657. updateGizmoRotationToMatchAttachedMesh: boolean;
  126658. /**
  126659. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  126660. */
  126661. updateGizmoPositionToMatchAttachedMesh: boolean;
  126662. /**
  126663. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  126664. */
  126665. updateScale: boolean;
  126666. protected _interactionsEnabled: boolean;
  126667. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126668. private _beforeRenderObserver;
  126669. private _tempVector;
  126670. /**
  126671. * Creates a gizmo
  126672. * @param gizmoLayer The utility layer the gizmo will be added to
  126673. */
  126674. constructor(
  126675. /** The utility layer the gizmo will be added to */
  126676. gizmoLayer?: UtilityLayerRenderer);
  126677. /**
  126678. * Updates the gizmo to match the attached mesh's position/rotation
  126679. */
  126680. protected _update(): void;
  126681. /**
  126682. * Disposes of the gizmo
  126683. */
  126684. dispose(): void;
  126685. }
  126686. }
  126687. declare module BABYLON {
  126688. /**
  126689. * Single plane drag gizmo
  126690. */
  126691. export class PlaneDragGizmo extends Gizmo {
  126692. /**
  126693. * Drag behavior responsible for the gizmos dragging interactions
  126694. */
  126695. dragBehavior: PointerDragBehavior;
  126696. private _pointerObserver;
  126697. /**
  126698. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126699. */
  126700. snapDistance: number;
  126701. /**
  126702. * Event that fires each time the gizmo snaps to a new location.
  126703. * * snapDistance is the the change in distance
  126704. */
  126705. onSnapObservable: Observable<{
  126706. snapDistance: number;
  126707. }>;
  126708. private _plane;
  126709. private _coloredMaterial;
  126710. private _hoverMaterial;
  126711. private _isEnabled;
  126712. private _parent;
  126713. /** @hidden */
  126714. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  126715. /** @hidden */
  126716. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126717. /**
  126718. * Creates a PlaneDragGizmo
  126719. * @param gizmoLayer The utility layer the gizmo will be added to
  126720. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  126721. * @param color The color of the gizmo
  126722. */
  126723. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126724. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126725. /**
  126726. * If the gizmo is enabled
  126727. */
  126728. set isEnabled(value: boolean);
  126729. get isEnabled(): boolean;
  126730. /**
  126731. * Disposes of the gizmo
  126732. */
  126733. dispose(): void;
  126734. }
  126735. }
  126736. declare module BABYLON {
  126737. /**
  126738. * Gizmo that enables dragging a mesh along 3 axis
  126739. */
  126740. export class PositionGizmo extends Gizmo {
  126741. /**
  126742. * Internal gizmo used for interactions on the x axis
  126743. */
  126744. xGizmo: AxisDragGizmo;
  126745. /**
  126746. * Internal gizmo used for interactions on the y axis
  126747. */
  126748. yGizmo: AxisDragGizmo;
  126749. /**
  126750. * Internal gizmo used for interactions on the z axis
  126751. */
  126752. zGizmo: AxisDragGizmo;
  126753. /**
  126754. * Internal gizmo used for interactions on the yz plane
  126755. */
  126756. xPlaneGizmo: PlaneDragGizmo;
  126757. /**
  126758. * Internal gizmo used for interactions on the xz plane
  126759. */
  126760. yPlaneGizmo: PlaneDragGizmo;
  126761. /**
  126762. * Internal gizmo used for interactions on the xy plane
  126763. */
  126764. zPlaneGizmo: PlaneDragGizmo;
  126765. /**
  126766. * private variables
  126767. */
  126768. private _meshAttached;
  126769. private _updateGizmoRotationToMatchAttachedMesh;
  126770. private _snapDistance;
  126771. private _scaleRatio;
  126772. /** Fires an event when any of it's sub gizmos are dragged */
  126773. onDragStartObservable: Observable<unknown>;
  126774. /** Fires an event when any of it's sub gizmos are released from dragging */
  126775. onDragEndObservable: Observable<unknown>;
  126776. /**
  126777. * If set to true, planar drag is enabled
  126778. */
  126779. private _planarGizmoEnabled;
  126780. get attachedMesh(): Nullable<AbstractMesh>;
  126781. set attachedMesh(mesh: Nullable<AbstractMesh>);
  126782. /**
  126783. * Creates a PositionGizmo
  126784. * @param gizmoLayer The utility layer the gizmo will be added to
  126785. */
  126786. constructor(gizmoLayer?: UtilityLayerRenderer);
  126787. /**
  126788. * If the planar drag gizmo is enabled
  126789. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  126790. */
  126791. set planarGizmoEnabled(value: boolean);
  126792. get planarGizmoEnabled(): boolean;
  126793. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  126794. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  126795. /**
  126796. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126797. */
  126798. set snapDistance(value: number);
  126799. get snapDistance(): number;
  126800. /**
  126801. * Ratio for the scale of the gizmo (Default: 1)
  126802. */
  126803. set scaleRatio(value: number);
  126804. get scaleRatio(): number;
  126805. /**
  126806. * Disposes of the gizmo
  126807. */
  126808. dispose(): void;
  126809. /**
  126810. * CustomMeshes are not supported by this gizmo
  126811. * @param mesh The mesh to replace the default mesh of the gizmo
  126812. */
  126813. setCustomMesh(mesh: Mesh): void;
  126814. }
  126815. }
  126816. declare module BABYLON {
  126817. /**
  126818. * Single axis drag gizmo
  126819. */
  126820. export class AxisDragGizmo extends Gizmo {
  126821. /**
  126822. * Drag behavior responsible for the gizmos dragging interactions
  126823. */
  126824. dragBehavior: PointerDragBehavior;
  126825. private _pointerObserver;
  126826. /**
  126827. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  126828. */
  126829. snapDistance: number;
  126830. /**
  126831. * Event that fires each time the gizmo snaps to a new location.
  126832. * * snapDistance is the the change in distance
  126833. */
  126834. onSnapObservable: Observable<{
  126835. snapDistance: number;
  126836. }>;
  126837. private _isEnabled;
  126838. private _parent;
  126839. private _arrow;
  126840. private _coloredMaterial;
  126841. private _hoverMaterial;
  126842. /** @hidden */
  126843. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  126844. /** @hidden */
  126845. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  126846. /**
  126847. * Creates an AxisDragGizmo
  126848. * @param gizmoLayer The utility layer the gizmo will be added to
  126849. * @param dragAxis The axis which the gizmo will be able to drag on
  126850. * @param color The color of the gizmo
  126851. */
  126852. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  126853. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  126854. /**
  126855. * If the gizmo is enabled
  126856. */
  126857. set isEnabled(value: boolean);
  126858. get isEnabled(): boolean;
  126859. /**
  126860. * Disposes of the gizmo
  126861. */
  126862. dispose(): void;
  126863. }
  126864. }
  126865. declare module BABYLON.Debug {
  126866. /**
  126867. * The Axes viewer will show 3 axes in a specific point in space
  126868. */
  126869. export class AxesViewer {
  126870. private _xAxis;
  126871. private _yAxis;
  126872. private _zAxis;
  126873. private _scaleLinesFactor;
  126874. private _instanced;
  126875. /**
  126876. * Gets the hosting scene
  126877. */
  126878. scene: Scene;
  126879. /**
  126880. * Gets or sets a number used to scale line length
  126881. */
  126882. scaleLines: number;
  126883. /** Gets the node hierarchy used to render x-axis */
  126884. get xAxis(): TransformNode;
  126885. /** Gets the node hierarchy used to render y-axis */
  126886. get yAxis(): TransformNode;
  126887. /** Gets the node hierarchy used to render z-axis */
  126888. get zAxis(): TransformNode;
  126889. /**
  126890. * Creates a new AxesViewer
  126891. * @param scene defines the hosting scene
  126892. * @param scaleLines defines a number used to scale line length (1 by default)
  126893. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  126894. * @param xAxis defines the node hierarchy used to render the x-axis
  126895. * @param yAxis defines the node hierarchy used to render the y-axis
  126896. * @param zAxis defines the node hierarchy used to render the z-axis
  126897. */
  126898. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  126899. /**
  126900. * Force the viewer to update
  126901. * @param position defines the position of the viewer
  126902. * @param xaxis defines the x axis of the viewer
  126903. * @param yaxis defines the y axis of the viewer
  126904. * @param zaxis defines the z axis of the viewer
  126905. */
  126906. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  126907. /**
  126908. * Creates an instance of this axes viewer.
  126909. * @returns a new axes viewer with instanced meshes
  126910. */
  126911. createInstance(): AxesViewer;
  126912. /** Releases resources */
  126913. dispose(): void;
  126914. private static _SetRenderingGroupId;
  126915. }
  126916. }
  126917. declare module BABYLON.Debug {
  126918. /**
  126919. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  126920. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  126921. */
  126922. export class BoneAxesViewer extends AxesViewer {
  126923. /**
  126924. * Gets or sets the target mesh where to display the axes viewer
  126925. */
  126926. mesh: Nullable<Mesh>;
  126927. /**
  126928. * Gets or sets the target bone where to display the axes viewer
  126929. */
  126930. bone: Nullable<Bone>;
  126931. /** Gets current position */
  126932. pos: Vector3;
  126933. /** Gets direction of X axis */
  126934. xaxis: Vector3;
  126935. /** Gets direction of Y axis */
  126936. yaxis: Vector3;
  126937. /** Gets direction of Z axis */
  126938. zaxis: Vector3;
  126939. /**
  126940. * Creates a new BoneAxesViewer
  126941. * @param scene defines the hosting scene
  126942. * @param bone defines the target bone
  126943. * @param mesh defines the target mesh
  126944. * @param scaleLines defines a scaling factor for line length (1 by default)
  126945. */
  126946. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  126947. /**
  126948. * Force the viewer to update
  126949. */
  126950. update(): void;
  126951. /** Releases resources */
  126952. dispose(): void;
  126953. }
  126954. }
  126955. declare module BABYLON {
  126956. /**
  126957. * Interface used to define scene explorer extensibility option
  126958. */
  126959. export interface IExplorerExtensibilityOption {
  126960. /**
  126961. * Define the option label
  126962. */
  126963. label: string;
  126964. /**
  126965. * Defines the action to execute on click
  126966. */
  126967. action: (entity: any) => void;
  126968. }
  126969. /**
  126970. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  126971. */
  126972. export interface IExplorerExtensibilityGroup {
  126973. /**
  126974. * Defines a predicate to test if a given type mut be extended
  126975. */
  126976. predicate: (entity: any) => boolean;
  126977. /**
  126978. * Gets the list of options added to a type
  126979. */
  126980. entries: IExplorerExtensibilityOption[];
  126981. }
  126982. /**
  126983. * Interface used to define the options to use to create the Inspector
  126984. */
  126985. export interface IInspectorOptions {
  126986. /**
  126987. * Display in overlay mode (default: false)
  126988. */
  126989. overlay?: boolean;
  126990. /**
  126991. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  126992. */
  126993. globalRoot?: HTMLElement;
  126994. /**
  126995. * Display the Scene explorer
  126996. */
  126997. showExplorer?: boolean;
  126998. /**
  126999. * Display the property inspector
  127000. */
  127001. showInspector?: boolean;
  127002. /**
  127003. * Display in embed mode (both panes on the right)
  127004. */
  127005. embedMode?: boolean;
  127006. /**
  127007. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  127008. */
  127009. handleResize?: boolean;
  127010. /**
  127011. * Allow the panes to popup (default: true)
  127012. */
  127013. enablePopup?: boolean;
  127014. /**
  127015. * Allow the panes to be closed by users (default: true)
  127016. */
  127017. enableClose?: boolean;
  127018. /**
  127019. * Optional list of extensibility entries
  127020. */
  127021. explorerExtensibility?: IExplorerExtensibilityGroup[];
  127022. /**
  127023. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  127024. */
  127025. inspectorURL?: string;
  127026. /**
  127027. * Optional initial tab (default to DebugLayerTab.Properties)
  127028. */
  127029. initialTab?: DebugLayerTab;
  127030. }
  127031. interface Scene {
  127032. /**
  127033. * @hidden
  127034. * Backing field
  127035. */
  127036. _debugLayer: DebugLayer;
  127037. /**
  127038. * Gets the debug layer (aka Inspector) associated with the scene
  127039. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127040. */
  127041. debugLayer: DebugLayer;
  127042. }
  127043. /**
  127044. * Enum of inspector action tab
  127045. */
  127046. export enum DebugLayerTab {
  127047. /**
  127048. * Properties tag (default)
  127049. */
  127050. Properties = 0,
  127051. /**
  127052. * Debug tab
  127053. */
  127054. Debug = 1,
  127055. /**
  127056. * Statistics tab
  127057. */
  127058. Statistics = 2,
  127059. /**
  127060. * Tools tab
  127061. */
  127062. Tools = 3,
  127063. /**
  127064. * Settings tab
  127065. */
  127066. Settings = 4
  127067. }
  127068. /**
  127069. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127070. * what is happening in your scene
  127071. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127072. */
  127073. export class DebugLayer {
  127074. /**
  127075. * Define the url to get the inspector script from.
  127076. * By default it uses the babylonjs CDN.
  127077. * @ignoreNaming
  127078. */
  127079. static InspectorURL: string;
  127080. private _scene;
  127081. private BJSINSPECTOR;
  127082. private _onPropertyChangedObservable?;
  127083. /**
  127084. * Observable triggered when a property is changed through the inspector.
  127085. */
  127086. get onPropertyChangedObservable(): any;
  127087. /**
  127088. * Instantiates a new debug layer.
  127089. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127090. * what is happening in your scene
  127091. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127092. * @param scene Defines the scene to inspect
  127093. */
  127094. constructor(scene: Scene);
  127095. /** Creates the inspector window. */
  127096. private _createInspector;
  127097. /**
  127098. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  127099. * @param entity defines the entity to select
  127100. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  127101. */
  127102. select(entity: any, lineContainerTitles?: string | string[]): void;
  127103. /** Get the inspector from bundle or global */
  127104. private _getGlobalInspector;
  127105. /**
  127106. * Get if the inspector is visible or not.
  127107. * @returns true if visible otherwise, false
  127108. */
  127109. isVisible(): boolean;
  127110. /**
  127111. * Hide the inspector and close its window.
  127112. */
  127113. hide(): void;
  127114. /**
  127115. * Update the scene in the inspector
  127116. */
  127117. setAsActiveScene(): void;
  127118. /**
  127119. * Launch the debugLayer.
  127120. * @param config Define the configuration of the inspector
  127121. * @return a promise fulfilled when the debug layer is visible
  127122. */
  127123. show(config?: IInspectorOptions): Promise<DebugLayer>;
  127124. }
  127125. }
  127126. declare module BABYLON {
  127127. /**
  127128. * Class containing static functions to help procedurally build meshes
  127129. */
  127130. export class BoxBuilder {
  127131. /**
  127132. * Creates a box mesh
  127133. * * The parameter `size` sets the size (float) of each box side (default 1)
  127134. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127135. * * 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)
  127136. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127140. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127141. * @param name defines the name of the mesh
  127142. * @param options defines the options used to create the mesh
  127143. * @param scene defines the hosting scene
  127144. * @returns the box mesh
  127145. */
  127146. static CreateBox(name: string, options: {
  127147. size?: number;
  127148. width?: number;
  127149. height?: number;
  127150. depth?: number;
  127151. faceUV?: Vector4[];
  127152. faceColors?: Color4[];
  127153. sideOrientation?: number;
  127154. frontUVs?: Vector4;
  127155. backUVs?: Vector4;
  127156. wrap?: boolean;
  127157. topBaseAt?: number;
  127158. bottomBaseAt?: number;
  127159. updatable?: boolean;
  127160. }, scene?: Nullable<Scene>): Mesh;
  127161. }
  127162. }
  127163. declare module BABYLON.Debug {
  127164. /**
  127165. * Used to show the physics impostor around the specific mesh
  127166. */
  127167. export class PhysicsViewer {
  127168. /** @hidden */
  127169. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  127170. /** @hidden */
  127171. protected _meshes: Array<Nullable<AbstractMesh>>;
  127172. /** @hidden */
  127173. protected _scene: Nullable<Scene>;
  127174. /** @hidden */
  127175. protected _numMeshes: number;
  127176. /** @hidden */
  127177. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  127178. private _renderFunction;
  127179. private _utilityLayer;
  127180. private _debugBoxMesh;
  127181. private _debugSphereMesh;
  127182. private _debugCylinderMesh;
  127183. private _debugMaterial;
  127184. private _debugMeshMeshes;
  127185. /**
  127186. * Creates a new PhysicsViewer
  127187. * @param scene defines the hosting scene
  127188. */
  127189. constructor(scene: Scene);
  127190. /** @hidden */
  127191. protected _updateDebugMeshes(): void;
  127192. /**
  127193. * Renders a specified physic impostor
  127194. * @param impostor defines the impostor to render
  127195. * @param targetMesh defines the mesh represented by the impostor
  127196. * @returns the new debug mesh used to render the impostor
  127197. */
  127198. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  127199. /**
  127200. * Hides a specified physic impostor
  127201. * @param impostor defines the impostor to hide
  127202. */
  127203. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  127204. private _getDebugMaterial;
  127205. private _getDebugBoxMesh;
  127206. private _getDebugSphereMesh;
  127207. private _getDebugCylinderMesh;
  127208. private _getDebugMeshMesh;
  127209. private _getDebugMesh;
  127210. /** Releases all resources */
  127211. dispose(): void;
  127212. }
  127213. }
  127214. declare module BABYLON {
  127215. /**
  127216. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127217. * in order to better appreciate the issue one might have.
  127218. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127219. */
  127220. export class RayHelper {
  127221. /**
  127222. * Defines the ray we are currently tryin to visualize.
  127223. */
  127224. ray: Nullable<Ray>;
  127225. private _renderPoints;
  127226. private _renderLine;
  127227. private _renderFunction;
  127228. private _scene;
  127229. private _updateToMeshFunction;
  127230. private _attachedToMesh;
  127231. private _meshSpaceDirection;
  127232. private _meshSpaceOrigin;
  127233. /**
  127234. * Helper function to create a colored helper in a scene in one line.
  127235. * @param ray Defines the ray we are currently tryin to visualize
  127236. * @param scene Defines the scene the ray is used in
  127237. * @param color Defines the color we want to see the ray in
  127238. * @returns The newly created ray helper.
  127239. */
  127240. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  127241. /**
  127242. * Instantiate a new ray helper.
  127243. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127244. * in order to better appreciate the issue one might have.
  127245. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127246. * @param ray Defines the ray we are currently tryin to visualize
  127247. */
  127248. constructor(ray: Ray);
  127249. /**
  127250. * Shows the ray we are willing to debug.
  127251. * @param scene Defines the scene the ray needs to be rendered in
  127252. * @param color Defines the color the ray needs to be rendered in
  127253. */
  127254. show(scene: Scene, color?: Color3): void;
  127255. /**
  127256. * Hides the ray we are debugging.
  127257. */
  127258. hide(): void;
  127259. private _render;
  127260. /**
  127261. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  127262. * @param mesh Defines the mesh we want the helper attached to
  127263. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  127264. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  127265. * @param length Defines the length of the ray
  127266. */
  127267. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  127268. /**
  127269. * Detach the ray helper from the mesh it has previously been attached to.
  127270. */
  127271. detachFromMesh(): void;
  127272. private _updateToMesh;
  127273. /**
  127274. * Dispose the helper and release its associated resources.
  127275. */
  127276. dispose(): void;
  127277. }
  127278. }
  127279. declare module BABYLON.Debug {
  127280. /**
  127281. * Class used to render a debug view of a given skeleton
  127282. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  127283. */
  127284. export class SkeletonViewer {
  127285. /** defines the skeleton to render */
  127286. skeleton: Skeleton;
  127287. /** defines the mesh attached to the skeleton */
  127288. mesh: AbstractMesh;
  127289. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127290. autoUpdateBonesMatrices: boolean;
  127291. /** defines the rendering group id to use with the viewer */
  127292. renderingGroupId: number;
  127293. /** Gets or sets the color used to render the skeleton */
  127294. color: Color3;
  127295. private _scene;
  127296. private _debugLines;
  127297. private _debugMesh;
  127298. private _isEnabled;
  127299. private _renderFunction;
  127300. private _utilityLayer;
  127301. /**
  127302. * Returns the mesh used to render the bones
  127303. */
  127304. get debugMesh(): Nullable<LinesMesh>;
  127305. /**
  127306. * Creates a new SkeletonViewer
  127307. * @param skeleton defines the skeleton to render
  127308. * @param mesh defines the mesh attached to the skeleton
  127309. * @param scene defines the hosting scene
  127310. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  127311. * @param renderingGroupId defines the rendering group id to use with the viewer
  127312. */
  127313. constructor(
  127314. /** defines the skeleton to render */
  127315. skeleton: Skeleton,
  127316. /** defines the mesh attached to the skeleton */
  127317. mesh: AbstractMesh, scene: Scene,
  127318. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127319. autoUpdateBonesMatrices?: boolean,
  127320. /** defines the rendering group id to use with the viewer */
  127321. renderingGroupId?: number);
  127322. /** Gets or sets a boolean indicating if the viewer is enabled */
  127323. set isEnabled(value: boolean);
  127324. get isEnabled(): boolean;
  127325. private _getBonePosition;
  127326. private _getLinesForBonesWithLength;
  127327. private _getLinesForBonesNoLength;
  127328. /** Update the viewer to sync with current skeleton state */
  127329. update(): void;
  127330. /** Release associated resources */
  127331. dispose(): void;
  127332. }
  127333. }
  127334. declare module BABYLON {
  127335. /**
  127336. * Enum for Device Types
  127337. */
  127338. export enum DeviceType {
  127339. /** Generic */
  127340. Generic = 0,
  127341. /** Keyboard */
  127342. Keyboard = 1,
  127343. /** Mouse */
  127344. Mouse = 2,
  127345. /** Touch Pointers */
  127346. Touch = 3,
  127347. /** PS4 Dual Shock */
  127348. DualShock = 4,
  127349. /** Xbox */
  127350. Xbox = 5,
  127351. /** Switch Controller */
  127352. Switch = 6
  127353. }
  127354. /**
  127355. * Enum for All Pointers (Touch/Mouse)
  127356. */
  127357. export enum PointerInput {
  127358. /** Horizontal Axis */
  127359. Horizontal = 0,
  127360. /** Vertical Axis */
  127361. Vertical = 1,
  127362. /** Left Click or Touch */
  127363. LeftClick = 2,
  127364. /** Middle Click */
  127365. MiddleClick = 3,
  127366. /** Right Click */
  127367. RightClick = 4,
  127368. /** Browser Back */
  127369. BrowserBack = 5,
  127370. /** Browser Forward */
  127371. BrowserForward = 6
  127372. }
  127373. /**
  127374. * Enum for Dual Shock Gamepad
  127375. */
  127376. export enum DualShockInput {
  127377. /** Cross */
  127378. Cross = 0,
  127379. /** Circle */
  127380. Circle = 1,
  127381. /** Square */
  127382. Square = 2,
  127383. /** Triangle */
  127384. Triangle = 3,
  127385. /** L1 */
  127386. L1 = 4,
  127387. /** R1 */
  127388. R1 = 5,
  127389. /** L2 */
  127390. L2 = 6,
  127391. /** R2 */
  127392. R2 = 7,
  127393. /** Share */
  127394. Share = 8,
  127395. /** Options */
  127396. Options = 9,
  127397. /** L3 */
  127398. L3 = 10,
  127399. /** R3 */
  127400. R3 = 11,
  127401. /** DPadUp */
  127402. DPadUp = 12,
  127403. /** DPadDown */
  127404. DPadDown = 13,
  127405. /** DPadLeft */
  127406. DPadLeft = 14,
  127407. /** DRight */
  127408. DPadRight = 15,
  127409. /** Home */
  127410. Home = 16,
  127411. /** TouchPad */
  127412. TouchPad = 17,
  127413. /** LStickXAxis */
  127414. LStickXAxis = 18,
  127415. /** LStickYAxis */
  127416. LStickYAxis = 19,
  127417. /** RStickXAxis */
  127418. RStickXAxis = 20,
  127419. /** RStickYAxis */
  127420. RStickYAxis = 21
  127421. }
  127422. /**
  127423. * Enum for Xbox Gamepad
  127424. */
  127425. export enum XboxInput {
  127426. /** A */
  127427. A = 0,
  127428. /** B */
  127429. B = 1,
  127430. /** X */
  127431. X = 2,
  127432. /** Y */
  127433. Y = 3,
  127434. /** LB */
  127435. LB = 4,
  127436. /** RB */
  127437. RB = 5,
  127438. /** LT */
  127439. LT = 6,
  127440. /** RT */
  127441. RT = 7,
  127442. /** Back */
  127443. Back = 8,
  127444. /** Start */
  127445. Start = 9,
  127446. /** LS */
  127447. LS = 10,
  127448. /** RS */
  127449. RS = 11,
  127450. /** DPadUp */
  127451. DPadUp = 12,
  127452. /** DPadDown */
  127453. DPadDown = 13,
  127454. /** DPadLeft */
  127455. DPadLeft = 14,
  127456. /** DRight */
  127457. DPadRight = 15,
  127458. /** Home */
  127459. Home = 16,
  127460. /** LStickXAxis */
  127461. LStickXAxis = 17,
  127462. /** LStickYAxis */
  127463. LStickYAxis = 18,
  127464. /** RStickXAxis */
  127465. RStickXAxis = 19,
  127466. /** RStickYAxis */
  127467. RStickYAxis = 20
  127468. }
  127469. /**
  127470. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  127471. */
  127472. export enum SwitchInput {
  127473. /** B */
  127474. B = 0,
  127475. /** A */
  127476. A = 1,
  127477. /** Y */
  127478. Y = 2,
  127479. /** X */
  127480. X = 3,
  127481. /** L */
  127482. L = 4,
  127483. /** R */
  127484. R = 5,
  127485. /** ZL */
  127486. ZL = 6,
  127487. /** ZR */
  127488. ZR = 7,
  127489. /** Minus */
  127490. Minus = 8,
  127491. /** Plus */
  127492. Plus = 9,
  127493. /** LS */
  127494. LS = 10,
  127495. /** RS */
  127496. RS = 11,
  127497. /** DPadUp */
  127498. DPadUp = 12,
  127499. /** DPadDown */
  127500. DPadDown = 13,
  127501. /** DPadLeft */
  127502. DPadLeft = 14,
  127503. /** DRight */
  127504. DPadRight = 15,
  127505. /** Home */
  127506. Home = 16,
  127507. /** Capture */
  127508. Capture = 17,
  127509. /** LStickXAxis */
  127510. LStickXAxis = 18,
  127511. /** LStickYAxis */
  127512. LStickYAxis = 19,
  127513. /** RStickXAxis */
  127514. RStickXAxis = 20,
  127515. /** RStickYAxis */
  127516. RStickYAxis = 21
  127517. }
  127518. }
  127519. declare module BABYLON {
  127520. /**
  127521. * This class will take all inputs from Keyboard, Pointer, and
  127522. * any Gamepads and provide a polling system that all devices
  127523. * will use. This class assumes that there will only be one
  127524. * pointer device and one keyboard.
  127525. */
  127526. export class DeviceInputSystem implements IDisposable {
  127527. /**
  127528. * Callback to be triggered when a device is connected
  127529. */
  127530. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127531. /**
  127532. * Callback to be triggered when a device is disconnected
  127533. */
  127534. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127535. /**
  127536. * Callback to be triggered when event driven input is updated
  127537. */
  127538. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  127539. private _inputs;
  127540. private _gamepads;
  127541. private _keyboardActive;
  127542. private _pointerActive;
  127543. private _elementToAttachTo;
  127544. private _keyboardDownEvent;
  127545. private _keyboardUpEvent;
  127546. private _pointerMoveEvent;
  127547. private _pointerDownEvent;
  127548. private _pointerUpEvent;
  127549. private _gamepadConnectedEvent;
  127550. private _gamepadDisconnectedEvent;
  127551. private static _MAX_KEYCODES;
  127552. private static _MAX_POINTER_INPUTS;
  127553. private constructor();
  127554. /**
  127555. * Creates a new DeviceInputSystem instance
  127556. * @param engine Engine to pull input element from
  127557. * @returns The new instance
  127558. */
  127559. static Create(engine: Engine): DeviceInputSystem;
  127560. /**
  127561. * Checks for current device input value, given an id and input index
  127562. * @param deviceName Id of connected device
  127563. * @param inputIndex Index of device input
  127564. * @returns Current value of input
  127565. */
  127566. /**
  127567. * Checks for current device input value, given an id and input index
  127568. * @param deviceType Enum specifiying device type
  127569. * @param deviceSlot "Slot" or index that device is referenced in
  127570. * @param inputIndex Id of input to be checked
  127571. * @returns Current value of input
  127572. */
  127573. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127574. /**
  127575. * Dispose of all the eventlisteners
  127576. */
  127577. dispose(): void;
  127578. /**
  127579. * Add device and inputs to device array
  127580. * @param deviceType Enum specifiying device type
  127581. * @param deviceSlot "Slot" or index that device is referenced in
  127582. * @param numberOfInputs Number of input entries to create for given device
  127583. */
  127584. private _registerDevice;
  127585. /**
  127586. * Given a specific device name, remove that device from the device map
  127587. * @param deviceType Enum specifiying device type
  127588. * @param deviceSlot "Slot" or index that device is referenced in
  127589. */
  127590. private _unregisterDevice;
  127591. /**
  127592. * Handle all actions that come from keyboard interaction
  127593. */
  127594. private _handleKeyActions;
  127595. /**
  127596. * Handle all actions that come from pointer interaction
  127597. */
  127598. private _handlePointerActions;
  127599. /**
  127600. * Handle all actions that come from gamepad interaction
  127601. */
  127602. private _handleGamepadActions;
  127603. /**
  127604. * Update all non-event based devices with each frame
  127605. * @param deviceType Enum specifiying device type
  127606. * @param deviceSlot "Slot" or index that device is referenced in
  127607. * @param inputIndex Id of input to be checked
  127608. */
  127609. private _updateDevice;
  127610. /**
  127611. * Gets DeviceType from the device name
  127612. * @param deviceName Name of Device from DeviceInputSystem
  127613. * @returns DeviceType enum value
  127614. */
  127615. private _getGamepadDeviceType;
  127616. }
  127617. }
  127618. declare module BABYLON {
  127619. /**
  127620. * Type to handle enforcement of inputs
  127621. */
  127622. 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;
  127623. }
  127624. declare module BABYLON {
  127625. /**
  127626. * Class that handles all input for a specific device
  127627. */
  127628. export class DeviceSource<T extends DeviceType> {
  127629. /** Type of device */
  127630. readonly deviceType: DeviceType;
  127631. /** "Slot" or index that device is referenced in */
  127632. readonly deviceSlot: number;
  127633. /**
  127634. * Observable to handle device input changes per device
  127635. */
  127636. readonly onInputChangedObservable: Observable<{
  127637. inputIndex: DeviceInput<T>;
  127638. previousState: Nullable<number>;
  127639. currentState: Nullable<number>;
  127640. }>;
  127641. private readonly _deviceInputSystem;
  127642. /**
  127643. * Default Constructor
  127644. * @param deviceInputSystem Reference to DeviceInputSystem
  127645. * @param deviceType Type of device
  127646. * @param deviceSlot "Slot" or index that device is referenced in
  127647. */
  127648. constructor(deviceInputSystem: DeviceInputSystem,
  127649. /** Type of device */
  127650. deviceType: DeviceType,
  127651. /** "Slot" or index that device is referenced in */
  127652. deviceSlot?: number);
  127653. /**
  127654. * Get input for specific input
  127655. * @param inputIndex index of specific input on device
  127656. * @returns Input value from DeviceInputSystem
  127657. */
  127658. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  127659. }
  127660. /**
  127661. * Class to keep track of devices
  127662. */
  127663. export class DeviceSourceManager implements IDisposable {
  127664. /**
  127665. * Observable to be triggered when before a device is connected
  127666. */
  127667. readonly onBeforeDeviceConnectedObservable: Observable<{
  127668. deviceType: DeviceType;
  127669. deviceSlot: number;
  127670. }>;
  127671. /**
  127672. * Observable to be triggered when before a device is disconnected
  127673. */
  127674. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  127675. deviceType: DeviceType;
  127676. deviceSlot: number;
  127677. }>;
  127678. /**
  127679. * Observable to be triggered when after a device is connected
  127680. */
  127681. readonly onAfterDeviceConnectedObservable: Observable<{
  127682. deviceType: DeviceType;
  127683. deviceSlot: number;
  127684. }>;
  127685. /**
  127686. * Observable to be triggered when after a device is disconnected
  127687. */
  127688. readonly onAfterDeviceDisconnectedObservable: Observable<{
  127689. deviceType: DeviceType;
  127690. deviceSlot: number;
  127691. }>;
  127692. private readonly _devices;
  127693. private readonly _firstDevice;
  127694. private readonly _deviceInputSystem;
  127695. /**
  127696. * Default Constructor
  127697. * @param engine engine to pull input element from
  127698. */
  127699. constructor(engine: Engine);
  127700. /**
  127701. * Gets a DeviceSource, given a type and slot
  127702. * @param deviceType Enum specifying device type
  127703. * @param deviceSlot "Slot" or index that device is referenced in
  127704. * @returns DeviceSource object
  127705. */
  127706. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  127707. /**
  127708. * Gets an array of DeviceSource objects for a given device type
  127709. * @param deviceType Enum specifying device type
  127710. * @returns Array of DeviceSource objects
  127711. */
  127712. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  127713. /**
  127714. * Dispose of DeviceInputSystem and other parts
  127715. */
  127716. dispose(): void;
  127717. /**
  127718. * Function to add device name to device list
  127719. * @param deviceType Enum specifying device type
  127720. * @param deviceSlot "Slot" or index that device is referenced in
  127721. */
  127722. private _addDevice;
  127723. /**
  127724. * Function to remove device name to device list
  127725. * @param deviceType Enum specifying device type
  127726. * @param deviceSlot "Slot" or index that device is referenced in
  127727. */
  127728. private _removeDevice;
  127729. /**
  127730. * Updates array storing first connected device of each type
  127731. * @param type Type of Device
  127732. */
  127733. private _updateFirstDevices;
  127734. }
  127735. }
  127736. declare module BABYLON {
  127737. /**
  127738. * Options to create the null engine
  127739. */
  127740. export class NullEngineOptions {
  127741. /**
  127742. * Render width (Default: 512)
  127743. */
  127744. renderWidth: number;
  127745. /**
  127746. * Render height (Default: 256)
  127747. */
  127748. renderHeight: number;
  127749. /**
  127750. * Texture size (Default: 512)
  127751. */
  127752. textureSize: number;
  127753. /**
  127754. * If delta time between frames should be constant
  127755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127756. */
  127757. deterministicLockstep: boolean;
  127758. /**
  127759. * Maximum about of steps between frames (Default: 4)
  127760. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127761. */
  127762. lockstepMaxSteps: number;
  127763. }
  127764. /**
  127765. * The null engine class provides support for headless version of babylon.js.
  127766. * This can be used in server side scenario or for testing purposes
  127767. */
  127768. export class NullEngine extends Engine {
  127769. private _options;
  127770. /**
  127771. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  127772. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127773. * @returns true if engine is in deterministic lock step mode
  127774. */
  127775. isDeterministicLockStep(): boolean;
  127776. /**
  127777. * Gets the max steps when engine is running in deterministic lock step
  127778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  127779. * @returns the max steps
  127780. */
  127781. getLockstepMaxSteps(): number;
  127782. /**
  127783. * Gets the current hardware scaling level.
  127784. * By default the hardware scaling level is computed from the window device ratio.
  127785. * 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.
  127786. * @returns a number indicating the current hardware scaling level
  127787. */
  127788. getHardwareScalingLevel(): number;
  127789. constructor(options?: NullEngineOptions);
  127790. /**
  127791. * Creates a vertex buffer
  127792. * @param vertices the data for the vertex buffer
  127793. * @returns the new WebGL static buffer
  127794. */
  127795. createVertexBuffer(vertices: FloatArray): DataBuffer;
  127796. /**
  127797. * Creates a new index buffer
  127798. * @param indices defines the content of the index buffer
  127799. * @param updatable defines if the index buffer must be updatable
  127800. * @returns a new webGL buffer
  127801. */
  127802. createIndexBuffer(indices: IndicesArray): DataBuffer;
  127803. /**
  127804. * Clear the current render buffer or the current render target (if any is set up)
  127805. * @param color defines the color to use
  127806. * @param backBuffer defines if the back buffer must be cleared
  127807. * @param depth defines if the depth buffer must be cleared
  127808. * @param stencil defines if the stencil buffer must be cleared
  127809. */
  127810. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  127811. /**
  127812. * Gets the current render width
  127813. * @param useScreen defines if screen size must be used (or the current render target if any)
  127814. * @returns a number defining the current render width
  127815. */
  127816. getRenderWidth(useScreen?: boolean): number;
  127817. /**
  127818. * Gets the current render height
  127819. * @param useScreen defines if screen size must be used (or the current render target if any)
  127820. * @returns a number defining the current render height
  127821. */
  127822. getRenderHeight(useScreen?: boolean): number;
  127823. /**
  127824. * Set the WebGL's viewport
  127825. * @param viewport defines the viewport element to be used
  127826. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  127827. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  127828. */
  127829. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  127830. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  127831. /**
  127832. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  127833. * @param pipelineContext defines the pipeline context to use
  127834. * @param uniformsNames defines the list of uniform names
  127835. * @returns an array of webGL uniform locations
  127836. */
  127837. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  127838. /**
  127839. * Gets the lsit of active attributes for a given webGL program
  127840. * @param pipelineContext defines the pipeline context to use
  127841. * @param attributesNames defines the list of attribute names to get
  127842. * @returns an array of indices indicating the offset of each attribute
  127843. */
  127844. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  127845. /**
  127846. * Binds an effect to the webGL context
  127847. * @param effect defines the effect to bind
  127848. */
  127849. bindSamplers(effect: Effect): void;
  127850. /**
  127851. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  127852. * @param effect defines the effect to activate
  127853. */
  127854. enableEffect(effect: Effect): void;
  127855. /**
  127856. * Set various states to the webGL context
  127857. * @param culling defines backface culling state
  127858. * @param zOffset defines the value to apply to zOffset (0 by default)
  127859. * @param force defines if states must be applied even if cache is up to date
  127860. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  127861. */
  127862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  127863. /**
  127864. * Set the value of an uniform to an array of int32
  127865. * @param uniform defines the webGL uniform location where to store the value
  127866. * @param array defines the array of int32 to store
  127867. */
  127868. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  127869. /**
  127870. * Set the value of an uniform to an array of int32 (stored as vec2)
  127871. * @param uniform defines the webGL uniform location where to store the value
  127872. * @param array defines the array of int32 to store
  127873. */
  127874. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  127875. /**
  127876. * Set the value of an uniform to an array of int32 (stored as vec3)
  127877. * @param uniform defines the webGL uniform location where to store the value
  127878. * @param array defines the array of int32 to store
  127879. */
  127880. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  127881. /**
  127882. * Set the value of an uniform to an array of int32 (stored as vec4)
  127883. * @param uniform defines the webGL uniform location where to store the value
  127884. * @param array defines the array of int32 to store
  127885. */
  127886. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  127887. /**
  127888. * Set the value of an uniform to an array of float32
  127889. * @param uniform defines the webGL uniform location where to store the value
  127890. * @param array defines the array of float32 to store
  127891. */
  127892. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  127893. /**
  127894. * Set the value of an uniform to an array of float32 (stored as vec2)
  127895. * @param uniform defines the webGL uniform location where to store the value
  127896. * @param array defines the array of float32 to store
  127897. */
  127898. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  127899. /**
  127900. * Set the value of an uniform to an array of float32 (stored as vec3)
  127901. * @param uniform defines the webGL uniform location where to store the value
  127902. * @param array defines the array of float32 to store
  127903. */
  127904. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  127905. /**
  127906. * Set the value of an uniform to an array of float32 (stored as vec4)
  127907. * @param uniform defines the webGL uniform location where to store the value
  127908. * @param array defines the array of float32 to store
  127909. */
  127910. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  127911. /**
  127912. * Set the value of an uniform to an array of number
  127913. * @param uniform defines the webGL uniform location where to store the value
  127914. * @param array defines the array of number to store
  127915. */
  127916. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  127917. /**
  127918. * Set the value of an uniform to an array of number (stored as vec2)
  127919. * @param uniform defines the webGL uniform location where to store the value
  127920. * @param array defines the array of number to store
  127921. */
  127922. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  127923. /**
  127924. * Set the value of an uniform to an array of number (stored as vec3)
  127925. * @param uniform defines the webGL uniform location where to store the value
  127926. * @param array defines the array of number to store
  127927. */
  127928. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  127929. /**
  127930. * Set the value of an uniform to an array of number (stored as vec4)
  127931. * @param uniform defines the webGL uniform location where to store the value
  127932. * @param array defines the array of number to store
  127933. */
  127934. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  127935. /**
  127936. * Set the value of an uniform to an array of float32 (stored as matrices)
  127937. * @param uniform defines the webGL uniform location where to store the value
  127938. * @param matrices defines the array of float32 to store
  127939. */
  127940. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  127941. /**
  127942. * Set the value of an uniform to a matrix (3x3)
  127943. * @param uniform defines the webGL uniform location where to store the value
  127944. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  127945. */
  127946. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127947. /**
  127948. * Set the value of an uniform to a matrix (2x2)
  127949. * @param uniform defines the webGL uniform location where to store the value
  127950. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  127951. */
  127952. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  127953. /**
  127954. * Set the value of an uniform to a number (float)
  127955. * @param uniform defines the webGL uniform location where to store the value
  127956. * @param value defines the float number to store
  127957. */
  127958. setFloat(uniform: WebGLUniformLocation, value: number): void;
  127959. /**
  127960. * Set the value of an uniform to a vec2
  127961. * @param uniform defines the webGL uniform location where to store the value
  127962. * @param x defines the 1st component of the value
  127963. * @param y defines the 2nd component of the value
  127964. */
  127965. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  127966. /**
  127967. * Set the value of an uniform to a vec3
  127968. * @param uniform defines the webGL uniform location where to store the value
  127969. * @param x defines the 1st component of the value
  127970. * @param y defines the 2nd component of the value
  127971. * @param z defines the 3rd component of the value
  127972. */
  127973. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  127974. /**
  127975. * Set the value of an uniform to a boolean
  127976. * @param uniform defines the webGL uniform location where to store the value
  127977. * @param bool defines the boolean to store
  127978. */
  127979. setBool(uniform: WebGLUniformLocation, bool: number): void;
  127980. /**
  127981. * Set the value of an uniform to a vec4
  127982. * @param uniform defines the webGL uniform location where to store the value
  127983. * @param x defines the 1st component of the value
  127984. * @param y defines the 2nd component of the value
  127985. * @param z defines the 3rd component of the value
  127986. * @param w defines the 4th component of the value
  127987. */
  127988. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  127989. /**
  127990. * Sets the current alpha mode
  127991. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  127992. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  127993. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  127994. */
  127995. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  127996. /**
  127997. * Bind webGl buffers directly to the webGL context
  127998. * @param vertexBuffers defines the vertex buffer to bind
  127999. * @param indexBuffer defines the index buffer to bind
  128000. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  128001. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  128002. * @param effect defines the effect associated with the vertex buffer
  128003. */
  128004. bindBuffers(vertexBuffers: {
  128005. [key: string]: VertexBuffer;
  128006. }, indexBuffer: DataBuffer, effect: Effect): void;
  128007. /**
  128008. * Force the entire cache to be cleared
  128009. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  128010. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  128011. */
  128012. wipeCaches(bruteForce?: boolean): void;
  128013. /**
  128014. * Send a draw order
  128015. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  128016. * @param indexStart defines the starting index
  128017. * @param indexCount defines the number of index to draw
  128018. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128019. */
  128020. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  128021. /**
  128022. * Draw a list of indexed primitives
  128023. * @param fillMode defines the primitive to use
  128024. * @param indexStart defines the starting index
  128025. * @param indexCount defines the number of index to draw
  128026. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128027. */
  128028. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128029. /**
  128030. * Draw a list of unindexed primitives
  128031. * @param fillMode defines the primitive to use
  128032. * @param verticesStart defines the index of first vertex to draw
  128033. * @param verticesCount defines the count of vertices to draw
  128034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128035. */
  128036. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128037. /** @hidden */
  128038. _createTexture(): WebGLTexture;
  128039. /** @hidden */
  128040. _releaseTexture(texture: InternalTexture): void;
  128041. /**
  128042. * Usually called from Texture.ts.
  128043. * Passed information to create a WebGLTexture
  128044. * @param urlArg defines a value which contains one of the following:
  128045. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128046. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128047. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128048. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128049. * @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)
  128050. * @param scene needed for loading to the correct scene
  128051. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128052. * @param onLoad optional callback to be called upon successful completion
  128053. * @param onError optional callback to be called upon failure
  128054. * @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
  128055. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128056. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128057. * @param forcedExtension defines the extension to use to pick the right loader
  128058. * @param mimeType defines an optional mime type
  128059. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128060. */
  128061. 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;
  128062. /**
  128063. * Creates a new render target texture
  128064. * @param size defines the size of the texture
  128065. * @param options defines the options used to create the texture
  128066. * @returns a new render target texture stored in an InternalTexture
  128067. */
  128068. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  128069. /**
  128070. * Update the sampling mode of a given texture
  128071. * @param samplingMode defines the required sampling mode
  128072. * @param texture defines the texture to update
  128073. */
  128074. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128075. /**
  128076. * Binds the frame buffer to the specified texture.
  128077. * @param texture The texture to render to or null for the default canvas
  128078. * @param faceIndex The face of the texture to render to in case of cube texture
  128079. * @param requiredWidth The width of the target to render to
  128080. * @param requiredHeight The height of the target to render to
  128081. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  128082. * @param lodLevel defines le lod level to bind to the frame buffer
  128083. */
  128084. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128085. /**
  128086. * Unbind the current render target texture from the webGL context
  128087. * @param texture defines the render target texture to unbind
  128088. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128089. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128090. */
  128091. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128092. /**
  128093. * Creates a dynamic vertex buffer
  128094. * @param vertices the data for the dynamic vertex buffer
  128095. * @returns the new WebGL dynamic buffer
  128096. */
  128097. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  128098. /**
  128099. * Update the content of a dynamic texture
  128100. * @param texture defines the texture to update
  128101. * @param canvas defines the canvas containing the source
  128102. * @param invertY defines if data must be stored with Y axis inverted
  128103. * @param premulAlpha defines if alpha is stored as premultiplied
  128104. * @param format defines the format of the data
  128105. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  128106. */
  128107. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  128108. /**
  128109. * Gets a boolean indicating if all created effects are ready
  128110. * @returns true if all effects are ready
  128111. */
  128112. areAllEffectsReady(): boolean;
  128113. /**
  128114. * @hidden
  128115. * Get the current error code of the webGL context
  128116. * @returns the error code
  128117. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  128118. */
  128119. getError(): number;
  128120. /** @hidden */
  128121. _getUnpackAlignement(): number;
  128122. /** @hidden */
  128123. _unpackFlipY(value: boolean): void;
  128124. /**
  128125. * Update a dynamic index buffer
  128126. * @param indexBuffer defines the target index buffer
  128127. * @param indices defines the data to update
  128128. * @param offset defines the offset in the target index buffer where update should start
  128129. */
  128130. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  128131. /**
  128132. * Updates a dynamic vertex buffer.
  128133. * @param vertexBuffer the vertex buffer to update
  128134. * @param vertices the data used to update the vertex buffer
  128135. * @param byteOffset the byte offset of the data (optional)
  128136. * @param byteLength the byte length of the data (optional)
  128137. */
  128138. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  128139. /** @hidden */
  128140. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  128141. /** @hidden */
  128142. _bindTexture(channel: number, texture: InternalTexture): void;
  128143. protected _deleteBuffer(buffer: WebGLBuffer): void;
  128144. /**
  128145. * 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
  128146. */
  128147. releaseEffects(): void;
  128148. displayLoadingUI(): void;
  128149. hideLoadingUI(): void;
  128150. /** @hidden */
  128151. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128152. /** @hidden */
  128153. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128154. /** @hidden */
  128155. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128156. /** @hidden */
  128157. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128158. }
  128159. }
  128160. declare module BABYLON {
  128161. /**
  128162. * @hidden
  128163. **/
  128164. export class _TimeToken {
  128165. _startTimeQuery: Nullable<WebGLQuery>;
  128166. _endTimeQuery: Nullable<WebGLQuery>;
  128167. _timeElapsedQuery: Nullable<WebGLQuery>;
  128168. _timeElapsedQueryEnded: boolean;
  128169. }
  128170. }
  128171. declare module BABYLON {
  128172. /** @hidden */
  128173. export class _OcclusionDataStorage {
  128174. /** @hidden */
  128175. occlusionInternalRetryCounter: number;
  128176. /** @hidden */
  128177. isOcclusionQueryInProgress: boolean;
  128178. /** @hidden */
  128179. isOccluded: boolean;
  128180. /** @hidden */
  128181. occlusionRetryCount: number;
  128182. /** @hidden */
  128183. occlusionType: number;
  128184. /** @hidden */
  128185. occlusionQueryAlgorithmType: number;
  128186. }
  128187. interface Engine {
  128188. /**
  128189. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  128190. * @return the new query
  128191. */
  128192. createQuery(): WebGLQuery;
  128193. /**
  128194. * Delete and release a webGL query
  128195. * @param query defines the query to delete
  128196. * @return the current engine
  128197. */
  128198. deleteQuery(query: WebGLQuery): Engine;
  128199. /**
  128200. * Check if a given query has resolved and got its value
  128201. * @param query defines the query to check
  128202. * @returns true if the query got its value
  128203. */
  128204. isQueryResultAvailable(query: WebGLQuery): boolean;
  128205. /**
  128206. * Gets the value of a given query
  128207. * @param query defines the query to check
  128208. * @returns the value of the query
  128209. */
  128210. getQueryResult(query: WebGLQuery): number;
  128211. /**
  128212. * Initiates an occlusion query
  128213. * @param algorithmType defines the algorithm to use
  128214. * @param query defines the query to use
  128215. * @returns the current engine
  128216. * @see http://doc.babylonjs.com/features/occlusionquery
  128217. */
  128218. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  128219. /**
  128220. * Ends an occlusion query
  128221. * @see http://doc.babylonjs.com/features/occlusionquery
  128222. * @param algorithmType defines the algorithm to use
  128223. * @returns the current engine
  128224. */
  128225. endOcclusionQuery(algorithmType: number): Engine;
  128226. /**
  128227. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  128228. * Please note that only one query can be issued at a time
  128229. * @returns a time token used to track the time span
  128230. */
  128231. startTimeQuery(): Nullable<_TimeToken>;
  128232. /**
  128233. * Ends a time query
  128234. * @param token defines the token used to measure the time span
  128235. * @returns the time spent (in ns)
  128236. */
  128237. endTimeQuery(token: _TimeToken): int;
  128238. /** @hidden */
  128239. _currentNonTimestampToken: Nullable<_TimeToken>;
  128240. /** @hidden */
  128241. _createTimeQuery(): WebGLQuery;
  128242. /** @hidden */
  128243. _deleteTimeQuery(query: WebGLQuery): void;
  128244. /** @hidden */
  128245. _getGlAlgorithmType(algorithmType: number): number;
  128246. /** @hidden */
  128247. _getTimeQueryResult(query: WebGLQuery): any;
  128248. /** @hidden */
  128249. _getTimeQueryAvailability(query: WebGLQuery): any;
  128250. }
  128251. interface AbstractMesh {
  128252. /**
  128253. * Backing filed
  128254. * @hidden
  128255. */
  128256. __occlusionDataStorage: _OcclusionDataStorage;
  128257. /**
  128258. * Access property
  128259. * @hidden
  128260. */
  128261. _occlusionDataStorage: _OcclusionDataStorage;
  128262. /**
  128263. * 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.
  128264. * The default value is -1 which means don't break the query and wait till the result
  128265. * @see http://doc.babylonjs.com/features/occlusionquery
  128266. */
  128267. occlusionRetryCount: number;
  128268. /**
  128269. * 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:
  128270. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  128271. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  128272. * * 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.
  128273. * @see http://doc.babylonjs.com/features/occlusionquery
  128274. */
  128275. occlusionType: number;
  128276. /**
  128277. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  128278. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  128279. * * 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.
  128280. * @see http://doc.babylonjs.com/features/occlusionquery
  128281. */
  128282. occlusionQueryAlgorithmType: number;
  128283. /**
  128284. * 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
  128285. * @see http://doc.babylonjs.com/features/occlusionquery
  128286. */
  128287. isOccluded: boolean;
  128288. /**
  128289. * Flag to check the progress status of the query
  128290. * @see http://doc.babylonjs.com/features/occlusionquery
  128291. */
  128292. isOcclusionQueryInProgress: boolean;
  128293. }
  128294. }
  128295. declare module BABYLON {
  128296. /** @hidden */
  128297. export var _forceTransformFeedbackToBundle: boolean;
  128298. interface Engine {
  128299. /**
  128300. * Creates a webGL transform feedback object
  128301. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  128302. * @returns the webGL transform feedback object
  128303. */
  128304. createTransformFeedback(): WebGLTransformFeedback;
  128305. /**
  128306. * Delete a webGL transform feedback object
  128307. * @param value defines the webGL transform feedback object to delete
  128308. */
  128309. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  128310. /**
  128311. * Bind a webGL transform feedback object to the webgl context
  128312. * @param value defines the webGL transform feedback object to bind
  128313. */
  128314. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  128315. /**
  128316. * Begins a transform feedback operation
  128317. * @param usePoints defines if points or triangles must be used
  128318. */
  128319. beginTransformFeedback(usePoints: boolean): void;
  128320. /**
  128321. * Ends a transform feedback operation
  128322. */
  128323. endTransformFeedback(): void;
  128324. /**
  128325. * Specify the varyings to use with transform feedback
  128326. * @param program defines the associated webGL program
  128327. * @param value defines the list of strings representing the varying names
  128328. */
  128329. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  128330. /**
  128331. * Bind a webGL buffer for a transform feedback operation
  128332. * @param value defines the webGL buffer to bind
  128333. */
  128334. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  128335. }
  128336. }
  128337. declare module BABYLON {
  128338. /**
  128339. * Creation options of the multi render target texture.
  128340. */
  128341. export interface IMultiRenderTargetOptions {
  128342. /**
  128343. * Define if the texture needs to create mip maps after render.
  128344. */
  128345. generateMipMaps?: boolean;
  128346. /**
  128347. * Define the types of all the draw buffers we want to create
  128348. */
  128349. types?: number[];
  128350. /**
  128351. * Define the sampling modes of all the draw buffers we want to create
  128352. */
  128353. samplingModes?: number[];
  128354. /**
  128355. * Define if a depth buffer is required
  128356. */
  128357. generateDepthBuffer?: boolean;
  128358. /**
  128359. * Define if a stencil buffer is required
  128360. */
  128361. generateStencilBuffer?: boolean;
  128362. /**
  128363. * Define if a depth texture is required instead of a depth buffer
  128364. */
  128365. generateDepthTexture?: boolean;
  128366. /**
  128367. * Define the number of desired draw buffers
  128368. */
  128369. textureCount?: number;
  128370. /**
  128371. * Define if aspect ratio should be adapted to the texture or stay the scene one
  128372. */
  128373. doNotChangeAspectRatio?: boolean;
  128374. /**
  128375. * Define the default type of the buffers we are creating
  128376. */
  128377. defaultType?: number;
  128378. }
  128379. /**
  128380. * A multi render target, like a render target provides the ability to render to a texture.
  128381. * Unlike the render target, it can render to several draw buffers in one draw.
  128382. * This is specially interesting in deferred rendering or for any effects requiring more than
  128383. * just one color from a single pass.
  128384. */
  128385. export class MultiRenderTarget extends RenderTargetTexture {
  128386. private _internalTextures;
  128387. private _textures;
  128388. private _multiRenderTargetOptions;
  128389. /**
  128390. * Get if draw buffers are currently supported by the used hardware and browser.
  128391. */
  128392. get isSupported(): boolean;
  128393. /**
  128394. * Get the list of textures generated by the multi render target.
  128395. */
  128396. get textures(): Texture[];
  128397. /**
  128398. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  128399. */
  128400. get depthTexture(): Texture;
  128401. /**
  128402. * Set the wrapping mode on U of all the textures we are rendering to.
  128403. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128404. */
  128405. set wrapU(wrap: number);
  128406. /**
  128407. * Set the wrapping mode on V of all the textures we are rendering to.
  128408. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128409. */
  128410. set wrapV(wrap: number);
  128411. /**
  128412. * Instantiate a new multi render target texture.
  128413. * A multi render target, like a render target provides the ability to render to a texture.
  128414. * Unlike the render target, it can render to several draw buffers in one draw.
  128415. * This is specially interesting in deferred rendering or for any effects requiring more than
  128416. * just one color from a single pass.
  128417. * @param name Define the name of the texture
  128418. * @param size Define the size of the buffers to render to
  128419. * @param count Define the number of target we are rendering into
  128420. * @param scene Define the scene the texture belongs to
  128421. * @param options Define the options used to create the multi render target
  128422. */
  128423. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  128424. /** @hidden */
  128425. _rebuild(): void;
  128426. private _createInternalTextures;
  128427. private _createTextures;
  128428. /**
  128429. * Define the number of samples used if MSAA is enabled.
  128430. */
  128431. get samples(): number;
  128432. set samples(value: number);
  128433. /**
  128434. * Resize all the textures in the multi render target.
  128435. * Be carrefull as it will recreate all the data in the new texture.
  128436. * @param size Define the new size
  128437. */
  128438. resize(size: any): void;
  128439. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  128440. /**
  128441. * Dispose the render targets and their associated resources
  128442. */
  128443. dispose(): void;
  128444. /**
  128445. * Release all the underlying texture used as draw buffers.
  128446. */
  128447. releaseInternalTextures(): void;
  128448. }
  128449. }
  128450. declare module BABYLON {
  128451. interface ThinEngine {
  128452. /**
  128453. * Unbind a list of render target textures from the webGL context
  128454. * This is used only when drawBuffer extension or webGL2 are active
  128455. * @param textures defines the render target textures to unbind
  128456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128458. */
  128459. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  128460. /**
  128461. * Create a multi render target texture
  128462. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  128463. * @param size defines the size of the texture
  128464. * @param options defines the creation options
  128465. * @returns the cube texture as an InternalTexture
  128466. */
  128467. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  128468. /**
  128469. * Update the sample count for a given multiple render target texture
  128470. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128471. * @param textures defines the textures to update
  128472. * @param samples defines the sample count to set
  128473. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128474. */
  128475. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  128476. }
  128477. }
  128478. declare module BABYLON {
  128479. /**
  128480. * Class used to define an additional view for the engine
  128481. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128482. */
  128483. export class EngineView {
  128484. /** Defines the canvas where to render the view */
  128485. target: HTMLCanvasElement;
  128486. /** Defines an optional camera used to render the view (will use active camera else) */
  128487. camera?: Camera;
  128488. }
  128489. interface Engine {
  128490. /**
  128491. * Gets or sets the HTML element to use for attaching events
  128492. */
  128493. inputElement: Nullable<HTMLElement>;
  128494. /**
  128495. * Gets the current engine view
  128496. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128497. */
  128498. activeView: Nullable<EngineView>;
  128499. /** Gets or sets the list of views */
  128500. views: EngineView[];
  128501. /**
  128502. * Register a new child canvas
  128503. * @param canvas defines the canvas to register
  128504. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  128505. * @returns the associated view
  128506. */
  128507. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  128508. /**
  128509. * Remove a registered child canvas
  128510. * @param canvas defines the canvas to remove
  128511. * @returns the current engine
  128512. */
  128513. unRegisterView(canvas: HTMLCanvasElement): Engine;
  128514. }
  128515. }
  128516. declare module BABYLON {
  128517. interface Engine {
  128518. /** @hidden */
  128519. _excludedCompressedTextures: string[];
  128520. /** @hidden */
  128521. _textureFormatInUse: string;
  128522. /**
  128523. * Gets the list of texture formats supported
  128524. */
  128525. readonly texturesSupported: Array<string>;
  128526. /**
  128527. * Gets the texture format in use
  128528. */
  128529. readonly textureFormatInUse: Nullable<string>;
  128530. /**
  128531. * Set the compressed texture extensions or file names to skip.
  128532. *
  128533. * @param skippedFiles defines the list of those texture files you want to skip
  128534. * Example: [".dds", ".env", "myfile.png"]
  128535. */
  128536. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  128537. /**
  128538. * Set the compressed texture format to use, based on the formats you have, and the formats
  128539. * supported by the hardware / browser.
  128540. *
  128541. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  128542. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  128543. * to API arguments needed to compressed textures. This puts the burden on the container
  128544. * generator to house the arcane code for determining these for current & future formats.
  128545. *
  128546. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128547. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128548. *
  128549. * Note: The result of this call is not taken into account when a texture is base64.
  128550. *
  128551. * @param formatsAvailable defines the list of those format families you have created
  128552. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  128553. *
  128554. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  128555. * @returns The extension selected.
  128556. */
  128557. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  128558. }
  128559. }
  128560. declare module BABYLON {
  128561. /**
  128562. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  128563. */
  128564. export interface CubeMapInfo {
  128565. /**
  128566. * The pixel array for the front face.
  128567. * This is stored in format, left to right, up to down format.
  128568. */
  128569. front: Nullable<ArrayBufferView>;
  128570. /**
  128571. * The pixel array for the back face.
  128572. * This is stored in format, left to right, up to down format.
  128573. */
  128574. back: Nullable<ArrayBufferView>;
  128575. /**
  128576. * The pixel array for the left face.
  128577. * This is stored in format, left to right, up to down format.
  128578. */
  128579. left: Nullable<ArrayBufferView>;
  128580. /**
  128581. * The pixel array for the right face.
  128582. * This is stored in format, left to right, up to down format.
  128583. */
  128584. right: Nullable<ArrayBufferView>;
  128585. /**
  128586. * The pixel array for the up face.
  128587. * This is stored in format, left to right, up to down format.
  128588. */
  128589. up: Nullable<ArrayBufferView>;
  128590. /**
  128591. * The pixel array for the down face.
  128592. * This is stored in format, left to right, up to down format.
  128593. */
  128594. down: Nullable<ArrayBufferView>;
  128595. /**
  128596. * The size of the cubemap stored.
  128597. *
  128598. * Each faces will be size * size pixels.
  128599. */
  128600. size: number;
  128601. /**
  128602. * The format of the texture.
  128603. *
  128604. * RGBA, RGB.
  128605. */
  128606. format: number;
  128607. /**
  128608. * The type of the texture data.
  128609. *
  128610. * UNSIGNED_INT, FLOAT.
  128611. */
  128612. type: number;
  128613. /**
  128614. * Specifies whether the texture is in gamma space.
  128615. */
  128616. gammaSpace: boolean;
  128617. }
  128618. /**
  128619. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128620. */
  128621. export class PanoramaToCubeMapTools {
  128622. private static FACE_LEFT;
  128623. private static FACE_RIGHT;
  128624. private static FACE_FRONT;
  128625. private static FACE_BACK;
  128626. private static FACE_DOWN;
  128627. private static FACE_UP;
  128628. /**
  128629. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128630. *
  128631. * @param float32Array The source data.
  128632. * @param inputWidth The width of the input panorama.
  128633. * @param inputHeight The height of the input panorama.
  128634. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128635. * @return The cubemap data
  128636. */
  128637. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128638. private static CreateCubemapTexture;
  128639. private static CalcProjectionSpherical;
  128640. }
  128641. }
  128642. declare module BABYLON {
  128643. /**
  128644. * Helper class dealing with the extraction of spherical polynomial dataArray
  128645. * from a cube map.
  128646. */
  128647. export class CubeMapToSphericalPolynomialTools {
  128648. private static FileFaces;
  128649. /**
  128650. * Converts a texture to the according Spherical Polynomial data.
  128651. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128652. *
  128653. * @param texture The texture to extract the information from.
  128654. * @return The Spherical Polynomial data.
  128655. */
  128656. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  128657. /**
  128658. * Converts a cubemap to the according Spherical Polynomial data.
  128659. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128660. *
  128661. * @param cubeInfo The Cube map to extract the information from.
  128662. * @return The Spherical Polynomial data.
  128663. */
  128664. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  128665. }
  128666. }
  128667. declare module BABYLON {
  128668. interface BaseTexture {
  128669. /**
  128670. * Get the polynomial representation of the texture data.
  128671. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  128672. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  128673. */
  128674. sphericalPolynomial: Nullable<SphericalPolynomial>;
  128675. }
  128676. }
  128677. declare module BABYLON {
  128678. /** @hidden */
  128679. export var rgbdEncodePixelShader: {
  128680. name: string;
  128681. shader: string;
  128682. };
  128683. }
  128684. declare module BABYLON {
  128685. /** @hidden */
  128686. export var rgbdDecodePixelShader: {
  128687. name: string;
  128688. shader: string;
  128689. };
  128690. }
  128691. declare module BABYLON {
  128692. /**
  128693. * Raw texture data and descriptor sufficient for WebGL texture upload
  128694. */
  128695. export interface EnvironmentTextureInfo {
  128696. /**
  128697. * Version of the environment map
  128698. */
  128699. version: number;
  128700. /**
  128701. * Width of image
  128702. */
  128703. width: number;
  128704. /**
  128705. * Irradiance information stored in the file.
  128706. */
  128707. irradiance: any;
  128708. /**
  128709. * Specular information stored in the file.
  128710. */
  128711. specular: any;
  128712. }
  128713. /**
  128714. * Defines One Image in the file. It requires only the position in the file
  128715. * as well as the length.
  128716. */
  128717. interface BufferImageData {
  128718. /**
  128719. * Length of the image data.
  128720. */
  128721. length: number;
  128722. /**
  128723. * Position of the data from the null terminator delimiting the end of the JSON.
  128724. */
  128725. position: number;
  128726. }
  128727. /**
  128728. * Defines the specular data enclosed in the file.
  128729. * This corresponds to the version 1 of the data.
  128730. */
  128731. export interface EnvironmentTextureSpecularInfoV1 {
  128732. /**
  128733. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  128734. */
  128735. specularDataPosition?: number;
  128736. /**
  128737. * This contains all the images data needed to reconstruct the cubemap.
  128738. */
  128739. mipmaps: Array<BufferImageData>;
  128740. /**
  128741. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  128742. */
  128743. lodGenerationScale: number;
  128744. }
  128745. /**
  128746. * Sets of helpers addressing the serialization and deserialization of environment texture
  128747. * stored in a BabylonJS env file.
  128748. * Those files are usually stored as .env files.
  128749. */
  128750. export class EnvironmentTextureTools {
  128751. /**
  128752. * Magic number identifying the env file.
  128753. */
  128754. private static _MagicBytes;
  128755. /**
  128756. * Gets the environment info from an env file.
  128757. * @param data The array buffer containing the .env bytes.
  128758. * @returns the environment file info (the json header) if successfully parsed.
  128759. */
  128760. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  128761. /**
  128762. * Creates an environment texture from a loaded cube texture.
  128763. * @param texture defines the cube texture to convert in env file
  128764. * @return a promise containing the environment data if succesfull.
  128765. */
  128766. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  128767. /**
  128768. * Creates a JSON representation of the spherical data.
  128769. * @param texture defines the texture containing the polynomials
  128770. * @return the JSON representation of the spherical info
  128771. */
  128772. private static _CreateEnvTextureIrradiance;
  128773. /**
  128774. * Creates the ArrayBufferViews used for initializing environment texture image data.
  128775. * @param data the image data
  128776. * @param info parameters that determine what views will be created for accessing the underlying buffer
  128777. * @return the views described by info providing access to the underlying buffer
  128778. */
  128779. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  128780. /**
  128781. * Uploads the texture info contained in the env file to the GPU.
  128782. * @param texture defines the internal texture to upload to
  128783. * @param data defines the data to load
  128784. * @param info defines the texture info retrieved through the GetEnvInfo method
  128785. * @returns a promise
  128786. */
  128787. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  128788. private static _OnImageReadyAsync;
  128789. /**
  128790. * Uploads the levels of image data to the GPU.
  128791. * @param texture defines the internal texture to upload to
  128792. * @param imageData defines the array buffer views of image data [mipmap][face]
  128793. * @returns a promise
  128794. */
  128795. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  128796. /**
  128797. * Uploads spherical polynomials information to the texture.
  128798. * @param texture defines the texture we are trying to upload the information to
  128799. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  128800. */
  128801. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  128802. /** @hidden */
  128803. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  128804. }
  128805. }
  128806. declare module BABYLON {
  128807. /** @hidden */
  128808. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  128809. private _genericAttributeLocation;
  128810. private _varyingLocationCount;
  128811. private _varyingLocationMap;
  128812. private _replacements;
  128813. private _textureCount;
  128814. private _uniforms;
  128815. lineProcessor(line: string): string;
  128816. attributeProcessor(attribute: string): string;
  128817. varyingProcessor(varying: string, isFragment: boolean): string;
  128818. uniformProcessor(uniform: string): string;
  128819. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  128820. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  128821. }
  128822. }
  128823. declare module BABYLON {
  128824. /**
  128825. * Class used to inline functions in shader code
  128826. */
  128827. export class ShaderCodeInliner {
  128828. private static readonly _RegexpFindFunctionNameAndType;
  128829. private _sourceCode;
  128830. private _functionDescr;
  128831. private _numMaxIterations;
  128832. /** Gets or sets the token used to mark the functions to inline */
  128833. inlineToken: string;
  128834. /** Gets or sets the debug mode */
  128835. debug: boolean;
  128836. /** Gets the code after the inlining process */
  128837. get code(): string;
  128838. /**
  128839. * Initializes the inliner
  128840. * @param sourceCode shader code source to inline
  128841. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  128842. */
  128843. constructor(sourceCode: string, numMaxIterations?: number);
  128844. /**
  128845. * Start the processing of the shader code
  128846. */
  128847. processCode(): void;
  128848. private _collectFunctions;
  128849. private _processInlining;
  128850. private _extractBetweenMarkers;
  128851. private _skipWhitespaces;
  128852. private _removeComments;
  128853. private _replaceFunctionCallsByCode;
  128854. private _findBackward;
  128855. private _escapeRegExp;
  128856. private _replaceNames;
  128857. }
  128858. }
  128859. declare module BABYLON {
  128860. /**
  128861. * Container for accessors for natively-stored mesh data buffers.
  128862. */
  128863. class NativeDataBuffer extends DataBuffer {
  128864. /**
  128865. * Accessor value used to identify/retrieve a natively-stored index buffer.
  128866. */
  128867. nativeIndexBuffer?: any;
  128868. /**
  128869. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  128870. */
  128871. nativeVertexBuffer?: any;
  128872. }
  128873. /** @hidden */
  128874. class NativeTexture extends InternalTexture {
  128875. getInternalTexture(): InternalTexture;
  128876. getViewCount(): number;
  128877. }
  128878. /** @hidden */
  128879. export class NativeEngine extends Engine {
  128880. private readonly _native;
  128881. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  128882. private readonly INVALID_HANDLE;
  128883. getHardwareScalingLevel(): number;
  128884. constructor();
  128885. dispose(): void;
  128886. /**
  128887. * Can be used to override the current requestAnimationFrame requester.
  128888. * @hidden
  128889. */
  128890. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  128891. /**
  128892. * Override default engine behavior.
  128893. * @param color
  128894. * @param backBuffer
  128895. * @param depth
  128896. * @param stencil
  128897. */
  128898. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  128899. /**
  128900. * Gets host document
  128901. * @returns the host document object
  128902. */
  128903. getHostDocument(): Nullable<Document>;
  128904. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128905. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  128906. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  128907. recordVertexArrayObject(vertexBuffers: {
  128908. [key: string]: VertexBuffer;
  128909. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  128910. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128911. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  128912. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128913. /**
  128914. * Draw a list of indexed primitives
  128915. * @param fillMode defines the primitive to use
  128916. * @param indexStart defines the starting index
  128917. * @param indexCount defines the number of index to draw
  128918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128919. */
  128920. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128921. /**
  128922. * Draw a list of unindexed primitives
  128923. * @param fillMode defines the primitive to use
  128924. * @param verticesStart defines the index of first vertex to draw
  128925. * @param verticesCount defines the count of vertices to draw
  128926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128927. */
  128928. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128929. createPipelineContext(): IPipelineContext;
  128930. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  128931. /** @hidden */
  128932. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  128933. /** @hidden */
  128934. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  128935. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128936. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  128937. protected _setProgram(program: WebGLProgram): void;
  128938. _releaseEffect(effect: Effect): void;
  128939. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  128940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  128941. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  128942. bindSamplers(effect: Effect): void;
  128943. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  128944. getRenderWidth(useScreen?: boolean): number;
  128945. getRenderHeight(useScreen?: boolean): number;
  128946. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  128947. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128948. /**
  128949. * Set the z offset to apply to current rendering
  128950. * @param value defines the offset to apply
  128951. */
  128952. setZOffset(value: number): void;
  128953. /**
  128954. * Gets the current value of the zOffset
  128955. * @returns the current zOffset state
  128956. */
  128957. getZOffset(): number;
  128958. /**
  128959. * Enable or disable depth buffering
  128960. * @param enable defines the state to set
  128961. */
  128962. setDepthBuffer(enable: boolean): void;
  128963. /**
  128964. * Gets a boolean indicating if depth writing is enabled
  128965. * @returns the current depth writing state
  128966. */
  128967. getDepthWrite(): boolean;
  128968. /**
  128969. * Enable or disable depth writing
  128970. * @param enable defines the state to set
  128971. */
  128972. setDepthWrite(enable: boolean): void;
  128973. /**
  128974. * Enable or disable color writing
  128975. * @param enable defines the state to set
  128976. */
  128977. setColorWrite(enable: boolean): void;
  128978. /**
  128979. * Gets a boolean indicating if color writing is enabled
  128980. * @returns the current color writing state
  128981. */
  128982. getColorWrite(): boolean;
  128983. /**
  128984. * Sets alpha constants used by some alpha blending modes
  128985. * @param r defines the red component
  128986. * @param g defines the green component
  128987. * @param b defines the blue component
  128988. * @param a defines the alpha component
  128989. */
  128990. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  128991. /**
  128992. * Sets the current alpha mode
  128993. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  128994. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128995. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128996. */
  128997. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128998. /**
  128999. * Gets the current alpha mode
  129000. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129001. * @returns the current alpha mode
  129002. */
  129003. getAlphaMode(): number;
  129004. setInt(uniform: WebGLUniformLocation, int: number): void;
  129005. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129006. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129007. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129008. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129009. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129010. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129011. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129012. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129013. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129014. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129015. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129016. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129017. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129018. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129019. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129020. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129021. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129022. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129023. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129024. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  129025. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  129026. wipeCaches(bruteForce?: boolean): void;
  129027. _createTexture(): WebGLTexture;
  129028. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  129029. /**
  129030. * Usually called from Texture.ts.
  129031. * Passed information to create a WebGLTexture
  129032. * @param url defines a value which contains one of the following:
  129033. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129034. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129035. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129036. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129037. * @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)
  129038. * @param scene needed for loading to the correct scene
  129039. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129040. * @param onLoad optional callback to be called upon successful completion
  129041. * @param onError optional callback to be called upon failure
  129042. * @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
  129043. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129044. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129045. * @param forcedExtension defines the extension to use to pick the right loader
  129046. * @param mimeType defines an optional mime type
  129047. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129048. */
  129049. 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;
  129050. /**
  129051. * Creates a cube texture
  129052. * @param rootUrl defines the url where the files to load is located
  129053. * @param scene defines the current scene
  129054. * @param files defines the list of files to load (1 per face)
  129055. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129056. * @param onLoad defines an optional callback raised when the texture is loaded
  129057. * @param onError defines an optional callback raised if there is an issue to load the texture
  129058. * @param format defines the format of the data
  129059. * @param forcedExtension defines the extension to use to pick the right loader
  129060. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129061. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129062. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129063. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129064. * @returns the cube texture as an InternalTexture
  129065. */
  129066. 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;
  129067. private _getSamplingFilter;
  129068. private static _GetNativeTextureFormat;
  129069. createRenderTargetTexture(size: number | {
  129070. width: number;
  129071. height: number;
  129072. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  129073. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129074. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129075. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129076. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129077. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129078. /**
  129079. * Updates a dynamic vertex buffer.
  129080. * @param vertexBuffer the vertex buffer to update
  129081. * @param data the data used to update the vertex buffer
  129082. * @param byteOffset the byte offset of the data (optional)
  129083. * @param byteLength the byte length of the data (optional)
  129084. */
  129085. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129086. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  129087. private _updateAnisotropicLevel;
  129088. private _getAddressMode;
  129089. /** @hidden */
  129090. _bindTexture(channel: number, texture: InternalTexture): void;
  129091. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  129092. releaseEffects(): void;
  129093. /** @hidden */
  129094. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129095. /** @hidden */
  129096. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129097. /** @hidden */
  129098. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129099. /** @hidden */
  129100. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129101. }
  129102. }
  129103. declare module BABYLON {
  129104. /**
  129105. * Gather the list of clipboard event types as constants.
  129106. */
  129107. export class ClipboardEventTypes {
  129108. /**
  129109. * The clipboard event is fired when a copy command is active (pressed).
  129110. */
  129111. static readonly COPY: number;
  129112. /**
  129113. * The clipboard event is fired when a cut command is active (pressed).
  129114. */
  129115. static readonly CUT: number;
  129116. /**
  129117. * The clipboard event is fired when a paste command is active (pressed).
  129118. */
  129119. static readonly PASTE: number;
  129120. }
  129121. /**
  129122. * This class is used to store clipboard related info for the onClipboardObservable event.
  129123. */
  129124. export class ClipboardInfo {
  129125. /**
  129126. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129127. */
  129128. type: number;
  129129. /**
  129130. * Defines the related dom event
  129131. */
  129132. event: ClipboardEvent;
  129133. /**
  129134. *Creates an instance of ClipboardInfo.
  129135. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  129136. * @param event Defines the related dom event
  129137. */
  129138. constructor(
  129139. /**
  129140. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129141. */
  129142. type: number,
  129143. /**
  129144. * Defines the related dom event
  129145. */
  129146. event: ClipboardEvent);
  129147. /**
  129148. * Get the clipboard event's type from the keycode.
  129149. * @param keyCode Defines the keyCode for the current keyboard event.
  129150. * @return {number}
  129151. */
  129152. static GetTypeFromCharacter(keyCode: number): number;
  129153. }
  129154. }
  129155. declare module BABYLON {
  129156. /**
  129157. * Google Daydream controller
  129158. */
  129159. export class DaydreamController extends WebVRController {
  129160. /**
  129161. * Base Url for the controller model.
  129162. */
  129163. static MODEL_BASE_URL: string;
  129164. /**
  129165. * File name for the controller model.
  129166. */
  129167. static MODEL_FILENAME: string;
  129168. /**
  129169. * Gamepad Id prefix used to identify Daydream Controller.
  129170. */
  129171. static readonly GAMEPAD_ID_PREFIX: string;
  129172. /**
  129173. * Creates a new DaydreamController from a gamepad
  129174. * @param vrGamepad the gamepad that the controller should be created from
  129175. */
  129176. constructor(vrGamepad: any);
  129177. /**
  129178. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129179. * @param scene scene in which to add meshes
  129180. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129181. */
  129182. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129183. /**
  129184. * Called once for each button that changed state since the last frame
  129185. * @param buttonIdx Which button index changed
  129186. * @param state New state of the button
  129187. * @param changes Which properties on the state changed since last frame
  129188. */
  129189. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129190. }
  129191. }
  129192. declare module BABYLON {
  129193. /**
  129194. * Gear VR Controller
  129195. */
  129196. export class GearVRController extends WebVRController {
  129197. /**
  129198. * Base Url for the controller model.
  129199. */
  129200. static MODEL_BASE_URL: string;
  129201. /**
  129202. * File name for the controller model.
  129203. */
  129204. static MODEL_FILENAME: string;
  129205. /**
  129206. * Gamepad Id prefix used to identify this controller.
  129207. */
  129208. static readonly GAMEPAD_ID_PREFIX: string;
  129209. private readonly _buttonIndexToObservableNameMap;
  129210. /**
  129211. * Creates a new GearVRController from a gamepad
  129212. * @param vrGamepad the gamepad that the controller should be created from
  129213. */
  129214. constructor(vrGamepad: any);
  129215. /**
  129216. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129217. * @param scene scene in which to add meshes
  129218. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129219. */
  129220. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129221. /**
  129222. * Called once for each button that changed state since the last frame
  129223. * @param buttonIdx Which button index changed
  129224. * @param state New state of the button
  129225. * @param changes Which properties on the state changed since last frame
  129226. */
  129227. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129228. }
  129229. }
  129230. declare module BABYLON {
  129231. /**
  129232. * Generic Controller
  129233. */
  129234. export class GenericController extends WebVRController {
  129235. /**
  129236. * Base Url for the controller model.
  129237. */
  129238. static readonly MODEL_BASE_URL: string;
  129239. /**
  129240. * File name for the controller model.
  129241. */
  129242. static readonly MODEL_FILENAME: string;
  129243. /**
  129244. * Creates a new GenericController from a gamepad
  129245. * @param vrGamepad the gamepad that the controller should be created from
  129246. */
  129247. constructor(vrGamepad: any);
  129248. /**
  129249. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129250. * @param scene scene in which to add meshes
  129251. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129252. */
  129253. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129254. /**
  129255. * Called once for each button that changed state since the last frame
  129256. * @param buttonIdx Which button index changed
  129257. * @param state New state of the button
  129258. * @param changes Which properties on the state changed since last frame
  129259. */
  129260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129261. }
  129262. }
  129263. declare module BABYLON {
  129264. /**
  129265. * Oculus Touch Controller
  129266. */
  129267. export class OculusTouchController extends WebVRController {
  129268. /**
  129269. * Base Url for the controller model.
  129270. */
  129271. static MODEL_BASE_URL: string;
  129272. /**
  129273. * File name for the left controller model.
  129274. */
  129275. static MODEL_LEFT_FILENAME: string;
  129276. /**
  129277. * File name for the right controller model.
  129278. */
  129279. static MODEL_RIGHT_FILENAME: string;
  129280. /**
  129281. * Base Url for the Quest controller model.
  129282. */
  129283. static QUEST_MODEL_BASE_URL: string;
  129284. /**
  129285. * @hidden
  129286. * If the controllers are running on a device that needs the updated Quest controller models
  129287. */
  129288. static _IsQuest: boolean;
  129289. /**
  129290. * Fired when the secondary trigger on this controller is modified
  129291. */
  129292. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  129293. /**
  129294. * Fired when the thumb rest on this controller is modified
  129295. */
  129296. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  129297. /**
  129298. * Creates a new OculusTouchController from a gamepad
  129299. * @param vrGamepad the gamepad that the controller should be created from
  129300. */
  129301. constructor(vrGamepad: any);
  129302. /**
  129303. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129304. * @param scene scene in which to add meshes
  129305. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129306. */
  129307. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129308. /**
  129309. * Fired when the A button on this controller is modified
  129310. */
  129311. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129312. /**
  129313. * Fired when the B button on this controller is modified
  129314. */
  129315. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129316. /**
  129317. * Fired when the X button on this controller is modified
  129318. */
  129319. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129320. /**
  129321. * Fired when the Y button on this controller is modified
  129322. */
  129323. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129324. /**
  129325. * Called once for each button that changed state since the last frame
  129326. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  129327. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  129328. * 2) secondary trigger (same)
  129329. * 3) A (right) X (left), touch, pressed = value
  129330. * 4) B / Y
  129331. * 5) thumb rest
  129332. * @param buttonIdx Which button index changed
  129333. * @param state New state of the button
  129334. * @param changes Which properties on the state changed since last frame
  129335. */
  129336. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129337. }
  129338. }
  129339. declare module BABYLON {
  129340. /**
  129341. * Vive Controller
  129342. */
  129343. export class ViveController extends WebVRController {
  129344. /**
  129345. * Base Url for the controller model.
  129346. */
  129347. static MODEL_BASE_URL: string;
  129348. /**
  129349. * File name for the controller model.
  129350. */
  129351. static MODEL_FILENAME: string;
  129352. /**
  129353. * Creates a new ViveController from a gamepad
  129354. * @param vrGamepad the gamepad that the controller should be created from
  129355. */
  129356. constructor(vrGamepad: any);
  129357. /**
  129358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129359. * @param scene scene in which to add meshes
  129360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129361. */
  129362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129363. /**
  129364. * Fired when the left button on this controller is modified
  129365. */
  129366. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129367. /**
  129368. * Fired when the right button on this controller is modified
  129369. */
  129370. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129371. /**
  129372. * Fired when the menu button on this controller is modified
  129373. */
  129374. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129375. /**
  129376. * Called once for each button that changed state since the last frame
  129377. * Vive mapping:
  129378. * 0: touchpad
  129379. * 1: trigger
  129380. * 2: left AND right buttons
  129381. * 3: menu button
  129382. * @param buttonIdx Which button index changed
  129383. * @param state New state of the button
  129384. * @param changes Which properties on the state changed since last frame
  129385. */
  129386. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129387. }
  129388. }
  129389. declare module BABYLON {
  129390. /**
  129391. * Defines the WindowsMotionController object that the state of the windows motion controller
  129392. */
  129393. export class WindowsMotionController extends WebVRController {
  129394. /**
  129395. * The base url used to load the left and right controller models
  129396. */
  129397. static MODEL_BASE_URL: string;
  129398. /**
  129399. * The name of the left controller model file
  129400. */
  129401. static MODEL_LEFT_FILENAME: string;
  129402. /**
  129403. * The name of the right controller model file
  129404. */
  129405. static MODEL_RIGHT_FILENAME: string;
  129406. /**
  129407. * The controller name prefix for this controller type
  129408. */
  129409. static readonly GAMEPAD_ID_PREFIX: string;
  129410. /**
  129411. * The controller id pattern for this controller type
  129412. */
  129413. private static readonly GAMEPAD_ID_PATTERN;
  129414. private _loadedMeshInfo;
  129415. protected readonly _mapping: {
  129416. buttons: string[];
  129417. buttonMeshNames: {
  129418. trigger: string;
  129419. menu: string;
  129420. grip: string;
  129421. thumbstick: string;
  129422. trackpad: string;
  129423. };
  129424. buttonObservableNames: {
  129425. trigger: string;
  129426. menu: string;
  129427. grip: string;
  129428. thumbstick: string;
  129429. trackpad: string;
  129430. };
  129431. axisMeshNames: string[];
  129432. pointingPoseMeshName: string;
  129433. };
  129434. /**
  129435. * Fired when the trackpad on this controller is clicked
  129436. */
  129437. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129438. /**
  129439. * Fired when the trackpad on this controller is modified
  129440. */
  129441. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129442. /**
  129443. * The current x and y values of this controller's trackpad
  129444. */
  129445. trackpad: StickValues;
  129446. /**
  129447. * Creates a new WindowsMotionController from a gamepad
  129448. * @param vrGamepad the gamepad that the controller should be created from
  129449. */
  129450. constructor(vrGamepad: any);
  129451. /**
  129452. * Fired when the trigger on this controller is modified
  129453. */
  129454. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129455. /**
  129456. * Fired when the menu button on this controller is modified
  129457. */
  129458. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129459. /**
  129460. * Fired when the grip button on this controller is modified
  129461. */
  129462. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129463. /**
  129464. * Fired when the thumbstick button on this controller is modified
  129465. */
  129466. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129467. /**
  129468. * Fired when the touchpad button on this controller is modified
  129469. */
  129470. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129471. /**
  129472. * Fired when the touchpad values on this controller are modified
  129473. */
  129474. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  129475. protected _updateTrackpad(): void;
  129476. /**
  129477. * Called once per frame by the engine.
  129478. */
  129479. update(): void;
  129480. /**
  129481. * Called once for each button that changed state since the last frame
  129482. * @param buttonIdx Which button index changed
  129483. * @param state New state of the button
  129484. * @param changes Which properties on the state changed since last frame
  129485. */
  129486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129487. /**
  129488. * Moves the buttons on the controller mesh based on their current state
  129489. * @param buttonName the name of the button to move
  129490. * @param buttonValue the value of the button which determines the buttons new position
  129491. */
  129492. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  129493. /**
  129494. * Moves the axis on the controller mesh based on its current state
  129495. * @param axis the index of the axis
  129496. * @param axisValue the value of the axis which determines the meshes new position
  129497. * @hidden
  129498. */
  129499. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  129500. /**
  129501. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129502. * @param scene scene in which to add meshes
  129503. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129504. */
  129505. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  129506. /**
  129507. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  129508. * can be transformed by button presses and axes values, based on this._mapping.
  129509. *
  129510. * @param scene scene in which the meshes exist
  129511. * @param meshes list of meshes that make up the controller model to process
  129512. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  129513. */
  129514. private processModel;
  129515. private createMeshInfo;
  129516. /**
  129517. * Gets the ray of the controller in the direction the controller is pointing
  129518. * @param length the length the resulting ray should be
  129519. * @returns a ray in the direction the controller is pointing
  129520. */
  129521. getForwardRay(length?: number): Ray;
  129522. /**
  129523. * Disposes of the controller
  129524. */
  129525. dispose(): void;
  129526. }
  129527. /**
  129528. * This class represents a new windows motion controller in XR.
  129529. */
  129530. export class XRWindowsMotionController extends WindowsMotionController {
  129531. /**
  129532. * Changing the original WIndowsMotionController mapping to fir the new mapping
  129533. */
  129534. protected readonly _mapping: {
  129535. buttons: string[];
  129536. buttonMeshNames: {
  129537. trigger: string;
  129538. menu: string;
  129539. grip: string;
  129540. thumbstick: string;
  129541. trackpad: string;
  129542. };
  129543. buttonObservableNames: {
  129544. trigger: string;
  129545. menu: string;
  129546. grip: string;
  129547. thumbstick: string;
  129548. trackpad: string;
  129549. };
  129550. axisMeshNames: string[];
  129551. pointingPoseMeshName: string;
  129552. };
  129553. /**
  129554. * Construct a new XR-Based windows motion controller
  129555. *
  129556. * @param gamepadInfo the gamepad object from the browser
  129557. */
  129558. constructor(gamepadInfo: any);
  129559. /**
  129560. * holds the thumbstick values (X,Y)
  129561. */
  129562. thumbstickValues: StickValues;
  129563. /**
  129564. * Fired when the thumbstick on this controller is clicked
  129565. */
  129566. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  129567. /**
  129568. * Fired when the thumbstick on this controller is modified
  129569. */
  129570. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129571. /**
  129572. * Fired when the touchpad button on this controller is modified
  129573. */
  129574. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129575. /**
  129576. * Fired when the touchpad values on this controller are modified
  129577. */
  129578. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129579. /**
  129580. * Fired when the thumbstick button on this controller is modified
  129581. * here to prevent breaking changes
  129582. */
  129583. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129584. /**
  129585. * updating the thumbstick(!) and not the trackpad.
  129586. * This is named this way due to the difference between WebVR and XR and to avoid
  129587. * changing the parent class.
  129588. */
  129589. protected _updateTrackpad(): void;
  129590. /**
  129591. * Disposes the class with joy
  129592. */
  129593. dispose(): void;
  129594. }
  129595. }
  129596. declare module BABYLON {
  129597. /**
  129598. * Class containing static functions to help procedurally build meshes
  129599. */
  129600. export class PolyhedronBuilder {
  129601. /**
  129602. * Creates a polyhedron mesh
  129603. * * 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
  129604. * * The parameter `size` (positive float, default 1) sets the polygon size
  129605. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129606. * * 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`
  129607. * * 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
  129608. * * 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)`)
  129609. * * 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
  129610. * * 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
  129611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129614. * @param name defines the name of the mesh
  129615. * @param options defines the options used to create the mesh
  129616. * @param scene defines the hosting scene
  129617. * @returns the polyhedron mesh
  129618. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129619. */
  129620. static CreatePolyhedron(name: string, options: {
  129621. type?: number;
  129622. size?: number;
  129623. sizeX?: number;
  129624. sizeY?: number;
  129625. sizeZ?: number;
  129626. custom?: any;
  129627. faceUV?: Vector4[];
  129628. faceColors?: Color4[];
  129629. flat?: boolean;
  129630. updatable?: boolean;
  129631. sideOrientation?: number;
  129632. frontUVs?: Vector4;
  129633. backUVs?: Vector4;
  129634. }, scene?: Nullable<Scene>): Mesh;
  129635. }
  129636. }
  129637. declare module BABYLON {
  129638. /**
  129639. * Gizmo that enables scaling a mesh along 3 axis
  129640. */
  129641. export class ScaleGizmo extends Gizmo {
  129642. /**
  129643. * Internal gizmo used for interactions on the x axis
  129644. */
  129645. xGizmo: AxisScaleGizmo;
  129646. /**
  129647. * Internal gizmo used for interactions on the y axis
  129648. */
  129649. yGizmo: AxisScaleGizmo;
  129650. /**
  129651. * Internal gizmo used for interactions on the z axis
  129652. */
  129653. zGizmo: AxisScaleGizmo;
  129654. /**
  129655. * Internal gizmo used to scale all axis equally
  129656. */
  129657. uniformScaleGizmo: AxisScaleGizmo;
  129658. private _meshAttached;
  129659. private _updateGizmoRotationToMatchAttachedMesh;
  129660. private _snapDistance;
  129661. private _scaleRatio;
  129662. private _uniformScalingMesh;
  129663. private _octahedron;
  129664. private _sensitivity;
  129665. /** Fires an event when any of it's sub gizmos are dragged */
  129666. onDragStartObservable: Observable<unknown>;
  129667. /** Fires an event when any of it's sub gizmos are released from dragging */
  129668. onDragEndObservable: Observable<unknown>;
  129669. get attachedMesh(): Nullable<AbstractMesh>;
  129670. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129671. /**
  129672. * Creates a ScaleGizmo
  129673. * @param gizmoLayer The utility layer the gizmo will be added to
  129674. */
  129675. constructor(gizmoLayer?: UtilityLayerRenderer);
  129676. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129677. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129678. /**
  129679. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129680. */
  129681. set snapDistance(value: number);
  129682. get snapDistance(): number;
  129683. /**
  129684. * Ratio for the scale of the gizmo (Default: 1)
  129685. */
  129686. set scaleRatio(value: number);
  129687. get scaleRatio(): number;
  129688. /**
  129689. * Sensitivity factor for dragging (Default: 1)
  129690. */
  129691. set sensitivity(value: number);
  129692. get sensitivity(): number;
  129693. /**
  129694. * Disposes of the gizmo
  129695. */
  129696. dispose(): void;
  129697. }
  129698. }
  129699. declare module BABYLON {
  129700. /**
  129701. * Single axis scale gizmo
  129702. */
  129703. export class AxisScaleGizmo extends Gizmo {
  129704. /**
  129705. * Drag behavior responsible for the gizmos dragging interactions
  129706. */
  129707. dragBehavior: PointerDragBehavior;
  129708. private _pointerObserver;
  129709. /**
  129710. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129711. */
  129712. snapDistance: number;
  129713. /**
  129714. * Event that fires each time the gizmo snaps to a new location.
  129715. * * snapDistance is the the change in distance
  129716. */
  129717. onSnapObservable: Observable<{
  129718. snapDistance: number;
  129719. }>;
  129720. /**
  129721. * If the scaling operation should be done on all axis (default: false)
  129722. */
  129723. uniformScaling: boolean;
  129724. /**
  129725. * Custom sensitivity value for the drag strength
  129726. */
  129727. sensitivity: number;
  129728. private _isEnabled;
  129729. private _parent;
  129730. private _arrow;
  129731. private _coloredMaterial;
  129732. private _hoverMaterial;
  129733. /**
  129734. * Creates an AxisScaleGizmo
  129735. * @param gizmoLayer The utility layer the gizmo will be added to
  129736. * @param dragAxis The axis which the gizmo will be able to scale on
  129737. * @param color The color of the gizmo
  129738. */
  129739. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  129740. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129741. /**
  129742. * If the gizmo is enabled
  129743. */
  129744. set isEnabled(value: boolean);
  129745. get isEnabled(): boolean;
  129746. /**
  129747. * Disposes of the gizmo
  129748. */
  129749. dispose(): void;
  129750. /**
  129751. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129752. * @param mesh The mesh to replace the default mesh of the gizmo
  129753. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  129754. */
  129755. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  129756. }
  129757. }
  129758. declare module BABYLON {
  129759. /**
  129760. * Bounding box gizmo
  129761. */
  129762. export class BoundingBoxGizmo extends Gizmo {
  129763. private _lineBoundingBox;
  129764. private _rotateSpheresParent;
  129765. private _scaleBoxesParent;
  129766. private _boundingDimensions;
  129767. private _renderObserver;
  129768. private _pointerObserver;
  129769. private _scaleDragSpeed;
  129770. private _tmpQuaternion;
  129771. private _tmpVector;
  129772. private _tmpRotationMatrix;
  129773. /**
  129774. * 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)
  129775. */
  129776. ignoreChildren: boolean;
  129777. /**
  129778. * 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)
  129779. */
  129780. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  129781. /**
  129782. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  129783. */
  129784. rotationSphereSize: number;
  129785. /**
  129786. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  129787. */
  129788. scaleBoxSize: number;
  129789. /**
  129790. * 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)
  129791. */
  129792. fixedDragMeshScreenSize: boolean;
  129793. /**
  129794. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  129795. */
  129796. fixedDragMeshScreenSizeDistanceFactor: number;
  129797. /**
  129798. * Fired when a rotation sphere or scale box is dragged
  129799. */
  129800. onDragStartObservable: Observable<{}>;
  129801. /**
  129802. * Fired when a scale box is dragged
  129803. */
  129804. onScaleBoxDragObservable: Observable<{}>;
  129805. /**
  129806. * Fired when a scale box drag is ended
  129807. */
  129808. onScaleBoxDragEndObservable: Observable<{}>;
  129809. /**
  129810. * Fired when a rotation sphere is dragged
  129811. */
  129812. onRotationSphereDragObservable: Observable<{}>;
  129813. /**
  129814. * Fired when a rotation sphere drag is ended
  129815. */
  129816. onRotationSphereDragEndObservable: Observable<{}>;
  129817. /**
  129818. * 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)
  129819. */
  129820. scalePivot: Nullable<Vector3>;
  129821. /**
  129822. * Mesh used as a pivot to rotate the attached mesh
  129823. */
  129824. private _anchorMesh;
  129825. private _existingMeshScale;
  129826. private _dragMesh;
  129827. private pointerDragBehavior;
  129828. private coloredMaterial;
  129829. private hoverColoredMaterial;
  129830. /**
  129831. * Sets the color of the bounding box gizmo
  129832. * @param color the color to set
  129833. */
  129834. setColor(color: Color3): void;
  129835. /**
  129836. * Creates an BoundingBoxGizmo
  129837. * @param gizmoLayer The utility layer the gizmo will be added to
  129838. * @param color The color of the gizmo
  129839. */
  129840. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  129841. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129842. private _selectNode;
  129843. /**
  129844. * Updates the bounding box information for the Gizmo
  129845. */
  129846. updateBoundingBox(): void;
  129847. private _updateRotationSpheres;
  129848. private _updateScaleBoxes;
  129849. /**
  129850. * Enables rotation on the specified axis and disables rotation on the others
  129851. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  129852. */
  129853. setEnabledRotationAxis(axis: string): void;
  129854. /**
  129855. * Enables/disables scaling
  129856. * @param enable if scaling should be enabled
  129857. * @param homogeneousScaling defines if scaling should only be homogeneous
  129858. */
  129859. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  129860. private _updateDummy;
  129861. /**
  129862. * Enables a pointer drag behavior on the bounding box of the gizmo
  129863. */
  129864. enableDragBehavior(): void;
  129865. /**
  129866. * Disposes of the gizmo
  129867. */
  129868. dispose(): void;
  129869. /**
  129870. * 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)
  129871. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  129872. * @returns the bounding box mesh with the passed in mesh as a child
  129873. */
  129874. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  129875. /**
  129876. * CustomMeshes are not supported by this gizmo
  129877. * @param mesh The mesh to replace the default mesh of the gizmo
  129878. */
  129879. setCustomMesh(mesh: Mesh): void;
  129880. }
  129881. }
  129882. declare module BABYLON {
  129883. /**
  129884. * Single plane rotation gizmo
  129885. */
  129886. export class PlaneRotationGizmo extends Gizmo {
  129887. /**
  129888. * Drag behavior responsible for the gizmos dragging interactions
  129889. */
  129890. dragBehavior: PointerDragBehavior;
  129891. private _pointerObserver;
  129892. /**
  129893. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  129894. */
  129895. snapDistance: number;
  129896. /**
  129897. * Event that fires each time the gizmo snaps to a new location.
  129898. * * snapDistance is the the change in distance
  129899. */
  129900. onSnapObservable: Observable<{
  129901. snapDistance: number;
  129902. }>;
  129903. private _isEnabled;
  129904. private _parent;
  129905. /**
  129906. * Creates a PlaneRotationGizmo
  129907. * @param gizmoLayer The utility layer the gizmo will be added to
  129908. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  129909. * @param color The color of the gizmo
  129910. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129911. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129912. */
  129913. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  129914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  129915. /**
  129916. * If the gizmo is enabled
  129917. */
  129918. set isEnabled(value: boolean);
  129919. get isEnabled(): boolean;
  129920. /**
  129921. * Disposes of the gizmo
  129922. */
  129923. dispose(): void;
  129924. }
  129925. }
  129926. declare module BABYLON {
  129927. /**
  129928. * Gizmo that enables rotating a mesh along 3 axis
  129929. */
  129930. export class RotationGizmo extends Gizmo {
  129931. /**
  129932. * Internal gizmo used for interactions on the x axis
  129933. */
  129934. xGizmo: PlaneRotationGizmo;
  129935. /**
  129936. * Internal gizmo used for interactions on the y axis
  129937. */
  129938. yGizmo: PlaneRotationGizmo;
  129939. /**
  129940. * Internal gizmo used for interactions on the z axis
  129941. */
  129942. zGizmo: PlaneRotationGizmo;
  129943. /** Fires an event when any of it's sub gizmos are dragged */
  129944. onDragStartObservable: Observable<unknown>;
  129945. /** Fires an event when any of it's sub gizmos are released from dragging */
  129946. onDragEndObservable: Observable<unknown>;
  129947. private _meshAttached;
  129948. get attachedMesh(): Nullable<AbstractMesh>;
  129949. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129950. /**
  129951. * Creates a RotationGizmo
  129952. * @param gizmoLayer The utility layer the gizmo will be added to
  129953. * @param tessellation Amount of tessellation to be used when creating rotation circles
  129954. * @param useEulerRotation Use and update Euler angle instead of quaternion
  129955. */
  129956. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  129957. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129958. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129959. /**
  129960. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129961. */
  129962. set snapDistance(value: number);
  129963. get snapDistance(): number;
  129964. /**
  129965. * Ratio for the scale of the gizmo (Default: 1)
  129966. */
  129967. set scaleRatio(value: number);
  129968. get scaleRatio(): number;
  129969. /**
  129970. * Disposes of the gizmo
  129971. */
  129972. dispose(): void;
  129973. /**
  129974. * CustomMeshes are not supported by this gizmo
  129975. * @param mesh The mesh to replace the default mesh of the gizmo
  129976. */
  129977. setCustomMesh(mesh: Mesh): void;
  129978. }
  129979. }
  129980. declare module BABYLON {
  129981. /**
  129982. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  129983. */
  129984. export class GizmoManager implements IDisposable {
  129985. private scene;
  129986. /**
  129987. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  129988. */
  129989. gizmos: {
  129990. positionGizmo: Nullable<PositionGizmo>;
  129991. rotationGizmo: Nullable<RotationGizmo>;
  129992. scaleGizmo: Nullable<ScaleGizmo>;
  129993. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  129994. };
  129995. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  129996. clearGizmoOnEmptyPointerEvent: boolean;
  129997. /** Fires an event when the manager is attached to a mesh */
  129998. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  129999. private _gizmosEnabled;
  130000. private _pointerObserver;
  130001. private _attachedMesh;
  130002. private _boundingBoxColor;
  130003. private _defaultUtilityLayer;
  130004. private _defaultKeepDepthUtilityLayer;
  130005. /**
  130006. * When bounding box gizmo is enabled, this can be used to track drag/end events
  130007. */
  130008. boundingBoxDragBehavior: SixDofDragBehavior;
  130009. /**
  130010. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  130011. */
  130012. attachableMeshes: Nullable<Array<AbstractMesh>>;
  130013. /**
  130014. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  130015. */
  130016. usePointerToAttachGizmos: boolean;
  130017. /**
  130018. * Utility layer that the bounding box gizmo belongs to
  130019. */
  130020. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  130021. /**
  130022. * Utility layer that all gizmos besides bounding box belong to
  130023. */
  130024. get utilityLayer(): UtilityLayerRenderer;
  130025. /**
  130026. * Instatiates a gizmo manager
  130027. * @param scene the scene to overlay the gizmos on top of
  130028. */
  130029. constructor(scene: Scene);
  130030. /**
  130031. * Attaches a set of gizmos to the specified mesh
  130032. * @param mesh The mesh the gizmo's should be attached to
  130033. */
  130034. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130035. /**
  130036. * If the position gizmo is enabled
  130037. */
  130038. set positionGizmoEnabled(value: boolean);
  130039. get positionGizmoEnabled(): boolean;
  130040. /**
  130041. * If the rotation gizmo is enabled
  130042. */
  130043. set rotationGizmoEnabled(value: boolean);
  130044. get rotationGizmoEnabled(): boolean;
  130045. /**
  130046. * If the scale gizmo is enabled
  130047. */
  130048. set scaleGizmoEnabled(value: boolean);
  130049. get scaleGizmoEnabled(): boolean;
  130050. /**
  130051. * If the boundingBox gizmo is enabled
  130052. */
  130053. set boundingBoxGizmoEnabled(value: boolean);
  130054. get boundingBoxGizmoEnabled(): boolean;
  130055. /**
  130056. * Disposes of the gizmo manager
  130057. */
  130058. dispose(): void;
  130059. }
  130060. }
  130061. declare module BABYLON {
  130062. /**
  130063. * A directional light is defined by a direction (what a surprise!).
  130064. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  130065. * 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.
  130066. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130067. */
  130068. export class DirectionalLight extends ShadowLight {
  130069. private _shadowFrustumSize;
  130070. /**
  130071. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  130072. */
  130073. get shadowFrustumSize(): number;
  130074. /**
  130075. * Specifies a fix frustum size for the shadow generation.
  130076. */
  130077. set shadowFrustumSize(value: number);
  130078. private _shadowOrthoScale;
  130079. /**
  130080. * Gets the shadow projection scale against the optimal computed one.
  130081. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130082. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130083. */
  130084. get shadowOrthoScale(): number;
  130085. /**
  130086. * Sets the shadow projection scale against the optimal computed one.
  130087. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130088. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130089. */
  130090. set shadowOrthoScale(value: number);
  130091. /**
  130092. * Automatically compute the projection matrix to best fit (including all the casters)
  130093. * on each frame.
  130094. */
  130095. autoUpdateExtends: boolean;
  130096. /**
  130097. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  130098. * on each frame. autoUpdateExtends must be set to true for this to work
  130099. */
  130100. autoCalcShadowZBounds: boolean;
  130101. private _orthoLeft;
  130102. private _orthoRight;
  130103. private _orthoTop;
  130104. private _orthoBottom;
  130105. /**
  130106. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  130107. * The directional light is emitted from everywhere in the given direction.
  130108. * It can cast shadows.
  130109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130110. * @param name The friendly name of the light
  130111. * @param direction The direction of the light
  130112. * @param scene The scene the light belongs to
  130113. */
  130114. constructor(name: string, direction: Vector3, scene: Scene);
  130115. /**
  130116. * Returns the string "DirectionalLight".
  130117. * @return The class name
  130118. */
  130119. getClassName(): string;
  130120. /**
  130121. * Returns the integer 1.
  130122. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130123. */
  130124. getTypeID(): number;
  130125. /**
  130126. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  130127. * Returns the DirectionalLight Shadow projection matrix.
  130128. */
  130129. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130130. /**
  130131. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  130132. * Returns the DirectionalLight Shadow projection matrix.
  130133. */
  130134. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  130135. /**
  130136. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  130137. * Returns the DirectionalLight Shadow projection matrix.
  130138. */
  130139. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130140. protected _buildUniformLayout(): void;
  130141. /**
  130142. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  130143. * @param effect The effect to update
  130144. * @param lightIndex The index of the light in the effect to update
  130145. * @returns The directional light
  130146. */
  130147. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  130148. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  130149. /**
  130150. * Gets the minZ used for shadow according to both the scene and the light.
  130151. *
  130152. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130153. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130154. * @param activeCamera The camera we are returning the min for
  130155. * @returns the depth min z
  130156. */
  130157. getDepthMinZ(activeCamera: Camera): number;
  130158. /**
  130159. * Gets the maxZ used for shadow according to both the scene and the light.
  130160. *
  130161. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130162. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130163. * @param activeCamera The camera we are returning the max for
  130164. * @returns the depth max z
  130165. */
  130166. getDepthMaxZ(activeCamera: Camera): number;
  130167. /**
  130168. * Prepares the list of defines specific to the light type.
  130169. * @param defines the list of defines
  130170. * @param lightIndex defines the index of the light for the effect
  130171. */
  130172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130173. }
  130174. }
  130175. declare module BABYLON {
  130176. /**
  130177. * Class containing static functions to help procedurally build meshes
  130178. */
  130179. export class HemisphereBuilder {
  130180. /**
  130181. * Creates a hemisphere mesh
  130182. * @param name defines the name of the mesh
  130183. * @param options defines the options used to create the mesh
  130184. * @param scene defines the hosting scene
  130185. * @returns the hemisphere mesh
  130186. */
  130187. static CreateHemisphere(name: string, options: {
  130188. segments?: number;
  130189. diameter?: number;
  130190. sideOrientation?: number;
  130191. }, scene: any): Mesh;
  130192. }
  130193. }
  130194. declare module BABYLON {
  130195. /**
  130196. * A spot light is defined by a position, a direction, an angle, and an exponent.
  130197. * These values define a cone of light starting from the position, emitting toward the direction.
  130198. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  130199. * and the exponent defines the speed of the decay of the light with distance (reach).
  130200. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130201. */
  130202. export class SpotLight extends ShadowLight {
  130203. private _angle;
  130204. private _innerAngle;
  130205. private _cosHalfAngle;
  130206. private _lightAngleScale;
  130207. private _lightAngleOffset;
  130208. /**
  130209. * Gets the cone angle of the spot light in Radians.
  130210. */
  130211. get angle(): number;
  130212. /**
  130213. * Sets the cone angle of the spot light in Radians.
  130214. */
  130215. set angle(value: number);
  130216. /**
  130217. * Only used in gltf falloff mode, this defines the angle where
  130218. * the directional falloff will start before cutting at angle which could be seen
  130219. * as outer angle.
  130220. */
  130221. get innerAngle(): number;
  130222. /**
  130223. * Only used in gltf falloff mode, this defines the angle where
  130224. * the directional falloff will start before cutting at angle which could be seen
  130225. * as outer angle.
  130226. */
  130227. set innerAngle(value: number);
  130228. private _shadowAngleScale;
  130229. /**
  130230. * Allows scaling the angle of the light for shadow generation only.
  130231. */
  130232. get shadowAngleScale(): number;
  130233. /**
  130234. * Allows scaling the angle of the light for shadow generation only.
  130235. */
  130236. set shadowAngleScale(value: number);
  130237. /**
  130238. * The light decay speed with the distance from the emission spot.
  130239. */
  130240. exponent: number;
  130241. private _projectionTextureMatrix;
  130242. /**
  130243. * Allows reading the projecton texture
  130244. */
  130245. get projectionTextureMatrix(): Matrix;
  130246. protected _projectionTextureLightNear: number;
  130247. /**
  130248. * Gets the near clip of the Spotlight for texture projection.
  130249. */
  130250. get projectionTextureLightNear(): number;
  130251. /**
  130252. * Sets the near clip of the Spotlight for texture projection.
  130253. */
  130254. set projectionTextureLightNear(value: number);
  130255. protected _projectionTextureLightFar: number;
  130256. /**
  130257. * Gets the far clip of the Spotlight for texture projection.
  130258. */
  130259. get projectionTextureLightFar(): number;
  130260. /**
  130261. * Sets the far clip of the Spotlight for texture projection.
  130262. */
  130263. set projectionTextureLightFar(value: number);
  130264. protected _projectionTextureUpDirection: Vector3;
  130265. /**
  130266. * Gets the Up vector of the Spotlight for texture projection.
  130267. */
  130268. get projectionTextureUpDirection(): Vector3;
  130269. /**
  130270. * Sets the Up vector of the Spotlight for texture projection.
  130271. */
  130272. set projectionTextureUpDirection(value: Vector3);
  130273. private _projectionTexture;
  130274. /**
  130275. * Gets the projection texture of the light.
  130276. */
  130277. get projectionTexture(): Nullable<BaseTexture>;
  130278. /**
  130279. * Sets the projection texture of the light.
  130280. */
  130281. set projectionTexture(value: Nullable<BaseTexture>);
  130282. private _projectionTextureViewLightDirty;
  130283. private _projectionTextureProjectionLightDirty;
  130284. private _projectionTextureDirty;
  130285. private _projectionTextureViewTargetVector;
  130286. private _projectionTextureViewLightMatrix;
  130287. private _projectionTextureProjectionLightMatrix;
  130288. private _projectionTextureScalingMatrix;
  130289. /**
  130290. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  130291. * It can cast shadows.
  130292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130293. * @param name The light friendly name
  130294. * @param position The position of the spot light in the scene
  130295. * @param direction The direction of the light in the scene
  130296. * @param angle The cone angle of the light in Radians
  130297. * @param exponent The light decay speed with the distance from the emission spot
  130298. * @param scene The scene the lights belongs to
  130299. */
  130300. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  130301. /**
  130302. * Returns the string "SpotLight".
  130303. * @returns the class name
  130304. */
  130305. getClassName(): string;
  130306. /**
  130307. * Returns the integer 2.
  130308. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130309. */
  130310. getTypeID(): number;
  130311. /**
  130312. * Overrides the direction setter to recompute the projection texture view light Matrix.
  130313. */
  130314. protected _setDirection(value: Vector3): void;
  130315. /**
  130316. * Overrides the position setter to recompute the projection texture view light Matrix.
  130317. */
  130318. protected _setPosition(value: Vector3): void;
  130319. /**
  130320. * 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.
  130321. * Returns the SpotLight.
  130322. */
  130323. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130324. protected _computeProjectionTextureViewLightMatrix(): void;
  130325. protected _computeProjectionTextureProjectionLightMatrix(): void;
  130326. /**
  130327. * Main function for light texture projection matrix computing.
  130328. */
  130329. protected _computeProjectionTextureMatrix(): void;
  130330. protected _buildUniformLayout(): void;
  130331. private _computeAngleValues;
  130332. /**
  130333. * Sets the passed Effect "effect" with the Light textures.
  130334. * @param effect The effect to update
  130335. * @param lightIndex The index of the light in the effect to update
  130336. * @returns The light
  130337. */
  130338. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  130339. /**
  130340. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  130341. * @param effect The effect to update
  130342. * @param lightIndex The index of the light in the effect to update
  130343. * @returns The spot light
  130344. */
  130345. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  130346. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130347. /**
  130348. * Disposes the light and the associated resources.
  130349. */
  130350. dispose(): void;
  130351. /**
  130352. * Prepares the list of defines specific to the light type.
  130353. * @param defines the list of defines
  130354. * @param lightIndex defines the index of the light for the effect
  130355. */
  130356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130357. }
  130358. }
  130359. declare module BABYLON {
  130360. /**
  130361. * Gizmo that enables viewing a light
  130362. */
  130363. export class LightGizmo extends Gizmo {
  130364. private _lightMesh;
  130365. private _material;
  130366. private _cachedPosition;
  130367. private _cachedForward;
  130368. private _attachedMeshParent;
  130369. /**
  130370. * Creates a LightGizmo
  130371. * @param gizmoLayer The utility layer the gizmo will be added to
  130372. */
  130373. constructor(gizmoLayer?: UtilityLayerRenderer);
  130374. private _light;
  130375. /**
  130376. * The light that the gizmo is attached to
  130377. */
  130378. set light(light: Nullable<Light>);
  130379. get light(): Nullable<Light>;
  130380. /**
  130381. * Gets the material used to render the light gizmo
  130382. */
  130383. get material(): StandardMaterial;
  130384. /**
  130385. * @hidden
  130386. * Updates the gizmo to match the attached mesh's position/rotation
  130387. */
  130388. protected _update(): void;
  130389. private static _Scale;
  130390. /**
  130391. * Creates the lines for a light mesh
  130392. */
  130393. private static _CreateLightLines;
  130394. /**
  130395. * Disposes of the light gizmo
  130396. */
  130397. dispose(): void;
  130398. private static _CreateHemisphericLightMesh;
  130399. private static _CreatePointLightMesh;
  130400. private static _CreateSpotLightMesh;
  130401. private static _CreateDirectionalLightMesh;
  130402. }
  130403. }
  130404. declare module BABYLON {
  130405. /** @hidden */
  130406. export var backgroundFragmentDeclaration: {
  130407. name: string;
  130408. shader: string;
  130409. };
  130410. }
  130411. declare module BABYLON {
  130412. /** @hidden */
  130413. export var backgroundUboDeclaration: {
  130414. name: string;
  130415. shader: string;
  130416. };
  130417. }
  130418. declare module BABYLON {
  130419. /** @hidden */
  130420. export var backgroundPixelShader: {
  130421. name: string;
  130422. shader: string;
  130423. };
  130424. }
  130425. declare module BABYLON {
  130426. /** @hidden */
  130427. export var backgroundVertexDeclaration: {
  130428. name: string;
  130429. shader: string;
  130430. };
  130431. }
  130432. declare module BABYLON {
  130433. /** @hidden */
  130434. export var backgroundVertexShader: {
  130435. name: string;
  130436. shader: string;
  130437. };
  130438. }
  130439. declare module BABYLON {
  130440. /**
  130441. * Background material used to create an efficient environement around your scene.
  130442. */
  130443. export class BackgroundMaterial extends PushMaterial {
  130444. /**
  130445. * Standard reflectance value at parallel view angle.
  130446. */
  130447. static StandardReflectance0: number;
  130448. /**
  130449. * Standard reflectance value at grazing angle.
  130450. */
  130451. static StandardReflectance90: number;
  130452. protected _primaryColor: Color3;
  130453. /**
  130454. * Key light Color (multiply against the environement texture)
  130455. */
  130456. primaryColor: Color3;
  130457. protected __perceptualColor: Nullable<Color3>;
  130458. /**
  130459. * Experimental Internal Use Only.
  130460. *
  130461. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  130462. * This acts as a helper to set the primary color to a more "human friendly" value.
  130463. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  130464. * output color as close as possible from the chosen value.
  130465. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  130466. * part of lighting setup.)
  130467. */
  130468. get _perceptualColor(): Nullable<Color3>;
  130469. set _perceptualColor(value: Nullable<Color3>);
  130470. protected _primaryColorShadowLevel: float;
  130471. /**
  130472. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  130473. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  130474. */
  130475. get primaryColorShadowLevel(): float;
  130476. set primaryColorShadowLevel(value: float);
  130477. protected _primaryColorHighlightLevel: float;
  130478. /**
  130479. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  130480. * The primary color is used at the level chosen to define what the white area would look.
  130481. */
  130482. get primaryColorHighlightLevel(): float;
  130483. set primaryColorHighlightLevel(value: float);
  130484. protected _reflectionTexture: Nullable<BaseTexture>;
  130485. /**
  130486. * Reflection Texture used in the material.
  130487. * Should be author in a specific way for the best result (refer to the documentation).
  130488. */
  130489. reflectionTexture: Nullable<BaseTexture>;
  130490. protected _reflectionBlur: float;
  130491. /**
  130492. * Reflection Texture level of blur.
  130493. *
  130494. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  130495. * texture twice.
  130496. */
  130497. reflectionBlur: float;
  130498. protected _diffuseTexture: Nullable<BaseTexture>;
  130499. /**
  130500. * Diffuse Texture used in the material.
  130501. * Should be author in a specific way for the best result (refer to the documentation).
  130502. */
  130503. diffuseTexture: Nullable<BaseTexture>;
  130504. protected _shadowLights: Nullable<IShadowLight[]>;
  130505. /**
  130506. * Specify the list of lights casting shadow on the material.
  130507. * All scene shadow lights will be included if null.
  130508. */
  130509. shadowLights: Nullable<IShadowLight[]>;
  130510. protected _shadowLevel: float;
  130511. /**
  130512. * Helps adjusting the shadow to a softer level if required.
  130513. * 0 means black shadows and 1 means no shadows.
  130514. */
  130515. shadowLevel: float;
  130516. protected _sceneCenter: Vector3;
  130517. /**
  130518. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  130519. * It is usually zero but might be interesting to modify according to your setup.
  130520. */
  130521. sceneCenter: Vector3;
  130522. protected _opacityFresnel: boolean;
  130523. /**
  130524. * This helps specifying that the material is falling off to the sky box at grazing angle.
  130525. * This helps ensuring a nice transition when the camera goes under the ground.
  130526. */
  130527. opacityFresnel: boolean;
  130528. protected _reflectionFresnel: boolean;
  130529. /**
  130530. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  130531. * This helps adding a mirror texture on the ground.
  130532. */
  130533. reflectionFresnel: boolean;
  130534. protected _reflectionFalloffDistance: number;
  130535. /**
  130536. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  130537. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  130538. */
  130539. reflectionFalloffDistance: number;
  130540. protected _reflectionAmount: number;
  130541. /**
  130542. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  130543. */
  130544. reflectionAmount: number;
  130545. protected _reflectionReflectance0: number;
  130546. /**
  130547. * This specifies the weight of the reflection at grazing angle.
  130548. */
  130549. reflectionReflectance0: number;
  130550. protected _reflectionReflectance90: number;
  130551. /**
  130552. * This specifies the weight of the reflection at a perpendicular point of view.
  130553. */
  130554. reflectionReflectance90: number;
  130555. /**
  130556. * Sets the reflection reflectance fresnel values according to the default standard
  130557. * empirically know to work well :-)
  130558. */
  130559. set reflectionStandardFresnelWeight(value: number);
  130560. protected _useRGBColor: boolean;
  130561. /**
  130562. * Helps to directly use the maps channels instead of their level.
  130563. */
  130564. useRGBColor: boolean;
  130565. protected _enableNoise: boolean;
  130566. /**
  130567. * This helps reducing the banding effect that could occur on the background.
  130568. */
  130569. enableNoise: boolean;
  130570. /**
  130571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130572. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130573. * Recommended to be keep at 1.0 except for special cases.
  130574. */
  130575. get fovMultiplier(): number;
  130576. set fovMultiplier(value: number);
  130577. private _fovMultiplier;
  130578. /**
  130579. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130580. */
  130581. useEquirectangularFOV: boolean;
  130582. private _maxSimultaneousLights;
  130583. /**
  130584. * Number of Simultaneous lights allowed on the material.
  130585. */
  130586. maxSimultaneousLights: int;
  130587. /**
  130588. * Default configuration related to image processing available in the Background Material.
  130589. */
  130590. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130591. /**
  130592. * Keep track of the image processing observer to allow dispose and replace.
  130593. */
  130594. private _imageProcessingObserver;
  130595. /**
  130596. * Attaches a new image processing configuration to the PBR Material.
  130597. * @param configuration (if null the scene configuration will be use)
  130598. */
  130599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130600. /**
  130601. * Gets the image processing configuration used either in this material.
  130602. */
  130603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130604. /**
  130605. * Sets the Default image processing configuration used either in the this material.
  130606. *
  130607. * If sets to null, the scene one is in use.
  130608. */
  130609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130610. /**
  130611. * Gets wether the color curves effect is enabled.
  130612. */
  130613. get cameraColorCurvesEnabled(): boolean;
  130614. /**
  130615. * Sets wether the color curves effect is enabled.
  130616. */
  130617. set cameraColorCurvesEnabled(value: boolean);
  130618. /**
  130619. * Gets wether the color grading effect is enabled.
  130620. */
  130621. get cameraColorGradingEnabled(): boolean;
  130622. /**
  130623. * Gets wether the color grading effect is enabled.
  130624. */
  130625. set cameraColorGradingEnabled(value: boolean);
  130626. /**
  130627. * Gets wether tonemapping is enabled or not.
  130628. */
  130629. get cameraToneMappingEnabled(): boolean;
  130630. /**
  130631. * Sets wether tonemapping is enabled or not
  130632. */
  130633. set cameraToneMappingEnabled(value: boolean);
  130634. /**
  130635. * The camera exposure used on this material.
  130636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130637. * This corresponds to a photographic exposure.
  130638. */
  130639. get cameraExposure(): float;
  130640. /**
  130641. * The camera exposure used on this material.
  130642. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130643. * This corresponds to a photographic exposure.
  130644. */
  130645. set cameraExposure(value: float);
  130646. /**
  130647. * Gets The camera contrast used on this material.
  130648. */
  130649. get cameraContrast(): float;
  130650. /**
  130651. * Sets The camera contrast used on this material.
  130652. */
  130653. set cameraContrast(value: float);
  130654. /**
  130655. * Gets the Color Grading 2D Lookup Texture.
  130656. */
  130657. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  130658. /**
  130659. * Sets the Color Grading 2D Lookup Texture.
  130660. */
  130661. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  130662. /**
  130663. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130664. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130665. * 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;
  130666. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130667. */
  130668. get cameraColorCurves(): Nullable<ColorCurves>;
  130669. /**
  130670. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130671. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  130672. * 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;
  130673. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  130674. */
  130675. set cameraColorCurves(value: Nullable<ColorCurves>);
  130676. /**
  130677. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  130678. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  130679. */
  130680. switchToBGR: boolean;
  130681. private _renderTargets;
  130682. private _reflectionControls;
  130683. private _white;
  130684. private _primaryShadowColor;
  130685. private _primaryHighlightColor;
  130686. /**
  130687. * Instantiates a Background Material in the given scene
  130688. * @param name The friendly name of the material
  130689. * @param scene The scene to add the material to
  130690. */
  130691. constructor(name: string, scene: Scene);
  130692. /**
  130693. * Gets a boolean indicating that current material needs to register RTT
  130694. */
  130695. get hasRenderTargetTextures(): boolean;
  130696. /**
  130697. * The entire material has been created in order to prevent overdraw.
  130698. * @returns false
  130699. */
  130700. needAlphaTesting(): boolean;
  130701. /**
  130702. * The entire material has been created in order to prevent overdraw.
  130703. * @returns true if blending is enable
  130704. */
  130705. needAlphaBlending(): boolean;
  130706. /**
  130707. * Checks wether the material is ready to be rendered for a given mesh.
  130708. * @param mesh The mesh to render
  130709. * @param subMesh The submesh to check against
  130710. * @param useInstances Specify wether or not the material is used with instances
  130711. * @returns true if all the dependencies are ready (Textures, Effects...)
  130712. */
  130713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130714. /**
  130715. * Compute the primary color according to the chosen perceptual color.
  130716. */
  130717. private _computePrimaryColorFromPerceptualColor;
  130718. /**
  130719. * Compute the highlights and shadow colors according to their chosen levels.
  130720. */
  130721. private _computePrimaryColors;
  130722. /**
  130723. * Build the uniform buffer used in the material.
  130724. */
  130725. buildUniformLayout(): void;
  130726. /**
  130727. * Unbind the material.
  130728. */
  130729. unbind(): void;
  130730. /**
  130731. * Bind only the world matrix to the material.
  130732. * @param world The world matrix to bind.
  130733. */
  130734. bindOnlyWorldMatrix(world: Matrix): void;
  130735. /**
  130736. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  130737. * @param world The world matrix to bind.
  130738. * @param subMesh The submesh to bind for.
  130739. */
  130740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130741. /**
  130742. * Checks to see if a texture is used in the material.
  130743. * @param texture - Base texture to use.
  130744. * @returns - Boolean specifying if a texture is used in the material.
  130745. */
  130746. hasTexture(texture: BaseTexture): boolean;
  130747. /**
  130748. * Dispose the material.
  130749. * @param forceDisposeEffect Force disposal of the associated effect.
  130750. * @param forceDisposeTextures Force disposal of the associated textures.
  130751. */
  130752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  130753. /**
  130754. * Clones the material.
  130755. * @param name The cloned name.
  130756. * @returns The cloned material.
  130757. */
  130758. clone(name: string): BackgroundMaterial;
  130759. /**
  130760. * Serializes the current material to its JSON representation.
  130761. * @returns The JSON representation.
  130762. */
  130763. serialize(): any;
  130764. /**
  130765. * Gets the class name of the material
  130766. * @returns "BackgroundMaterial"
  130767. */
  130768. getClassName(): string;
  130769. /**
  130770. * Parse a JSON input to create back a background material.
  130771. * @param source The JSON data to parse
  130772. * @param scene The scene to create the parsed material in
  130773. * @param rootUrl The root url of the assets the material depends upon
  130774. * @returns the instantiated BackgroundMaterial.
  130775. */
  130776. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  130777. }
  130778. }
  130779. declare module BABYLON {
  130780. /**
  130781. * Represents the different options available during the creation of
  130782. * a Environment helper.
  130783. *
  130784. * This can control the default ground, skybox and image processing setup of your scene.
  130785. */
  130786. export interface IEnvironmentHelperOptions {
  130787. /**
  130788. * Specifies whether or not to create a ground.
  130789. * True by default.
  130790. */
  130791. createGround: boolean;
  130792. /**
  130793. * Specifies the ground size.
  130794. * 15 by default.
  130795. */
  130796. groundSize: number;
  130797. /**
  130798. * The texture used on the ground for the main color.
  130799. * Comes from the BabylonJS CDN by default.
  130800. *
  130801. * Remarks: Can be either a texture or a url.
  130802. */
  130803. groundTexture: string | BaseTexture;
  130804. /**
  130805. * The color mixed in the ground texture by default.
  130806. * BabylonJS clearColor by default.
  130807. */
  130808. groundColor: Color3;
  130809. /**
  130810. * Specifies the ground opacity.
  130811. * 1 by default.
  130812. */
  130813. groundOpacity: number;
  130814. /**
  130815. * Enables the ground to receive shadows.
  130816. * True by default.
  130817. */
  130818. enableGroundShadow: boolean;
  130819. /**
  130820. * Helps preventing the shadow to be fully black on the ground.
  130821. * 0.5 by default.
  130822. */
  130823. groundShadowLevel: number;
  130824. /**
  130825. * Creates a mirror texture attach to the ground.
  130826. * false by default.
  130827. */
  130828. enableGroundMirror: boolean;
  130829. /**
  130830. * Specifies the ground mirror size ratio.
  130831. * 0.3 by default as the default kernel is 64.
  130832. */
  130833. groundMirrorSizeRatio: number;
  130834. /**
  130835. * Specifies the ground mirror blur kernel size.
  130836. * 64 by default.
  130837. */
  130838. groundMirrorBlurKernel: number;
  130839. /**
  130840. * Specifies the ground mirror visibility amount.
  130841. * 1 by default
  130842. */
  130843. groundMirrorAmount: number;
  130844. /**
  130845. * Specifies the ground mirror reflectance weight.
  130846. * This uses the standard weight of the background material to setup the fresnel effect
  130847. * of the mirror.
  130848. * 1 by default.
  130849. */
  130850. groundMirrorFresnelWeight: number;
  130851. /**
  130852. * Specifies the ground mirror Falloff distance.
  130853. * This can helps reducing the size of the reflection.
  130854. * 0 by Default.
  130855. */
  130856. groundMirrorFallOffDistance: number;
  130857. /**
  130858. * Specifies the ground mirror texture type.
  130859. * Unsigned Int by Default.
  130860. */
  130861. groundMirrorTextureType: number;
  130862. /**
  130863. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  130864. * the shown objects.
  130865. */
  130866. groundYBias: number;
  130867. /**
  130868. * Specifies whether or not to create a skybox.
  130869. * True by default.
  130870. */
  130871. createSkybox: boolean;
  130872. /**
  130873. * Specifies the skybox size.
  130874. * 20 by default.
  130875. */
  130876. skyboxSize: number;
  130877. /**
  130878. * The texture used on the skybox for the main color.
  130879. * Comes from the BabylonJS CDN by default.
  130880. *
  130881. * Remarks: Can be either a texture or a url.
  130882. */
  130883. skyboxTexture: string | BaseTexture;
  130884. /**
  130885. * The color mixed in the skybox texture by default.
  130886. * BabylonJS clearColor by default.
  130887. */
  130888. skyboxColor: Color3;
  130889. /**
  130890. * The background rotation around the Y axis of the scene.
  130891. * This helps aligning the key lights of your scene with the background.
  130892. * 0 by default.
  130893. */
  130894. backgroundYRotation: number;
  130895. /**
  130896. * Compute automatically the size of the elements to best fit with the scene.
  130897. */
  130898. sizeAuto: boolean;
  130899. /**
  130900. * Default position of the rootMesh if autoSize is not true.
  130901. */
  130902. rootPosition: Vector3;
  130903. /**
  130904. * Sets up the image processing in the scene.
  130905. * true by default.
  130906. */
  130907. setupImageProcessing: boolean;
  130908. /**
  130909. * The texture used as your environment texture in the scene.
  130910. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  130911. *
  130912. * Remarks: Can be either a texture or a url.
  130913. */
  130914. environmentTexture: string | BaseTexture;
  130915. /**
  130916. * The value of the exposure to apply to the scene.
  130917. * 0.6 by default if setupImageProcessing is true.
  130918. */
  130919. cameraExposure: number;
  130920. /**
  130921. * The value of the contrast to apply to the scene.
  130922. * 1.6 by default if setupImageProcessing is true.
  130923. */
  130924. cameraContrast: number;
  130925. /**
  130926. * Specifies whether or not tonemapping should be enabled in the scene.
  130927. * true by default if setupImageProcessing is true.
  130928. */
  130929. toneMappingEnabled: boolean;
  130930. }
  130931. /**
  130932. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  130933. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  130934. * It also helps with the default setup of your imageProcessing configuration.
  130935. */
  130936. export class EnvironmentHelper {
  130937. /**
  130938. * Default ground texture URL.
  130939. */
  130940. private static _groundTextureCDNUrl;
  130941. /**
  130942. * Default skybox texture URL.
  130943. */
  130944. private static _skyboxTextureCDNUrl;
  130945. /**
  130946. * Default environment texture URL.
  130947. */
  130948. private static _environmentTextureCDNUrl;
  130949. /**
  130950. * Creates the default options for the helper.
  130951. */
  130952. private static _getDefaultOptions;
  130953. private _rootMesh;
  130954. /**
  130955. * Gets the root mesh created by the helper.
  130956. */
  130957. get rootMesh(): Mesh;
  130958. private _skybox;
  130959. /**
  130960. * Gets the skybox created by the helper.
  130961. */
  130962. get skybox(): Nullable<Mesh>;
  130963. private _skyboxTexture;
  130964. /**
  130965. * Gets the skybox texture created by the helper.
  130966. */
  130967. get skyboxTexture(): Nullable<BaseTexture>;
  130968. private _skyboxMaterial;
  130969. /**
  130970. * Gets the skybox material created by the helper.
  130971. */
  130972. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  130973. private _ground;
  130974. /**
  130975. * Gets the ground mesh created by the helper.
  130976. */
  130977. get ground(): Nullable<Mesh>;
  130978. private _groundTexture;
  130979. /**
  130980. * Gets the ground texture created by the helper.
  130981. */
  130982. get groundTexture(): Nullable<BaseTexture>;
  130983. private _groundMirror;
  130984. /**
  130985. * Gets the ground mirror created by the helper.
  130986. */
  130987. get groundMirror(): Nullable<MirrorTexture>;
  130988. /**
  130989. * Gets the ground mirror render list to helps pushing the meshes
  130990. * you wish in the ground reflection.
  130991. */
  130992. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  130993. private _groundMaterial;
  130994. /**
  130995. * Gets the ground material created by the helper.
  130996. */
  130997. get groundMaterial(): Nullable<BackgroundMaterial>;
  130998. /**
  130999. * Stores the creation options.
  131000. */
  131001. private readonly _scene;
  131002. private _options;
  131003. /**
  131004. * This observable will be notified with any error during the creation of the environment,
  131005. * mainly texture creation errors.
  131006. */
  131007. onErrorObservable: Observable<{
  131008. message?: string;
  131009. exception?: any;
  131010. }>;
  131011. /**
  131012. * constructor
  131013. * @param options Defines the options we want to customize the helper
  131014. * @param scene The scene to add the material to
  131015. */
  131016. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  131017. /**
  131018. * Updates the background according to the new options
  131019. * @param options
  131020. */
  131021. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  131022. /**
  131023. * Sets the primary color of all the available elements.
  131024. * @param color the main color to affect to the ground and the background
  131025. */
  131026. setMainColor(color: Color3): void;
  131027. /**
  131028. * Setup the image processing according to the specified options.
  131029. */
  131030. private _setupImageProcessing;
  131031. /**
  131032. * Setup the environment texture according to the specified options.
  131033. */
  131034. private _setupEnvironmentTexture;
  131035. /**
  131036. * Setup the background according to the specified options.
  131037. */
  131038. private _setupBackground;
  131039. /**
  131040. * Get the scene sizes according to the setup.
  131041. */
  131042. private _getSceneSize;
  131043. /**
  131044. * Setup the ground according to the specified options.
  131045. */
  131046. private _setupGround;
  131047. /**
  131048. * Setup the ground material according to the specified options.
  131049. */
  131050. private _setupGroundMaterial;
  131051. /**
  131052. * Setup the ground diffuse texture according to the specified options.
  131053. */
  131054. private _setupGroundDiffuseTexture;
  131055. /**
  131056. * Setup the ground mirror texture according to the specified options.
  131057. */
  131058. private _setupGroundMirrorTexture;
  131059. /**
  131060. * Setup the ground to receive the mirror texture.
  131061. */
  131062. private _setupMirrorInGroundMaterial;
  131063. /**
  131064. * Setup the skybox according to the specified options.
  131065. */
  131066. private _setupSkybox;
  131067. /**
  131068. * Setup the skybox material according to the specified options.
  131069. */
  131070. private _setupSkyboxMaterial;
  131071. /**
  131072. * Setup the skybox reflection texture according to the specified options.
  131073. */
  131074. private _setupSkyboxReflectionTexture;
  131075. private _errorHandler;
  131076. /**
  131077. * Dispose all the elements created by the Helper.
  131078. */
  131079. dispose(): void;
  131080. }
  131081. }
  131082. declare module BABYLON {
  131083. /**
  131084. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  131085. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  131086. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  131087. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  131088. */
  131089. export class PhotoDome extends TransformNode {
  131090. /**
  131091. * Define the image as a Monoscopic panoramic 360 image.
  131092. */
  131093. static readonly MODE_MONOSCOPIC: number;
  131094. /**
  131095. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131096. */
  131097. static readonly MODE_TOPBOTTOM: number;
  131098. /**
  131099. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131100. */
  131101. static readonly MODE_SIDEBYSIDE: number;
  131102. private _useDirectMapping;
  131103. /**
  131104. * The texture being displayed on the sphere
  131105. */
  131106. protected _photoTexture: Texture;
  131107. /**
  131108. * Gets or sets the texture being displayed on the sphere
  131109. */
  131110. get photoTexture(): Texture;
  131111. set photoTexture(value: Texture);
  131112. /**
  131113. * Observable raised when an error occured while loading the 360 image
  131114. */
  131115. onLoadErrorObservable: Observable<string>;
  131116. /**
  131117. * The skybox material
  131118. */
  131119. protected _material: BackgroundMaterial;
  131120. /**
  131121. * The surface used for the skybox
  131122. */
  131123. protected _mesh: Mesh;
  131124. /**
  131125. * Gets the mesh used for the skybox.
  131126. */
  131127. get mesh(): Mesh;
  131128. /**
  131129. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131130. * Also see the options.resolution property.
  131131. */
  131132. get fovMultiplier(): number;
  131133. set fovMultiplier(value: number);
  131134. private _imageMode;
  131135. /**
  131136. * Gets or set the current video mode for the video. It can be:
  131137. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  131138. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131139. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131140. */
  131141. get imageMode(): number;
  131142. set imageMode(value: number);
  131143. /**
  131144. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  131145. * @param name Element's name, child elements will append suffixes for their own names.
  131146. * @param urlsOfPhoto defines the url of the photo to display
  131147. * @param options defines an object containing optional or exposed sub element properties
  131148. * @param onError defines a callback called when an error occured while loading the texture
  131149. */
  131150. constructor(name: string, urlOfPhoto: string, options: {
  131151. resolution?: number;
  131152. size?: number;
  131153. useDirectMapping?: boolean;
  131154. faceForward?: boolean;
  131155. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  131156. private _onBeforeCameraRenderObserver;
  131157. private _changeImageMode;
  131158. /**
  131159. * Releases resources associated with this node.
  131160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  131161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  131162. */
  131163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  131164. }
  131165. }
  131166. declare module BABYLON {
  131167. /**
  131168. * Class used to host RGBD texture specific utilities
  131169. */
  131170. export class RGBDTextureTools {
  131171. /**
  131172. * Expand the RGBD Texture from RGBD to Half Float if possible.
  131173. * @param texture the texture to expand.
  131174. */
  131175. static ExpandRGBDTexture(texture: Texture): void;
  131176. }
  131177. }
  131178. declare module BABYLON {
  131179. /**
  131180. * Class used to host texture specific utilities
  131181. */
  131182. export class BRDFTextureTools {
  131183. /**
  131184. * Prevents texture cache collision
  131185. */
  131186. private static _instanceNumber;
  131187. /**
  131188. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  131189. * @param scene defines the hosting scene
  131190. * @returns the environment BRDF texture
  131191. */
  131192. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  131193. private static _environmentBRDFBase64Texture;
  131194. }
  131195. }
  131196. declare module BABYLON {
  131197. /**
  131198. * @hidden
  131199. */
  131200. export interface IMaterialClearCoatDefines {
  131201. CLEARCOAT: boolean;
  131202. CLEARCOAT_DEFAULTIOR: boolean;
  131203. CLEARCOAT_TEXTURE: boolean;
  131204. CLEARCOAT_TEXTUREDIRECTUV: number;
  131205. CLEARCOAT_BUMP: boolean;
  131206. CLEARCOAT_BUMPDIRECTUV: number;
  131207. CLEARCOAT_TINT: boolean;
  131208. CLEARCOAT_TINT_TEXTURE: boolean;
  131209. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131210. /** @hidden */
  131211. _areTexturesDirty: boolean;
  131212. }
  131213. /**
  131214. * Define the code related to the clear coat parameters of the pbr material.
  131215. */
  131216. export class PBRClearCoatConfiguration {
  131217. /**
  131218. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131219. * The default fits with a polyurethane material.
  131220. */
  131221. private static readonly _DefaultIndexOfRefraction;
  131222. private _isEnabled;
  131223. /**
  131224. * Defines if the clear coat is enabled in the material.
  131225. */
  131226. isEnabled: boolean;
  131227. /**
  131228. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  131229. */
  131230. intensity: number;
  131231. /**
  131232. * Defines the clear coat layer roughness.
  131233. */
  131234. roughness: number;
  131235. private _indexOfRefraction;
  131236. /**
  131237. * Defines the index of refraction of the clear coat.
  131238. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131239. * The default fits with a polyurethane material.
  131240. * Changing the default value is more performance intensive.
  131241. */
  131242. indexOfRefraction: number;
  131243. private _texture;
  131244. /**
  131245. * Stores the clear coat values in a texture.
  131246. */
  131247. texture: Nullable<BaseTexture>;
  131248. private _bumpTexture;
  131249. /**
  131250. * Define the clear coat specific bump texture.
  131251. */
  131252. bumpTexture: Nullable<BaseTexture>;
  131253. private _isTintEnabled;
  131254. /**
  131255. * Defines if the clear coat tint is enabled in the material.
  131256. */
  131257. isTintEnabled: boolean;
  131258. /**
  131259. * Defines the clear coat tint of the material.
  131260. * This is only use if tint is enabled
  131261. */
  131262. tintColor: Color3;
  131263. /**
  131264. * Defines the distance at which the tint color should be found in the
  131265. * clear coat media.
  131266. * This is only use if tint is enabled
  131267. */
  131268. tintColorAtDistance: number;
  131269. /**
  131270. * Defines the clear coat layer thickness.
  131271. * This is only use if tint is enabled
  131272. */
  131273. tintThickness: number;
  131274. private _tintTexture;
  131275. /**
  131276. * Stores the clear tint values in a texture.
  131277. * rgb is tint
  131278. * a is a thickness factor
  131279. */
  131280. tintTexture: Nullable<BaseTexture>;
  131281. /** @hidden */
  131282. private _internalMarkAllSubMeshesAsTexturesDirty;
  131283. /** @hidden */
  131284. _markAllSubMeshesAsTexturesDirty(): void;
  131285. /**
  131286. * Instantiate a new istance of clear coat configuration.
  131287. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131288. */
  131289. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131290. /**
  131291. * Gets wehter the submesh is ready to be used or not.
  131292. * @param defines the list of "defines" to update.
  131293. * @param scene defines the scene the material belongs to.
  131294. * @param engine defines the engine the material belongs to.
  131295. * @param disableBumpMap defines wether the material disables bump or not.
  131296. * @returns - boolean indicating that the submesh is ready or not.
  131297. */
  131298. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  131299. /**
  131300. * Checks to see if a texture is used in the material.
  131301. * @param defines the list of "defines" to update.
  131302. * @param scene defines the scene to the material belongs to.
  131303. */
  131304. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  131305. /**
  131306. * Binds the material data.
  131307. * @param uniformBuffer defines the Uniform buffer to fill in.
  131308. * @param scene defines the scene the material belongs to.
  131309. * @param engine defines the engine the material belongs to.
  131310. * @param disableBumpMap defines wether the material disables bump or not.
  131311. * @param isFrozen defines wether the material is frozen or not.
  131312. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131313. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131314. */
  131315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  131316. /**
  131317. * Checks to see if a texture is used in the material.
  131318. * @param texture - Base texture to use.
  131319. * @returns - Boolean specifying if a texture is used in the material.
  131320. */
  131321. hasTexture(texture: BaseTexture): boolean;
  131322. /**
  131323. * Returns an array of the actively used textures.
  131324. * @param activeTextures Array of BaseTextures
  131325. */
  131326. getActiveTextures(activeTextures: BaseTexture[]): void;
  131327. /**
  131328. * Returns the animatable textures.
  131329. * @param animatables Array of animatable textures.
  131330. */
  131331. getAnimatables(animatables: IAnimatable[]): void;
  131332. /**
  131333. * Disposes the resources of the material.
  131334. * @param forceDisposeTextures - Forces the disposal of all textures.
  131335. */
  131336. dispose(forceDisposeTextures?: boolean): void;
  131337. /**
  131338. * Get the current class name of the texture useful for serialization or dynamic coding.
  131339. * @returns "PBRClearCoatConfiguration"
  131340. */
  131341. getClassName(): string;
  131342. /**
  131343. * Add fallbacks to the effect fallbacks list.
  131344. * @param defines defines the Base texture to use.
  131345. * @param fallbacks defines the current fallback list.
  131346. * @param currentRank defines the current fallback rank.
  131347. * @returns the new fallback rank.
  131348. */
  131349. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131350. /**
  131351. * Add the required uniforms to the current list.
  131352. * @param uniforms defines the current uniform list.
  131353. */
  131354. static AddUniforms(uniforms: string[]): void;
  131355. /**
  131356. * Add the required samplers to the current list.
  131357. * @param samplers defines the current sampler list.
  131358. */
  131359. static AddSamplers(samplers: string[]): void;
  131360. /**
  131361. * Add the required uniforms to the current buffer.
  131362. * @param uniformBuffer defines the current uniform buffer.
  131363. */
  131364. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131365. /**
  131366. * Makes a duplicate of the current configuration into another one.
  131367. * @param clearCoatConfiguration define the config where to copy the info
  131368. */
  131369. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  131370. /**
  131371. * Serializes this clear coat configuration.
  131372. * @returns - An object with the serialized config.
  131373. */
  131374. serialize(): any;
  131375. /**
  131376. * Parses a anisotropy Configuration from a serialized object.
  131377. * @param source - Serialized object.
  131378. * @param scene Defines the scene we are parsing for
  131379. * @param rootUrl Defines the rootUrl to load from
  131380. */
  131381. parse(source: any, scene: Scene, rootUrl: string): void;
  131382. }
  131383. }
  131384. declare module BABYLON {
  131385. /**
  131386. * @hidden
  131387. */
  131388. export interface IMaterialAnisotropicDefines {
  131389. ANISOTROPIC: boolean;
  131390. ANISOTROPIC_TEXTURE: boolean;
  131391. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131392. MAINUV1: boolean;
  131393. _areTexturesDirty: boolean;
  131394. _needUVs: boolean;
  131395. }
  131396. /**
  131397. * Define the code related to the anisotropic parameters of the pbr material.
  131398. */
  131399. export class PBRAnisotropicConfiguration {
  131400. private _isEnabled;
  131401. /**
  131402. * Defines if the anisotropy is enabled in the material.
  131403. */
  131404. isEnabled: boolean;
  131405. /**
  131406. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  131407. */
  131408. intensity: number;
  131409. /**
  131410. * Defines if the effect is along the tangents, bitangents or in between.
  131411. * By default, the effect is "strectching" the highlights along the tangents.
  131412. */
  131413. direction: Vector2;
  131414. private _texture;
  131415. /**
  131416. * Stores the anisotropy values in a texture.
  131417. * rg is direction (like normal from -1 to 1)
  131418. * b is a intensity
  131419. */
  131420. texture: Nullable<BaseTexture>;
  131421. /** @hidden */
  131422. private _internalMarkAllSubMeshesAsTexturesDirty;
  131423. /** @hidden */
  131424. _markAllSubMeshesAsTexturesDirty(): void;
  131425. /**
  131426. * Instantiate a new istance of anisotropy configuration.
  131427. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131428. */
  131429. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131430. /**
  131431. * Specifies that the submesh is ready to be used.
  131432. * @param defines the list of "defines" to update.
  131433. * @param scene defines the scene the material belongs to.
  131434. * @returns - boolean indicating that the submesh is ready or not.
  131435. */
  131436. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  131437. /**
  131438. * Checks to see if a texture is used in the material.
  131439. * @param defines the list of "defines" to update.
  131440. * @param mesh the mesh we are preparing the defines for.
  131441. * @param scene defines the scene the material belongs to.
  131442. */
  131443. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  131444. /**
  131445. * Binds the material data.
  131446. * @param uniformBuffer defines the Uniform buffer to fill in.
  131447. * @param scene defines the scene the material belongs to.
  131448. * @param isFrozen defines wether the material is frozen or not.
  131449. */
  131450. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131451. /**
  131452. * Checks to see if a texture is used in the material.
  131453. * @param texture - Base texture to use.
  131454. * @returns - Boolean specifying if a texture is used in the material.
  131455. */
  131456. hasTexture(texture: BaseTexture): boolean;
  131457. /**
  131458. * Returns an array of the actively used textures.
  131459. * @param activeTextures Array of BaseTextures
  131460. */
  131461. getActiveTextures(activeTextures: BaseTexture[]): void;
  131462. /**
  131463. * Returns the animatable textures.
  131464. * @param animatables Array of animatable textures.
  131465. */
  131466. getAnimatables(animatables: IAnimatable[]): void;
  131467. /**
  131468. * Disposes the resources of the material.
  131469. * @param forceDisposeTextures - Forces the disposal of all textures.
  131470. */
  131471. dispose(forceDisposeTextures?: boolean): void;
  131472. /**
  131473. * Get the current class name of the texture useful for serialization or dynamic coding.
  131474. * @returns "PBRAnisotropicConfiguration"
  131475. */
  131476. getClassName(): string;
  131477. /**
  131478. * Add fallbacks to the effect fallbacks list.
  131479. * @param defines defines the Base texture to use.
  131480. * @param fallbacks defines the current fallback list.
  131481. * @param currentRank defines the current fallback rank.
  131482. * @returns the new fallback rank.
  131483. */
  131484. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131485. /**
  131486. * Add the required uniforms to the current list.
  131487. * @param uniforms defines the current uniform list.
  131488. */
  131489. static AddUniforms(uniforms: string[]): void;
  131490. /**
  131491. * Add the required uniforms to the current buffer.
  131492. * @param uniformBuffer defines the current uniform buffer.
  131493. */
  131494. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131495. /**
  131496. * Add the required samplers to the current list.
  131497. * @param samplers defines the current sampler list.
  131498. */
  131499. static AddSamplers(samplers: string[]): void;
  131500. /**
  131501. * Makes a duplicate of the current configuration into another one.
  131502. * @param anisotropicConfiguration define the config where to copy the info
  131503. */
  131504. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  131505. /**
  131506. * Serializes this anisotropy configuration.
  131507. * @returns - An object with the serialized config.
  131508. */
  131509. serialize(): any;
  131510. /**
  131511. * Parses a anisotropy Configuration from a serialized object.
  131512. * @param source - Serialized object.
  131513. * @param scene Defines the scene we are parsing for
  131514. * @param rootUrl Defines the rootUrl to load from
  131515. */
  131516. parse(source: any, scene: Scene, rootUrl: string): void;
  131517. }
  131518. }
  131519. declare module BABYLON {
  131520. /**
  131521. * @hidden
  131522. */
  131523. export interface IMaterialBRDFDefines {
  131524. BRDF_V_HEIGHT_CORRELATED: boolean;
  131525. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131526. SPHERICAL_HARMONICS: boolean;
  131527. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131528. /** @hidden */
  131529. _areMiscDirty: boolean;
  131530. }
  131531. /**
  131532. * Define the code related to the BRDF parameters of the pbr material.
  131533. */
  131534. export class PBRBRDFConfiguration {
  131535. /**
  131536. * Default value used for the energy conservation.
  131537. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131538. */
  131539. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  131540. /**
  131541. * Default value used for the Smith Visibility Height Correlated mode.
  131542. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131543. */
  131544. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  131545. /**
  131546. * Default value used for the IBL diffuse part.
  131547. * This can help switching back to the polynomials mode globally which is a tiny bit
  131548. * less GPU intensive at the drawback of a lower quality.
  131549. */
  131550. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  131551. /**
  131552. * Default value used for activating energy conservation for the specular workflow.
  131553. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131554. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131555. */
  131556. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  131557. private _useEnergyConservation;
  131558. /**
  131559. * Defines if the material uses energy conservation.
  131560. */
  131561. useEnergyConservation: boolean;
  131562. private _useSmithVisibilityHeightCorrelated;
  131563. /**
  131564. * LEGACY Mode set to false
  131565. * Defines if the material uses height smith correlated visibility term.
  131566. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  131567. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  131568. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131569. * Not relying on height correlated will also disable energy conservation.
  131570. */
  131571. useSmithVisibilityHeightCorrelated: boolean;
  131572. private _useSphericalHarmonics;
  131573. /**
  131574. * LEGACY Mode set to false
  131575. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131576. * diffuse part of the IBL.
  131577. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131578. * to the ground truth.
  131579. */
  131580. useSphericalHarmonics: boolean;
  131581. private _useSpecularGlossinessInputEnergyConservation;
  131582. /**
  131583. * Defines if the material uses energy conservation, when the specular workflow is active.
  131584. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131585. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131586. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131587. */
  131588. useSpecularGlossinessInputEnergyConservation: boolean;
  131589. /** @hidden */
  131590. private _internalMarkAllSubMeshesAsMiscDirty;
  131591. /** @hidden */
  131592. _markAllSubMeshesAsMiscDirty(): void;
  131593. /**
  131594. * Instantiate a new istance of clear coat configuration.
  131595. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131596. */
  131597. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131598. /**
  131599. * Checks to see if a texture is used in the material.
  131600. * @param defines the list of "defines" to update.
  131601. */
  131602. prepareDefines(defines: IMaterialBRDFDefines): void;
  131603. /**
  131604. * Get the current class name of the texture useful for serialization or dynamic coding.
  131605. * @returns "PBRClearCoatConfiguration"
  131606. */
  131607. getClassName(): string;
  131608. /**
  131609. * Makes a duplicate of the current configuration into another one.
  131610. * @param brdfConfiguration define the config where to copy the info
  131611. */
  131612. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131613. /**
  131614. * Serializes this BRDF configuration.
  131615. * @returns - An object with the serialized config.
  131616. */
  131617. serialize(): any;
  131618. /**
  131619. * Parses a anisotropy Configuration from a serialized object.
  131620. * @param source - Serialized object.
  131621. * @param scene Defines the scene we are parsing for
  131622. * @param rootUrl Defines the rootUrl to load from
  131623. */
  131624. parse(source: any, scene: Scene, rootUrl: string): void;
  131625. }
  131626. }
  131627. declare module BABYLON {
  131628. /**
  131629. * @hidden
  131630. */
  131631. export interface IMaterialSheenDefines {
  131632. SHEEN: boolean;
  131633. SHEEN_TEXTURE: boolean;
  131634. SHEEN_TEXTUREDIRECTUV: number;
  131635. SHEEN_LINKWITHALBEDO: boolean;
  131636. SHEEN_ROUGHNESS: boolean;
  131637. SHEEN_ALBEDOSCALING: boolean;
  131638. /** @hidden */
  131639. _areTexturesDirty: boolean;
  131640. }
  131641. /**
  131642. * Define the code related to the Sheen parameters of the pbr material.
  131643. */
  131644. export class PBRSheenConfiguration {
  131645. private _isEnabled;
  131646. /**
  131647. * Defines if the material uses sheen.
  131648. */
  131649. isEnabled: boolean;
  131650. private _linkSheenWithAlbedo;
  131651. /**
  131652. * Defines if the sheen is linked to the sheen color.
  131653. */
  131654. linkSheenWithAlbedo: boolean;
  131655. /**
  131656. * Defines the sheen intensity.
  131657. */
  131658. intensity: number;
  131659. /**
  131660. * Defines the sheen color.
  131661. */
  131662. color: Color3;
  131663. private _texture;
  131664. /**
  131665. * Stores the sheen tint values in a texture.
  131666. * rgb is tint
  131667. * a is a intensity
  131668. */
  131669. texture: Nullable<BaseTexture>;
  131670. private _roughness;
  131671. /**
  131672. * Defines the sheen roughness.
  131673. * It is not taken into account if linkSheenWithAlbedo is true.
  131674. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  131675. */
  131676. roughness: Nullable<number>;
  131677. private _albedoScaling;
  131678. /**
  131679. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  131680. * It allows the strength of the sheen effect to not depend on the base color of the material,
  131681. * making it easier to setup and tweak the effect
  131682. */
  131683. albedoScaling: boolean;
  131684. /** @hidden */
  131685. private _internalMarkAllSubMeshesAsTexturesDirty;
  131686. /** @hidden */
  131687. _markAllSubMeshesAsTexturesDirty(): void;
  131688. /**
  131689. * Instantiate a new istance of clear coat configuration.
  131690. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131691. */
  131692. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131693. /**
  131694. * Specifies that the submesh is ready to be used.
  131695. * @param defines the list of "defines" to update.
  131696. * @param scene defines the scene the material belongs to.
  131697. * @returns - boolean indicating that the submesh is ready or not.
  131698. */
  131699. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  131700. /**
  131701. * Checks to see if a texture is used in the material.
  131702. * @param defines the list of "defines" to update.
  131703. * @param scene defines the scene the material belongs to.
  131704. */
  131705. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  131706. /**
  131707. * Binds the material data.
  131708. * @param uniformBuffer defines the Uniform buffer to fill in.
  131709. * @param scene defines the scene the material belongs to.
  131710. * @param isFrozen defines wether the material is frozen or not.
  131711. */
  131712. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131713. /**
  131714. * Checks to see if a texture is used in the material.
  131715. * @param texture - Base texture to use.
  131716. * @returns - Boolean specifying if a texture is used in the material.
  131717. */
  131718. hasTexture(texture: BaseTexture): boolean;
  131719. /**
  131720. * Returns an array of the actively used textures.
  131721. * @param activeTextures Array of BaseTextures
  131722. */
  131723. getActiveTextures(activeTextures: BaseTexture[]): void;
  131724. /**
  131725. * Returns the animatable textures.
  131726. * @param animatables Array of animatable textures.
  131727. */
  131728. getAnimatables(animatables: IAnimatable[]): void;
  131729. /**
  131730. * Disposes the resources of the material.
  131731. * @param forceDisposeTextures - Forces the disposal of all textures.
  131732. */
  131733. dispose(forceDisposeTextures?: boolean): void;
  131734. /**
  131735. * Get the current class name of the texture useful for serialization or dynamic coding.
  131736. * @returns "PBRSheenConfiguration"
  131737. */
  131738. getClassName(): string;
  131739. /**
  131740. * Add fallbacks to the effect fallbacks list.
  131741. * @param defines defines the Base texture to use.
  131742. * @param fallbacks defines the current fallback list.
  131743. * @param currentRank defines the current fallback rank.
  131744. * @returns the new fallback rank.
  131745. */
  131746. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131747. /**
  131748. * Add the required uniforms to the current list.
  131749. * @param uniforms defines the current uniform list.
  131750. */
  131751. static AddUniforms(uniforms: string[]): void;
  131752. /**
  131753. * Add the required uniforms to the current buffer.
  131754. * @param uniformBuffer defines the current uniform buffer.
  131755. */
  131756. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131757. /**
  131758. * Add the required samplers to the current list.
  131759. * @param samplers defines the current sampler list.
  131760. */
  131761. static AddSamplers(samplers: string[]): void;
  131762. /**
  131763. * Makes a duplicate of the current configuration into another one.
  131764. * @param sheenConfiguration define the config where to copy the info
  131765. */
  131766. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  131767. /**
  131768. * Serializes this BRDF configuration.
  131769. * @returns - An object with the serialized config.
  131770. */
  131771. serialize(): any;
  131772. /**
  131773. * Parses a anisotropy Configuration from a serialized object.
  131774. * @param source - Serialized object.
  131775. * @param scene Defines the scene we are parsing for
  131776. * @param rootUrl Defines the rootUrl to load from
  131777. */
  131778. parse(source: any, scene: Scene, rootUrl: string): void;
  131779. }
  131780. }
  131781. declare module BABYLON {
  131782. /**
  131783. * @hidden
  131784. */
  131785. export interface IMaterialSubSurfaceDefines {
  131786. SUBSURFACE: boolean;
  131787. SS_REFRACTION: boolean;
  131788. SS_TRANSLUCENCY: boolean;
  131789. SS_SCATTERING: boolean;
  131790. SS_THICKNESSANDMASK_TEXTURE: boolean;
  131791. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  131792. SS_REFRACTIONMAP_3D: boolean;
  131793. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  131794. SS_LODINREFRACTIONALPHA: boolean;
  131795. SS_GAMMAREFRACTION: boolean;
  131796. SS_RGBDREFRACTION: boolean;
  131797. SS_LINEARSPECULARREFRACTION: boolean;
  131798. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  131799. SS_ALBEDOFORREFRACTIONTINT: boolean;
  131800. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  131801. /** @hidden */
  131802. _areTexturesDirty: boolean;
  131803. }
  131804. /**
  131805. * Define the code related to the sub surface parameters of the pbr material.
  131806. */
  131807. export class PBRSubSurfaceConfiguration {
  131808. private _isRefractionEnabled;
  131809. /**
  131810. * Defines if the refraction is enabled in the material.
  131811. */
  131812. isRefractionEnabled: boolean;
  131813. private _isTranslucencyEnabled;
  131814. /**
  131815. * Defines if the translucency is enabled in the material.
  131816. */
  131817. isTranslucencyEnabled: boolean;
  131818. private _isScatteringEnabled;
  131819. /**
  131820. * Defines the refraction intensity of the material.
  131821. * The refraction when enabled replaces the Diffuse part of the material.
  131822. * The intensity helps transitionning between diffuse and refraction.
  131823. */
  131824. refractionIntensity: number;
  131825. /**
  131826. * Defines the translucency intensity of the material.
  131827. * When translucency has been enabled, this defines how much of the "translucency"
  131828. * is addded to the diffuse part of the material.
  131829. */
  131830. translucencyIntensity: number;
  131831. /**
  131832. * Defines the scattering intensity of the material.
  131833. * When scattering has been enabled, this defines how much of the "scattered light"
  131834. * is addded to the diffuse part of the material.
  131835. */
  131836. scatteringIntensity: number;
  131837. /**
  131838. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  131839. */
  131840. useAlbedoToTintRefraction: boolean;
  131841. private _thicknessTexture;
  131842. /**
  131843. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  131844. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  131845. * 0 would mean minimumThickness
  131846. * 1 would mean maximumThickness
  131847. * The other channels might be use as a mask to vary the different effects intensity.
  131848. */
  131849. thicknessTexture: Nullable<BaseTexture>;
  131850. private _refractionTexture;
  131851. /**
  131852. * Defines the texture to use for refraction.
  131853. */
  131854. refractionTexture: Nullable<BaseTexture>;
  131855. private _indexOfRefraction;
  131856. /**
  131857. * Index of refraction of the material base layer.
  131858. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131859. *
  131860. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  131861. *
  131862. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  131863. */
  131864. indexOfRefraction: number;
  131865. private _volumeIndexOfRefraction;
  131866. /**
  131867. * Index of refraction of the material's volume.
  131868. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  131869. *
  131870. * This ONLY impacts refraction. If not provided or given a non-valid value,
  131871. * the volume will use the same IOR as the surface.
  131872. */
  131873. get volumeIndexOfRefraction(): number;
  131874. set volumeIndexOfRefraction(value: number);
  131875. private _invertRefractionY;
  131876. /**
  131877. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  131878. */
  131879. invertRefractionY: boolean;
  131880. private _linkRefractionWithTransparency;
  131881. /**
  131882. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  131883. * Materials half opaque for instance using refraction could benefit from this control.
  131884. */
  131885. linkRefractionWithTransparency: boolean;
  131886. /**
  131887. * Defines the minimum thickness stored in the thickness map.
  131888. * If no thickness map is defined, this value will be used to simulate thickness.
  131889. */
  131890. minimumThickness: number;
  131891. /**
  131892. * Defines the maximum thickness stored in the thickness map.
  131893. */
  131894. maximumThickness: number;
  131895. /**
  131896. * Defines the volume tint of the material.
  131897. * This is used for both translucency and scattering.
  131898. */
  131899. tintColor: Color3;
  131900. /**
  131901. * Defines the distance at which the tint color should be found in the media.
  131902. * This is used for refraction only.
  131903. */
  131904. tintColorAtDistance: number;
  131905. /**
  131906. * Defines how far each channel transmit through the media.
  131907. * It is defined as a color to simplify it selection.
  131908. */
  131909. diffusionDistance: Color3;
  131910. private _useMaskFromThicknessTexture;
  131911. /**
  131912. * Stores the intensity of the different subsurface effects in the thickness texture.
  131913. * * the green channel is the translucency intensity.
  131914. * * the blue channel is the scattering intensity.
  131915. * * the alpha channel is the refraction intensity.
  131916. */
  131917. useMaskFromThicknessTexture: boolean;
  131918. /** @hidden */
  131919. private _internalMarkAllSubMeshesAsTexturesDirty;
  131920. /** @hidden */
  131921. _markAllSubMeshesAsTexturesDirty(): void;
  131922. /**
  131923. * Instantiate a new istance of sub surface configuration.
  131924. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131925. */
  131926. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131927. /**
  131928. * Gets wehter the submesh is ready to be used or not.
  131929. * @param defines the list of "defines" to update.
  131930. * @param scene defines the scene the material belongs to.
  131931. * @returns - boolean indicating that the submesh is ready or not.
  131932. */
  131933. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  131934. /**
  131935. * Checks to see if a texture is used in the material.
  131936. * @param defines the list of "defines" to update.
  131937. * @param scene defines the scene to the material belongs to.
  131938. */
  131939. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  131940. /**
  131941. * Binds the material data.
  131942. * @param uniformBuffer defines the Uniform buffer to fill in.
  131943. * @param scene defines the scene the material belongs to.
  131944. * @param engine defines the engine the material belongs to.
  131945. * @param isFrozen defines whether the material is frozen or not.
  131946. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  131947. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  131948. */
  131949. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  131950. /**
  131951. * Unbinds the material from the mesh.
  131952. * @param activeEffect defines the effect that should be unbound from.
  131953. * @returns true if unbound, otherwise false
  131954. */
  131955. unbind(activeEffect: Effect): boolean;
  131956. /**
  131957. * Returns the texture used for refraction or null if none is used.
  131958. * @param scene defines the scene the material belongs to.
  131959. * @returns - Refraction texture if present. If no refraction texture and refraction
  131960. * is linked with transparency, returns environment texture. Otherwise, returns null.
  131961. */
  131962. private _getRefractionTexture;
  131963. /**
  131964. * Returns true if alpha blending should be disabled.
  131965. */
  131966. get disableAlphaBlending(): boolean;
  131967. /**
  131968. * Fills the list of render target textures.
  131969. * @param renderTargets the list of render targets to update
  131970. */
  131971. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  131972. /**
  131973. * Checks to see if a texture is used in the material.
  131974. * @param texture - Base texture to use.
  131975. * @returns - Boolean specifying if a texture is used in the material.
  131976. */
  131977. hasTexture(texture: BaseTexture): boolean;
  131978. /**
  131979. * Gets a boolean indicating that current material needs to register RTT
  131980. * @returns true if this uses a render target otherwise false.
  131981. */
  131982. hasRenderTargetTextures(): boolean;
  131983. /**
  131984. * Returns an array of the actively used textures.
  131985. * @param activeTextures Array of BaseTextures
  131986. */
  131987. getActiveTextures(activeTextures: BaseTexture[]): void;
  131988. /**
  131989. * Returns the animatable textures.
  131990. * @param animatables Array of animatable textures.
  131991. */
  131992. getAnimatables(animatables: IAnimatable[]): void;
  131993. /**
  131994. * Disposes the resources of the material.
  131995. * @param forceDisposeTextures - Forces the disposal of all textures.
  131996. */
  131997. dispose(forceDisposeTextures?: boolean): void;
  131998. /**
  131999. * Get the current class name of the texture useful for serialization or dynamic coding.
  132000. * @returns "PBRSubSurfaceConfiguration"
  132001. */
  132002. getClassName(): string;
  132003. /**
  132004. * Add fallbacks to the effect fallbacks list.
  132005. * @param defines defines the Base texture to use.
  132006. * @param fallbacks defines the current fallback list.
  132007. * @param currentRank defines the current fallback rank.
  132008. * @returns the new fallback rank.
  132009. */
  132010. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132011. /**
  132012. * Add the required uniforms to the current list.
  132013. * @param uniforms defines the current uniform list.
  132014. */
  132015. static AddUniforms(uniforms: string[]): void;
  132016. /**
  132017. * Add the required samplers to the current list.
  132018. * @param samplers defines the current sampler list.
  132019. */
  132020. static AddSamplers(samplers: string[]): void;
  132021. /**
  132022. * Add the required uniforms to the current buffer.
  132023. * @param uniformBuffer defines the current uniform buffer.
  132024. */
  132025. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132026. /**
  132027. * Makes a duplicate of the current configuration into another one.
  132028. * @param configuration define the config where to copy the info
  132029. */
  132030. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  132031. /**
  132032. * Serializes this Sub Surface configuration.
  132033. * @returns - An object with the serialized config.
  132034. */
  132035. serialize(): any;
  132036. /**
  132037. * Parses a anisotropy Configuration from a serialized object.
  132038. * @param source - Serialized object.
  132039. * @param scene Defines the scene we are parsing for
  132040. * @param rootUrl Defines the rootUrl to load from
  132041. */
  132042. parse(source: any, scene: Scene, rootUrl: string): void;
  132043. }
  132044. }
  132045. declare module BABYLON {
  132046. /** @hidden */
  132047. export var pbrFragmentDeclaration: {
  132048. name: string;
  132049. shader: string;
  132050. };
  132051. }
  132052. declare module BABYLON {
  132053. /** @hidden */
  132054. export var pbrUboDeclaration: {
  132055. name: string;
  132056. shader: string;
  132057. };
  132058. }
  132059. declare module BABYLON {
  132060. /** @hidden */
  132061. export var pbrFragmentExtraDeclaration: {
  132062. name: string;
  132063. shader: string;
  132064. };
  132065. }
  132066. declare module BABYLON {
  132067. /** @hidden */
  132068. export var pbrFragmentSamplersDeclaration: {
  132069. name: string;
  132070. shader: string;
  132071. };
  132072. }
  132073. declare module BABYLON {
  132074. /** @hidden */
  132075. export var importanceSampling: {
  132076. name: string;
  132077. shader: string;
  132078. };
  132079. }
  132080. declare module BABYLON {
  132081. /** @hidden */
  132082. export var pbrHelperFunctions: {
  132083. name: string;
  132084. shader: string;
  132085. };
  132086. }
  132087. declare module BABYLON {
  132088. /** @hidden */
  132089. export var harmonicsFunctions: {
  132090. name: string;
  132091. shader: string;
  132092. };
  132093. }
  132094. declare module BABYLON {
  132095. /** @hidden */
  132096. export var pbrDirectLightingSetupFunctions: {
  132097. name: string;
  132098. shader: string;
  132099. };
  132100. }
  132101. declare module BABYLON {
  132102. /** @hidden */
  132103. export var pbrDirectLightingFalloffFunctions: {
  132104. name: string;
  132105. shader: string;
  132106. };
  132107. }
  132108. declare module BABYLON {
  132109. /** @hidden */
  132110. export var pbrBRDFFunctions: {
  132111. name: string;
  132112. shader: string;
  132113. };
  132114. }
  132115. declare module BABYLON {
  132116. /** @hidden */
  132117. export var hdrFilteringFunctions: {
  132118. name: string;
  132119. shader: string;
  132120. };
  132121. }
  132122. declare module BABYLON {
  132123. /** @hidden */
  132124. export var pbrDirectLightingFunctions: {
  132125. name: string;
  132126. shader: string;
  132127. };
  132128. }
  132129. declare module BABYLON {
  132130. /** @hidden */
  132131. export var pbrIBLFunctions: {
  132132. name: string;
  132133. shader: string;
  132134. };
  132135. }
  132136. declare module BABYLON {
  132137. /** @hidden */
  132138. export var pbrBlockAlbedoOpacity: {
  132139. name: string;
  132140. shader: string;
  132141. };
  132142. }
  132143. declare module BABYLON {
  132144. /** @hidden */
  132145. export var pbrBlockReflectivity: {
  132146. name: string;
  132147. shader: string;
  132148. };
  132149. }
  132150. declare module BABYLON {
  132151. /** @hidden */
  132152. export var pbrBlockAmbientOcclusion: {
  132153. name: string;
  132154. shader: string;
  132155. };
  132156. }
  132157. declare module BABYLON {
  132158. /** @hidden */
  132159. export var pbrBlockAlphaFresnel: {
  132160. name: string;
  132161. shader: string;
  132162. };
  132163. }
  132164. declare module BABYLON {
  132165. /** @hidden */
  132166. export var pbrBlockAnisotropic: {
  132167. name: string;
  132168. shader: string;
  132169. };
  132170. }
  132171. declare module BABYLON {
  132172. /** @hidden */
  132173. export var pbrBlockReflection: {
  132174. name: string;
  132175. shader: string;
  132176. };
  132177. }
  132178. declare module BABYLON {
  132179. /** @hidden */
  132180. export var pbrBlockSheen: {
  132181. name: string;
  132182. shader: string;
  132183. };
  132184. }
  132185. declare module BABYLON {
  132186. /** @hidden */
  132187. export var pbrBlockClearcoat: {
  132188. name: string;
  132189. shader: string;
  132190. };
  132191. }
  132192. declare module BABYLON {
  132193. /** @hidden */
  132194. export var pbrBlockSubSurface: {
  132195. name: string;
  132196. shader: string;
  132197. };
  132198. }
  132199. declare module BABYLON {
  132200. /** @hidden */
  132201. export var pbrBlockNormalGeometric: {
  132202. name: string;
  132203. shader: string;
  132204. };
  132205. }
  132206. declare module BABYLON {
  132207. /** @hidden */
  132208. export var pbrBlockNormalFinal: {
  132209. name: string;
  132210. shader: string;
  132211. };
  132212. }
  132213. declare module BABYLON {
  132214. /** @hidden */
  132215. export var pbrBlockGeometryInfo: {
  132216. name: string;
  132217. shader: string;
  132218. };
  132219. }
  132220. declare module BABYLON {
  132221. /** @hidden */
  132222. export var pbrBlockReflectance0: {
  132223. name: string;
  132224. shader: string;
  132225. };
  132226. }
  132227. declare module BABYLON {
  132228. /** @hidden */
  132229. export var pbrBlockReflectance: {
  132230. name: string;
  132231. shader: string;
  132232. };
  132233. }
  132234. declare module BABYLON {
  132235. /** @hidden */
  132236. export var pbrBlockDirectLighting: {
  132237. name: string;
  132238. shader: string;
  132239. };
  132240. }
  132241. declare module BABYLON {
  132242. /** @hidden */
  132243. export var pbrBlockFinalLitComponents: {
  132244. name: string;
  132245. shader: string;
  132246. };
  132247. }
  132248. declare module BABYLON {
  132249. /** @hidden */
  132250. export var pbrBlockFinalUnlitComponents: {
  132251. name: string;
  132252. shader: string;
  132253. };
  132254. }
  132255. declare module BABYLON {
  132256. /** @hidden */
  132257. export var pbrBlockFinalColorComposition: {
  132258. name: string;
  132259. shader: string;
  132260. };
  132261. }
  132262. declare module BABYLON {
  132263. /** @hidden */
  132264. export var pbrBlockImageProcessing: {
  132265. name: string;
  132266. shader: string;
  132267. };
  132268. }
  132269. declare module BABYLON {
  132270. /** @hidden */
  132271. export var pbrDebug: {
  132272. name: string;
  132273. shader: string;
  132274. };
  132275. }
  132276. declare module BABYLON {
  132277. /** @hidden */
  132278. export var pbrPixelShader: {
  132279. name: string;
  132280. shader: string;
  132281. };
  132282. }
  132283. declare module BABYLON {
  132284. /** @hidden */
  132285. export var pbrVertexDeclaration: {
  132286. name: string;
  132287. shader: string;
  132288. };
  132289. }
  132290. declare module BABYLON {
  132291. /** @hidden */
  132292. export var pbrVertexShader: {
  132293. name: string;
  132294. shader: string;
  132295. };
  132296. }
  132297. declare module BABYLON {
  132298. /**
  132299. * Manages the defines for the PBR Material.
  132300. * @hidden
  132301. */
  132302. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  132303. PBR: boolean;
  132304. NUM_SAMPLES: string;
  132305. REALTIME_FILTERING: boolean;
  132306. MAINUV1: boolean;
  132307. MAINUV2: boolean;
  132308. UV1: boolean;
  132309. UV2: boolean;
  132310. ALBEDO: boolean;
  132311. GAMMAALBEDO: boolean;
  132312. ALBEDODIRECTUV: number;
  132313. VERTEXCOLOR: boolean;
  132314. AMBIENT: boolean;
  132315. AMBIENTDIRECTUV: number;
  132316. AMBIENTINGRAYSCALE: boolean;
  132317. OPACITY: boolean;
  132318. VERTEXALPHA: boolean;
  132319. OPACITYDIRECTUV: number;
  132320. OPACITYRGB: boolean;
  132321. ALPHATEST: boolean;
  132322. DEPTHPREPASS: boolean;
  132323. ALPHABLEND: boolean;
  132324. ALPHAFROMALBEDO: boolean;
  132325. ALPHATESTVALUE: string;
  132326. SPECULAROVERALPHA: boolean;
  132327. RADIANCEOVERALPHA: boolean;
  132328. ALPHAFRESNEL: boolean;
  132329. LINEARALPHAFRESNEL: boolean;
  132330. PREMULTIPLYALPHA: boolean;
  132331. EMISSIVE: boolean;
  132332. EMISSIVEDIRECTUV: number;
  132333. REFLECTIVITY: boolean;
  132334. REFLECTIVITYDIRECTUV: number;
  132335. SPECULARTERM: boolean;
  132336. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  132337. MICROSURFACEAUTOMATIC: boolean;
  132338. LODBASEDMICROSFURACE: boolean;
  132339. MICROSURFACEMAP: boolean;
  132340. MICROSURFACEMAPDIRECTUV: number;
  132341. METALLICWORKFLOW: boolean;
  132342. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  132343. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  132344. METALLNESSSTOREINMETALMAPBLUE: boolean;
  132345. AOSTOREINMETALMAPRED: boolean;
  132346. METALLIC_REFLECTANCE: boolean;
  132347. METALLIC_REFLECTANCEDIRECTUV: number;
  132348. ENVIRONMENTBRDF: boolean;
  132349. ENVIRONMENTBRDF_RGBD: boolean;
  132350. NORMAL: boolean;
  132351. TANGENT: boolean;
  132352. BUMP: boolean;
  132353. BUMPDIRECTUV: number;
  132354. OBJECTSPACE_NORMALMAP: boolean;
  132355. PARALLAX: boolean;
  132356. PARALLAXOCCLUSION: boolean;
  132357. NORMALXYSCALE: boolean;
  132358. LIGHTMAP: boolean;
  132359. LIGHTMAPDIRECTUV: number;
  132360. USELIGHTMAPASSHADOWMAP: boolean;
  132361. GAMMALIGHTMAP: boolean;
  132362. RGBDLIGHTMAP: boolean;
  132363. REFLECTION: boolean;
  132364. REFLECTIONMAP_3D: boolean;
  132365. REFLECTIONMAP_SPHERICAL: boolean;
  132366. REFLECTIONMAP_PLANAR: boolean;
  132367. REFLECTIONMAP_CUBIC: boolean;
  132368. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  132369. REFLECTIONMAP_PROJECTION: boolean;
  132370. REFLECTIONMAP_SKYBOX: boolean;
  132371. REFLECTIONMAP_EXPLICIT: boolean;
  132372. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  132373. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  132374. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  132375. INVERTCUBICMAP: boolean;
  132376. USESPHERICALFROMREFLECTIONMAP: boolean;
  132377. USEIRRADIANCEMAP: boolean;
  132378. SPHERICAL_HARMONICS: boolean;
  132379. USESPHERICALINVERTEX: boolean;
  132380. REFLECTIONMAP_OPPOSITEZ: boolean;
  132381. LODINREFLECTIONALPHA: boolean;
  132382. GAMMAREFLECTION: boolean;
  132383. RGBDREFLECTION: boolean;
  132384. LINEARSPECULARREFLECTION: boolean;
  132385. RADIANCEOCCLUSION: boolean;
  132386. HORIZONOCCLUSION: boolean;
  132387. INSTANCES: boolean;
  132388. THIN_INSTANCES: boolean;
  132389. NUM_BONE_INFLUENCERS: number;
  132390. BonesPerMesh: number;
  132391. BONETEXTURE: boolean;
  132392. NONUNIFORMSCALING: boolean;
  132393. MORPHTARGETS: boolean;
  132394. MORPHTARGETS_NORMAL: boolean;
  132395. MORPHTARGETS_TANGENT: boolean;
  132396. MORPHTARGETS_UV: boolean;
  132397. NUM_MORPH_INFLUENCERS: number;
  132398. IMAGEPROCESSING: boolean;
  132399. VIGNETTE: boolean;
  132400. VIGNETTEBLENDMODEMULTIPLY: boolean;
  132401. VIGNETTEBLENDMODEOPAQUE: boolean;
  132402. TONEMAPPING: boolean;
  132403. TONEMAPPING_ACES: boolean;
  132404. CONTRAST: boolean;
  132405. COLORCURVES: boolean;
  132406. COLORGRADING: boolean;
  132407. COLORGRADING3D: boolean;
  132408. SAMPLER3DGREENDEPTH: boolean;
  132409. SAMPLER3DBGRMAP: boolean;
  132410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  132411. EXPOSURE: boolean;
  132412. MULTIVIEW: boolean;
  132413. USEPHYSICALLIGHTFALLOFF: boolean;
  132414. USEGLTFLIGHTFALLOFF: boolean;
  132415. TWOSIDEDLIGHTING: boolean;
  132416. SHADOWFLOAT: boolean;
  132417. CLIPPLANE: boolean;
  132418. CLIPPLANE2: boolean;
  132419. CLIPPLANE3: boolean;
  132420. CLIPPLANE4: boolean;
  132421. CLIPPLANE5: boolean;
  132422. CLIPPLANE6: boolean;
  132423. POINTSIZE: boolean;
  132424. FOG: boolean;
  132425. LOGARITHMICDEPTH: boolean;
  132426. FORCENORMALFORWARD: boolean;
  132427. SPECULARAA: boolean;
  132428. CLEARCOAT: boolean;
  132429. CLEARCOAT_DEFAULTIOR: boolean;
  132430. CLEARCOAT_TEXTURE: boolean;
  132431. CLEARCOAT_TEXTUREDIRECTUV: number;
  132432. CLEARCOAT_BUMP: boolean;
  132433. CLEARCOAT_BUMPDIRECTUV: number;
  132434. CLEARCOAT_TINT: boolean;
  132435. CLEARCOAT_TINT_TEXTURE: boolean;
  132436. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132437. ANISOTROPIC: boolean;
  132438. ANISOTROPIC_TEXTURE: boolean;
  132439. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132440. BRDF_V_HEIGHT_CORRELATED: boolean;
  132441. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132442. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132443. SHEEN: boolean;
  132444. SHEEN_TEXTURE: boolean;
  132445. SHEEN_TEXTUREDIRECTUV: number;
  132446. SHEEN_LINKWITHALBEDO: boolean;
  132447. SHEEN_ROUGHNESS: boolean;
  132448. SHEEN_ALBEDOSCALING: boolean;
  132449. SUBSURFACE: boolean;
  132450. SS_REFRACTION: boolean;
  132451. SS_TRANSLUCENCY: boolean;
  132452. SS_SCATTERING: boolean;
  132453. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132454. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132455. SS_REFRACTIONMAP_3D: boolean;
  132456. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132457. SS_LODINREFRACTIONALPHA: boolean;
  132458. SS_GAMMAREFRACTION: boolean;
  132459. SS_RGBDREFRACTION: boolean;
  132460. SS_LINEARSPECULARREFRACTION: boolean;
  132461. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132462. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132463. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132464. UNLIT: boolean;
  132465. DEBUGMODE: number;
  132466. /**
  132467. * Initializes the PBR Material defines.
  132468. */
  132469. constructor();
  132470. /**
  132471. * Resets the PBR Material defines.
  132472. */
  132473. reset(): void;
  132474. }
  132475. /**
  132476. * The Physically based material base class of BJS.
  132477. *
  132478. * This offers the main features of a standard PBR material.
  132479. * For more information, please refer to the documentation :
  132480. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132481. */
  132482. export abstract class PBRBaseMaterial extends PushMaterial {
  132483. /**
  132484. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132485. */
  132486. static readonly PBRMATERIAL_OPAQUE: number;
  132487. /**
  132488. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132489. */
  132490. static readonly PBRMATERIAL_ALPHATEST: number;
  132491. /**
  132492. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132493. */
  132494. static readonly PBRMATERIAL_ALPHABLEND: number;
  132495. /**
  132496. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132497. * They are also discarded below the alpha cutoff threshold to improve performances.
  132498. */
  132499. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132500. /**
  132501. * Defines the default value of how much AO map is occluding the analytical lights
  132502. * (point spot...).
  132503. */
  132504. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132505. /**
  132506. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  132507. */
  132508. static readonly LIGHTFALLOFF_PHYSICAL: number;
  132509. /**
  132510. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  132511. * to enhance interoperability with other engines.
  132512. */
  132513. static readonly LIGHTFALLOFF_GLTF: number;
  132514. /**
  132515. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  132516. * to enhance interoperability with other materials.
  132517. */
  132518. static readonly LIGHTFALLOFF_STANDARD: number;
  132519. /**
  132520. * Intensity of the direct lights e.g. the four lights available in your scene.
  132521. * This impacts both the direct diffuse and specular highlights.
  132522. */
  132523. protected _directIntensity: number;
  132524. /**
  132525. * Intensity of the emissive part of the material.
  132526. * This helps controlling the emissive effect without modifying the emissive color.
  132527. */
  132528. protected _emissiveIntensity: number;
  132529. /**
  132530. * Intensity of the environment e.g. how much the environment will light the object
  132531. * either through harmonics for rough material or through the refelction for shiny ones.
  132532. */
  132533. protected _environmentIntensity: number;
  132534. /**
  132535. * This is a special control allowing the reduction of the specular highlights coming from the
  132536. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132537. */
  132538. protected _specularIntensity: number;
  132539. /**
  132540. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  132541. */
  132542. private _lightingInfos;
  132543. /**
  132544. * Debug Control allowing disabling the bump map on this material.
  132545. */
  132546. protected _disableBumpMap: boolean;
  132547. /**
  132548. * AKA Diffuse Texture in standard nomenclature.
  132549. */
  132550. protected _albedoTexture: Nullable<BaseTexture>;
  132551. /**
  132552. * AKA Occlusion Texture in other nomenclature.
  132553. */
  132554. protected _ambientTexture: Nullable<BaseTexture>;
  132555. /**
  132556. * AKA Occlusion Texture Intensity in other nomenclature.
  132557. */
  132558. protected _ambientTextureStrength: number;
  132559. /**
  132560. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132561. * 1 means it completely occludes it
  132562. * 0 mean it has no impact
  132563. */
  132564. protected _ambientTextureImpactOnAnalyticalLights: number;
  132565. /**
  132566. * Stores the alpha values in a texture.
  132567. */
  132568. protected _opacityTexture: Nullable<BaseTexture>;
  132569. /**
  132570. * Stores the reflection values in a texture.
  132571. */
  132572. protected _reflectionTexture: Nullable<BaseTexture>;
  132573. /**
  132574. * Stores the emissive values in a texture.
  132575. */
  132576. protected _emissiveTexture: Nullable<BaseTexture>;
  132577. /**
  132578. * AKA Specular texture in other nomenclature.
  132579. */
  132580. protected _reflectivityTexture: Nullable<BaseTexture>;
  132581. /**
  132582. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132583. */
  132584. protected _metallicTexture: Nullable<BaseTexture>;
  132585. /**
  132586. * Specifies the metallic scalar of the metallic/roughness workflow.
  132587. * Can also be used to scale the metalness values of the metallic texture.
  132588. */
  132589. protected _metallic: Nullable<number>;
  132590. /**
  132591. * Specifies the roughness scalar of the metallic/roughness workflow.
  132592. * Can also be used to scale the roughness values of the metallic texture.
  132593. */
  132594. protected _roughness: Nullable<number>;
  132595. /**
  132596. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132597. * By default the indexOfrefraction is used to compute F0;
  132598. *
  132599. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132600. *
  132601. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132602. * F90 = metallicReflectanceColor;
  132603. */
  132604. protected _metallicF0Factor: number;
  132605. /**
  132606. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132607. * By default the F90 is always 1;
  132608. *
  132609. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132610. *
  132611. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132612. * F90 = metallicReflectanceColor;
  132613. */
  132614. protected _metallicReflectanceColor: Color3;
  132615. /**
  132616. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132617. * This is multiply against the scalar values defined in the material.
  132618. */
  132619. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132620. /**
  132621. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132622. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132623. */
  132624. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132625. /**
  132626. * Stores surface normal data used to displace a mesh in a texture.
  132627. */
  132628. protected _bumpTexture: Nullable<BaseTexture>;
  132629. /**
  132630. * Stores the pre-calculated light information of a mesh in a texture.
  132631. */
  132632. protected _lightmapTexture: Nullable<BaseTexture>;
  132633. /**
  132634. * The color of a material in ambient lighting.
  132635. */
  132636. protected _ambientColor: Color3;
  132637. /**
  132638. * AKA Diffuse Color in other nomenclature.
  132639. */
  132640. protected _albedoColor: Color3;
  132641. /**
  132642. * AKA Specular Color in other nomenclature.
  132643. */
  132644. protected _reflectivityColor: Color3;
  132645. /**
  132646. * The color applied when light is reflected from a material.
  132647. */
  132648. protected _reflectionColor: Color3;
  132649. /**
  132650. * The color applied when light is emitted from a material.
  132651. */
  132652. protected _emissiveColor: Color3;
  132653. /**
  132654. * AKA Glossiness in other nomenclature.
  132655. */
  132656. protected _microSurface: number;
  132657. /**
  132658. * Specifies that the material will use the light map as a show map.
  132659. */
  132660. protected _useLightmapAsShadowmap: boolean;
  132661. /**
  132662. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  132663. * makes the reflect vector face the model (under horizon).
  132664. */
  132665. protected _useHorizonOcclusion: boolean;
  132666. /**
  132667. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  132668. * too much the area relying on ambient texture to define their ambient occlusion.
  132669. */
  132670. protected _useRadianceOcclusion: boolean;
  132671. /**
  132672. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  132673. */
  132674. protected _useAlphaFromAlbedoTexture: boolean;
  132675. /**
  132676. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  132677. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  132678. */
  132679. protected _useSpecularOverAlpha: boolean;
  132680. /**
  132681. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  132682. */
  132683. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  132684. /**
  132685. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  132686. */
  132687. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  132688. /**
  132689. * Specifies if the metallic texture contains the roughness information in its green channel.
  132690. */
  132691. protected _useRoughnessFromMetallicTextureGreen: boolean;
  132692. /**
  132693. * Specifies if the metallic texture contains the metallness information in its blue channel.
  132694. */
  132695. protected _useMetallnessFromMetallicTextureBlue: boolean;
  132696. /**
  132697. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  132698. */
  132699. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  132700. /**
  132701. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  132702. */
  132703. protected _useAmbientInGrayScale: boolean;
  132704. /**
  132705. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  132706. * The material will try to infer what glossiness each pixel should be.
  132707. */
  132708. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  132709. /**
  132710. * Defines the falloff type used in this material.
  132711. * It by default is Physical.
  132712. */
  132713. protected _lightFalloff: number;
  132714. /**
  132715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  132716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  132717. */
  132718. protected _useRadianceOverAlpha: boolean;
  132719. /**
  132720. * Allows using an object space normal map (instead of tangent space).
  132721. */
  132722. protected _useObjectSpaceNormalMap: boolean;
  132723. /**
  132724. * Allows using the bump map in parallax mode.
  132725. */
  132726. protected _useParallax: boolean;
  132727. /**
  132728. * Allows using the bump map in parallax occlusion mode.
  132729. */
  132730. protected _useParallaxOcclusion: boolean;
  132731. /**
  132732. * Controls the scale bias of the parallax mode.
  132733. */
  132734. protected _parallaxScaleBias: number;
  132735. /**
  132736. * If sets to true, disables all the lights affecting the material.
  132737. */
  132738. protected _disableLighting: boolean;
  132739. /**
  132740. * Number of Simultaneous lights allowed on the material.
  132741. */
  132742. protected _maxSimultaneousLights: number;
  132743. /**
  132744. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132745. */
  132746. protected _invertNormalMapX: boolean;
  132747. /**
  132748. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132749. */
  132750. protected _invertNormalMapY: boolean;
  132751. /**
  132752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  132753. */
  132754. protected _twoSidedLighting: boolean;
  132755. /**
  132756. * Defines the alpha limits in alpha test mode.
  132757. */
  132758. protected _alphaCutOff: number;
  132759. /**
  132760. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  132761. */
  132762. protected _forceAlphaTest: boolean;
  132763. /**
  132764. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132765. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  132766. */
  132767. protected _useAlphaFresnel: boolean;
  132768. /**
  132769. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  132770. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  132771. */
  132772. protected _useLinearAlphaFresnel: boolean;
  132773. /**
  132774. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  132775. * from cos thetav and roughness:
  132776. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  132777. */
  132778. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  132779. /**
  132780. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  132781. */
  132782. protected _forceIrradianceInFragment: boolean;
  132783. private _realTimeFiltering;
  132784. /**
  132785. * Enables realtime filtering on the texture.
  132786. */
  132787. get realTimeFiltering(): boolean;
  132788. set realTimeFiltering(b: boolean);
  132789. private _realTimeFilteringQuality;
  132790. /**
  132791. * Quality switch for realtime filtering
  132792. */
  132793. get realTimeFilteringQuality(): number;
  132794. set realTimeFilteringQuality(n: number);
  132795. /**
  132796. * Force normal to face away from face.
  132797. */
  132798. protected _forceNormalForward: boolean;
  132799. /**
  132800. * Enables specular anti aliasing in the PBR shader.
  132801. * It will both interacts on the Geometry for analytical and IBL lighting.
  132802. * It also prefilter the roughness map based on the bump values.
  132803. */
  132804. protected _enableSpecularAntiAliasing: boolean;
  132805. /**
  132806. * Default configuration related to image processing available in the PBR Material.
  132807. */
  132808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  132809. /**
  132810. * Keep track of the image processing observer to allow dispose and replace.
  132811. */
  132812. private _imageProcessingObserver;
  132813. /**
  132814. * Attaches a new image processing configuration to the PBR Material.
  132815. * @param configuration
  132816. */
  132817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  132818. /**
  132819. * Stores the available render targets.
  132820. */
  132821. private _renderTargets;
  132822. /**
  132823. * Sets the global ambient color for the material used in lighting calculations.
  132824. */
  132825. private _globalAmbientColor;
  132826. /**
  132827. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  132828. */
  132829. private _useLogarithmicDepth;
  132830. /**
  132831. * If set to true, no lighting calculations will be applied.
  132832. */
  132833. private _unlit;
  132834. private _debugMode;
  132835. /**
  132836. * @hidden
  132837. * This is reserved for the inspector.
  132838. * Defines the material debug mode.
  132839. * It helps seeing only some components of the material while troubleshooting.
  132840. */
  132841. debugMode: number;
  132842. /**
  132843. * @hidden
  132844. * This is reserved for the inspector.
  132845. * Specify from where on screen the debug mode should start.
  132846. * The value goes from -1 (full screen) to 1 (not visible)
  132847. * It helps with side by side comparison against the final render
  132848. * This defaults to -1
  132849. */
  132850. private debugLimit;
  132851. /**
  132852. * @hidden
  132853. * This is reserved for the inspector.
  132854. * As the default viewing range might not be enough (if the ambient is really small for instance)
  132855. * You can use the factor to better multiply the final value.
  132856. */
  132857. private debugFactor;
  132858. /**
  132859. * Defines the clear coat layer parameters for the material.
  132860. */
  132861. readonly clearCoat: PBRClearCoatConfiguration;
  132862. /**
  132863. * Defines the anisotropic parameters for the material.
  132864. */
  132865. readonly anisotropy: PBRAnisotropicConfiguration;
  132866. /**
  132867. * Defines the BRDF parameters for the material.
  132868. */
  132869. readonly brdf: PBRBRDFConfiguration;
  132870. /**
  132871. * Defines the Sheen parameters for the material.
  132872. */
  132873. readonly sheen: PBRSheenConfiguration;
  132874. /**
  132875. * Defines the SubSurface parameters for the material.
  132876. */
  132877. readonly subSurface: PBRSubSurfaceConfiguration;
  132878. protected _rebuildInParallel: boolean;
  132879. /**
  132880. * Instantiates a new PBRMaterial instance.
  132881. *
  132882. * @param name The material name
  132883. * @param scene The scene the material will be use in.
  132884. */
  132885. constructor(name: string, scene: Scene);
  132886. /**
  132887. * Gets a boolean indicating that current material needs to register RTT
  132888. */
  132889. get hasRenderTargetTextures(): boolean;
  132890. /**
  132891. * Gets the name of the material class.
  132892. */
  132893. getClassName(): string;
  132894. /**
  132895. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132896. */
  132897. get useLogarithmicDepth(): boolean;
  132898. /**
  132899. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  132900. */
  132901. set useLogarithmicDepth(value: boolean);
  132902. /**
  132903. * Returns true if alpha blending should be disabled.
  132904. */
  132905. protected get _disableAlphaBlending(): boolean;
  132906. /**
  132907. * Specifies whether or not this material should be rendered in alpha blend mode.
  132908. */
  132909. needAlphaBlending(): boolean;
  132910. /**
  132911. * Specifies whether or not this material should be rendered in alpha test mode.
  132912. */
  132913. needAlphaTesting(): boolean;
  132914. /**
  132915. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  132916. */
  132917. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  132918. /**
  132919. * Gets the texture used for the alpha test.
  132920. */
  132921. getAlphaTestTexture(): Nullable<BaseTexture>;
  132922. /**
  132923. * Specifies that the submesh is ready to be used.
  132924. * @param mesh - BJS mesh.
  132925. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  132926. * @param useInstances - Specifies that instances should be used.
  132927. * @returns - boolean indicating that the submesh is ready or not.
  132928. */
  132929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132930. /**
  132931. * Specifies if the material uses metallic roughness workflow.
  132932. * @returns boolean specifiying if the material uses metallic roughness workflow.
  132933. */
  132934. isMetallicWorkflow(): boolean;
  132935. private _prepareEffect;
  132936. private _prepareDefines;
  132937. /**
  132938. * Force shader compilation
  132939. */
  132940. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  132941. /**
  132942. * Initializes the uniform buffer layout for the shader.
  132943. */
  132944. buildUniformLayout(): void;
  132945. /**
  132946. * Unbinds the material from the mesh
  132947. */
  132948. unbind(): void;
  132949. /**
  132950. * Binds the submesh data.
  132951. * @param world - The world matrix.
  132952. * @param mesh - The BJS mesh.
  132953. * @param subMesh - A submesh of the BJS mesh.
  132954. */
  132955. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132956. /**
  132957. * Returns the animatable textures.
  132958. * @returns - Array of animatable textures.
  132959. */
  132960. getAnimatables(): IAnimatable[];
  132961. /**
  132962. * Returns the texture used for reflections.
  132963. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  132964. */
  132965. private _getReflectionTexture;
  132966. /**
  132967. * Returns an array of the actively used textures.
  132968. * @returns - Array of BaseTextures
  132969. */
  132970. getActiveTextures(): BaseTexture[];
  132971. /**
  132972. * Checks to see if a texture is used in the material.
  132973. * @param texture - Base texture to use.
  132974. * @returns - Boolean specifying if a texture is used in the material.
  132975. */
  132976. hasTexture(texture: BaseTexture): boolean;
  132977. /**
  132978. * Disposes the resources of the material.
  132979. * @param forceDisposeEffect - Forces the disposal of effects.
  132980. * @param forceDisposeTextures - Forces the disposal of all textures.
  132981. */
  132982. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  132983. }
  132984. }
  132985. declare module BABYLON {
  132986. /**
  132987. * The Physically based material of BJS.
  132988. *
  132989. * This offers the main features of a standard PBR material.
  132990. * For more information, please refer to the documentation :
  132991. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132992. */
  132993. export class PBRMaterial extends PBRBaseMaterial {
  132994. /**
  132995. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132996. */
  132997. static readonly PBRMATERIAL_OPAQUE: number;
  132998. /**
  132999. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133000. */
  133001. static readonly PBRMATERIAL_ALPHATEST: number;
  133002. /**
  133003. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133004. */
  133005. static readonly PBRMATERIAL_ALPHABLEND: number;
  133006. /**
  133007. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133008. * They are also discarded below the alpha cutoff threshold to improve performances.
  133009. */
  133010. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133011. /**
  133012. * Defines the default value of how much AO map is occluding the analytical lights
  133013. * (point spot...).
  133014. */
  133015. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133016. /**
  133017. * Intensity of the direct lights e.g. the four lights available in your scene.
  133018. * This impacts both the direct diffuse and specular highlights.
  133019. */
  133020. directIntensity: number;
  133021. /**
  133022. * Intensity of the emissive part of the material.
  133023. * This helps controlling the emissive effect without modifying the emissive color.
  133024. */
  133025. emissiveIntensity: number;
  133026. /**
  133027. * Intensity of the environment e.g. how much the environment will light the object
  133028. * either through harmonics for rough material or through the refelction for shiny ones.
  133029. */
  133030. environmentIntensity: number;
  133031. /**
  133032. * This is a special control allowing the reduction of the specular highlights coming from the
  133033. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133034. */
  133035. specularIntensity: number;
  133036. /**
  133037. * Debug Control allowing disabling the bump map on this material.
  133038. */
  133039. disableBumpMap: boolean;
  133040. /**
  133041. * AKA Diffuse Texture in standard nomenclature.
  133042. */
  133043. albedoTexture: BaseTexture;
  133044. /**
  133045. * AKA Occlusion Texture in other nomenclature.
  133046. */
  133047. ambientTexture: BaseTexture;
  133048. /**
  133049. * AKA Occlusion Texture Intensity in other nomenclature.
  133050. */
  133051. ambientTextureStrength: number;
  133052. /**
  133053. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133054. * 1 means it completely occludes it
  133055. * 0 mean it has no impact
  133056. */
  133057. ambientTextureImpactOnAnalyticalLights: number;
  133058. /**
  133059. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  133060. */
  133061. opacityTexture: BaseTexture;
  133062. /**
  133063. * Stores the reflection values in a texture.
  133064. */
  133065. reflectionTexture: Nullable<BaseTexture>;
  133066. /**
  133067. * Stores the emissive values in a texture.
  133068. */
  133069. emissiveTexture: BaseTexture;
  133070. /**
  133071. * AKA Specular texture in other nomenclature.
  133072. */
  133073. reflectivityTexture: BaseTexture;
  133074. /**
  133075. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133076. */
  133077. metallicTexture: BaseTexture;
  133078. /**
  133079. * Specifies the metallic scalar of the metallic/roughness workflow.
  133080. * Can also be used to scale the metalness values of the metallic texture.
  133081. */
  133082. metallic: Nullable<number>;
  133083. /**
  133084. * Specifies the roughness scalar of the metallic/roughness workflow.
  133085. * Can also be used to scale the roughness values of the metallic texture.
  133086. */
  133087. roughness: Nullable<number>;
  133088. /**
  133089. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133090. * By default the indexOfrefraction is used to compute F0;
  133091. *
  133092. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133093. *
  133094. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133095. * F90 = metallicReflectanceColor;
  133096. */
  133097. metallicF0Factor: number;
  133098. /**
  133099. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133100. * By default the F90 is always 1;
  133101. *
  133102. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133103. *
  133104. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133105. * F90 = metallicReflectanceColor;
  133106. */
  133107. metallicReflectanceColor: Color3;
  133108. /**
  133109. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133110. * This is multiply against the scalar values defined in the material.
  133111. */
  133112. metallicReflectanceTexture: Nullable<BaseTexture>;
  133113. /**
  133114. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133115. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133116. */
  133117. microSurfaceTexture: BaseTexture;
  133118. /**
  133119. * Stores surface normal data used to displace a mesh in a texture.
  133120. */
  133121. bumpTexture: BaseTexture;
  133122. /**
  133123. * Stores the pre-calculated light information of a mesh in a texture.
  133124. */
  133125. lightmapTexture: BaseTexture;
  133126. /**
  133127. * Stores the refracted light information in a texture.
  133128. */
  133129. get refractionTexture(): Nullable<BaseTexture>;
  133130. set refractionTexture(value: Nullable<BaseTexture>);
  133131. /**
  133132. * The color of a material in ambient lighting.
  133133. */
  133134. ambientColor: Color3;
  133135. /**
  133136. * AKA Diffuse Color in other nomenclature.
  133137. */
  133138. albedoColor: Color3;
  133139. /**
  133140. * AKA Specular Color in other nomenclature.
  133141. */
  133142. reflectivityColor: Color3;
  133143. /**
  133144. * The color reflected from the material.
  133145. */
  133146. reflectionColor: Color3;
  133147. /**
  133148. * The color emitted from the material.
  133149. */
  133150. emissiveColor: Color3;
  133151. /**
  133152. * AKA Glossiness in other nomenclature.
  133153. */
  133154. microSurface: number;
  133155. /**
  133156. * Index of refraction of the material base layer.
  133157. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133158. *
  133159. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133160. *
  133161. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133162. */
  133163. get indexOfRefraction(): number;
  133164. set indexOfRefraction(value: number);
  133165. /**
  133166. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133167. */
  133168. get invertRefractionY(): boolean;
  133169. set invertRefractionY(value: boolean);
  133170. /**
  133171. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133172. * Materials half opaque for instance using refraction could benefit from this control.
  133173. */
  133174. get linkRefractionWithTransparency(): boolean;
  133175. set linkRefractionWithTransparency(value: boolean);
  133176. /**
  133177. * If true, the light map contains occlusion information instead of lighting info.
  133178. */
  133179. useLightmapAsShadowmap: boolean;
  133180. /**
  133181. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133182. */
  133183. useAlphaFromAlbedoTexture: boolean;
  133184. /**
  133185. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133186. */
  133187. forceAlphaTest: boolean;
  133188. /**
  133189. * Defines the alpha limits in alpha test mode.
  133190. */
  133191. alphaCutOff: number;
  133192. /**
  133193. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  133194. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133195. */
  133196. useSpecularOverAlpha: boolean;
  133197. /**
  133198. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133199. */
  133200. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133201. /**
  133202. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133203. */
  133204. useRoughnessFromMetallicTextureAlpha: boolean;
  133205. /**
  133206. * Specifies if the metallic texture contains the roughness information in its green channel.
  133207. */
  133208. useRoughnessFromMetallicTextureGreen: boolean;
  133209. /**
  133210. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133211. */
  133212. useMetallnessFromMetallicTextureBlue: boolean;
  133213. /**
  133214. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133215. */
  133216. useAmbientOcclusionFromMetallicTextureRed: boolean;
  133217. /**
  133218. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133219. */
  133220. useAmbientInGrayScale: boolean;
  133221. /**
  133222. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133223. * The material will try to infer what glossiness each pixel should be.
  133224. */
  133225. useAutoMicroSurfaceFromReflectivityMap: boolean;
  133226. /**
  133227. * BJS is using an harcoded light falloff based on a manually sets up range.
  133228. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133229. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133230. */
  133231. get usePhysicalLightFalloff(): boolean;
  133232. /**
  133233. * BJS is using an harcoded light falloff based on a manually sets up range.
  133234. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133235. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133236. */
  133237. set usePhysicalLightFalloff(value: boolean);
  133238. /**
  133239. * In order to support the falloff compatibility with gltf, a special mode has been added
  133240. * to reproduce the gltf light falloff.
  133241. */
  133242. get useGLTFLightFalloff(): boolean;
  133243. /**
  133244. * In order to support the falloff compatibility with gltf, a special mode has been added
  133245. * to reproduce the gltf light falloff.
  133246. */
  133247. set useGLTFLightFalloff(value: boolean);
  133248. /**
  133249. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133250. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133251. */
  133252. useRadianceOverAlpha: boolean;
  133253. /**
  133254. * Allows using an object space normal map (instead of tangent space).
  133255. */
  133256. useObjectSpaceNormalMap: boolean;
  133257. /**
  133258. * Allows using the bump map in parallax mode.
  133259. */
  133260. useParallax: boolean;
  133261. /**
  133262. * Allows using the bump map in parallax occlusion mode.
  133263. */
  133264. useParallaxOcclusion: boolean;
  133265. /**
  133266. * Controls the scale bias of the parallax mode.
  133267. */
  133268. parallaxScaleBias: number;
  133269. /**
  133270. * If sets to true, disables all the lights affecting the material.
  133271. */
  133272. disableLighting: boolean;
  133273. /**
  133274. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133275. */
  133276. forceIrradianceInFragment: boolean;
  133277. /**
  133278. * Number of Simultaneous lights allowed on the material.
  133279. */
  133280. maxSimultaneousLights: number;
  133281. /**
  133282. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  133283. */
  133284. invertNormalMapX: boolean;
  133285. /**
  133286. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  133287. */
  133288. invertNormalMapY: boolean;
  133289. /**
  133290. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133291. */
  133292. twoSidedLighting: boolean;
  133293. /**
  133294. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133295. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133296. */
  133297. useAlphaFresnel: boolean;
  133298. /**
  133299. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133300. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133301. */
  133302. useLinearAlphaFresnel: boolean;
  133303. /**
  133304. * Let user defines the brdf lookup texture used for IBL.
  133305. * A default 8bit version is embedded but you could point at :
  133306. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  133307. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  133308. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  133309. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  133310. */
  133311. environmentBRDFTexture: Nullable<BaseTexture>;
  133312. /**
  133313. * Force normal to face away from face.
  133314. */
  133315. forceNormalForward: boolean;
  133316. /**
  133317. * Enables specular anti aliasing in the PBR shader.
  133318. * It will both interacts on the Geometry for analytical and IBL lighting.
  133319. * It also prefilter the roughness map based on the bump values.
  133320. */
  133321. enableSpecularAntiAliasing: boolean;
  133322. /**
  133323. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133324. * makes the reflect vector face the model (under horizon).
  133325. */
  133326. useHorizonOcclusion: boolean;
  133327. /**
  133328. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133329. * too much the area relying on ambient texture to define their ambient occlusion.
  133330. */
  133331. useRadianceOcclusion: boolean;
  133332. /**
  133333. * If set to true, no lighting calculations will be applied.
  133334. */
  133335. unlit: boolean;
  133336. /**
  133337. * Gets the image processing configuration used either in this material.
  133338. */
  133339. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133340. /**
  133341. * Sets the Default image processing configuration used either in the this material.
  133342. *
  133343. * If sets to null, the scene one is in use.
  133344. */
  133345. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133346. /**
  133347. * Gets wether the color curves effect is enabled.
  133348. */
  133349. get cameraColorCurvesEnabled(): boolean;
  133350. /**
  133351. * Sets wether the color curves effect is enabled.
  133352. */
  133353. set cameraColorCurvesEnabled(value: boolean);
  133354. /**
  133355. * Gets wether the color grading effect is enabled.
  133356. */
  133357. get cameraColorGradingEnabled(): boolean;
  133358. /**
  133359. * Gets wether the color grading effect is enabled.
  133360. */
  133361. set cameraColorGradingEnabled(value: boolean);
  133362. /**
  133363. * Gets wether tonemapping is enabled or not.
  133364. */
  133365. get cameraToneMappingEnabled(): boolean;
  133366. /**
  133367. * Sets wether tonemapping is enabled or not
  133368. */
  133369. set cameraToneMappingEnabled(value: boolean);
  133370. /**
  133371. * The camera exposure used on this material.
  133372. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133373. * This corresponds to a photographic exposure.
  133374. */
  133375. get cameraExposure(): number;
  133376. /**
  133377. * The camera exposure used on this material.
  133378. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133379. * This corresponds to a photographic exposure.
  133380. */
  133381. set cameraExposure(value: number);
  133382. /**
  133383. * Gets The camera contrast used on this material.
  133384. */
  133385. get cameraContrast(): number;
  133386. /**
  133387. * Sets The camera contrast used on this material.
  133388. */
  133389. set cameraContrast(value: number);
  133390. /**
  133391. * Gets the Color Grading 2D Lookup Texture.
  133392. */
  133393. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133394. /**
  133395. * Sets the Color Grading 2D Lookup Texture.
  133396. */
  133397. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133398. /**
  133399. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133400. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133401. * 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;
  133402. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133403. */
  133404. get cameraColorCurves(): Nullable<ColorCurves>;
  133405. /**
  133406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133408. * 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;
  133409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133410. */
  133411. set cameraColorCurves(value: Nullable<ColorCurves>);
  133412. /**
  133413. * Instantiates a new PBRMaterial instance.
  133414. *
  133415. * @param name The material name
  133416. * @param scene The scene the material will be use in.
  133417. */
  133418. constructor(name: string, scene: Scene);
  133419. /**
  133420. * Returns the name of this material class.
  133421. */
  133422. getClassName(): string;
  133423. /**
  133424. * Makes a duplicate of the current material.
  133425. * @param name - name to use for the new material.
  133426. */
  133427. clone(name: string): PBRMaterial;
  133428. /**
  133429. * Serializes this PBR Material.
  133430. * @returns - An object with the serialized material.
  133431. */
  133432. serialize(): any;
  133433. /**
  133434. * Parses a PBR Material from a serialized object.
  133435. * @param source - Serialized object.
  133436. * @param scene - BJS scene instance.
  133437. * @param rootUrl - url for the scene object
  133438. * @returns - PBRMaterial
  133439. */
  133440. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  133441. }
  133442. }
  133443. declare module BABYLON {
  133444. /**
  133445. * Direct draw surface info
  133446. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  133447. */
  133448. export interface DDSInfo {
  133449. /**
  133450. * Width of the texture
  133451. */
  133452. width: number;
  133453. /**
  133454. * Width of the texture
  133455. */
  133456. height: number;
  133457. /**
  133458. * Number of Mipmaps for the texture
  133459. * @see https://en.wikipedia.org/wiki/Mipmap
  133460. */
  133461. mipmapCount: number;
  133462. /**
  133463. * If the textures format is a known fourCC format
  133464. * @see https://www.fourcc.org/
  133465. */
  133466. isFourCC: boolean;
  133467. /**
  133468. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  133469. */
  133470. isRGB: boolean;
  133471. /**
  133472. * If the texture is a lumincance format
  133473. */
  133474. isLuminance: boolean;
  133475. /**
  133476. * If this is a cube texture
  133477. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  133478. */
  133479. isCube: boolean;
  133480. /**
  133481. * If the texture is a compressed format eg. FOURCC_DXT1
  133482. */
  133483. isCompressed: boolean;
  133484. /**
  133485. * The dxgiFormat of the texture
  133486. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  133487. */
  133488. dxgiFormat: number;
  133489. /**
  133490. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  133491. */
  133492. textureType: number;
  133493. /**
  133494. * Sphericle polynomial created for the dds texture
  133495. */
  133496. sphericalPolynomial?: SphericalPolynomial;
  133497. }
  133498. /**
  133499. * Class used to provide DDS decompression tools
  133500. */
  133501. export class DDSTools {
  133502. /**
  133503. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  133504. */
  133505. static StoreLODInAlphaChannel: boolean;
  133506. /**
  133507. * Gets DDS information from an array buffer
  133508. * @param data defines the array buffer view to read data from
  133509. * @returns the DDS information
  133510. */
  133511. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  133512. private static _FloatView;
  133513. private static _Int32View;
  133514. private static _ToHalfFloat;
  133515. private static _FromHalfFloat;
  133516. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  133517. private static _GetHalfFloatRGBAArrayBuffer;
  133518. private static _GetFloatRGBAArrayBuffer;
  133519. private static _GetFloatAsUIntRGBAArrayBuffer;
  133520. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  133521. private static _GetRGBAArrayBuffer;
  133522. private static _ExtractLongWordOrder;
  133523. private static _GetRGBArrayBuffer;
  133524. private static _GetLuminanceArrayBuffer;
  133525. /**
  133526. * Uploads DDS Levels to a Babylon Texture
  133527. * @hidden
  133528. */
  133529. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  133530. }
  133531. interface ThinEngine {
  133532. /**
  133533. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  133534. * @param rootUrl defines the url where the file to load is located
  133535. * @param scene defines the current scene
  133536. * @param lodScale defines scale to apply to the mip map selection
  133537. * @param lodOffset defines offset to apply to the mip map selection
  133538. * @param onLoad defines an optional callback raised when the texture is loaded
  133539. * @param onError defines an optional callback raised if there is an issue to load the texture
  133540. * @param format defines the format of the data
  133541. * @param forcedExtension defines the extension to use to pick the right loader
  133542. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  133543. * @returns the cube texture as an InternalTexture
  133544. */
  133545. 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;
  133546. }
  133547. }
  133548. declare module BABYLON {
  133549. /**
  133550. * Implementation of the DDS Texture Loader.
  133551. * @hidden
  133552. */
  133553. export class _DDSTextureLoader implements IInternalTextureLoader {
  133554. /**
  133555. * Defines wether the loader supports cascade loading the different faces.
  133556. */
  133557. readonly supportCascades: boolean;
  133558. /**
  133559. * This returns if the loader support the current file information.
  133560. * @param extension defines the file extension of the file being loaded
  133561. * @returns true if the loader can load the specified file
  133562. */
  133563. canLoad(extension: string): boolean;
  133564. /**
  133565. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133566. * @param data contains the texture data
  133567. * @param texture defines the BabylonJS internal texture
  133568. * @param createPolynomials will be true if polynomials have been requested
  133569. * @param onLoad defines the callback to trigger once the texture is ready
  133570. * @param onError defines the callback to trigger in case of error
  133571. */
  133572. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133573. /**
  133574. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133575. * @param data contains the texture data
  133576. * @param texture defines the BabylonJS internal texture
  133577. * @param callback defines the method to call once ready to upload
  133578. */
  133579. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133580. }
  133581. }
  133582. declare module BABYLON {
  133583. /**
  133584. * Implementation of the ENV Texture Loader.
  133585. * @hidden
  133586. */
  133587. export class _ENVTextureLoader implements IInternalTextureLoader {
  133588. /**
  133589. * Defines wether the loader supports cascade loading the different faces.
  133590. */
  133591. readonly supportCascades: boolean;
  133592. /**
  133593. * This returns if the loader support the current file information.
  133594. * @param extension defines the file extension of the file being loaded
  133595. * @returns true if the loader can load the specified file
  133596. */
  133597. canLoad(extension: string): boolean;
  133598. /**
  133599. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133600. * @param data contains the texture data
  133601. * @param texture defines the BabylonJS internal texture
  133602. * @param createPolynomials will be true if polynomials have been requested
  133603. * @param onLoad defines the callback to trigger once the texture is ready
  133604. * @param onError defines the callback to trigger in case of error
  133605. */
  133606. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133607. /**
  133608. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133609. * @param data contains the texture data
  133610. * @param texture defines the BabylonJS internal texture
  133611. * @param callback defines the method to call once ready to upload
  133612. */
  133613. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133614. }
  133615. }
  133616. declare module BABYLON {
  133617. /**
  133618. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133619. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133620. */
  133621. export class KhronosTextureContainer {
  133622. /** contents of the KTX container file */
  133623. data: ArrayBufferView;
  133624. private static HEADER_LEN;
  133625. private static COMPRESSED_2D;
  133626. private static COMPRESSED_3D;
  133627. private static TEX_2D;
  133628. private static TEX_3D;
  133629. /**
  133630. * Gets the openGL type
  133631. */
  133632. glType: number;
  133633. /**
  133634. * Gets the openGL type size
  133635. */
  133636. glTypeSize: number;
  133637. /**
  133638. * Gets the openGL format
  133639. */
  133640. glFormat: number;
  133641. /**
  133642. * Gets the openGL internal format
  133643. */
  133644. glInternalFormat: number;
  133645. /**
  133646. * Gets the base internal format
  133647. */
  133648. glBaseInternalFormat: number;
  133649. /**
  133650. * Gets image width in pixel
  133651. */
  133652. pixelWidth: number;
  133653. /**
  133654. * Gets image height in pixel
  133655. */
  133656. pixelHeight: number;
  133657. /**
  133658. * Gets image depth in pixels
  133659. */
  133660. pixelDepth: number;
  133661. /**
  133662. * Gets the number of array elements
  133663. */
  133664. numberOfArrayElements: number;
  133665. /**
  133666. * Gets the number of faces
  133667. */
  133668. numberOfFaces: number;
  133669. /**
  133670. * Gets the number of mipmap levels
  133671. */
  133672. numberOfMipmapLevels: number;
  133673. /**
  133674. * Gets the bytes of key value data
  133675. */
  133676. bytesOfKeyValueData: number;
  133677. /**
  133678. * Gets the load type
  133679. */
  133680. loadType: number;
  133681. /**
  133682. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  133683. */
  133684. isInvalid: boolean;
  133685. /**
  133686. * Creates a new KhronosTextureContainer
  133687. * @param data contents of the KTX container file
  133688. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  133689. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  133690. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  133691. */
  133692. constructor(
  133693. /** contents of the KTX container file */
  133694. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  133695. /**
  133696. * Uploads KTX content to a Babylon Texture.
  133697. * It is assumed that the texture has already been created & is currently bound
  133698. * @hidden
  133699. */
  133700. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  133701. private _upload2DCompressedLevels;
  133702. /**
  133703. * Checks if the given data starts with a KTX file identifier.
  133704. * @param data the data to check
  133705. * @returns true if the data is a KTX file or false otherwise
  133706. */
  133707. static IsValid(data: ArrayBufferView): boolean;
  133708. }
  133709. }
  133710. declare module BABYLON {
  133711. /**
  133712. * Class for loading KTX2 files
  133713. * !!! Experimental Extension Subject to Changes !!!
  133714. * @hidden
  133715. */
  133716. export class KhronosTextureContainer2 {
  133717. private static _ModulePromise;
  133718. private static _TranscodeFormat;
  133719. constructor(engine: ThinEngine);
  133720. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  133721. private _determineTranscodeFormat;
  133722. /**
  133723. * Checks if the given data starts with a KTX2 file identifier.
  133724. * @param data the data to check
  133725. * @returns true if the data is a KTX2 file or false otherwise
  133726. */
  133727. static IsValid(data: ArrayBufferView): boolean;
  133728. }
  133729. }
  133730. declare module BABYLON {
  133731. /**
  133732. * Implementation of the KTX Texture Loader.
  133733. * @hidden
  133734. */
  133735. export class _KTXTextureLoader implements IInternalTextureLoader {
  133736. /**
  133737. * Defines wether the loader supports cascade loading the different faces.
  133738. */
  133739. readonly supportCascades: boolean;
  133740. /**
  133741. * This returns if the loader support the current file information.
  133742. * @param extension defines the file extension of the file being loaded
  133743. * @returns true if the loader can load the specified file
  133744. */
  133745. canLoad(extension: string): boolean;
  133746. /**
  133747. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133748. * @param data contains the texture data
  133749. * @param texture defines the BabylonJS internal texture
  133750. * @param createPolynomials will be true if polynomials have been requested
  133751. * @param onLoad defines the callback to trigger once the texture is ready
  133752. * @param onError defines the callback to trigger in case of error
  133753. */
  133754. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133755. /**
  133756. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133757. * @param data contains the texture data
  133758. * @param texture defines the BabylonJS internal texture
  133759. * @param callback defines the method to call once ready to upload
  133760. */
  133761. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  133762. }
  133763. }
  133764. declare module BABYLON {
  133765. /** @hidden */
  133766. export var _forceSceneHelpersToBundle: boolean;
  133767. interface Scene {
  133768. /**
  133769. * Creates a default light for the scene.
  133770. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  133771. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  133772. */
  133773. createDefaultLight(replace?: boolean): void;
  133774. /**
  133775. * Creates a default camera for the scene.
  133776. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  133777. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133778. * @param replace has default false, when true replaces the active camera in the scene
  133779. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  133780. */
  133781. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133782. /**
  133783. * Creates a default camera and a default light.
  133784. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  133785. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  133786. * @param replace has the default false, when true replaces the active camera/light in the scene
  133787. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  133788. */
  133789. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  133790. /**
  133791. * Creates a new sky box
  133792. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  133793. * @param environmentTexture defines the texture to use as environment texture
  133794. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  133795. * @param scale defines the overall scale of the skybox
  133796. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  133797. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  133798. * @returns a new mesh holding the sky box
  133799. */
  133800. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  133801. /**
  133802. * Creates a new environment
  133803. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  133804. * @param options defines the options you can use to configure the environment
  133805. * @returns the new EnvironmentHelper
  133806. */
  133807. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  133808. /**
  133809. * Creates a new VREXperienceHelper
  133810. * @see http://doc.babylonjs.com/how_to/webvr_helper
  133811. * @param webVROptions defines the options used to create the new VREXperienceHelper
  133812. * @returns a new VREXperienceHelper
  133813. */
  133814. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  133815. /**
  133816. * Creates a new WebXRDefaultExperience
  133817. * @see http://doc.babylonjs.com/how_to/webxr
  133818. * @param options experience options
  133819. * @returns a promise for a new WebXRDefaultExperience
  133820. */
  133821. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  133822. }
  133823. }
  133824. declare module BABYLON {
  133825. /**
  133826. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  133827. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  133828. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  133829. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133830. */
  133831. export class VideoDome extends TransformNode {
  133832. /**
  133833. * Define the video source as a Monoscopic panoramic 360 video.
  133834. */
  133835. static readonly MODE_MONOSCOPIC: number;
  133836. /**
  133837. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133838. */
  133839. static readonly MODE_TOPBOTTOM: number;
  133840. /**
  133841. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133842. */
  133843. static readonly MODE_SIDEBYSIDE: number;
  133844. private _halfDome;
  133845. private _useDirectMapping;
  133846. /**
  133847. * The video texture being displayed on the sphere
  133848. */
  133849. protected _videoTexture: VideoTexture;
  133850. /**
  133851. * Gets the video texture being displayed on the sphere
  133852. */
  133853. get videoTexture(): VideoTexture;
  133854. /**
  133855. * The skybox material
  133856. */
  133857. protected _material: BackgroundMaterial;
  133858. /**
  133859. * The surface used for the skybox
  133860. */
  133861. protected _mesh: Mesh;
  133862. /**
  133863. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  133864. */
  133865. private _halfDomeMask;
  133866. /**
  133867. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133868. * Also see the options.resolution property.
  133869. */
  133870. get fovMultiplier(): number;
  133871. set fovMultiplier(value: number);
  133872. private _videoMode;
  133873. /**
  133874. * Gets or set the current video mode for the video. It can be:
  133875. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  133876. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  133877. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  133878. */
  133879. get videoMode(): number;
  133880. set videoMode(value: number);
  133881. /**
  133882. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  133883. *
  133884. */
  133885. get halfDome(): boolean;
  133886. /**
  133887. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  133888. */
  133889. set halfDome(enabled: boolean);
  133890. /**
  133891. * Oberserver used in Stereoscopic VR Mode.
  133892. */
  133893. private _onBeforeCameraRenderObserver;
  133894. /**
  133895. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  133896. * @param name Element's name, child elements will append suffixes for their own names.
  133897. * @param urlsOrVideo defines the url(s) or the video element to use
  133898. * @param options An object containing optional or exposed sub element properties
  133899. */
  133900. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  133901. resolution?: number;
  133902. clickToPlay?: boolean;
  133903. autoPlay?: boolean;
  133904. loop?: boolean;
  133905. size?: number;
  133906. poster?: string;
  133907. faceForward?: boolean;
  133908. useDirectMapping?: boolean;
  133909. halfDomeMode?: boolean;
  133910. }, scene: Scene);
  133911. private _changeVideoMode;
  133912. /**
  133913. * Releases resources associated with this node.
  133914. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133915. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133916. */
  133917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133918. }
  133919. }
  133920. declare module BABYLON {
  133921. /**
  133922. * This class can be used to get instrumentation data from a Babylon engine
  133923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133924. */
  133925. export class EngineInstrumentation implements IDisposable {
  133926. /**
  133927. * Define the instrumented engine.
  133928. */
  133929. engine: Engine;
  133930. private _captureGPUFrameTime;
  133931. private _gpuFrameTimeToken;
  133932. private _gpuFrameTime;
  133933. private _captureShaderCompilationTime;
  133934. private _shaderCompilationTime;
  133935. private _onBeginFrameObserver;
  133936. private _onEndFrameObserver;
  133937. private _onBeforeShaderCompilationObserver;
  133938. private _onAfterShaderCompilationObserver;
  133939. /**
  133940. * Gets the perf counter used for GPU frame time
  133941. */
  133942. get gpuFrameTimeCounter(): PerfCounter;
  133943. /**
  133944. * Gets the GPU frame time capture status
  133945. */
  133946. get captureGPUFrameTime(): boolean;
  133947. /**
  133948. * Enable or disable the GPU frame time capture
  133949. */
  133950. set captureGPUFrameTime(value: boolean);
  133951. /**
  133952. * Gets the perf counter used for shader compilation time
  133953. */
  133954. get shaderCompilationTimeCounter(): PerfCounter;
  133955. /**
  133956. * Gets the shader compilation time capture status
  133957. */
  133958. get captureShaderCompilationTime(): boolean;
  133959. /**
  133960. * Enable or disable the shader compilation time capture
  133961. */
  133962. set captureShaderCompilationTime(value: boolean);
  133963. /**
  133964. * Instantiates a new engine instrumentation.
  133965. * This class can be used to get instrumentation data from a Babylon engine
  133966. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  133967. * @param engine Defines the engine to instrument
  133968. */
  133969. constructor(
  133970. /**
  133971. * Define the instrumented engine.
  133972. */
  133973. engine: Engine);
  133974. /**
  133975. * Dispose and release associated resources.
  133976. */
  133977. dispose(): void;
  133978. }
  133979. }
  133980. declare module BABYLON {
  133981. /**
  133982. * This class can be used to get instrumentation data from a Babylon engine
  133983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  133984. */
  133985. export class SceneInstrumentation implements IDisposable {
  133986. /**
  133987. * Defines the scene to instrument
  133988. */
  133989. scene: Scene;
  133990. private _captureActiveMeshesEvaluationTime;
  133991. private _activeMeshesEvaluationTime;
  133992. private _captureRenderTargetsRenderTime;
  133993. private _renderTargetsRenderTime;
  133994. private _captureFrameTime;
  133995. private _frameTime;
  133996. private _captureRenderTime;
  133997. private _renderTime;
  133998. private _captureInterFrameTime;
  133999. private _interFrameTime;
  134000. private _captureParticlesRenderTime;
  134001. private _particlesRenderTime;
  134002. private _captureSpritesRenderTime;
  134003. private _spritesRenderTime;
  134004. private _capturePhysicsTime;
  134005. private _physicsTime;
  134006. private _captureAnimationsTime;
  134007. private _animationsTime;
  134008. private _captureCameraRenderTime;
  134009. private _cameraRenderTime;
  134010. private _onBeforeActiveMeshesEvaluationObserver;
  134011. private _onAfterActiveMeshesEvaluationObserver;
  134012. private _onBeforeRenderTargetsRenderObserver;
  134013. private _onAfterRenderTargetsRenderObserver;
  134014. private _onAfterRenderObserver;
  134015. private _onBeforeDrawPhaseObserver;
  134016. private _onAfterDrawPhaseObserver;
  134017. private _onBeforeAnimationsObserver;
  134018. private _onBeforeParticlesRenderingObserver;
  134019. private _onAfterParticlesRenderingObserver;
  134020. private _onBeforeSpritesRenderingObserver;
  134021. private _onAfterSpritesRenderingObserver;
  134022. private _onBeforePhysicsObserver;
  134023. private _onAfterPhysicsObserver;
  134024. private _onAfterAnimationsObserver;
  134025. private _onBeforeCameraRenderObserver;
  134026. private _onAfterCameraRenderObserver;
  134027. /**
  134028. * Gets the perf counter used for active meshes evaluation time
  134029. */
  134030. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  134031. /**
  134032. * Gets the active meshes evaluation time capture status
  134033. */
  134034. get captureActiveMeshesEvaluationTime(): boolean;
  134035. /**
  134036. * Enable or disable the active meshes evaluation time capture
  134037. */
  134038. set captureActiveMeshesEvaluationTime(value: boolean);
  134039. /**
  134040. * Gets the perf counter used for render targets render time
  134041. */
  134042. get renderTargetsRenderTimeCounter(): PerfCounter;
  134043. /**
  134044. * Gets the render targets render time capture status
  134045. */
  134046. get captureRenderTargetsRenderTime(): boolean;
  134047. /**
  134048. * Enable or disable the render targets render time capture
  134049. */
  134050. set captureRenderTargetsRenderTime(value: boolean);
  134051. /**
  134052. * Gets the perf counter used for particles render time
  134053. */
  134054. get particlesRenderTimeCounter(): PerfCounter;
  134055. /**
  134056. * Gets the particles render time capture status
  134057. */
  134058. get captureParticlesRenderTime(): boolean;
  134059. /**
  134060. * Enable or disable the particles render time capture
  134061. */
  134062. set captureParticlesRenderTime(value: boolean);
  134063. /**
  134064. * Gets the perf counter used for sprites render time
  134065. */
  134066. get spritesRenderTimeCounter(): PerfCounter;
  134067. /**
  134068. * Gets the sprites render time capture status
  134069. */
  134070. get captureSpritesRenderTime(): boolean;
  134071. /**
  134072. * Enable or disable the sprites render time capture
  134073. */
  134074. set captureSpritesRenderTime(value: boolean);
  134075. /**
  134076. * Gets the perf counter used for physics time
  134077. */
  134078. get physicsTimeCounter(): PerfCounter;
  134079. /**
  134080. * Gets the physics time capture status
  134081. */
  134082. get capturePhysicsTime(): boolean;
  134083. /**
  134084. * Enable or disable the physics time capture
  134085. */
  134086. set capturePhysicsTime(value: boolean);
  134087. /**
  134088. * Gets the perf counter used for animations time
  134089. */
  134090. get animationsTimeCounter(): PerfCounter;
  134091. /**
  134092. * Gets the animations time capture status
  134093. */
  134094. get captureAnimationsTime(): boolean;
  134095. /**
  134096. * Enable or disable the animations time capture
  134097. */
  134098. set captureAnimationsTime(value: boolean);
  134099. /**
  134100. * Gets the perf counter used for frame time capture
  134101. */
  134102. get frameTimeCounter(): PerfCounter;
  134103. /**
  134104. * Gets the frame time capture status
  134105. */
  134106. get captureFrameTime(): boolean;
  134107. /**
  134108. * Enable or disable the frame time capture
  134109. */
  134110. set captureFrameTime(value: boolean);
  134111. /**
  134112. * Gets the perf counter used for inter-frames time capture
  134113. */
  134114. get interFrameTimeCounter(): PerfCounter;
  134115. /**
  134116. * Gets the inter-frames time capture status
  134117. */
  134118. get captureInterFrameTime(): boolean;
  134119. /**
  134120. * Enable or disable the inter-frames time capture
  134121. */
  134122. set captureInterFrameTime(value: boolean);
  134123. /**
  134124. * Gets the perf counter used for render time capture
  134125. */
  134126. get renderTimeCounter(): PerfCounter;
  134127. /**
  134128. * Gets the render time capture status
  134129. */
  134130. get captureRenderTime(): boolean;
  134131. /**
  134132. * Enable or disable the render time capture
  134133. */
  134134. set captureRenderTime(value: boolean);
  134135. /**
  134136. * Gets the perf counter used for camera render time capture
  134137. */
  134138. get cameraRenderTimeCounter(): PerfCounter;
  134139. /**
  134140. * Gets the camera render time capture status
  134141. */
  134142. get captureCameraRenderTime(): boolean;
  134143. /**
  134144. * Enable or disable the camera render time capture
  134145. */
  134146. set captureCameraRenderTime(value: boolean);
  134147. /**
  134148. * Gets the perf counter used for draw calls
  134149. */
  134150. get drawCallsCounter(): PerfCounter;
  134151. /**
  134152. * Instantiates a new scene instrumentation.
  134153. * This class can be used to get instrumentation data from a Babylon engine
  134154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134155. * @param scene Defines the scene to instrument
  134156. */
  134157. constructor(
  134158. /**
  134159. * Defines the scene to instrument
  134160. */
  134161. scene: Scene);
  134162. /**
  134163. * Dispose and release associated resources.
  134164. */
  134165. dispose(): void;
  134166. }
  134167. }
  134168. declare module BABYLON {
  134169. /** @hidden */
  134170. export var glowMapGenerationPixelShader: {
  134171. name: string;
  134172. shader: string;
  134173. };
  134174. }
  134175. declare module BABYLON {
  134176. /** @hidden */
  134177. export var glowMapGenerationVertexShader: {
  134178. name: string;
  134179. shader: string;
  134180. };
  134181. }
  134182. declare module BABYLON {
  134183. /**
  134184. * Effect layer options. This helps customizing the behaviour
  134185. * of the effect layer.
  134186. */
  134187. export interface IEffectLayerOptions {
  134188. /**
  134189. * Multiplication factor apply to the canvas size to compute the render target size
  134190. * used to generated the objects (the smaller the faster).
  134191. */
  134192. mainTextureRatio: number;
  134193. /**
  134194. * Enforces a fixed size texture to ensure effect stability across devices.
  134195. */
  134196. mainTextureFixedSize?: number;
  134197. /**
  134198. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  134199. */
  134200. alphaBlendingMode: number;
  134201. /**
  134202. * The camera attached to the layer.
  134203. */
  134204. camera: Nullable<Camera>;
  134205. /**
  134206. * The rendering group to draw the layer in.
  134207. */
  134208. renderingGroupId: number;
  134209. }
  134210. /**
  134211. * The effect layer Helps adding post process effect blended with the main pass.
  134212. *
  134213. * This can be for instance use to generate glow or higlight effects on the scene.
  134214. *
  134215. * The effect layer class can not be used directly and is intented to inherited from to be
  134216. * customized per effects.
  134217. */
  134218. export abstract class EffectLayer {
  134219. private _vertexBuffers;
  134220. private _indexBuffer;
  134221. private _cachedDefines;
  134222. private _effectLayerMapGenerationEffect;
  134223. private _effectLayerOptions;
  134224. private _mergeEffect;
  134225. protected _scene: Scene;
  134226. protected _engine: Engine;
  134227. protected _maxSize: number;
  134228. protected _mainTextureDesiredSize: ISize;
  134229. protected _mainTexture: RenderTargetTexture;
  134230. protected _shouldRender: boolean;
  134231. protected _postProcesses: PostProcess[];
  134232. protected _textures: BaseTexture[];
  134233. protected _emissiveTextureAndColor: {
  134234. texture: Nullable<BaseTexture>;
  134235. color: Color4;
  134236. };
  134237. /**
  134238. * The name of the layer
  134239. */
  134240. name: string;
  134241. /**
  134242. * The clear color of the texture used to generate the glow map.
  134243. */
  134244. neutralColor: Color4;
  134245. /**
  134246. * Specifies whether the highlight layer is enabled or not.
  134247. */
  134248. isEnabled: boolean;
  134249. /**
  134250. * Gets the camera attached to the layer.
  134251. */
  134252. get camera(): Nullable<Camera>;
  134253. /**
  134254. * Gets the rendering group id the layer should render in.
  134255. */
  134256. get renderingGroupId(): number;
  134257. set renderingGroupId(renderingGroupId: number);
  134258. /**
  134259. * An event triggered when the effect layer has been disposed.
  134260. */
  134261. onDisposeObservable: Observable<EffectLayer>;
  134262. /**
  134263. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  134264. */
  134265. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  134266. /**
  134267. * An event triggered when the generated texture is being merged in the scene.
  134268. */
  134269. onBeforeComposeObservable: Observable<EffectLayer>;
  134270. /**
  134271. * An event triggered when the mesh is rendered into the effect render target.
  134272. */
  134273. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  134274. /**
  134275. * An event triggered after the mesh has been rendered into the effect render target.
  134276. */
  134277. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  134278. /**
  134279. * An event triggered when the generated texture has been merged in the scene.
  134280. */
  134281. onAfterComposeObservable: Observable<EffectLayer>;
  134282. /**
  134283. * An event triggered when the efffect layer changes its size.
  134284. */
  134285. onSizeChangedObservable: Observable<EffectLayer>;
  134286. /** @hidden */
  134287. static _SceneComponentInitialization: (scene: Scene) => void;
  134288. /**
  134289. * Instantiates a new effect Layer and references it in the scene.
  134290. * @param name The name of the layer
  134291. * @param scene The scene to use the layer in
  134292. */
  134293. constructor(
  134294. /** The Friendly of the effect in the scene */
  134295. name: string, scene: Scene);
  134296. /**
  134297. * Get the effect name of the layer.
  134298. * @return The effect name
  134299. */
  134300. abstract getEffectName(): string;
  134301. /**
  134302. * Checks for the readiness of the element composing the layer.
  134303. * @param subMesh the mesh to check for
  134304. * @param useInstances specify whether or not to use instances to render the mesh
  134305. * @return true if ready otherwise, false
  134306. */
  134307. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134308. /**
  134309. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134310. * @returns true if the effect requires stencil during the main canvas render pass.
  134311. */
  134312. abstract needStencil(): boolean;
  134313. /**
  134314. * Create the merge effect. This is the shader use to blit the information back
  134315. * to the main canvas at the end of the scene rendering.
  134316. * @returns The effect containing the shader used to merge the effect on the main canvas
  134317. */
  134318. protected abstract _createMergeEffect(): Effect;
  134319. /**
  134320. * Creates the render target textures and post processes used in the effect layer.
  134321. */
  134322. protected abstract _createTextureAndPostProcesses(): void;
  134323. /**
  134324. * Implementation specific of rendering the generating effect on the main canvas.
  134325. * @param effect The effect used to render through
  134326. */
  134327. protected abstract _internalRender(effect: Effect): void;
  134328. /**
  134329. * Sets the required values for both the emissive texture and and the main color.
  134330. */
  134331. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134332. /**
  134333. * Free any resources and references associated to a mesh.
  134334. * Internal use
  134335. * @param mesh The mesh to free.
  134336. */
  134337. abstract _disposeMesh(mesh: Mesh): void;
  134338. /**
  134339. * Serializes this layer (Glow or Highlight for example)
  134340. * @returns a serialized layer object
  134341. */
  134342. abstract serialize?(): any;
  134343. /**
  134344. * Initializes the effect layer with the required options.
  134345. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  134346. */
  134347. protected _init(options: Partial<IEffectLayerOptions>): void;
  134348. /**
  134349. * Generates the index buffer of the full screen quad blending to the main canvas.
  134350. */
  134351. private _generateIndexBuffer;
  134352. /**
  134353. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  134354. */
  134355. private _generateVertexBuffer;
  134356. /**
  134357. * Sets the main texture desired size which is the closest power of two
  134358. * of the engine canvas size.
  134359. */
  134360. private _setMainTextureSize;
  134361. /**
  134362. * Creates the main texture for the effect layer.
  134363. */
  134364. protected _createMainTexture(): void;
  134365. /**
  134366. * Adds specific effects defines.
  134367. * @param defines The defines to add specifics to.
  134368. */
  134369. protected _addCustomEffectDefines(defines: string[]): void;
  134370. /**
  134371. * Checks for the readiness of the element composing the layer.
  134372. * @param subMesh the mesh to check for
  134373. * @param useInstances specify whether or not to use instances to render the mesh
  134374. * @param emissiveTexture the associated emissive texture used to generate the glow
  134375. * @return true if ready otherwise, false
  134376. */
  134377. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  134378. /**
  134379. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  134380. */
  134381. render(): void;
  134382. /**
  134383. * Determine if a given mesh will be used in the current effect.
  134384. * @param mesh mesh to test
  134385. * @returns true if the mesh will be used
  134386. */
  134387. hasMesh(mesh: AbstractMesh): boolean;
  134388. /**
  134389. * Returns true if the layer contains information to display, otherwise false.
  134390. * @returns true if the glow layer should be rendered
  134391. */
  134392. shouldRender(): boolean;
  134393. /**
  134394. * Returns true if the mesh should render, otherwise false.
  134395. * @param mesh The mesh to render
  134396. * @returns true if it should render otherwise false
  134397. */
  134398. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  134399. /**
  134400. * Returns true if the mesh can be rendered, otherwise false.
  134401. * @param mesh The mesh to render
  134402. * @param material The material used on the mesh
  134403. * @returns true if it can be rendered otherwise false
  134404. */
  134405. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134406. /**
  134407. * Returns true if the mesh should render, otherwise false.
  134408. * @param mesh The mesh to render
  134409. * @returns true if it should render otherwise false
  134410. */
  134411. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  134412. /**
  134413. * Renders the submesh passed in parameter to the generation map.
  134414. */
  134415. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  134416. /**
  134417. * Defines whether the current material of the mesh should be use to render the effect.
  134418. * @param mesh defines the current mesh to render
  134419. */
  134420. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134421. /**
  134422. * Rebuild the required buffers.
  134423. * @hidden Internal use only.
  134424. */
  134425. _rebuild(): void;
  134426. /**
  134427. * Dispose only the render target textures and post process.
  134428. */
  134429. private _disposeTextureAndPostProcesses;
  134430. /**
  134431. * Dispose the highlight layer and free resources.
  134432. */
  134433. dispose(): void;
  134434. /**
  134435. * Gets the class name of the effect layer
  134436. * @returns the string with the class name of the effect layer
  134437. */
  134438. getClassName(): string;
  134439. /**
  134440. * Creates an effect layer from parsed effect layer data
  134441. * @param parsedEffectLayer defines effect layer data
  134442. * @param scene defines the current scene
  134443. * @param rootUrl defines the root URL containing the effect layer information
  134444. * @returns a parsed effect Layer
  134445. */
  134446. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  134447. }
  134448. }
  134449. declare module BABYLON {
  134450. interface AbstractScene {
  134451. /**
  134452. * The list of effect layers (highlights/glow) added to the scene
  134453. * @see http://doc.babylonjs.com/how_to/highlight_layer
  134454. * @see http://doc.babylonjs.com/how_to/glow_layer
  134455. */
  134456. effectLayers: Array<EffectLayer>;
  134457. /**
  134458. * Removes the given effect layer from this scene.
  134459. * @param toRemove defines the effect layer to remove
  134460. * @returns the index of the removed effect layer
  134461. */
  134462. removeEffectLayer(toRemove: EffectLayer): number;
  134463. /**
  134464. * Adds the given effect layer to this scene
  134465. * @param newEffectLayer defines the effect layer to add
  134466. */
  134467. addEffectLayer(newEffectLayer: EffectLayer): void;
  134468. }
  134469. /**
  134470. * Defines the layer scene component responsible to manage any effect layers
  134471. * in a given scene.
  134472. */
  134473. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  134474. /**
  134475. * The component name helpfull to identify the component in the list of scene components.
  134476. */
  134477. readonly name: string;
  134478. /**
  134479. * The scene the component belongs to.
  134480. */
  134481. scene: Scene;
  134482. private _engine;
  134483. private _renderEffects;
  134484. private _needStencil;
  134485. private _previousStencilState;
  134486. /**
  134487. * Creates a new instance of the component for the given scene
  134488. * @param scene Defines the scene to register the component in
  134489. */
  134490. constructor(scene: Scene);
  134491. /**
  134492. * Registers the component in a given scene
  134493. */
  134494. register(): void;
  134495. /**
  134496. * Rebuilds the elements related to this component in case of
  134497. * context lost for instance.
  134498. */
  134499. rebuild(): void;
  134500. /**
  134501. * Serializes the component data to the specified json object
  134502. * @param serializationObject The object to serialize to
  134503. */
  134504. serialize(serializationObject: any): void;
  134505. /**
  134506. * Adds all the elements from the container to the scene
  134507. * @param container the container holding the elements
  134508. */
  134509. addFromContainer(container: AbstractScene): void;
  134510. /**
  134511. * Removes all the elements in the container from the scene
  134512. * @param container contains the elements to remove
  134513. * @param dispose if the removed element should be disposed (default: false)
  134514. */
  134515. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134516. /**
  134517. * Disposes the component and the associated ressources.
  134518. */
  134519. dispose(): void;
  134520. private _isReadyForMesh;
  134521. private _renderMainTexture;
  134522. private _setStencil;
  134523. private _setStencilBack;
  134524. private _draw;
  134525. private _drawCamera;
  134526. private _drawRenderingGroup;
  134527. }
  134528. }
  134529. declare module BABYLON {
  134530. /** @hidden */
  134531. export var glowMapMergePixelShader: {
  134532. name: string;
  134533. shader: string;
  134534. };
  134535. }
  134536. declare module BABYLON {
  134537. /** @hidden */
  134538. export var glowMapMergeVertexShader: {
  134539. name: string;
  134540. shader: string;
  134541. };
  134542. }
  134543. declare module BABYLON {
  134544. interface AbstractScene {
  134545. /**
  134546. * Return a the first highlight layer of the scene with a given name.
  134547. * @param name The name of the highlight layer to look for.
  134548. * @return The highlight layer if found otherwise null.
  134549. */
  134550. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  134551. }
  134552. /**
  134553. * Glow layer options. This helps customizing the behaviour
  134554. * of the glow layer.
  134555. */
  134556. export interface IGlowLayerOptions {
  134557. /**
  134558. * Multiplication factor apply to the canvas size to compute the render target size
  134559. * used to generated the glowing objects (the smaller the faster).
  134560. */
  134561. mainTextureRatio: number;
  134562. /**
  134563. * Enforces a fixed size texture to ensure resize independant blur.
  134564. */
  134565. mainTextureFixedSize?: number;
  134566. /**
  134567. * How big is the kernel of the blur texture.
  134568. */
  134569. blurKernelSize: number;
  134570. /**
  134571. * The camera attached to the layer.
  134572. */
  134573. camera: Nullable<Camera>;
  134574. /**
  134575. * Enable MSAA by chosing the number of samples.
  134576. */
  134577. mainTextureSamples?: number;
  134578. /**
  134579. * The rendering group to draw the layer in.
  134580. */
  134581. renderingGroupId: number;
  134582. }
  134583. /**
  134584. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134585. *
  134586. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134587. *
  134588. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134589. */
  134590. export class GlowLayer extends EffectLayer {
  134591. /**
  134592. * Effect Name of the layer.
  134593. */
  134594. static readonly EffectName: string;
  134595. /**
  134596. * The default blur kernel size used for the glow.
  134597. */
  134598. static DefaultBlurKernelSize: number;
  134599. /**
  134600. * The default texture size ratio used for the glow.
  134601. */
  134602. static DefaultTextureRatio: number;
  134603. /**
  134604. * Sets the kernel size of the blur.
  134605. */
  134606. set blurKernelSize(value: number);
  134607. /**
  134608. * Gets the kernel size of the blur.
  134609. */
  134610. get blurKernelSize(): number;
  134611. /**
  134612. * Sets the glow intensity.
  134613. */
  134614. set intensity(value: number);
  134615. /**
  134616. * Gets the glow intensity.
  134617. */
  134618. get intensity(): number;
  134619. private _options;
  134620. private _intensity;
  134621. private _horizontalBlurPostprocess1;
  134622. private _verticalBlurPostprocess1;
  134623. private _horizontalBlurPostprocess2;
  134624. private _verticalBlurPostprocess2;
  134625. private _blurTexture1;
  134626. private _blurTexture2;
  134627. private _postProcesses1;
  134628. private _postProcesses2;
  134629. private _includedOnlyMeshes;
  134630. private _excludedMeshes;
  134631. private _meshesUsingTheirOwnMaterials;
  134632. /**
  134633. * Callback used to let the user override the color selection on a per mesh basis
  134634. */
  134635. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134636. /**
  134637. * Callback used to let the user override the texture selection on a per mesh basis
  134638. */
  134639. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134640. /**
  134641. * Instantiates a new glow Layer and references it to the scene.
  134642. * @param name The name of the layer
  134643. * @param scene The scene to use the layer in
  134644. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134645. */
  134646. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134647. /**
  134648. * Get the effect name of the layer.
  134649. * @return The effect name
  134650. */
  134651. getEffectName(): string;
  134652. /**
  134653. * Create the merge effect. This is the shader use to blit the information back
  134654. * to the main canvas at the end of the scene rendering.
  134655. */
  134656. protected _createMergeEffect(): Effect;
  134657. /**
  134658. * Creates the render target textures and post processes used in the glow layer.
  134659. */
  134660. protected _createTextureAndPostProcesses(): void;
  134661. /**
  134662. * Checks for the readiness of the element composing the layer.
  134663. * @param subMesh the mesh to check for
  134664. * @param useInstances specify wether or not to use instances to render the mesh
  134665. * @param emissiveTexture the associated emissive texture used to generate the glow
  134666. * @return true if ready otherwise, false
  134667. */
  134668. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134669. /**
  134670. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134671. */
  134672. needStencil(): boolean;
  134673. /**
  134674. * Returns true if the mesh can be rendered, otherwise false.
  134675. * @param mesh The mesh to render
  134676. * @param material The material used on the mesh
  134677. * @returns true if it can be rendered otherwise false
  134678. */
  134679. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134680. /**
  134681. * Implementation specific of rendering the generating effect on the main canvas.
  134682. * @param effect The effect used to render through
  134683. */
  134684. protected _internalRender(effect: Effect): void;
  134685. /**
  134686. * Sets the required values for both the emissive texture and and the main color.
  134687. */
  134688. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134689. /**
  134690. * Returns true if the mesh should render, otherwise false.
  134691. * @param mesh The mesh to render
  134692. * @returns true if it should render otherwise false
  134693. */
  134694. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134695. /**
  134696. * Adds specific effects defines.
  134697. * @param defines The defines to add specifics to.
  134698. */
  134699. protected _addCustomEffectDefines(defines: string[]): void;
  134700. /**
  134701. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  134702. * @param mesh The mesh to exclude from the glow layer
  134703. */
  134704. addExcludedMesh(mesh: Mesh): void;
  134705. /**
  134706. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  134707. * @param mesh The mesh to remove
  134708. */
  134709. removeExcludedMesh(mesh: Mesh): void;
  134710. /**
  134711. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  134712. * @param mesh The mesh to include in the glow layer
  134713. */
  134714. addIncludedOnlyMesh(mesh: Mesh): void;
  134715. /**
  134716. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  134717. * @param mesh The mesh to remove
  134718. */
  134719. removeIncludedOnlyMesh(mesh: Mesh): void;
  134720. /**
  134721. * Determine if a given mesh will be used in the glow layer
  134722. * @param mesh The mesh to test
  134723. * @returns true if the mesh will be highlighted by the current glow layer
  134724. */
  134725. hasMesh(mesh: AbstractMesh): boolean;
  134726. /**
  134727. * Defines whether the current material of the mesh should be use to render the effect.
  134728. * @param mesh defines the current mesh to render
  134729. */
  134730. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134731. /**
  134732. * Add a mesh to be rendered through its own material and not with emissive only.
  134733. * @param mesh The mesh for which we need to use its material
  134734. */
  134735. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  134736. /**
  134737. * Remove a mesh from being rendered through its own material and not with emissive only.
  134738. * @param mesh The mesh for which we need to not use its material
  134739. */
  134740. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  134741. /**
  134742. * Free any resources and references associated to a mesh.
  134743. * Internal use
  134744. * @param mesh The mesh to free.
  134745. * @hidden
  134746. */
  134747. _disposeMesh(mesh: Mesh): void;
  134748. /**
  134749. * Gets the class name of the effect layer
  134750. * @returns the string with the class name of the effect layer
  134751. */
  134752. getClassName(): string;
  134753. /**
  134754. * Serializes this glow layer
  134755. * @returns a serialized glow layer object
  134756. */
  134757. serialize(): any;
  134758. /**
  134759. * Creates a Glow Layer from parsed glow layer data
  134760. * @param parsedGlowLayer defines glow layer data
  134761. * @param scene defines the current scene
  134762. * @param rootUrl defines the root URL containing the glow layer information
  134763. * @returns a parsed Glow Layer
  134764. */
  134765. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  134766. }
  134767. }
  134768. declare module BABYLON {
  134769. /** @hidden */
  134770. export var glowBlurPostProcessPixelShader: {
  134771. name: string;
  134772. shader: string;
  134773. };
  134774. }
  134775. declare module BABYLON {
  134776. interface AbstractScene {
  134777. /**
  134778. * Return a the first highlight layer of the scene with a given name.
  134779. * @param name The name of the highlight layer to look for.
  134780. * @return The highlight layer if found otherwise null.
  134781. */
  134782. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  134783. }
  134784. /**
  134785. * Highlight layer options. This helps customizing the behaviour
  134786. * of the highlight layer.
  134787. */
  134788. export interface IHighlightLayerOptions {
  134789. /**
  134790. * Multiplication factor apply to the canvas size to compute the render target size
  134791. * used to generated the glowing objects (the smaller the faster).
  134792. */
  134793. mainTextureRatio: number;
  134794. /**
  134795. * Enforces a fixed size texture to ensure resize independant blur.
  134796. */
  134797. mainTextureFixedSize?: number;
  134798. /**
  134799. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  134800. * of the picture to blur (the smaller the faster).
  134801. */
  134802. blurTextureSizeRatio: number;
  134803. /**
  134804. * How big in texel of the blur texture is the vertical blur.
  134805. */
  134806. blurVerticalSize: number;
  134807. /**
  134808. * How big in texel of the blur texture is the horizontal blur.
  134809. */
  134810. blurHorizontalSize: number;
  134811. /**
  134812. * Alpha blending mode used to apply the blur. Default is combine.
  134813. */
  134814. alphaBlendingMode: number;
  134815. /**
  134816. * The camera attached to the layer.
  134817. */
  134818. camera: Nullable<Camera>;
  134819. /**
  134820. * Should we display highlight as a solid stroke?
  134821. */
  134822. isStroke?: boolean;
  134823. /**
  134824. * The rendering group to draw the layer in.
  134825. */
  134826. renderingGroupId: number;
  134827. }
  134828. /**
  134829. * The highlight layer Helps adding a glow effect around a mesh.
  134830. *
  134831. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  134832. * glowy meshes to your scene.
  134833. *
  134834. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  134835. */
  134836. export class HighlightLayer extends EffectLayer {
  134837. name: string;
  134838. /**
  134839. * Effect Name of the highlight layer.
  134840. */
  134841. static readonly EffectName: string;
  134842. /**
  134843. * The neutral color used during the preparation of the glow effect.
  134844. * This is black by default as the blend operation is a blend operation.
  134845. */
  134846. static NeutralColor: Color4;
  134847. /**
  134848. * Stencil value used for glowing meshes.
  134849. */
  134850. static GlowingMeshStencilReference: number;
  134851. /**
  134852. * Stencil value used for the other meshes in the scene.
  134853. */
  134854. static NormalMeshStencilReference: number;
  134855. /**
  134856. * Specifies whether or not the inner glow is ACTIVE in the layer.
  134857. */
  134858. innerGlow: boolean;
  134859. /**
  134860. * Specifies whether or not the outer glow is ACTIVE in the layer.
  134861. */
  134862. outerGlow: boolean;
  134863. /**
  134864. * Specifies the horizontal size of the blur.
  134865. */
  134866. set blurHorizontalSize(value: number);
  134867. /**
  134868. * Specifies the vertical size of the blur.
  134869. */
  134870. set blurVerticalSize(value: number);
  134871. /**
  134872. * Gets the horizontal size of the blur.
  134873. */
  134874. get blurHorizontalSize(): number;
  134875. /**
  134876. * Gets the vertical size of the blur.
  134877. */
  134878. get blurVerticalSize(): number;
  134879. /**
  134880. * An event triggered when the highlight layer is being blurred.
  134881. */
  134882. onBeforeBlurObservable: Observable<HighlightLayer>;
  134883. /**
  134884. * An event triggered when the highlight layer has been blurred.
  134885. */
  134886. onAfterBlurObservable: Observable<HighlightLayer>;
  134887. private _instanceGlowingMeshStencilReference;
  134888. private _options;
  134889. private _downSamplePostprocess;
  134890. private _horizontalBlurPostprocess;
  134891. private _verticalBlurPostprocess;
  134892. private _blurTexture;
  134893. private _meshes;
  134894. private _excludedMeshes;
  134895. /**
  134896. * Instantiates a new highlight Layer and references it to the scene..
  134897. * @param name The name of the layer
  134898. * @param scene The scene to use the layer in
  134899. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  134900. */
  134901. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  134902. /**
  134903. * Get the effect name of the layer.
  134904. * @return The effect name
  134905. */
  134906. getEffectName(): string;
  134907. /**
  134908. * Create the merge effect. This is the shader use to blit the information back
  134909. * to the main canvas at the end of the scene rendering.
  134910. */
  134911. protected _createMergeEffect(): Effect;
  134912. /**
  134913. * Creates the render target textures and post processes used in the highlight layer.
  134914. */
  134915. protected _createTextureAndPostProcesses(): void;
  134916. /**
  134917. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  134918. */
  134919. needStencil(): boolean;
  134920. /**
  134921. * Checks for the readiness of the element composing the layer.
  134922. * @param subMesh the mesh to check for
  134923. * @param useInstances specify wether or not to use instances to render the mesh
  134924. * @param emissiveTexture the associated emissive texture used to generate the glow
  134925. * @return true if ready otherwise, false
  134926. */
  134927. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134928. /**
  134929. * Implementation specific of rendering the generating effect on the main canvas.
  134930. * @param effect The effect used to render through
  134931. */
  134932. protected _internalRender(effect: Effect): void;
  134933. /**
  134934. * Returns true if the layer contains information to display, otherwise false.
  134935. */
  134936. shouldRender(): boolean;
  134937. /**
  134938. * Returns true if the mesh should render, otherwise false.
  134939. * @param mesh The mesh to render
  134940. * @returns true if it should render otherwise false
  134941. */
  134942. protected _shouldRenderMesh(mesh: Mesh): boolean;
  134943. /**
  134944. * Adds specific effects defines.
  134945. * @param defines The defines to add specifics to.
  134946. */
  134947. protected _addCustomEffectDefines(defines: string[]): void;
  134948. /**
  134949. * Sets the required values for both the emissive texture and and the main color.
  134950. */
  134951. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134952. /**
  134953. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  134954. * @param mesh The mesh to exclude from the highlight layer
  134955. */
  134956. addExcludedMesh(mesh: Mesh): void;
  134957. /**
  134958. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  134959. * @param mesh The mesh to highlight
  134960. */
  134961. removeExcludedMesh(mesh: Mesh): void;
  134962. /**
  134963. * Determine if a given mesh will be highlighted by the current HighlightLayer
  134964. * @param mesh mesh to test
  134965. * @returns true if the mesh will be highlighted by the current HighlightLayer
  134966. */
  134967. hasMesh(mesh: AbstractMesh): boolean;
  134968. /**
  134969. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  134970. * @param mesh The mesh to highlight
  134971. * @param color The color of the highlight
  134972. * @param glowEmissiveOnly Extract the glow from the emissive texture
  134973. */
  134974. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  134975. /**
  134976. * Remove a mesh from the highlight layer in order to make it stop glowing.
  134977. * @param mesh The mesh to highlight
  134978. */
  134979. removeMesh(mesh: Mesh): void;
  134980. /**
  134981. * Remove all the meshes currently referenced in the highlight layer
  134982. */
  134983. removeAllMeshes(): void;
  134984. /**
  134985. * Force the stencil to the normal expected value for none glowing parts
  134986. */
  134987. private _defaultStencilReference;
  134988. /**
  134989. * Free any resources and references associated to a mesh.
  134990. * Internal use
  134991. * @param mesh The mesh to free.
  134992. * @hidden
  134993. */
  134994. _disposeMesh(mesh: Mesh): void;
  134995. /**
  134996. * Dispose the highlight layer and free resources.
  134997. */
  134998. dispose(): void;
  134999. /**
  135000. * Gets the class name of the effect layer
  135001. * @returns the string with the class name of the effect layer
  135002. */
  135003. getClassName(): string;
  135004. /**
  135005. * Serializes this Highlight layer
  135006. * @returns a serialized Highlight layer object
  135007. */
  135008. serialize(): any;
  135009. /**
  135010. * Creates a Highlight layer from parsed Highlight layer data
  135011. * @param parsedHightlightLayer defines the Highlight layer data
  135012. * @param scene defines the current scene
  135013. * @param rootUrl defines the root URL containing the Highlight layer information
  135014. * @returns a parsed Highlight layer
  135015. */
  135016. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  135017. }
  135018. }
  135019. declare module BABYLON {
  135020. interface AbstractScene {
  135021. /**
  135022. * The list of layers (background and foreground) of the scene
  135023. */
  135024. layers: Array<Layer>;
  135025. }
  135026. /**
  135027. * Defines the layer scene component responsible to manage any layers
  135028. * in a given scene.
  135029. */
  135030. export class LayerSceneComponent implements ISceneComponent {
  135031. /**
  135032. * The component name helpfull to identify the component in the list of scene components.
  135033. */
  135034. readonly name: string;
  135035. /**
  135036. * The scene the component belongs to.
  135037. */
  135038. scene: Scene;
  135039. private _engine;
  135040. /**
  135041. * Creates a new instance of the component for the given scene
  135042. * @param scene Defines the scene to register the component in
  135043. */
  135044. constructor(scene: Scene);
  135045. /**
  135046. * Registers the component in a given scene
  135047. */
  135048. register(): void;
  135049. /**
  135050. * Rebuilds the elements related to this component in case of
  135051. * context lost for instance.
  135052. */
  135053. rebuild(): void;
  135054. /**
  135055. * Disposes the component and the associated ressources.
  135056. */
  135057. dispose(): void;
  135058. private _draw;
  135059. private _drawCameraPredicate;
  135060. private _drawCameraBackground;
  135061. private _drawCameraForeground;
  135062. private _drawRenderTargetPredicate;
  135063. private _drawRenderTargetBackground;
  135064. private _drawRenderTargetForeground;
  135065. /**
  135066. * Adds all the elements from the container to the scene
  135067. * @param container the container holding the elements
  135068. */
  135069. addFromContainer(container: AbstractScene): void;
  135070. /**
  135071. * Removes all the elements in the container from the scene
  135072. * @param container contains the elements to remove
  135073. * @param dispose if the removed element should be disposed (default: false)
  135074. */
  135075. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135076. }
  135077. }
  135078. declare module BABYLON {
  135079. /** @hidden */
  135080. export var layerPixelShader: {
  135081. name: string;
  135082. shader: string;
  135083. };
  135084. }
  135085. declare module BABYLON {
  135086. /** @hidden */
  135087. export var layerVertexShader: {
  135088. name: string;
  135089. shader: string;
  135090. };
  135091. }
  135092. declare module BABYLON {
  135093. /**
  135094. * This represents a full screen 2d layer.
  135095. * This can be useful to display a picture in the background of your scene for instance.
  135096. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135097. */
  135098. export class Layer {
  135099. /**
  135100. * Define the name of the layer.
  135101. */
  135102. name: string;
  135103. /**
  135104. * Define the texture the layer should display.
  135105. */
  135106. texture: Nullable<Texture>;
  135107. /**
  135108. * Is the layer in background or foreground.
  135109. */
  135110. isBackground: boolean;
  135111. /**
  135112. * Define the color of the layer (instead of texture).
  135113. */
  135114. color: Color4;
  135115. /**
  135116. * Define the scale of the layer in order to zoom in out of the texture.
  135117. */
  135118. scale: Vector2;
  135119. /**
  135120. * Define an offset for the layer in order to shift the texture.
  135121. */
  135122. offset: Vector2;
  135123. /**
  135124. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  135125. */
  135126. alphaBlendingMode: number;
  135127. /**
  135128. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  135129. * Alpha test will not mix with the background color in case of transparency.
  135130. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  135131. */
  135132. alphaTest: boolean;
  135133. /**
  135134. * Define a mask to restrict the layer to only some of the scene cameras.
  135135. */
  135136. layerMask: number;
  135137. /**
  135138. * Define the list of render target the layer is visible into.
  135139. */
  135140. renderTargetTextures: RenderTargetTexture[];
  135141. /**
  135142. * Define if the layer is only used in renderTarget or if it also
  135143. * renders in the main frame buffer of the canvas.
  135144. */
  135145. renderOnlyInRenderTargetTextures: boolean;
  135146. private _scene;
  135147. private _vertexBuffers;
  135148. private _indexBuffer;
  135149. private _effect;
  135150. private _previousDefines;
  135151. /**
  135152. * An event triggered when the layer is disposed.
  135153. */
  135154. onDisposeObservable: Observable<Layer>;
  135155. private _onDisposeObserver;
  135156. /**
  135157. * Back compatibility with callback before the onDisposeObservable existed.
  135158. * The set callback will be triggered when the layer has been disposed.
  135159. */
  135160. set onDispose(callback: () => void);
  135161. /**
  135162. * An event triggered before rendering the scene
  135163. */
  135164. onBeforeRenderObservable: Observable<Layer>;
  135165. private _onBeforeRenderObserver;
  135166. /**
  135167. * Back compatibility with callback before the onBeforeRenderObservable existed.
  135168. * The set callback will be triggered just before rendering the layer.
  135169. */
  135170. set onBeforeRender(callback: () => void);
  135171. /**
  135172. * An event triggered after rendering the scene
  135173. */
  135174. onAfterRenderObservable: Observable<Layer>;
  135175. private _onAfterRenderObserver;
  135176. /**
  135177. * Back compatibility with callback before the onAfterRenderObservable existed.
  135178. * The set callback will be triggered just after rendering the layer.
  135179. */
  135180. set onAfterRender(callback: () => void);
  135181. /**
  135182. * Instantiates a new layer.
  135183. * This represents a full screen 2d layer.
  135184. * This can be useful to display a picture in the background of your scene for instance.
  135185. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135186. * @param name Define the name of the layer in the scene
  135187. * @param imgUrl Define the url of the texture to display in the layer
  135188. * @param scene Define the scene the layer belongs to
  135189. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  135190. * @param color Defines a color for the layer
  135191. */
  135192. constructor(
  135193. /**
  135194. * Define the name of the layer.
  135195. */
  135196. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  135197. private _createIndexBuffer;
  135198. /** @hidden */
  135199. _rebuild(): void;
  135200. /**
  135201. * Renders the layer in the scene.
  135202. */
  135203. render(): void;
  135204. /**
  135205. * Disposes and releases the associated ressources.
  135206. */
  135207. dispose(): void;
  135208. }
  135209. }
  135210. declare module BABYLON {
  135211. /** @hidden */
  135212. export var lensFlarePixelShader: {
  135213. name: string;
  135214. shader: string;
  135215. };
  135216. }
  135217. declare module BABYLON {
  135218. /** @hidden */
  135219. export var lensFlareVertexShader: {
  135220. name: string;
  135221. shader: string;
  135222. };
  135223. }
  135224. declare module BABYLON {
  135225. /**
  135226. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135227. * It is usually composed of several `lensFlare`.
  135228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135229. */
  135230. export class LensFlareSystem {
  135231. /**
  135232. * Define the name of the lens flare system
  135233. */
  135234. name: string;
  135235. /**
  135236. * List of lens flares used in this system.
  135237. */
  135238. lensFlares: LensFlare[];
  135239. /**
  135240. * Define a limit from the border the lens flare can be visible.
  135241. */
  135242. borderLimit: number;
  135243. /**
  135244. * Define a viewport border we do not want to see the lens flare in.
  135245. */
  135246. viewportBorder: number;
  135247. /**
  135248. * Define a predicate which could limit the list of meshes able to occlude the effect.
  135249. */
  135250. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135251. /**
  135252. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  135253. */
  135254. layerMask: number;
  135255. /**
  135256. * Define the id of the lens flare system in the scene.
  135257. * (equal to name by default)
  135258. */
  135259. id: string;
  135260. private _scene;
  135261. private _emitter;
  135262. private _vertexBuffers;
  135263. private _indexBuffer;
  135264. private _effect;
  135265. private _positionX;
  135266. private _positionY;
  135267. private _isEnabled;
  135268. /** @hidden */
  135269. static _SceneComponentInitialization: (scene: Scene) => void;
  135270. /**
  135271. * Instantiates a lens flare system.
  135272. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135273. * It is usually composed of several `lensFlare`.
  135274. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135275. * @param name Define the name of the lens flare system in the scene
  135276. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  135277. * @param scene Define the scene the lens flare system belongs to
  135278. */
  135279. constructor(
  135280. /**
  135281. * Define the name of the lens flare system
  135282. */
  135283. name: string, emitter: any, scene: Scene);
  135284. /**
  135285. * Define if the lens flare system is enabled.
  135286. */
  135287. get isEnabled(): boolean;
  135288. set isEnabled(value: boolean);
  135289. /**
  135290. * Get the scene the effects belongs to.
  135291. * @returns the scene holding the lens flare system
  135292. */
  135293. getScene(): Scene;
  135294. /**
  135295. * Get the emitter of the lens flare system.
  135296. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135297. * @returns the emitter of the lens flare system
  135298. */
  135299. getEmitter(): any;
  135300. /**
  135301. * Set the emitter of the lens flare system.
  135302. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135303. * @param newEmitter Define the new emitter of the system
  135304. */
  135305. setEmitter(newEmitter: any): void;
  135306. /**
  135307. * Get the lens flare system emitter position.
  135308. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  135309. * @returns the position
  135310. */
  135311. getEmitterPosition(): Vector3;
  135312. /**
  135313. * @hidden
  135314. */
  135315. computeEffectivePosition(globalViewport: Viewport): boolean;
  135316. /** @hidden */
  135317. _isVisible(): boolean;
  135318. /**
  135319. * @hidden
  135320. */
  135321. render(): boolean;
  135322. /**
  135323. * Dispose and release the lens flare with its associated resources.
  135324. */
  135325. dispose(): void;
  135326. /**
  135327. * Parse a lens flare system from a JSON repressentation
  135328. * @param parsedLensFlareSystem Define the JSON to parse
  135329. * @param scene Define the scene the parsed system should be instantiated in
  135330. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  135331. * @returns the parsed system
  135332. */
  135333. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  135334. /**
  135335. * Serialize the current Lens Flare System into a JSON representation.
  135336. * @returns the serialized JSON
  135337. */
  135338. serialize(): any;
  135339. }
  135340. }
  135341. declare module BABYLON {
  135342. /**
  135343. * This represents one of the lens effect in a `lensFlareSystem`.
  135344. * It controls one of the indiviual texture used in the effect.
  135345. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135346. */
  135347. export class LensFlare {
  135348. /**
  135349. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135350. */
  135351. size: number;
  135352. /**
  135353. * 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.
  135354. */
  135355. position: number;
  135356. /**
  135357. * Define the lens color.
  135358. */
  135359. color: Color3;
  135360. /**
  135361. * Define the lens texture.
  135362. */
  135363. texture: Nullable<Texture>;
  135364. /**
  135365. * Define the alpha mode to render this particular lens.
  135366. */
  135367. alphaMode: number;
  135368. private _system;
  135369. /**
  135370. * Creates a new Lens Flare.
  135371. * This represents one of the lens effect in a `lensFlareSystem`.
  135372. * It controls one of the indiviual texture used in the effect.
  135373. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135374. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  135375. * @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.
  135376. * @param color Define the lens color
  135377. * @param imgUrl Define the lens texture url
  135378. * @param system Define the `lensFlareSystem` this flare is part of
  135379. * @returns The newly created Lens Flare
  135380. */
  135381. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  135382. /**
  135383. * Instantiates a new Lens Flare.
  135384. * This represents one of the lens effect in a `lensFlareSystem`.
  135385. * It controls one of the indiviual texture used in the effect.
  135386. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135387. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  135388. * @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.
  135389. * @param color Define the lens color
  135390. * @param imgUrl Define the lens texture url
  135391. * @param system Define the `lensFlareSystem` this flare is part of
  135392. */
  135393. constructor(
  135394. /**
  135395. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135396. */
  135397. size: number,
  135398. /**
  135399. * 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.
  135400. */
  135401. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  135402. /**
  135403. * Dispose and release the lens flare with its associated resources.
  135404. */
  135405. dispose(): void;
  135406. }
  135407. }
  135408. declare module BABYLON {
  135409. interface AbstractScene {
  135410. /**
  135411. * The list of lens flare system added to the scene
  135412. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135413. */
  135414. lensFlareSystems: Array<LensFlareSystem>;
  135415. /**
  135416. * Removes the given lens flare system from this scene.
  135417. * @param toRemove The lens flare system to remove
  135418. * @returns The index of the removed lens flare system
  135419. */
  135420. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  135421. /**
  135422. * Adds the given lens flare system to this scene
  135423. * @param newLensFlareSystem The lens flare system to add
  135424. */
  135425. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  135426. /**
  135427. * Gets a lens flare system using its name
  135428. * @param name defines the name to look for
  135429. * @returns the lens flare system or null if not found
  135430. */
  135431. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  135432. /**
  135433. * Gets a lens flare system using its id
  135434. * @param id defines the id to look for
  135435. * @returns the lens flare system or null if not found
  135436. */
  135437. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  135438. }
  135439. /**
  135440. * Defines the lens flare scene component responsible to manage any lens flares
  135441. * in a given scene.
  135442. */
  135443. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  135444. /**
  135445. * The component name helpfull to identify the component in the list of scene components.
  135446. */
  135447. readonly name: string;
  135448. /**
  135449. * The scene the component belongs to.
  135450. */
  135451. scene: Scene;
  135452. /**
  135453. * Creates a new instance of the component for the given scene
  135454. * @param scene Defines the scene to register the component in
  135455. */
  135456. constructor(scene: Scene);
  135457. /**
  135458. * Registers the component in a given scene
  135459. */
  135460. register(): void;
  135461. /**
  135462. * Rebuilds the elements related to this component in case of
  135463. * context lost for instance.
  135464. */
  135465. rebuild(): void;
  135466. /**
  135467. * Adds all the elements from the container to the scene
  135468. * @param container the container holding the elements
  135469. */
  135470. addFromContainer(container: AbstractScene): void;
  135471. /**
  135472. * Removes all the elements in the container from the scene
  135473. * @param container contains the elements to remove
  135474. * @param dispose if the removed element should be disposed (default: false)
  135475. */
  135476. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135477. /**
  135478. * Serializes the component data to the specified json object
  135479. * @param serializationObject The object to serialize to
  135480. */
  135481. serialize(serializationObject: any): void;
  135482. /**
  135483. * Disposes the component and the associated ressources.
  135484. */
  135485. dispose(): void;
  135486. private _draw;
  135487. }
  135488. }
  135489. declare module BABYLON {
  135490. /** @hidden */
  135491. export var depthPixelShader: {
  135492. name: string;
  135493. shader: string;
  135494. };
  135495. }
  135496. declare module BABYLON {
  135497. /** @hidden */
  135498. export var depthVertexShader: {
  135499. name: string;
  135500. shader: string;
  135501. };
  135502. }
  135503. declare module BABYLON {
  135504. /**
  135505. * This represents a depth renderer in Babylon.
  135506. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135507. */
  135508. export class DepthRenderer {
  135509. private _scene;
  135510. private _depthMap;
  135511. private _effect;
  135512. private readonly _storeNonLinearDepth;
  135513. private readonly _clearColor;
  135514. /** Get if the depth renderer is using packed depth or not */
  135515. readonly isPacked: boolean;
  135516. private _cachedDefines;
  135517. private _camera;
  135518. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  135519. enabled: boolean;
  135520. /**
  135521. * Specifiess that the depth renderer will only be used within
  135522. * the camera it is created for.
  135523. * This can help forcing its rendering during the camera processing.
  135524. */
  135525. useOnlyInActiveCamera: boolean;
  135526. /** @hidden */
  135527. static _SceneComponentInitialization: (scene: Scene) => void;
  135528. /**
  135529. * Instantiates a depth renderer
  135530. * @param scene The scene the renderer belongs to
  135531. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135532. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135533. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135534. */
  135535. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135536. /**
  135537. * Creates the depth rendering effect and checks if the effect is ready.
  135538. * @param subMesh The submesh to be used to render the depth map of
  135539. * @param useInstances If multiple world instances should be used
  135540. * @returns if the depth renderer is ready to render the depth map
  135541. */
  135542. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135543. /**
  135544. * Gets the texture which the depth map will be written to.
  135545. * @returns The depth map texture
  135546. */
  135547. getDepthMap(): RenderTargetTexture;
  135548. /**
  135549. * Disposes of the depth renderer.
  135550. */
  135551. dispose(): void;
  135552. }
  135553. }
  135554. declare module BABYLON {
  135555. /** @hidden */
  135556. export var minmaxReduxPixelShader: {
  135557. name: string;
  135558. shader: string;
  135559. };
  135560. }
  135561. declare module BABYLON {
  135562. /**
  135563. * This class computes a min/max reduction from a texture: it means it computes the minimum
  135564. * and maximum values from all values of the texture.
  135565. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  135566. * The source values are read from the red channel of the texture.
  135567. */
  135568. export class MinMaxReducer {
  135569. /**
  135570. * Observable triggered when the computation has been performed
  135571. */
  135572. onAfterReductionPerformed: Observable<{
  135573. min: number;
  135574. max: number;
  135575. }>;
  135576. protected _camera: Camera;
  135577. protected _sourceTexture: Nullable<RenderTargetTexture>;
  135578. protected _reductionSteps: Nullable<Array<PostProcess>>;
  135579. protected _postProcessManager: PostProcessManager;
  135580. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  135581. protected _forceFullscreenViewport: boolean;
  135582. /**
  135583. * Creates a min/max reducer
  135584. * @param camera The camera to use for the post processes
  135585. */
  135586. constructor(camera: Camera);
  135587. /**
  135588. * Gets the texture used to read the values from.
  135589. */
  135590. get sourceTexture(): Nullable<RenderTargetTexture>;
  135591. /**
  135592. * Sets the source texture to read the values from.
  135593. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135594. * because in such textures '1' value must not be taken into account to compute the maximum
  135595. * as this value is used to clear the texture.
  135596. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135597. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135598. * @param depthRedux Indicates if the texture is a depth texture or not
  135599. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135600. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135601. */
  135602. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135603. /**
  135604. * Defines the refresh rate of the computation.
  135605. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135606. */
  135607. get refreshRate(): number;
  135608. set refreshRate(value: number);
  135609. protected _activated: boolean;
  135610. /**
  135611. * Gets the activation status of the reducer
  135612. */
  135613. get activated(): boolean;
  135614. /**
  135615. * Activates the reduction computation.
  135616. * When activated, the observers registered in onAfterReductionPerformed are
  135617. * called after the compuation is performed
  135618. */
  135619. activate(): void;
  135620. /**
  135621. * Deactivates the reduction computation.
  135622. */
  135623. deactivate(): void;
  135624. /**
  135625. * Disposes the min/max reducer
  135626. * @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.
  135627. */
  135628. dispose(disposeAll?: boolean): void;
  135629. }
  135630. }
  135631. declare module BABYLON {
  135632. /**
  135633. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135634. */
  135635. export class DepthReducer extends MinMaxReducer {
  135636. private _depthRenderer;
  135637. private _depthRendererId;
  135638. /**
  135639. * Gets the depth renderer used for the computation.
  135640. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135641. */
  135642. get depthRenderer(): Nullable<DepthRenderer>;
  135643. /**
  135644. * Creates a depth reducer
  135645. * @param camera The camera used to render the depth texture
  135646. */
  135647. constructor(camera: Camera);
  135648. /**
  135649. * Sets the depth renderer to use to generate the depth map
  135650. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  135651. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  135652. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135653. */
  135654. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  135655. /** @hidden */
  135656. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135657. /**
  135658. * Activates the reduction computation.
  135659. * When activated, the observers registered in onAfterReductionPerformed are
  135660. * called after the compuation is performed
  135661. */
  135662. activate(): void;
  135663. /**
  135664. * Deactivates the reduction computation.
  135665. */
  135666. deactivate(): void;
  135667. /**
  135668. * Disposes the depth reducer
  135669. * @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.
  135670. */
  135671. dispose(disposeAll?: boolean): void;
  135672. }
  135673. }
  135674. declare module BABYLON {
  135675. /**
  135676. * A CSM implementation allowing casting shadows on large scenes.
  135677. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135678. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  135679. */
  135680. export class CascadedShadowGenerator extends ShadowGenerator {
  135681. private static readonly frustumCornersNDCSpace;
  135682. /**
  135683. * Name of the CSM class
  135684. */
  135685. static CLASSNAME: string;
  135686. /**
  135687. * Defines the default number of cascades used by the CSM.
  135688. */
  135689. static readonly DEFAULT_CASCADES_COUNT: number;
  135690. /**
  135691. * Defines the minimum number of cascades used by the CSM.
  135692. */
  135693. static readonly MIN_CASCADES_COUNT: number;
  135694. /**
  135695. * Defines the maximum number of cascades used by the CSM.
  135696. */
  135697. static readonly MAX_CASCADES_COUNT: number;
  135698. protected _validateFilter(filter: number): number;
  135699. /**
  135700. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  135701. */
  135702. penumbraDarkness: number;
  135703. private _numCascades;
  135704. /**
  135705. * Gets or set the number of cascades used by the CSM.
  135706. */
  135707. get numCascades(): number;
  135708. set numCascades(value: number);
  135709. /**
  135710. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  135711. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  135712. */
  135713. stabilizeCascades: boolean;
  135714. private _freezeShadowCastersBoundingInfo;
  135715. private _freezeShadowCastersBoundingInfoObservable;
  135716. /**
  135717. * Enables or disables the shadow casters bounding info computation.
  135718. * If your shadow casters don't move, you can disable this feature.
  135719. * If it is enabled, the bounding box computation is done every frame.
  135720. */
  135721. get freezeShadowCastersBoundingInfo(): boolean;
  135722. set freezeShadowCastersBoundingInfo(freeze: boolean);
  135723. private _scbiMin;
  135724. private _scbiMax;
  135725. protected _computeShadowCastersBoundingInfo(): void;
  135726. protected _shadowCastersBoundingInfo: BoundingInfo;
  135727. /**
  135728. * Gets or sets the shadow casters bounding info.
  135729. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  135730. * so that the system won't overwrite the bounds you provide
  135731. */
  135732. get shadowCastersBoundingInfo(): BoundingInfo;
  135733. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  135734. protected _breaksAreDirty: boolean;
  135735. protected _minDistance: number;
  135736. protected _maxDistance: number;
  135737. /**
  135738. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  135739. *
  135740. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  135741. * If you don't know these values, simply leave them to their defaults and don't call this function.
  135742. * @param min minimal distance for the breaks (default to 0.)
  135743. * @param max maximal distance for the breaks (default to 1.)
  135744. */
  135745. setMinMaxDistance(min: number, max: number): void;
  135746. /** Gets the minimal distance used in the cascade break computation */
  135747. get minDistance(): number;
  135748. /** Gets the maximal distance used in the cascade break computation */
  135749. get maxDistance(): number;
  135750. /**
  135751. * Gets the class name of that object
  135752. * @returns "CascadedShadowGenerator"
  135753. */
  135754. getClassName(): string;
  135755. private _cascadeMinExtents;
  135756. private _cascadeMaxExtents;
  135757. /**
  135758. * Gets a cascade minimum extents
  135759. * @param cascadeIndex index of the cascade
  135760. * @returns the minimum cascade extents
  135761. */
  135762. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  135763. /**
  135764. * Gets a cascade maximum extents
  135765. * @param cascadeIndex index of the cascade
  135766. * @returns the maximum cascade extents
  135767. */
  135768. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  135769. private _cascades;
  135770. private _currentLayer;
  135771. private _viewSpaceFrustumsZ;
  135772. private _viewMatrices;
  135773. private _projectionMatrices;
  135774. private _transformMatrices;
  135775. private _transformMatricesAsArray;
  135776. private _frustumLengths;
  135777. private _lightSizeUVCorrection;
  135778. private _depthCorrection;
  135779. private _frustumCornersWorldSpace;
  135780. private _frustumCenter;
  135781. private _shadowCameraPos;
  135782. private _shadowMaxZ;
  135783. /**
  135784. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  135785. * It defaults to camera.maxZ
  135786. */
  135787. get shadowMaxZ(): number;
  135788. /**
  135789. * Sets the shadow max z distance.
  135790. */
  135791. set shadowMaxZ(value: number);
  135792. protected _debug: boolean;
  135793. /**
  135794. * Gets or sets the debug flag.
  135795. * When enabled, the cascades are materialized by different colors on the screen.
  135796. */
  135797. get debug(): boolean;
  135798. set debug(dbg: boolean);
  135799. private _depthClamp;
  135800. /**
  135801. * Gets or sets the depth clamping value.
  135802. *
  135803. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  135804. * to account for the shadow casters far away.
  135805. *
  135806. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  135807. */
  135808. get depthClamp(): boolean;
  135809. set depthClamp(value: boolean);
  135810. private _cascadeBlendPercentage;
  135811. /**
  135812. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  135813. * It defaults to 0.1 (10% blending).
  135814. */
  135815. get cascadeBlendPercentage(): number;
  135816. set cascadeBlendPercentage(value: number);
  135817. private _lambda;
  135818. /**
  135819. * Gets or set the lambda parameter.
  135820. * This parameter is used to split the camera frustum and create the cascades.
  135821. * 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.
  135822. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  135823. */
  135824. get lambda(): number;
  135825. set lambda(value: number);
  135826. /**
  135827. * Gets the view matrix corresponding to a given cascade
  135828. * @param cascadeNum cascade to retrieve the view matrix from
  135829. * @returns the cascade view matrix
  135830. */
  135831. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  135832. /**
  135833. * Gets the projection matrix corresponding to a given cascade
  135834. * @param cascadeNum cascade to retrieve the projection matrix from
  135835. * @returns the cascade projection matrix
  135836. */
  135837. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  135838. /**
  135839. * Gets the transformation matrix corresponding to a given cascade
  135840. * @param cascadeNum cascade to retrieve the transformation matrix from
  135841. * @returns the cascade transformation matrix
  135842. */
  135843. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  135844. private _depthRenderer;
  135845. /**
  135846. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  135847. *
  135848. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  135849. *
  135850. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  135851. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  135852. * @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
  135853. */
  135854. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  135855. private _depthReducer;
  135856. private _autoCalcDepthBounds;
  135857. /**
  135858. * Gets or sets the autoCalcDepthBounds property.
  135859. *
  135860. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  135861. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  135862. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  135863. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  135864. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  135865. */
  135866. get autoCalcDepthBounds(): boolean;
  135867. set autoCalcDepthBounds(value: boolean);
  135868. /**
  135869. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  135870. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135871. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  135872. * for setting the refresh rate on the renderer yourself!
  135873. */
  135874. get autoCalcDepthBoundsRefreshRate(): number;
  135875. set autoCalcDepthBoundsRefreshRate(value: number);
  135876. /**
  135877. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  135878. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  135879. * you change the camera near/far planes!
  135880. */
  135881. splitFrustum(): void;
  135882. private _splitFrustum;
  135883. private _computeMatrices;
  135884. private _computeFrustumInWorldSpace;
  135885. private _computeCascadeFrustum;
  135886. /**
  135887. * Support test.
  135888. */
  135889. static get IsSupported(): boolean;
  135890. /** @hidden */
  135891. static _SceneComponentInitialization: (scene: Scene) => void;
  135892. /**
  135893. * Creates a Cascaded Shadow Generator object.
  135894. * A ShadowGenerator is the required tool to use the shadows.
  135895. * Each directional light casting shadows needs to use its own ShadowGenerator.
  135896. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  135897. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  135898. * @param light The directional light object generating the shadows.
  135899. * @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.
  135900. */
  135901. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  135902. protected _initializeGenerator(): void;
  135903. protected _createTargetRenderTexture(): void;
  135904. protected _initializeShadowMap(): void;
  135905. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  135906. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  135907. /**
  135908. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  135909. * @param defines Defines of the material we want to update
  135910. * @param lightIndex Index of the light in the enabled light list of the material
  135911. */
  135912. prepareDefines(defines: any, lightIndex: number): void;
  135913. /**
  135914. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  135915. * defined in the generator but impacting the effect).
  135916. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  135917. * @param effect The effect we are binfing the information for
  135918. */
  135919. bindShadowLight(lightIndex: string, effect: Effect): void;
  135920. /**
  135921. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  135922. * (eq to view projection * shadow projection matrices)
  135923. * @returns The transform matrix used to create the shadow map
  135924. */
  135925. getTransformMatrix(): Matrix;
  135926. /**
  135927. * Disposes the ShadowGenerator.
  135928. * Returns nothing.
  135929. */
  135930. dispose(): void;
  135931. /**
  135932. * Serializes the shadow generator setup to a json object.
  135933. * @returns The serialized JSON object
  135934. */
  135935. serialize(): any;
  135936. /**
  135937. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  135938. * @param parsedShadowGenerator The JSON object to parse
  135939. * @param scene The scene to create the shadow map for
  135940. * @returns The parsed shadow generator
  135941. */
  135942. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  135943. }
  135944. }
  135945. declare module BABYLON {
  135946. /**
  135947. * Defines the shadow generator component responsible to manage any shadow generators
  135948. * in a given scene.
  135949. */
  135950. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  135951. /**
  135952. * The component name helpfull to identify the component in the list of scene components.
  135953. */
  135954. readonly name: string;
  135955. /**
  135956. * The scene the component belongs to.
  135957. */
  135958. scene: Scene;
  135959. /**
  135960. * Creates a new instance of the component for the given scene
  135961. * @param scene Defines the scene to register the component in
  135962. */
  135963. constructor(scene: Scene);
  135964. /**
  135965. * Registers the component in a given scene
  135966. */
  135967. register(): void;
  135968. /**
  135969. * Rebuilds the elements related to this component in case of
  135970. * context lost for instance.
  135971. */
  135972. rebuild(): void;
  135973. /**
  135974. * Serializes the component data to the specified json object
  135975. * @param serializationObject The object to serialize to
  135976. */
  135977. serialize(serializationObject: any): void;
  135978. /**
  135979. * Adds all the elements from the container to the scene
  135980. * @param container the container holding the elements
  135981. */
  135982. addFromContainer(container: AbstractScene): void;
  135983. /**
  135984. * Removes all the elements in the container from the scene
  135985. * @param container contains the elements to remove
  135986. * @param dispose if the removed element should be disposed (default: false)
  135987. */
  135988. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135989. /**
  135990. * Rebuilds the elements related to this component in case of
  135991. * context lost for instance.
  135992. */
  135993. dispose(): void;
  135994. private _gatherRenderTargets;
  135995. }
  135996. }
  135997. declare module BABYLON {
  135998. /**
  135999. * A point light is a light defined by an unique point in world space.
  136000. * The light is emitted in every direction from this point.
  136001. * A good example of a point light is a standard light bulb.
  136002. * Documentation: https://doc.babylonjs.com/babylon101/lights
  136003. */
  136004. export class PointLight extends ShadowLight {
  136005. private _shadowAngle;
  136006. /**
  136007. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136008. * This specifies what angle the shadow will use to be created.
  136009. *
  136010. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136011. */
  136012. get shadowAngle(): number;
  136013. /**
  136014. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136015. * This specifies what angle the shadow will use to be created.
  136016. *
  136017. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136018. */
  136019. set shadowAngle(value: number);
  136020. /**
  136021. * Gets the direction if it has been set.
  136022. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136023. */
  136024. get direction(): Vector3;
  136025. /**
  136026. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136027. */
  136028. set direction(value: Vector3);
  136029. /**
  136030. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  136031. * A PointLight emits the light in every direction.
  136032. * It can cast shadows.
  136033. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  136034. * ```javascript
  136035. * var pointLight = new PointLight("pl", camera.position, scene);
  136036. * ```
  136037. * Documentation : https://doc.babylonjs.com/babylon101/lights
  136038. * @param name The light friendly name
  136039. * @param position The position of the point light in the scene
  136040. * @param scene The scene the lights belongs to
  136041. */
  136042. constructor(name: string, position: Vector3, scene: Scene);
  136043. /**
  136044. * Returns the string "PointLight"
  136045. * @returns the class name
  136046. */
  136047. getClassName(): string;
  136048. /**
  136049. * Returns the integer 0.
  136050. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  136051. */
  136052. getTypeID(): number;
  136053. /**
  136054. * Specifies wether or not the shadowmap should be a cube texture.
  136055. * @returns true if the shadowmap needs to be a cube texture.
  136056. */
  136057. needCube(): boolean;
  136058. /**
  136059. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  136060. * @param faceIndex The index of the face we are computed the direction to generate shadow
  136061. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  136062. */
  136063. getShadowDirection(faceIndex?: number): Vector3;
  136064. /**
  136065. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  136066. * - fov = PI / 2
  136067. * - aspect ratio : 1.0
  136068. * - z-near and far equal to the active camera minZ and maxZ.
  136069. * Returns the PointLight.
  136070. */
  136071. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  136072. protected _buildUniformLayout(): void;
  136073. /**
  136074. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  136075. * @param effect The effect to update
  136076. * @param lightIndex The index of the light in the effect to update
  136077. * @returns The point light
  136078. */
  136079. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  136080. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  136081. /**
  136082. * Prepares the list of defines specific to the light type.
  136083. * @param defines the list of defines
  136084. * @param lightIndex defines the index of the light for the effect
  136085. */
  136086. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  136087. }
  136088. }
  136089. declare module BABYLON {
  136090. /**
  136091. * Header information of HDR texture files.
  136092. */
  136093. export interface HDRInfo {
  136094. /**
  136095. * The height of the texture in pixels.
  136096. */
  136097. height: number;
  136098. /**
  136099. * The width of the texture in pixels.
  136100. */
  136101. width: number;
  136102. /**
  136103. * The index of the beginning of the data in the binary file.
  136104. */
  136105. dataPosition: number;
  136106. }
  136107. /**
  136108. * This groups tools to convert HDR texture to native colors array.
  136109. */
  136110. export class HDRTools {
  136111. private static Ldexp;
  136112. private static Rgbe2float;
  136113. private static readStringLine;
  136114. /**
  136115. * Reads header information from an RGBE texture stored in a native array.
  136116. * More information on this format are available here:
  136117. * https://en.wikipedia.org/wiki/RGBE_image_format
  136118. *
  136119. * @param uint8array The binary file stored in native array.
  136120. * @return The header information.
  136121. */
  136122. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  136123. /**
  136124. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  136125. * This RGBE texture needs to store the information as a panorama.
  136126. *
  136127. * More information on this format are available here:
  136128. * https://en.wikipedia.org/wiki/RGBE_image_format
  136129. *
  136130. * @param buffer The binary file stored in an array buffer.
  136131. * @param size The expected size of the extracted cubemap.
  136132. * @return The Cube Map information.
  136133. */
  136134. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  136135. /**
  136136. * Returns the pixels data extracted from an RGBE texture.
  136137. * This pixels will be stored left to right up to down in the R G B order in one array.
  136138. *
  136139. * More information on this format are available here:
  136140. * https://en.wikipedia.org/wiki/RGBE_image_format
  136141. *
  136142. * @param uint8array The binary file stored in an array buffer.
  136143. * @param hdrInfo The header information of the file.
  136144. * @return The pixels data in RGB right to left up to down order.
  136145. */
  136146. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  136147. private static RGBE_ReadPixels_RLE;
  136148. }
  136149. }
  136150. declare module BABYLON {
  136151. /**
  136152. * Effect Render Options
  136153. */
  136154. export interface IEffectRendererOptions {
  136155. /**
  136156. * Defines the vertices positions.
  136157. */
  136158. positions?: number[];
  136159. /**
  136160. * Defines the indices.
  136161. */
  136162. indices?: number[];
  136163. }
  136164. /**
  136165. * Helper class to render one or more effects.
  136166. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  136167. */
  136168. export class EffectRenderer {
  136169. private engine;
  136170. private static _DefaultOptions;
  136171. private _vertexBuffers;
  136172. private _indexBuffer;
  136173. private _fullscreenViewport;
  136174. /**
  136175. * Creates an effect renderer
  136176. * @param engine the engine to use for rendering
  136177. * @param options defines the options of the effect renderer
  136178. */
  136179. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  136180. /**
  136181. * Sets the current viewport in normalized coordinates 0-1
  136182. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  136183. */
  136184. setViewport(viewport?: Viewport): void;
  136185. /**
  136186. * Binds the embedded attributes buffer to the effect.
  136187. * @param effect Defines the effect to bind the attributes for
  136188. */
  136189. bindBuffers(effect: Effect): void;
  136190. /**
  136191. * Sets the current effect wrapper to use during draw.
  136192. * The effect needs to be ready before calling this api.
  136193. * This also sets the default full screen position attribute.
  136194. * @param effectWrapper Defines the effect to draw with
  136195. */
  136196. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  136197. /**
  136198. * Restores engine states
  136199. */
  136200. restoreStates(): void;
  136201. /**
  136202. * Draws a full screen quad.
  136203. */
  136204. draw(): void;
  136205. private isRenderTargetTexture;
  136206. /**
  136207. * renders one or more effects to a specified texture
  136208. * @param effectWrapper the effect to renderer
  136209. * @param outputTexture texture to draw to, if null it will render to the screen.
  136210. */
  136211. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  136212. /**
  136213. * Disposes of the effect renderer
  136214. */
  136215. dispose(): void;
  136216. }
  136217. /**
  136218. * Options to create an EffectWrapper
  136219. */
  136220. interface EffectWrapperCreationOptions {
  136221. /**
  136222. * Engine to use to create the effect
  136223. */
  136224. engine: ThinEngine;
  136225. /**
  136226. * Fragment shader for the effect
  136227. */
  136228. fragmentShader: string;
  136229. /**
  136230. * Use the shader store instead of direct source code
  136231. */
  136232. useShaderStore?: boolean;
  136233. /**
  136234. * Vertex shader for the effect
  136235. */
  136236. vertexShader?: string;
  136237. /**
  136238. * Attributes to use in the shader
  136239. */
  136240. attributeNames?: Array<string>;
  136241. /**
  136242. * Uniforms to use in the shader
  136243. */
  136244. uniformNames?: Array<string>;
  136245. /**
  136246. * Texture sampler names to use in the shader
  136247. */
  136248. samplerNames?: Array<string>;
  136249. /**
  136250. * Defines to use in the shader
  136251. */
  136252. defines?: Array<string>;
  136253. /**
  136254. * Callback when effect is compiled
  136255. */
  136256. onCompiled?: Nullable<(effect: Effect) => void>;
  136257. /**
  136258. * The friendly name of the effect displayed in Spector.
  136259. */
  136260. name?: string;
  136261. }
  136262. /**
  136263. * Wraps an effect to be used for rendering
  136264. */
  136265. export class EffectWrapper {
  136266. /**
  136267. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  136268. */
  136269. onApplyObservable: Observable<{}>;
  136270. /**
  136271. * The underlying effect
  136272. */
  136273. effect: Effect;
  136274. /**
  136275. * Creates an effect to be renderer
  136276. * @param creationOptions options to create the effect
  136277. */
  136278. constructor(creationOptions: EffectWrapperCreationOptions);
  136279. /**
  136280. * Disposes of the effect wrapper
  136281. */
  136282. dispose(): void;
  136283. }
  136284. }
  136285. declare module BABYLON {
  136286. /** @hidden */
  136287. export var hdrFilteringVertexShader: {
  136288. name: string;
  136289. shader: string;
  136290. };
  136291. }
  136292. declare module BABYLON {
  136293. /** @hidden */
  136294. export var hdrFilteringPixelShader: {
  136295. name: string;
  136296. shader: string;
  136297. };
  136298. }
  136299. declare module BABYLON {
  136300. /**
  136301. * Options for texture filtering
  136302. */
  136303. interface IHDRFilteringOptions {
  136304. /**
  136305. * Scales pixel intensity for the input HDR map.
  136306. */
  136307. hdrScale?: number;
  136308. /**
  136309. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  136310. */
  136311. quality?: number;
  136312. }
  136313. /**
  136314. * Filters HDR maps to get correct renderings of PBR reflections
  136315. */
  136316. export class HDRFiltering {
  136317. private _engine;
  136318. private _effectRenderer;
  136319. private _effectWrapper;
  136320. private _lodGenerationOffset;
  136321. private _lodGenerationScale;
  136322. /**
  136323. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  136324. * you care about baking speed.
  136325. */
  136326. quality: number;
  136327. /**
  136328. * Scales pixel intensity for the input HDR map.
  136329. */
  136330. hdrScale: number;
  136331. /**
  136332. * Instantiates HDR filter for reflection maps
  136333. *
  136334. * @param engine Thin engine
  136335. * @param options Options
  136336. */
  136337. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  136338. private _createRenderTarget;
  136339. private _prefilterInternal;
  136340. private _createEffect;
  136341. /**
  136342. * Get a value indicating if the filter is ready to be used
  136343. * @param texture Texture to filter
  136344. * @returns true if the filter is ready
  136345. */
  136346. isReady(texture: BaseTexture): boolean;
  136347. /**
  136348. * Prefilters a cube texture to have mipmap levels representing roughness values.
  136349. * Prefiltering will be invoked at the end of next rendering pass.
  136350. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  136351. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  136352. * @param texture Texture to filter
  136353. * @param onFinished Callback when filtering is done
  136354. * @return Promise called when prefiltering is done
  136355. */
  136356. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  136357. }
  136358. }
  136359. declare module BABYLON {
  136360. /**
  136361. * This represents a texture coming from an HDR input.
  136362. *
  136363. * The only supported format is currently panorama picture stored in RGBE format.
  136364. * Example of such files can be found on HDRLib: http://hdrlib.com/
  136365. */
  136366. export class HDRCubeTexture extends BaseTexture {
  136367. private static _facesMapping;
  136368. private _generateHarmonics;
  136369. private _noMipmap;
  136370. private _prefilterOnLoad;
  136371. private _textureMatrix;
  136372. private _size;
  136373. private _onLoad;
  136374. private _onError;
  136375. /**
  136376. * The texture URL.
  136377. */
  136378. url: string;
  136379. /**
  136380. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  136381. */
  136382. coordinatesMode: number;
  136383. protected _isBlocking: boolean;
  136384. /**
  136385. * Sets wether or not the texture is blocking during loading.
  136386. */
  136387. set isBlocking(value: boolean);
  136388. /**
  136389. * Gets wether or not the texture is blocking during loading.
  136390. */
  136391. get isBlocking(): boolean;
  136392. protected _rotationY: number;
  136393. /**
  136394. * Sets texture matrix rotation angle around Y axis in radians.
  136395. */
  136396. set rotationY(value: number);
  136397. /**
  136398. * Gets texture matrix rotation angle around Y axis radians.
  136399. */
  136400. get rotationY(): number;
  136401. /**
  136402. * Gets or sets the center of the bounding box associated with the cube texture
  136403. * It must define where the camera used to render the texture was set
  136404. */
  136405. boundingBoxPosition: Vector3;
  136406. private _boundingBoxSize;
  136407. /**
  136408. * Gets or sets the size of the bounding box associated with the cube texture
  136409. * When defined, the cubemap will switch to local mode
  136410. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  136411. * @example https://www.babylonjs-playground.com/#RNASML
  136412. */
  136413. set boundingBoxSize(value: Vector3);
  136414. get boundingBoxSize(): Vector3;
  136415. /**
  136416. * Instantiates an HDRTexture from the following parameters.
  136417. *
  136418. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  136419. * @param sceneOrEngine The scene or engine the texture will be used in
  136420. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136421. * @param noMipmap Forces to not generate the mipmap if true
  136422. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  136423. * @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)
  136424. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  136425. */
  136426. 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>);
  136427. /**
  136428. * Get the current class name of the texture useful for serialization or dynamic coding.
  136429. * @returns "HDRCubeTexture"
  136430. */
  136431. getClassName(): string;
  136432. /**
  136433. * Occurs when the file is raw .hdr file.
  136434. */
  136435. private loadTexture;
  136436. clone(): HDRCubeTexture;
  136437. delayLoad(): void;
  136438. /**
  136439. * Get the texture reflection matrix used to rotate/transform the reflection.
  136440. * @returns the reflection matrix
  136441. */
  136442. getReflectionTextureMatrix(): Matrix;
  136443. /**
  136444. * Set the texture reflection matrix used to rotate/transform the reflection.
  136445. * @param value Define the reflection matrix to set
  136446. */
  136447. setReflectionTextureMatrix(value: Matrix): void;
  136448. /**
  136449. * Parses a JSON representation of an HDR Texture in order to create the texture
  136450. * @param parsedTexture Define the JSON representation
  136451. * @param scene Define the scene the texture should be created in
  136452. * @param rootUrl Define the root url in case we need to load relative dependencies
  136453. * @returns the newly created texture after parsing
  136454. */
  136455. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  136456. serialize(): any;
  136457. }
  136458. }
  136459. declare module BABYLON {
  136460. /**
  136461. * Class used to control physics engine
  136462. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136463. */
  136464. export class PhysicsEngine implements IPhysicsEngine {
  136465. private _physicsPlugin;
  136466. /**
  136467. * Global value used to control the smallest number supported by the simulation
  136468. */
  136469. static Epsilon: number;
  136470. private _impostors;
  136471. private _joints;
  136472. private _subTimeStep;
  136473. /**
  136474. * Gets the gravity vector used by the simulation
  136475. */
  136476. gravity: Vector3;
  136477. /**
  136478. * Factory used to create the default physics plugin.
  136479. * @returns The default physics plugin
  136480. */
  136481. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  136482. /**
  136483. * Creates a new Physics Engine
  136484. * @param gravity defines the gravity vector used by the simulation
  136485. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  136486. */
  136487. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  136488. /**
  136489. * Sets the gravity vector used by the simulation
  136490. * @param gravity defines the gravity vector to use
  136491. */
  136492. setGravity(gravity: Vector3): void;
  136493. /**
  136494. * Set the time step of the physics engine.
  136495. * Default is 1/60.
  136496. * To slow it down, enter 1/600 for example.
  136497. * To speed it up, 1/30
  136498. * @param newTimeStep defines the new timestep to apply to this world.
  136499. */
  136500. setTimeStep(newTimeStep?: number): void;
  136501. /**
  136502. * Get the time step of the physics engine.
  136503. * @returns the current time step
  136504. */
  136505. getTimeStep(): number;
  136506. /**
  136507. * Set the sub time step of the physics engine.
  136508. * Default is 0 meaning there is no sub steps
  136509. * To increase physics resolution precision, set a small value (like 1 ms)
  136510. * @param subTimeStep defines the new sub timestep used for physics resolution.
  136511. */
  136512. setSubTimeStep(subTimeStep?: number): void;
  136513. /**
  136514. * Get the sub time step of the physics engine.
  136515. * @returns the current sub time step
  136516. */
  136517. getSubTimeStep(): number;
  136518. /**
  136519. * Release all resources
  136520. */
  136521. dispose(): void;
  136522. /**
  136523. * Gets the name of the current physics plugin
  136524. * @returns the name of the plugin
  136525. */
  136526. getPhysicsPluginName(): string;
  136527. /**
  136528. * Adding a new impostor for the impostor tracking.
  136529. * This will be done by the impostor itself.
  136530. * @param impostor the impostor to add
  136531. */
  136532. addImpostor(impostor: PhysicsImpostor): void;
  136533. /**
  136534. * Remove an impostor from the engine.
  136535. * This impostor and its mesh will not longer be updated by the physics engine.
  136536. * @param impostor the impostor to remove
  136537. */
  136538. removeImpostor(impostor: PhysicsImpostor): void;
  136539. /**
  136540. * Add a joint to the physics engine
  136541. * @param mainImpostor defines the main impostor to which the joint is added.
  136542. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  136543. * @param joint defines the joint that will connect both impostors.
  136544. */
  136545. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136546. /**
  136547. * Removes a joint from the simulation
  136548. * @param mainImpostor defines the impostor used with the joint
  136549. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  136550. * @param joint defines the joint to remove
  136551. */
  136552. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136553. /**
  136554. * Called by the scene. No need to call it.
  136555. * @param delta defines the timespam between frames
  136556. */
  136557. _step(delta: number): void;
  136558. /**
  136559. * Gets the current plugin used to run the simulation
  136560. * @returns current plugin
  136561. */
  136562. getPhysicsPlugin(): IPhysicsEnginePlugin;
  136563. /**
  136564. * Gets the list of physic impostors
  136565. * @returns an array of PhysicsImpostor
  136566. */
  136567. getImpostors(): Array<PhysicsImpostor>;
  136568. /**
  136569. * Gets the impostor for a physics enabled object
  136570. * @param object defines the object impersonated by the impostor
  136571. * @returns the PhysicsImpostor or null if not found
  136572. */
  136573. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  136574. /**
  136575. * Gets the impostor for a physics body object
  136576. * @param body defines physics body used by the impostor
  136577. * @returns the PhysicsImpostor or null if not found
  136578. */
  136579. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  136580. /**
  136581. * Does a raycast in the physics world
  136582. * @param from when should the ray start?
  136583. * @param to when should the ray end?
  136584. * @returns PhysicsRaycastResult
  136585. */
  136586. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136587. }
  136588. }
  136589. declare module BABYLON {
  136590. /** @hidden */
  136591. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136592. private _useDeltaForWorldStep;
  136593. world: any;
  136594. name: string;
  136595. private _physicsMaterials;
  136596. private _fixedTimeStep;
  136597. private _cannonRaycastResult;
  136598. private _raycastResult;
  136599. private _physicsBodysToRemoveAfterStep;
  136600. private _firstFrame;
  136601. BJSCANNON: any;
  136602. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136603. setGravity(gravity: Vector3): void;
  136604. setTimeStep(timeStep: number): void;
  136605. getTimeStep(): number;
  136606. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136607. private _removeMarkedPhysicsBodiesFromWorld;
  136608. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136609. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136610. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136611. private _processChildMeshes;
  136612. removePhysicsBody(impostor: PhysicsImpostor): void;
  136613. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136614. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136615. private _addMaterial;
  136616. private _checkWithEpsilon;
  136617. private _createShape;
  136618. private _createHeightmap;
  136619. private _minus90X;
  136620. private _plus90X;
  136621. private _tmpPosition;
  136622. private _tmpDeltaPosition;
  136623. private _tmpUnityRotation;
  136624. private _updatePhysicsBodyTransformation;
  136625. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136626. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136627. isSupported(): boolean;
  136628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136629. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136631. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136633. getBodyMass(impostor: PhysicsImpostor): number;
  136634. getBodyFriction(impostor: PhysicsImpostor): number;
  136635. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136636. getBodyRestitution(impostor: PhysicsImpostor): number;
  136637. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136638. sleepBody(impostor: PhysicsImpostor): void;
  136639. wakeUpBody(impostor: PhysicsImpostor): void;
  136640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136641. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136642. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136644. getRadius(impostor: PhysicsImpostor): number;
  136645. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136646. dispose(): void;
  136647. private _extendNamespace;
  136648. /**
  136649. * Does a raycast in the physics world
  136650. * @param from when should the ray start?
  136651. * @param to when should the ray end?
  136652. * @returns PhysicsRaycastResult
  136653. */
  136654. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136655. }
  136656. }
  136657. declare module BABYLON {
  136658. /** @hidden */
  136659. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  136660. private _useDeltaForWorldStep;
  136661. world: any;
  136662. name: string;
  136663. BJSOIMO: any;
  136664. private _raycastResult;
  136665. private _fixedTimeStep;
  136666. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  136667. setGravity(gravity: Vector3): void;
  136668. setTimeStep(timeStep: number): void;
  136669. getTimeStep(): number;
  136670. private _tmpImpostorsArray;
  136671. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136672. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136674. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136675. private _tmpPositionVector;
  136676. removePhysicsBody(impostor: PhysicsImpostor): void;
  136677. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136678. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136679. isSupported(): boolean;
  136680. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136681. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136682. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136683. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136684. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136685. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136686. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136687. getBodyMass(impostor: PhysicsImpostor): number;
  136688. getBodyFriction(impostor: PhysicsImpostor): number;
  136689. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136690. getBodyRestitution(impostor: PhysicsImpostor): number;
  136691. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136692. sleepBody(impostor: PhysicsImpostor): void;
  136693. wakeUpBody(impostor: PhysicsImpostor): void;
  136694. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  136695. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  136696. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  136697. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136698. getRadius(impostor: PhysicsImpostor): number;
  136699. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136700. dispose(): void;
  136701. /**
  136702. * Does a raycast in the physics world
  136703. * @param from when should the ray start?
  136704. * @param to when should the ray end?
  136705. * @returns PhysicsRaycastResult
  136706. */
  136707. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136708. }
  136709. }
  136710. declare module BABYLON {
  136711. /**
  136712. * Class containing static functions to help procedurally build meshes
  136713. */
  136714. export class RibbonBuilder {
  136715. /**
  136716. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136717. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136718. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136719. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136720. * * 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
  136721. * * 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
  136722. * * 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
  136723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136726. * * 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
  136727. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136728. * * 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
  136729. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136731. * @param name defines the name of the mesh
  136732. * @param options defines the options used to create the mesh
  136733. * @param scene defines the hosting scene
  136734. * @returns the ribbon mesh
  136735. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  136736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136737. */
  136738. static CreateRibbon(name: string, options: {
  136739. pathArray: Vector3[][];
  136740. closeArray?: boolean;
  136741. closePath?: boolean;
  136742. offset?: number;
  136743. updatable?: boolean;
  136744. sideOrientation?: number;
  136745. frontUVs?: Vector4;
  136746. backUVs?: Vector4;
  136747. instance?: Mesh;
  136748. invertUV?: boolean;
  136749. uvs?: Vector2[];
  136750. colors?: Color4[];
  136751. }, scene?: Nullable<Scene>): Mesh;
  136752. }
  136753. }
  136754. declare module BABYLON {
  136755. /**
  136756. * Class containing static functions to help procedurally build meshes
  136757. */
  136758. export class ShapeBuilder {
  136759. /**
  136760. * 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.
  136761. * * 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.
  136762. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136763. * * 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.
  136764. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136765. * * 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
  136766. * * 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
  136767. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136770. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136772. * @param name defines the name of the mesh
  136773. * @param options defines the options used to create the mesh
  136774. * @param scene defines the hosting scene
  136775. * @returns the extruded shape mesh
  136776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136778. */
  136779. static ExtrudeShape(name: string, options: {
  136780. shape: Vector3[];
  136781. path: Vector3[];
  136782. scale?: number;
  136783. rotation?: number;
  136784. cap?: number;
  136785. updatable?: boolean;
  136786. sideOrientation?: number;
  136787. frontUVs?: Vector4;
  136788. backUVs?: Vector4;
  136789. instance?: Mesh;
  136790. invertUV?: boolean;
  136791. }, scene?: Nullable<Scene>): Mesh;
  136792. /**
  136793. * Creates an custom extruded shape mesh.
  136794. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136795. * * 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.
  136796. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136797. * * 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
  136798. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136799. * * 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
  136800. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136801. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136802. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136803. * * 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
  136804. * * 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
  136805. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136810. * @param name defines the name of the mesh
  136811. * @param options defines the options used to create the mesh
  136812. * @param scene defines the hosting scene
  136813. * @returns the custom extruded shape mesh
  136814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136815. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136817. */
  136818. static ExtrudeShapeCustom(name: string, options: {
  136819. shape: Vector3[];
  136820. path: Vector3[];
  136821. scaleFunction?: any;
  136822. rotationFunction?: any;
  136823. ribbonCloseArray?: boolean;
  136824. ribbonClosePath?: boolean;
  136825. cap?: number;
  136826. updatable?: boolean;
  136827. sideOrientation?: number;
  136828. frontUVs?: Vector4;
  136829. backUVs?: Vector4;
  136830. instance?: Mesh;
  136831. invertUV?: boolean;
  136832. }, scene?: Nullable<Scene>): Mesh;
  136833. private static _ExtrudeShapeGeneric;
  136834. }
  136835. }
  136836. declare module BABYLON {
  136837. /**
  136838. * AmmoJS Physics plugin
  136839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  136840. * @see https://github.com/kripken/ammo.js/
  136841. */
  136842. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  136843. private _useDeltaForWorldStep;
  136844. /**
  136845. * Reference to the Ammo library
  136846. */
  136847. bjsAMMO: any;
  136848. /**
  136849. * Created ammoJS world which physics bodies are added to
  136850. */
  136851. world: any;
  136852. /**
  136853. * Name of the plugin
  136854. */
  136855. name: string;
  136856. private _timeStep;
  136857. private _fixedTimeStep;
  136858. private _maxSteps;
  136859. private _tmpQuaternion;
  136860. private _tmpAmmoTransform;
  136861. private _tmpAmmoQuaternion;
  136862. private _tmpAmmoConcreteContactResultCallback;
  136863. private _collisionConfiguration;
  136864. private _dispatcher;
  136865. private _overlappingPairCache;
  136866. private _solver;
  136867. private _softBodySolver;
  136868. private _tmpAmmoVectorA;
  136869. private _tmpAmmoVectorB;
  136870. private _tmpAmmoVectorC;
  136871. private _tmpAmmoVectorD;
  136872. private _tmpContactCallbackResult;
  136873. private _tmpAmmoVectorRCA;
  136874. private _tmpAmmoVectorRCB;
  136875. private _raycastResult;
  136876. private static readonly DISABLE_COLLISION_FLAG;
  136877. private static readonly KINEMATIC_FLAG;
  136878. private static readonly DISABLE_DEACTIVATION_FLAG;
  136879. /**
  136880. * Initializes the ammoJS plugin
  136881. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  136882. * @param ammoInjection can be used to inject your own ammo reference
  136883. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  136884. */
  136885. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  136886. /**
  136887. * Sets the gravity of the physics world (m/(s^2))
  136888. * @param gravity Gravity to set
  136889. */
  136890. setGravity(gravity: Vector3): void;
  136891. /**
  136892. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  136893. * @param timeStep timestep to use in seconds
  136894. */
  136895. setTimeStep(timeStep: number): void;
  136896. /**
  136897. * 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)
  136898. * @param fixedTimeStep fixedTimeStep to use in seconds
  136899. */
  136900. setFixedTimeStep(fixedTimeStep: number): void;
  136901. /**
  136902. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  136903. * @param maxSteps the maximum number of steps by the physics engine per frame
  136904. */
  136905. setMaxSteps(maxSteps: number): void;
  136906. /**
  136907. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  136908. * @returns the current timestep in seconds
  136909. */
  136910. getTimeStep(): number;
  136911. /**
  136912. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  136913. */
  136914. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  136915. private _isImpostorInContact;
  136916. private _isImpostorPairInContact;
  136917. private _stepSimulation;
  136918. /**
  136919. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  136920. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  136921. * After the step the babylon meshes are set to the position of the physics imposters
  136922. * @param delta amount of time to step forward
  136923. * @param impostors array of imposters to update before/after the step
  136924. */
  136925. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136926. /**
  136927. * Update babylon mesh to match physics world object
  136928. * @param impostor imposter to match
  136929. */
  136930. private _afterSoftStep;
  136931. /**
  136932. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136933. * @param impostor imposter to match
  136934. */
  136935. private _ropeStep;
  136936. /**
  136937. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  136938. * @param impostor imposter to match
  136939. */
  136940. private _softbodyOrClothStep;
  136941. private _tmpMatrix;
  136942. /**
  136943. * Applies an impulse on the imposter
  136944. * @param impostor imposter to apply impulse to
  136945. * @param force amount of force to be applied to the imposter
  136946. * @param contactPoint the location to apply the impulse on the imposter
  136947. */
  136948. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136949. /**
  136950. * Applies a force on the imposter
  136951. * @param impostor imposter to apply force
  136952. * @param force amount of force to be applied to the imposter
  136953. * @param contactPoint the location to apply the force on the imposter
  136954. */
  136955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136956. /**
  136957. * Creates a physics body using the plugin
  136958. * @param impostor the imposter to create the physics body on
  136959. */
  136960. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136961. /**
  136962. * Removes the physics body from the imposter and disposes of the body's memory
  136963. * @param impostor imposter to remove the physics body from
  136964. */
  136965. removePhysicsBody(impostor: PhysicsImpostor): void;
  136966. /**
  136967. * Generates a joint
  136968. * @param impostorJoint the imposter joint to create the joint with
  136969. */
  136970. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136971. /**
  136972. * Removes a joint
  136973. * @param impostorJoint the imposter joint to remove the joint from
  136974. */
  136975. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136976. private _addMeshVerts;
  136977. /**
  136978. * Initialise the soft body vertices to match its object's (mesh) vertices
  136979. * Softbody vertices (nodes) are in world space and to match this
  136980. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  136981. * @param impostor to create the softbody for
  136982. */
  136983. private _softVertexData;
  136984. /**
  136985. * Create an impostor's soft body
  136986. * @param impostor to create the softbody for
  136987. */
  136988. private _createSoftbody;
  136989. /**
  136990. * Create cloth for an impostor
  136991. * @param impostor to create the softbody for
  136992. */
  136993. private _createCloth;
  136994. /**
  136995. * Create rope for an impostor
  136996. * @param impostor to create the softbody for
  136997. */
  136998. private _createRope;
  136999. /**
  137000. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  137001. * @param impostor to create the custom physics shape for
  137002. */
  137003. private _createCustom;
  137004. private _addHullVerts;
  137005. private _createShape;
  137006. /**
  137007. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  137008. * @param impostor imposter containing the physics body and babylon object
  137009. */
  137010. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137011. /**
  137012. * Sets the babylon object's position/rotation from the physics body's position/rotation
  137013. * @param impostor imposter containing the physics body and babylon object
  137014. * @param newPosition new position
  137015. * @param newRotation new rotation
  137016. */
  137017. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137018. /**
  137019. * If this plugin is supported
  137020. * @returns true if its supported
  137021. */
  137022. isSupported(): boolean;
  137023. /**
  137024. * Sets the linear velocity of the physics body
  137025. * @param impostor imposter to set the velocity on
  137026. * @param velocity velocity to set
  137027. */
  137028. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137029. /**
  137030. * Sets the angular velocity of the physics body
  137031. * @param impostor imposter to set the velocity on
  137032. * @param velocity velocity to set
  137033. */
  137034. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137035. /**
  137036. * gets the linear velocity
  137037. * @param impostor imposter to get linear velocity from
  137038. * @returns linear velocity
  137039. */
  137040. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137041. /**
  137042. * gets the angular velocity
  137043. * @param impostor imposter to get angular velocity from
  137044. * @returns angular velocity
  137045. */
  137046. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137047. /**
  137048. * Sets the mass of physics body
  137049. * @param impostor imposter to set the mass on
  137050. * @param mass mass to set
  137051. */
  137052. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137053. /**
  137054. * Gets the mass of the physics body
  137055. * @param impostor imposter to get the mass from
  137056. * @returns mass
  137057. */
  137058. getBodyMass(impostor: PhysicsImpostor): number;
  137059. /**
  137060. * Gets friction of the impostor
  137061. * @param impostor impostor to get friction from
  137062. * @returns friction value
  137063. */
  137064. getBodyFriction(impostor: PhysicsImpostor): number;
  137065. /**
  137066. * Sets friction of the impostor
  137067. * @param impostor impostor to set friction on
  137068. * @param friction friction value
  137069. */
  137070. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137071. /**
  137072. * Gets restitution of the impostor
  137073. * @param impostor impostor to get restitution from
  137074. * @returns restitution value
  137075. */
  137076. getBodyRestitution(impostor: PhysicsImpostor): number;
  137077. /**
  137078. * Sets resitution of the impostor
  137079. * @param impostor impostor to set resitution on
  137080. * @param restitution resitution value
  137081. */
  137082. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137083. /**
  137084. * Gets pressure inside the impostor
  137085. * @param impostor impostor to get pressure from
  137086. * @returns pressure value
  137087. */
  137088. getBodyPressure(impostor: PhysicsImpostor): number;
  137089. /**
  137090. * Sets pressure inside a soft body impostor
  137091. * Cloth and rope must remain 0 pressure
  137092. * @param impostor impostor to set pressure on
  137093. * @param pressure pressure value
  137094. */
  137095. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  137096. /**
  137097. * Gets stiffness of the impostor
  137098. * @param impostor impostor to get stiffness from
  137099. * @returns pressure value
  137100. */
  137101. getBodyStiffness(impostor: PhysicsImpostor): number;
  137102. /**
  137103. * Sets stiffness of the impostor
  137104. * @param impostor impostor to set stiffness on
  137105. * @param stiffness stiffness value from 0 to 1
  137106. */
  137107. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  137108. /**
  137109. * Gets velocityIterations of the impostor
  137110. * @param impostor impostor to get velocity iterations from
  137111. * @returns velocityIterations value
  137112. */
  137113. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  137114. /**
  137115. * Sets velocityIterations of the impostor
  137116. * @param impostor impostor to set velocity iterations on
  137117. * @param velocityIterations velocityIterations value
  137118. */
  137119. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  137120. /**
  137121. * Gets positionIterations of the impostor
  137122. * @param impostor impostor to get position iterations from
  137123. * @returns positionIterations value
  137124. */
  137125. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  137126. /**
  137127. * Sets positionIterations of the impostor
  137128. * @param impostor impostor to set position on
  137129. * @param positionIterations positionIterations value
  137130. */
  137131. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  137132. /**
  137133. * Append an anchor to a cloth object
  137134. * @param impostor is the cloth impostor to add anchor to
  137135. * @param otherImpostor is the rigid impostor to anchor to
  137136. * @param width ratio across width from 0 to 1
  137137. * @param height ratio up height from 0 to 1
  137138. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  137139. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137140. */
  137141. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137142. /**
  137143. * Append an hook to a rope object
  137144. * @param impostor is the rope impostor to add hook to
  137145. * @param otherImpostor is the rigid impostor to hook to
  137146. * @param length ratio along the rope from 0 to 1
  137147. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  137148. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137149. */
  137150. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137151. /**
  137152. * Sleeps the physics body and stops it from being active
  137153. * @param impostor impostor to sleep
  137154. */
  137155. sleepBody(impostor: PhysicsImpostor): void;
  137156. /**
  137157. * Activates the physics body
  137158. * @param impostor impostor to activate
  137159. */
  137160. wakeUpBody(impostor: PhysicsImpostor): void;
  137161. /**
  137162. * Updates the distance parameters of the joint
  137163. * @param joint joint to update
  137164. * @param maxDistance maximum distance of the joint
  137165. * @param minDistance minimum distance of the joint
  137166. */
  137167. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137168. /**
  137169. * Sets a motor on the joint
  137170. * @param joint joint to set motor on
  137171. * @param speed speed of the motor
  137172. * @param maxForce maximum force of the motor
  137173. * @param motorIndex index of the motor
  137174. */
  137175. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137176. /**
  137177. * Sets the motors limit
  137178. * @param joint joint to set limit on
  137179. * @param upperLimit upper limit
  137180. * @param lowerLimit lower limit
  137181. */
  137182. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137183. /**
  137184. * Syncs the position and rotation of a mesh with the impostor
  137185. * @param mesh mesh to sync
  137186. * @param impostor impostor to update the mesh with
  137187. */
  137188. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137189. /**
  137190. * Gets the radius of the impostor
  137191. * @param impostor impostor to get radius from
  137192. * @returns the radius
  137193. */
  137194. getRadius(impostor: PhysicsImpostor): number;
  137195. /**
  137196. * Gets the box size of the impostor
  137197. * @param impostor impostor to get box size from
  137198. * @param result the resulting box size
  137199. */
  137200. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137201. /**
  137202. * Disposes of the impostor
  137203. */
  137204. dispose(): void;
  137205. /**
  137206. * Does a raycast in the physics world
  137207. * @param from when should the ray start?
  137208. * @param to when should the ray end?
  137209. * @returns PhysicsRaycastResult
  137210. */
  137211. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137212. }
  137213. }
  137214. declare module BABYLON {
  137215. interface AbstractScene {
  137216. /**
  137217. * The list of reflection probes added to the scene
  137218. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137219. */
  137220. reflectionProbes: Array<ReflectionProbe>;
  137221. /**
  137222. * Removes the given reflection probe from this scene.
  137223. * @param toRemove The reflection probe to remove
  137224. * @returns The index of the removed reflection probe
  137225. */
  137226. removeReflectionProbe(toRemove: ReflectionProbe): number;
  137227. /**
  137228. * Adds the given reflection probe to this scene.
  137229. * @param newReflectionProbe The reflection probe to add
  137230. */
  137231. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  137232. }
  137233. /**
  137234. * Class used to generate realtime reflection / refraction cube textures
  137235. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137236. */
  137237. export class ReflectionProbe {
  137238. /** defines the name of the probe */
  137239. name: string;
  137240. private _scene;
  137241. private _renderTargetTexture;
  137242. private _projectionMatrix;
  137243. private _viewMatrix;
  137244. private _target;
  137245. private _add;
  137246. private _attachedMesh;
  137247. private _invertYAxis;
  137248. /** Gets or sets probe position (center of the cube map) */
  137249. position: Vector3;
  137250. /**
  137251. * Creates a new reflection probe
  137252. * @param name defines the name of the probe
  137253. * @param size defines the texture resolution (for each face)
  137254. * @param scene defines the hosting scene
  137255. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  137256. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  137257. */
  137258. constructor(
  137259. /** defines the name of the probe */
  137260. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  137261. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  137262. get samples(): number;
  137263. set samples(value: number);
  137264. /** Gets or sets the refresh rate to use (on every frame by default) */
  137265. get refreshRate(): number;
  137266. set refreshRate(value: number);
  137267. /**
  137268. * Gets the hosting scene
  137269. * @returns a Scene
  137270. */
  137271. getScene(): Scene;
  137272. /** Gets the internal CubeTexture used to render to */
  137273. get cubeTexture(): RenderTargetTexture;
  137274. /** Gets the list of meshes to render */
  137275. get renderList(): Nullable<AbstractMesh[]>;
  137276. /**
  137277. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  137278. * @param mesh defines the mesh to attach to
  137279. */
  137280. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137281. /**
  137282. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  137283. * @param renderingGroupId The rendering group id corresponding to its index
  137284. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137285. */
  137286. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  137287. /**
  137288. * Clean all associated resources
  137289. */
  137290. dispose(): void;
  137291. /**
  137292. * Converts the reflection probe information to a readable string for debug purpose.
  137293. * @param fullDetails Supports for multiple levels of logging within scene loading
  137294. * @returns the human readable reflection probe info
  137295. */
  137296. toString(fullDetails?: boolean): string;
  137297. /**
  137298. * Get the class name of the relfection probe.
  137299. * @returns "ReflectionProbe"
  137300. */
  137301. getClassName(): string;
  137302. /**
  137303. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  137304. * @returns The JSON representation of the texture
  137305. */
  137306. serialize(): any;
  137307. /**
  137308. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  137309. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  137310. * @param scene Define the scene the parsed reflection probe should be instantiated in
  137311. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  137312. * @returns The parsed reflection probe if successful
  137313. */
  137314. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  137315. }
  137316. }
  137317. declare module BABYLON {
  137318. /** @hidden */
  137319. export var _BabylonLoaderRegistered: boolean;
  137320. /**
  137321. * Helps setting up some configuration for the babylon file loader.
  137322. */
  137323. export class BabylonFileLoaderConfiguration {
  137324. /**
  137325. * The loader does not allow injecting custom physix engine into the plugins.
  137326. * Unfortunately in ES6, we need to manually inject them into the plugin.
  137327. * So you could set this variable to your engine import to make it work.
  137328. */
  137329. static LoaderInjectedPhysicsEngine: any;
  137330. }
  137331. }
  137332. declare module BABYLON {
  137333. /**
  137334. * The Physically based simple base material of BJS.
  137335. *
  137336. * This enables better naming and convention enforcements on top of the pbrMaterial.
  137337. * It is used as the base class for both the specGloss and metalRough conventions.
  137338. */
  137339. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  137340. /**
  137341. * Number of Simultaneous lights allowed on the material.
  137342. */
  137343. maxSimultaneousLights: number;
  137344. /**
  137345. * If sets to true, disables all the lights affecting the material.
  137346. */
  137347. disableLighting: boolean;
  137348. /**
  137349. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  137350. */
  137351. environmentTexture: BaseTexture;
  137352. /**
  137353. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137354. */
  137355. invertNormalMapX: boolean;
  137356. /**
  137357. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137358. */
  137359. invertNormalMapY: boolean;
  137360. /**
  137361. * Normal map used in the model.
  137362. */
  137363. normalTexture: BaseTexture;
  137364. /**
  137365. * Emissivie color used to self-illuminate the model.
  137366. */
  137367. emissiveColor: Color3;
  137368. /**
  137369. * Emissivie texture used to self-illuminate the model.
  137370. */
  137371. emissiveTexture: BaseTexture;
  137372. /**
  137373. * Occlusion Channel Strenght.
  137374. */
  137375. occlusionStrength: number;
  137376. /**
  137377. * Occlusion Texture of the material (adding extra occlusion effects).
  137378. */
  137379. occlusionTexture: BaseTexture;
  137380. /**
  137381. * Defines the alpha limits in alpha test mode.
  137382. */
  137383. alphaCutOff: number;
  137384. /**
  137385. * Gets the current double sided mode.
  137386. */
  137387. get doubleSided(): boolean;
  137388. /**
  137389. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137390. */
  137391. set doubleSided(value: boolean);
  137392. /**
  137393. * Stores the pre-calculated light information of a mesh in a texture.
  137394. */
  137395. lightmapTexture: BaseTexture;
  137396. /**
  137397. * If true, the light map contains occlusion information instead of lighting info.
  137398. */
  137399. useLightmapAsShadowmap: boolean;
  137400. /**
  137401. * Instantiates a new PBRMaterial instance.
  137402. *
  137403. * @param name The material name
  137404. * @param scene The scene the material will be use in.
  137405. */
  137406. constructor(name: string, scene: Scene);
  137407. getClassName(): string;
  137408. }
  137409. }
  137410. declare module BABYLON {
  137411. /**
  137412. * The PBR material of BJS following the metal roughness convention.
  137413. *
  137414. * This fits to the PBR convention in the GLTF definition:
  137415. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  137416. */
  137417. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  137418. /**
  137419. * The base color has two different interpretations depending on the value of metalness.
  137420. * When the material is a metal, the base color is the specific measured reflectance value
  137421. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  137422. * of the material.
  137423. */
  137424. baseColor: Color3;
  137425. /**
  137426. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  137427. * well as opacity information in the alpha channel.
  137428. */
  137429. baseTexture: BaseTexture;
  137430. /**
  137431. * Specifies the metallic scalar value of the material.
  137432. * Can also be used to scale the metalness values of the metallic texture.
  137433. */
  137434. metallic: number;
  137435. /**
  137436. * Specifies the roughness scalar value of the material.
  137437. * Can also be used to scale the roughness values of the metallic texture.
  137438. */
  137439. roughness: number;
  137440. /**
  137441. * Texture containing both the metallic value in the B channel and the
  137442. * roughness value in the G channel to keep better precision.
  137443. */
  137444. metallicRoughnessTexture: BaseTexture;
  137445. /**
  137446. * Instantiates a new PBRMetalRoughnessMaterial instance.
  137447. *
  137448. * @param name The material name
  137449. * @param scene The scene the material will be use in.
  137450. */
  137451. constructor(name: string, scene: Scene);
  137452. /**
  137453. * Return the currrent class name of the material.
  137454. */
  137455. getClassName(): string;
  137456. /**
  137457. * Makes a duplicate of the current material.
  137458. * @param name - name to use for the new material.
  137459. */
  137460. clone(name: string): PBRMetallicRoughnessMaterial;
  137461. /**
  137462. * Serialize the material to a parsable JSON object.
  137463. */
  137464. serialize(): any;
  137465. /**
  137466. * Parses a JSON object correponding to the serialize function.
  137467. */
  137468. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  137469. }
  137470. }
  137471. declare module BABYLON {
  137472. /**
  137473. * The PBR material of BJS following the specular glossiness convention.
  137474. *
  137475. * This fits to the PBR convention in the GLTF definition:
  137476. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  137477. */
  137478. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  137479. /**
  137480. * Specifies the diffuse color of the material.
  137481. */
  137482. diffuseColor: Color3;
  137483. /**
  137484. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  137485. * channel.
  137486. */
  137487. diffuseTexture: BaseTexture;
  137488. /**
  137489. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  137490. */
  137491. specularColor: Color3;
  137492. /**
  137493. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  137494. */
  137495. glossiness: number;
  137496. /**
  137497. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  137498. */
  137499. specularGlossinessTexture: BaseTexture;
  137500. /**
  137501. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  137502. *
  137503. * @param name The material name
  137504. * @param scene The scene the material will be use in.
  137505. */
  137506. constructor(name: string, scene: Scene);
  137507. /**
  137508. * Return the currrent class name of the material.
  137509. */
  137510. getClassName(): string;
  137511. /**
  137512. * Makes a duplicate of the current material.
  137513. * @param name - name to use for the new material.
  137514. */
  137515. clone(name: string): PBRSpecularGlossinessMaterial;
  137516. /**
  137517. * Serialize the material to a parsable JSON object.
  137518. */
  137519. serialize(): any;
  137520. /**
  137521. * Parses a JSON object correponding to the serialize function.
  137522. */
  137523. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  137524. }
  137525. }
  137526. declare module BABYLON {
  137527. /**
  137528. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  137529. * It can help converting any input color in a desired output one. This can then be used to create effects
  137530. * from sepia, black and white to sixties or futuristic rendering...
  137531. *
  137532. * The only supported format is currently 3dl.
  137533. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  137534. */
  137535. export class ColorGradingTexture extends BaseTexture {
  137536. /**
  137537. * The texture URL.
  137538. */
  137539. url: string;
  137540. /**
  137541. * Empty line regex stored for GC.
  137542. */
  137543. private static _noneEmptyLineRegex;
  137544. private _textureMatrix;
  137545. private _onLoad;
  137546. /**
  137547. * Instantiates a ColorGradingTexture from the following parameters.
  137548. *
  137549. * @param url The location of the color gradind data (currently only supporting 3dl)
  137550. * @param sceneOrEngine The scene or engine the texture will be used in
  137551. * @param onLoad defines a callback triggered when the texture has been loaded
  137552. */
  137553. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  137554. /**
  137555. * Fires the onload event from the constructor if requested.
  137556. */
  137557. private _triggerOnLoad;
  137558. /**
  137559. * Returns the texture matrix used in most of the material.
  137560. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  137561. */
  137562. getTextureMatrix(): Matrix;
  137563. /**
  137564. * Occurs when the file being loaded is a .3dl LUT file.
  137565. */
  137566. private load3dlTexture;
  137567. /**
  137568. * Starts the loading process of the texture.
  137569. */
  137570. private loadTexture;
  137571. /**
  137572. * Clones the color gradind texture.
  137573. */
  137574. clone(): ColorGradingTexture;
  137575. /**
  137576. * Called during delayed load for textures.
  137577. */
  137578. delayLoad(): void;
  137579. /**
  137580. * Parses a color grading texture serialized by Babylon.
  137581. * @param parsedTexture The texture information being parsedTexture
  137582. * @param scene The scene to load the texture in
  137583. * @param rootUrl The root url of the data assets to load
  137584. * @return A color gradind texture
  137585. */
  137586. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137587. /**
  137588. * Serializes the LUT texture to json format.
  137589. */
  137590. serialize(): any;
  137591. }
  137592. }
  137593. declare module BABYLON {
  137594. /**
  137595. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137596. */
  137597. export class EquiRectangularCubeTexture extends BaseTexture {
  137598. /** The six faces of the cube. */
  137599. private static _FacesMapping;
  137600. private _noMipmap;
  137601. private _onLoad;
  137602. private _onError;
  137603. /** The size of the cubemap. */
  137604. private _size;
  137605. /** The buffer of the image. */
  137606. private _buffer;
  137607. /** The width of the input image. */
  137608. private _width;
  137609. /** The height of the input image. */
  137610. private _height;
  137611. /** The URL to the image. */
  137612. url: string;
  137613. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137614. coordinatesMode: number;
  137615. /**
  137616. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137617. * @param url The location of the image
  137618. * @param scene The scene the texture will be used in
  137619. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137620. * @param noMipmap Forces to not generate the mipmap if true
  137621. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137622. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137623. * @param onLoad — defines a callback called when texture is loaded
  137624. * @param onError — defines a callback called if there is an error
  137625. */
  137626. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137627. /**
  137628. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137629. */
  137630. private loadImage;
  137631. /**
  137632. * Convert the image buffer into a cubemap and create a CubeTexture.
  137633. */
  137634. private loadTexture;
  137635. /**
  137636. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137637. * @param buffer The ArrayBuffer that should be converted.
  137638. * @returns The buffer as Float32Array.
  137639. */
  137640. private getFloat32ArrayFromArrayBuffer;
  137641. /**
  137642. * Get the current class name of the texture useful for serialization or dynamic coding.
  137643. * @returns "EquiRectangularCubeTexture"
  137644. */
  137645. getClassName(): string;
  137646. /**
  137647. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137648. * @returns A clone of the current EquiRectangularCubeTexture.
  137649. */
  137650. clone(): EquiRectangularCubeTexture;
  137651. }
  137652. }
  137653. declare module BABYLON {
  137654. /**
  137655. * Defines the options related to the creation of an HtmlElementTexture
  137656. */
  137657. export interface IHtmlElementTextureOptions {
  137658. /**
  137659. * Defines wether mip maps should be created or not.
  137660. */
  137661. generateMipMaps?: boolean;
  137662. /**
  137663. * Defines the sampling mode of the texture.
  137664. */
  137665. samplingMode?: number;
  137666. /**
  137667. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  137668. */
  137669. engine: Nullable<ThinEngine>;
  137670. /**
  137671. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  137672. */
  137673. scene: Nullable<Scene>;
  137674. }
  137675. /**
  137676. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  137677. * To be as efficient as possible depending on your constraints nothing aside the first upload
  137678. * is automatically managed.
  137679. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  137680. * in your application.
  137681. *
  137682. * As the update is not automatic, you need to call them manually.
  137683. */
  137684. export class HtmlElementTexture extends BaseTexture {
  137685. /**
  137686. * The texture URL.
  137687. */
  137688. element: HTMLVideoElement | HTMLCanvasElement;
  137689. private static readonly DefaultOptions;
  137690. private _textureMatrix;
  137691. private _isVideo;
  137692. private _generateMipMaps;
  137693. private _samplingMode;
  137694. /**
  137695. * Instantiates a HtmlElementTexture from the following parameters.
  137696. *
  137697. * @param name Defines the name of the texture
  137698. * @param element Defines the video or canvas the texture is filled with
  137699. * @param options Defines the other none mandatory texture creation options
  137700. */
  137701. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  137702. private _createInternalTexture;
  137703. /**
  137704. * Returns the texture matrix used in most of the material.
  137705. */
  137706. getTextureMatrix(): Matrix;
  137707. /**
  137708. * Updates the content of the texture.
  137709. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  137710. */
  137711. update(invertY?: Nullable<boolean>): void;
  137712. }
  137713. }
  137714. declare module BABYLON {
  137715. /**
  137716. * Based on jsTGALoader - Javascript loader for TGA file
  137717. * By Vincent Thibault
  137718. * @see http://blog.robrowser.com/javascript-tga-loader.html
  137719. */
  137720. export class TGATools {
  137721. private static _TYPE_INDEXED;
  137722. private static _TYPE_RGB;
  137723. private static _TYPE_GREY;
  137724. private static _TYPE_RLE_INDEXED;
  137725. private static _TYPE_RLE_RGB;
  137726. private static _TYPE_RLE_GREY;
  137727. private static _ORIGIN_MASK;
  137728. private static _ORIGIN_SHIFT;
  137729. private static _ORIGIN_BL;
  137730. private static _ORIGIN_BR;
  137731. private static _ORIGIN_UL;
  137732. private static _ORIGIN_UR;
  137733. /**
  137734. * Gets the header of a TGA file
  137735. * @param data defines the TGA data
  137736. * @returns the header
  137737. */
  137738. static GetTGAHeader(data: Uint8Array): any;
  137739. /**
  137740. * Uploads TGA content to a Babylon Texture
  137741. * @hidden
  137742. */
  137743. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  137744. /** @hidden */
  137745. 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;
  137746. /** @hidden */
  137747. 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;
  137748. /** @hidden */
  137749. 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;
  137750. /** @hidden */
  137751. 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;
  137752. /** @hidden */
  137753. 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;
  137754. /** @hidden */
  137755. 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;
  137756. }
  137757. }
  137758. declare module BABYLON {
  137759. /**
  137760. * Implementation of the TGA Texture Loader.
  137761. * @hidden
  137762. */
  137763. export class _TGATextureLoader implements IInternalTextureLoader {
  137764. /**
  137765. * Defines wether the loader supports cascade loading the different faces.
  137766. */
  137767. readonly supportCascades: boolean;
  137768. /**
  137769. * This returns if the loader support the current file information.
  137770. * @param extension defines the file extension of the file being loaded
  137771. * @returns true if the loader can load the specified file
  137772. */
  137773. canLoad(extension: string): boolean;
  137774. /**
  137775. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137776. * @param data contains the texture data
  137777. * @param texture defines the BabylonJS internal texture
  137778. * @param createPolynomials will be true if polynomials have been requested
  137779. * @param onLoad defines the callback to trigger once the texture is ready
  137780. * @param onError defines the callback to trigger in case of error
  137781. */
  137782. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137783. /**
  137784. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137785. * @param data contains the texture data
  137786. * @param texture defines the BabylonJS internal texture
  137787. * @param callback defines the method to call once ready to upload
  137788. */
  137789. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137790. }
  137791. }
  137792. declare module BABYLON {
  137793. /**
  137794. * Info about the .basis files
  137795. */
  137796. class BasisFileInfo {
  137797. /**
  137798. * If the file has alpha
  137799. */
  137800. hasAlpha: boolean;
  137801. /**
  137802. * Info about each image of the basis file
  137803. */
  137804. images: Array<{
  137805. levels: Array<{
  137806. width: number;
  137807. height: number;
  137808. transcodedPixels: ArrayBufferView;
  137809. }>;
  137810. }>;
  137811. }
  137812. /**
  137813. * Result of transcoding a basis file
  137814. */
  137815. class TranscodeResult {
  137816. /**
  137817. * Info about the .basis file
  137818. */
  137819. fileInfo: BasisFileInfo;
  137820. /**
  137821. * Format to use when loading the file
  137822. */
  137823. format: number;
  137824. }
  137825. /**
  137826. * Configuration options for the Basis transcoder
  137827. */
  137828. export class BasisTranscodeConfiguration {
  137829. /**
  137830. * Supported compression formats used to determine the supported output format of the transcoder
  137831. */
  137832. supportedCompressionFormats?: {
  137833. /**
  137834. * etc1 compression format
  137835. */
  137836. etc1?: boolean;
  137837. /**
  137838. * s3tc compression format
  137839. */
  137840. s3tc?: boolean;
  137841. /**
  137842. * pvrtc compression format
  137843. */
  137844. pvrtc?: boolean;
  137845. /**
  137846. * etc2 compression format
  137847. */
  137848. etc2?: boolean;
  137849. };
  137850. /**
  137851. * If mipmap levels should be loaded for transcoded images (Default: true)
  137852. */
  137853. loadMipmapLevels?: boolean;
  137854. /**
  137855. * Index of a single image to load (Default: all images)
  137856. */
  137857. loadSingleImage?: number;
  137858. }
  137859. /**
  137860. * Used to load .Basis files
  137861. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  137862. */
  137863. export class BasisTools {
  137864. private static _IgnoreSupportedFormats;
  137865. /**
  137866. * URL to use when loading the basis transcoder
  137867. */
  137868. static JSModuleURL: string;
  137869. /**
  137870. * URL to use when loading the wasm module for the transcoder
  137871. */
  137872. static WasmModuleURL: string;
  137873. /**
  137874. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  137875. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  137876. * @returns internal format corresponding to the Basis format
  137877. */
  137878. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  137879. private static _WorkerPromise;
  137880. private static _Worker;
  137881. private static _actionId;
  137882. private static _CreateWorkerAsync;
  137883. /**
  137884. * Transcodes a loaded image file to compressed pixel data
  137885. * @param data image data to transcode
  137886. * @param config configuration options for the transcoding
  137887. * @returns a promise resulting in the transcoded image
  137888. */
  137889. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  137890. /**
  137891. * Loads a texture from the transcode result
  137892. * @param texture texture load to
  137893. * @param transcodeResult the result of transcoding the basis file to load from
  137894. */
  137895. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  137896. }
  137897. }
  137898. declare module BABYLON {
  137899. /**
  137900. * Loader for .basis file format
  137901. */
  137902. export class _BasisTextureLoader implements IInternalTextureLoader {
  137903. /**
  137904. * Defines whether the loader supports cascade loading the different faces.
  137905. */
  137906. readonly supportCascades: boolean;
  137907. /**
  137908. * This returns if the loader support the current file information.
  137909. * @param extension defines the file extension of the file being loaded
  137910. * @returns true if the loader can load the specified file
  137911. */
  137912. canLoad(extension: string): boolean;
  137913. /**
  137914. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137915. * @param data contains the texture data
  137916. * @param texture defines the BabylonJS internal texture
  137917. * @param createPolynomials will be true if polynomials have been requested
  137918. * @param onLoad defines the callback to trigger once the texture is ready
  137919. * @param onError defines the callback to trigger in case of error
  137920. */
  137921. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137922. /**
  137923. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137924. * @param data contains the texture data
  137925. * @param texture defines the BabylonJS internal texture
  137926. * @param callback defines the method to call once ready to upload
  137927. */
  137928. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137929. }
  137930. }
  137931. declare module BABYLON {
  137932. /**
  137933. * Defines the basic options interface of a TexturePacker Frame
  137934. */
  137935. export interface ITexturePackerFrame {
  137936. /**
  137937. * The frame ID
  137938. */
  137939. id: number;
  137940. /**
  137941. * The frames Scale
  137942. */
  137943. scale: Vector2;
  137944. /**
  137945. * The Frames offset
  137946. */
  137947. offset: Vector2;
  137948. }
  137949. /**
  137950. * This is a support class for frame Data on texture packer sets.
  137951. */
  137952. export class TexturePackerFrame implements ITexturePackerFrame {
  137953. /**
  137954. * The frame ID
  137955. */
  137956. id: number;
  137957. /**
  137958. * The frames Scale
  137959. */
  137960. scale: Vector2;
  137961. /**
  137962. * The Frames offset
  137963. */
  137964. offset: Vector2;
  137965. /**
  137966. * Initializes a texture package frame.
  137967. * @param id The numerical frame identifier
  137968. * @param scale Scalar Vector2 for UV frame
  137969. * @param offset Vector2 for the frame position in UV units.
  137970. * @returns TexturePackerFrame
  137971. */
  137972. constructor(id: number, scale: Vector2, offset: Vector2);
  137973. }
  137974. }
  137975. declare module BABYLON {
  137976. /**
  137977. * Defines the basic options interface of a TexturePacker
  137978. */
  137979. export interface ITexturePackerOptions {
  137980. /**
  137981. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  137982. */
  137983. map?: string[];
  137984. /**
  137985. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137986. */
  137987. uvsIn?: string;
  137988. /**
  137989. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  137990. */
  137991. uvsOut?: string;
  137992. /**
  137993. * number representing the layout style. Defaults to LAYOUT_STRIP
  137994. */
  137995. layout?: number;
  137996. /**
  137997. * number of columns if using custom column count layout(2). This defaults to 4.
  137998. */
  137999. colnum?: number;
  138000. /**
  138001. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  138002. */
  138003. updateInputMeshes?: boolean;
  138004. /**
  138005. * boolean flag to dispose all the source textures. Defaults to true.
  138006. */
  138007. disposeSources?: boolean;
  138008. /**
  138009. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  138010. */
  138011. fillBlanks?: boolean;
  138012. /**
  138013. * string value representing the context fill style color. Defaults to 'black'.
  138014. */
  138015. customFillColor?: string;
  138016. /**
  138017. * Width and Height Value of each Frame in the TexturePacker Sets
  138018. */
  138019. frameSize?: number;
  138020. /**
  138021. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  138022. */
  138023. paddingRatio?: number;
  138024. /**
  138025. * Number that declares the fill method for the padding gutter.
  138026. */
  138027. paddingMode?: number;
  138028. /**
  138029. * If in SUBUV_COLOR padding mode what color to use.
  138030. */
  138031. paddingColor?: Color3 | Color4;
  138032. }
  138033. /**
  138034. * Defines the basic interface of a TexturePacker JSON File
  138035. */
  138036. export interface ITexturePackerJSON {
  138037. /**
  138038. * The frame ID
  138039. */
  138040. name: string;
  138041. /**
  138042. * The base64 channel data
  138043. */
  138044. sets: any;
  138045. /**
  138046. * The options of the Packer
  138047. */
  138048. options: ITexturePackerOptions;
  138049. /**
  138050. * The frame data of the Packer
  138051. */
  138052. frames: Array<number>;
  138053. }
  138054. /**
  138055. * This is a support class that generates a series of packed texture sets.
  138056. * @see https://doc.babylonjs.com/babylon101/materials
  138057. */
  138058. export class TexturePacker {
  138059. /** Packer Layout Constant 0 */
  138060. static readonly LAYOUT_STRIP: number;
  138061. /** Packer Layout Constant 1 */
  138062. static readonly LAYOUT_POWER2: number;
  138063. /** Packer Layout Constant 2 */
  138064. static readonly LAYOUT_COLNUM: number;
  138065. /** Packer Layout Constant 0 */
  138066. static readonly SUBUV_WRAP: number;
  138067. /** Packer Layout Constant 1 */
  138068. static readonly SUBUV_EXTEND: number;
  138069. /** Packer Layout Constant 2 */
  138070. static readonly SUBUV_COLOR: number;
  138071. /** The Name of the Texture Package */
  138072. name: string;
  138073. /** The scene scope of the TexturePacker */
  138074. scene: Scene;
  138075. /** The Meshes to target */
  138076. meshes: AbstractMesh[];
  138077. /** Arguments passed with the Constructor */
  138078. options: ITexturePackerOptions;
  138079. /** The promise that is started upon initialization */
  138080. promise: Nullable<Promise<TexturePacker | string>>;
  138081. /** The Container object for the channel sets that are generated */
  138082. sets: object;
  138083. /** The Container array for the frames that are generated */
  138084. frames: TexturePackerFrame[];
  138085. /** The expected number of textures the system is parsing. */
  138086. private _expecting;
  138087. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  138088. private _paddingValue;
  138089. /**
  138090. * Initializes a texture package series from an array of meshes or a single mesh.
  138091. * @param name The name of the package
  138092. * @param meshes The target meshes to compose the package from
  138093. * @param options The arguments that texture packer should follow while building.
  138094. * @param scene The scene which the textures are scoped to.
  138095. * @returns TexturePacker
  138096. */
  138097. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  138098. /**
  138099. * Starts the package process
  138100. * @param resolve The promises resolution function
  138101. * @returns TexturePacker
  138102. */
  138103. private _createFrames;
  138104. /**
  138105. * Calculates the Size of the Channel Sets
  138106. * @returns Vector2
  138107. */
  138108. private _calculateSize;
  138109. /**
  138110. * Calculates the UV data for the frames.
  138111. * @param baseSize the base frameSize
  138112. * @param padding the base frame padding
  138113. * @param dtSize size of the Dynamic Texture for that channel
  138114. * @param dtUnits is 1/dtSize
  138115. * @param update flag to update the input meshes
  138116. */
  138117. private _calculateMeshUVFrames;
  138118. /**
  138119. * Calculates the frames Offset.
  138120. * @param index of the frame
  138121. * @returns Vector2
  138122. */
  138123. private _getFrameOffset;
  138124. /**
  138125. * Updates a Mesh to the frame data
  138126. * @param mesh that is the target
  138127. * @param frameID or the frame index
  138128. */
  138129. private _updateMeshUV;
  138130. /**
  138131. * Updates a Meshes materials to use the texture packer channels
  138132. * @param m is the mesh to target
  138133. * @param force all channels on the packer to be set.
  138134. */
  138135. private _updateTextureReferences;
  138136. /**
  138137. * Public method to set a Mesh to a frame
  138138. * @param m that is the target
  138139. * @param frameID or the frame index
  138140. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  138141. */
  138142. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  138143. /**
  138144. * Starts the async promise to compile the texture packer.
  138145. * @returns Promise<void>
  138146. */
  138147. processAsync(): Promise<void>;
  138148. /**
  138149. * Disposes all textures associated with this packer
  138150. */
  138151. dispose(): void;
  138152. /**
  138153. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  138154. * @param imageType is the image type to use.
  138155. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  138156. */
  138157. download(imageType?: string, quality?: number): void;
  138158. /**
  138159. * Public method to load a texturePacker JSON file.
  138160. * @param data of the JSON file in string format.
  138161. */
  138162. updateFromJSON(data: string): void;
  138163. }
  138164. }
  138165. declare module BABYLON {
  138166. /**
  138167. * 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.
  138168. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138169. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138170. */
  138171. export class CustomProceduralTexture extends ProceduralTexture {
  138172. private _animate;
  138173. private _time;
  138174. private _config;
  138175. private _texturePath;
  138176. /**
  138177. * Instantiates a new Custom Procedural Texture.
  138178. * 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.
  138179. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138180. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138181. * @param name Define the name of the texture
  138182. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  138183. * @param size Define the size of the texture to create
  138184. * @param scene Define the scene the texture belongs to
  138185. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  138186. * @param generateMipMaps Define if the texture should creates mip maps or not
  138187. */
  138188. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138189. private _loadJson;
  138190. /**
  138191. * Is the texture ready to be used ? (rendered at least once)
  138192. * @returns true if ready, otherwise, false.
  138193. */
  138194. isReady(): boolean;
  138195. /**
  138196. * Render the texture to its associated render target.
  138197. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  138198. */
  138199. render(useCameraPostProcess?: boolean): void;
  138200. /**
  138201. * Update the list of dependant textures samplers in the shader.
  138202. */
  138203. updateTextures(): void;
  138204. /**
  138205. * Update the uniform values of the procedural texture in the shader.
  138206. */
  138207. updateShaderUniforms(): void;
  138208. /**
  138209. * Define if the texture animates or not.
  138210. */
  138211. get animate(): boolean;
  138212. set animate(value: boolean);
  138213. }
  138214. }
  138215. declare module BABYLON {
  138216. /** @hidden */
  138217. export var noisePixelShader: {
  138218. name: string;
  138219. shader: string;
  138220. };
  138221. }
  138222. declare module BABYLON {
  138223. /**
  138224. * Class used to generate noise procedural textures
  138225. */
  138226. export class NoiseProceduralTexture extends ProceduralTexture {
  138227. private _time;
  138228. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  138229. brightness: number;
  138230. /** Defines the number of octaves to process */
  138231. octaves: number;
  138232. /** Defines the level of persistence (0.8 by default) */
  138233. persistence: number;
  138234. /** Gets or sets animation speed factor (default is 1) */
  138235. animationSpeedFactor: number;
  138236. /**
  138237. * Creates a new NoiseProceduralTexture
  138238. * @param name defines the name fo the texture
  138239. * @param size defines the size of the texture (default is 256)
  138240. * @param scene defines the hosting scene
  138241. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  138242. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  138243. */
  138244. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138245. private _updateShaderUniforms;
  138246. protected _getDefines(): string;
  138247. /** Generate the current state of the procedural texture */
  138248. render(useCameraPostProcess?: boolean): void;
  138249. /**
  138250. * Serializes this noise procedural texture
  138251. * @returns a serialized noise procedural texture object
  138252. */
  138253. serialize(): any;
  138254. /**
  138255. * Clone the texture.
  138256. * @returns the cloned texture
  138257. */
  138258. clone(): NoiseProceduralTexture;
  138259. /**
  138260. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  138261. * @param parsedTexture defines parsed texture data
  138262. * @param scene defines the current scene
  138263. * @param rootUrl defines the root URL containing noise procedural texture information
  138264. * @returns a parsed NoiseProceduralTexture
  138265. */
  138266. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  138267. }
  138268. }
  138269. declare module BABYLON {
  138270. /**
  138271. * Raw cube texture where the raw buffers are passed in
  138272. */
  138273. export class RawCubeTexture extends CubeTexture {
  138274. /**
  138275. * Creates a cube texture where the raw buffers are passed in.
  138276. * @param scene defines the scene the texture is attached to
  138277. * @param data defines the array of data to use to create each face
  138278. * @param size defines the size of the textures
  138279. * @param format defines the format of the data
  138280. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  138281. * @param generateMipMaps defines if the engine should generate the mip levels
  138282. * @param invertY defines if data must be stored with Y axis inverted
  138283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  138284. * @param compression defines the compression used (null by default)
  138285. */
  138286. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  138287. /**
  138288. * Updates the raw cube texture.
  138289. * @param data defines the data to store
  138290. * @param format defines the data format
  138291. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138292. * @param invertY defines if data must be stored with Y axis inverted
  138293. * @param compression defines the compression used (null by default)
  138294. * @param level defines which level of the texture to update
  138295. */
  138296. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  138297. /**
  138298. * Updates a raw cube texture with RGBD encoded data.
  138299. * @param data defines the array of data [mipmap][face] to use to create each face
  138300. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  138301. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138302. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138303. * @returns a promsie that resolves when the operation is complete
  138304. */
  138305. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  138306. /**
  138307. * Clones the raw cube texture.
  138308. * @return a new cube texture
  138309. */
  138310. clone(): CubeTexture;
  138311. /** @hidden */
  138312. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138313. }
  138314. }
  138315. declare module BABYLON {
  138316. /**
  138317. * Class used to store 2D array textures containing user data
  138318. */
  138319. export class RawTexture2DArray extends Texture {
  138320. /** Gets or sets the texture format to use */
  138321. format: number;
  138322. /**
  138323. * Create a new RawTexture2DArray
  138324. * @param data defines the data of the texture
  138325. * @param width defines the width of the texture
  138326. * @param height defines the height of the texture
  138327. * @param depth defines the number of layers of the texture
  138328. * @param format defines the texture format to use
  138329. * @param scene defines the hosting scene
  138330. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138331. * @param invertY defines if texture must be stored with Y axis inverted
  138332. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138333. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138334. */
  138335. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138336. /** Gets or sets the texture format to use */
  138337. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138338. /**
  138339. * Update the texture with new data
  138340. * @param data defines the data to store in the texture
  138341. */
  138342. update(data: ArrayBufferView): void;
  138343. }
  138344. }
  138345. declare module BABYLON {
  138346. /**
  138347. * Class used to store 3D textures containing user data
  138348. */
  138349. export class RawTexture3D extends Texture {
  138350. /** Gets or sets the texture format to use */
  138351. format: number;
  138352. /**
  138353. * Create a new RawTexture3D
  138354. * @param data defines the data of the texture
  138355. * @param width defines the width of the texture
  138356. * @param height defines the height of the texture
  138357. * @param depth defines the depth of the texture
  138358. * @param format defines the texture format to use
  138359. * @param scene defines the hosting scene
  138360. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138361. * @param invertY defines if texture must be stored with Y axis inverted
  138362. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138363. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138364. */
  138365. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138366. /** Gets or sets the texture format to use */
  138367. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138368. /**
  138369. * Update the texture with new data
  138370. * @param data defines the data to store in the texture
  138371. */
  138372. update(data: ArrayBufferView): void;
  138373. }
  138374. }
  138375. declare module BABYLON {
  138376. /**
  138377. * Creates a refraction texture used by refraction channel of the standard material.
  138378. * It is like a mirror but to see through a material.
  138379. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138380. */
  138381. export class RefractionTexture extends RenderTargetTexture {
  138382. /**
  138383. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  138384. * 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.
  138385. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138386. */
  138387. refractionPlane: Plane;
  138388. /**
  138389. * Define how deep under the surface we should see.
  138390. */
  138391. depth: number;
  138392. /**
  138393. * Creates a refraction texture used by refraction channel of the standard material.
  138394. * It is like a mirror but to see through a material.
  138395. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138396. * @param name Define the texture name
  138397. * @param size Define the size of the underlying texture
  138398. * @param scene Define the scene the refraction belongs to
  138399. * @param generateMipMaps Define if we need to generate mips level for the refraction
  138400. */
  138401. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  138402. /**
  138403. * Clone the refraction texture.
  138404. * @returns the cloned texture
  138405. */
  138406. clone(): RefractionTexture;
  138407. /**
  138408. * Serialize the texture to a JSON representation you could use in Parse later on
  138409. * @returns the serialized JSON representation
  138410. */
  138411. serialize(): any;
  138412. }
  138413. }
  138414. declare module BABYLON {
  138415. /**
  138416. * Block used to add support for vertex skinning (bones)
  138417. */
  138418. export class BonesBlock extends NodeMaterialBlock {
  138419. /**
  138420. * Creates a new BonesBlock
  138421. * @param name defines the block name
  138422. */
  138423. constructor(name: string);
  138424. /**
  138425. * Initialize the block and prepare the context for build
  138426. * @param state defines the state that will be used for the build
  138427. */
  138428. initialize(state: NodeMaterialBuildState): void;
  138429. /**
  138430. * Gets the current class name
  138431. * @returns the class name
  138432. */
  138433. getClassName(): string;
  138434. /**
  138435. * Gets the matrix indices input component
  138436. */
  138437. get matricesIndices(): NodeMaterialConnectionPoint;
  138438. /**
  138439. * Gets the matrix weights input component
  138440. */
  138441. get matricesWeights(): NodeMaterialConnectionPoint;
  138442. /**
  138443. * Gets the extra matrix indices input component
  138444. */
  138445. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  138446. /**
  138447. * Gets the extra matrix weights input component
  138448. */
  138449. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  138450. /**
  138451. * Gets the world input component
  138452. */
  138453. get world(): NodeMaterialConnectionPoint;
  138454. /**
  138455. * Gets the output component
  138456. */
  138457. get output(): NodeMaterialConnectionPoint;
  138458. autoConfigure(material: NodeMaterial): void;
  138459. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  138460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138462. protected _buildBlock(state: NodeMaterialBuildState): this;
  138463. }
  138464. }
  138465. declare module BABYLON {
  138466. /**
  138467. * Block used to add support for instances
  138468. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  138469. */
  138470. export class InstancesBlock extends NodeMaterialBlock {
  138471. /**
  138472. * Creates a new InstancesBlock
  138473. * @param name defines the block name
  138474. */
  138475. constructor(name: string);
  138476. /**
  138477. * Gets the current class name
  138478. * @returns the class name
  138479. */
  138480. getClassName(): string;
  138481. /**
  138482. * Gets the first world row input component
  138483. */
  138484. get world0(): NodeMaterialConnectionPoint;
  138485. /**
  138486. * Gets the second world row input component
  138487. */
  138488. get world1(): NodeMaterialConnectionPoint;
  138489. /**
  138490. * Gets the third world row input component
  138491. */
  138492. get world2(): NodeMaterialConnectionPoint;
  138493. /**
  138494. * Gets the forth world row input component
  138495. */
  138496. get world3(): NodeMaterialConnectionPoint;
  138497. /**
  138498. * Gets the world input component
  138499. */
  138500. get world(): NodeMaterialConnectionPoint;
  138501. /**
  138502. * Gets the output component
  138503. */
  138504. get output(): NodeMaterialConnectionPoint;
  138505. /**
  138506. * Gets the isntanceID component
  138507. */
  138508. get instanceID(): NodeMaterialConnectionPoint;
  138509. autoConfigure(material: NodeMaterial): void;
  138510. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  138511. protected _buildBlock(state: NodeMaterialBuildState): this;
  138512. }
  138513. }
  138514. declare module BABYLON {
  138515. /**
  138516. * Block used to add morph targets support to vertex shader
  138517. */
  138518. export class MorphTargetsBlock extends NodeMaterialBlock {
  138519. private _repeatableContentAnchor;
  138520. /**
  138521. * Create a new MorphTargetsBlock
  138522. * @param name defines the block name
  138523. */
  138524. constructor(name: string);
  138525. /**
  138526. * Gets the current class name
  138527. * @returns the class name
  138528. */
  138529. getClassName(): string;
  138530. /**
  138531. * Gets the position input component
  138532. */
  138533. get position(): NodeMaterialConnectionPoint;
  138534. /**
  138535. * Gets the normal input component
  138536. */
  138537. get normal(): NodeMaterialConnectionPoint;
  138538. /**
  138539. * Gets the tangent input component
  138540. */
  138541. get tangent(): NodeMaterialConnectionPoint;
  138542. /**
  138543. * Gets the tangent input component
  138544. */
  138545. get uv(): NodeMaterialConnectionPoint;
  138546. /**
  138547. * Gets the position output component
  138548. */
  138549. get positionOutput(): NodeMaterialConnectionPoint;
  138550. /**
  138551. * Gets the normal output component
  138552. */
  138553. get normalOutput(): NodeMaterialConnectionPoint;
  138554. /**
  138555. * Gets the tangent output component
  138556. */
  138557. get tangentOutput(): NodeMaterialConnectionPoint;
  138558. /**
  138559. * Gets the tangent output component
  138560. */
  138561. get uvOutput(): NodeMaterialConnectionPoint;
  138562. initialize(state: NodeMaterialBuildState): void;
  138563. autoConfigure(material: NodeMaterial): void;
  138564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138566. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  138567. protected _buildBlock(state: NodeMaterialBuildState): this;
  138568. }
  138569. }
  138570. declare module BABYLON {
  138571. /**
  138572. * Block used to get data information from a light
  138573. */
  138574. export class LightInformationBlock extends NodeMaterialBlock {
  138575. private _lightDataUniformName;
  138576. private _lightColorUniformName;
  138577. private _lightTypeDefineName;
  138578. /**
  138579. * Gets or sets the light associated with this block
  138580. */
  138581. light: Nullable<Light>;
  138582. /**
  138583. * Creates a new LightInformationBlock
  138584. * @param name defines the block name
  138585. */
  138586. constructor(name: string);
  138587. /**
  138588. * Gets the current class name
  138589. * @returns the class name
  138590. */
  138591. getClassName(): string;
  138592. /**
  138593. * Gets the world position input component
  138594. */
  138595. get worldPosition(): NodeMaterialConnectionPoint;
  138596. /**
  138597. * Gets the direction output component
  138598. */
  138599. get direction(): NodeMaterialConnectionPoint;
  138600. /**
  138601. * Gets the direction output component
  138602. */
  138603. get color(): NodeMaterialConnectionPoint;
  138604. /**
  138605. * Gets the direction output component
  138606. */
  138607. get intensity(): NodeMaterialConnectionPoint;
  138608. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138610. protected _buildBlock(state: NodeMaterialBuildState): this;
  138611. serialize(): any;
  138612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138613. }
  138614. }
  138615. declare module BABYLON {
  138616. /**
  138617. * Block used to add image processing support to fragment shader
  138618. */
  138619. export class ImageProcessingBlock extends NodeMaterialBlock {
  138620. /**
  138621. * Create a new ImageProcessingBlock
  138622. * @param name defines the block name
  138623. */
  138624. constructor(name: string);
  138625. /**
  138626. * Gets the current class name
  138627. * @returns the class name
  138628. */
  138629. getClassName(): string;
  138630. /**
  138631. * Gets the color input component
  138632. */
  138633. get color(): NodeMaterialConnectionPoint;
  138634. /**
  138635. * Gets the output component
  138636. */
  138637. get output(): NodeMaterialConnectionPoint;
  138638. /**
  138639. * Initialize the block and prepare the context for build
  138640. * @param state defines the state that will be used for the build
  138641. */
  138642. initialize(state: NodeMaterialBuildState): void;
  138643. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138645. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138646. protected _buildBlock(state: NodeMaterialBuildState): this;
  138647. }
  138648. }
  138649. declare module BABYLON {
  138650. /**
  138651. * Block used to pertub normals based on a normal map
  138652. */
  138653. export class PerturbNormalBlock extends NodeMaterialBlock {
  138654. private _tangentSpaceParameterName;
  138655. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  138656. invertX: boolean;
  138657. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  138658. invertY: boolean;
  138659. /**
  138660. * Create a new PerturbNormalBlock
  138661. * @param name defines the block name
  138662. */
  138663. constructor(name: string);
  138664. /**
  138665. * Gets the current class name
  138666. * @returns the class name
  138667. */
  138668. getClassName(): string;
  138669. /**
  138670. * Gets the world position input component
  138671. */
  138672. get worldPosition(): NodeMaterialConnectionPoint;
  138673. /**
  138674. * Gets the world normal input component
  138675. */
  138676. get worldNormal(): NodeMaterialConnectionPoint;
  138677. /**
  138678. * Gets the world tangent input component
  138679. */
  138680. get worldTangent(): NodeMaterialConnectionPoint;
  138681. /**
  138682. * Gets the uv input component
  138683. */
  138684. get uv(): NodeMaterialConnectionPoint;
  138685. /**
  138686. * Gets the normal map color input component
  138687. */
  138688. get normalMapColor(): NodeMaterialConnectionPoint;
  138689. /**
  138690. * Gets the strength input component
  138691. */
  138692. get strength(): NodeMaterialConnectionPoint;
  138693. /**
  138694. * Gets the output component
  138695. */
  138696. get output(): NodeMaterialConnectionPoint;
  138697. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138698. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138699. autoConfigure(material: NodeMaterial): void;
  138700. protected _buildBlock(state: NodeMaterialBuildState): this;
  138701. protected _dumpPropertiesCode(): string;
  138702. serialize(): any;
  138703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138704. }
  138705. }
  138706. declare module BABYLON {
  138707. /**
  138708. * Block used to discard a pixel if a value is smaller than a cutoff
  138709. */
  138710. export class DiscardBlock extends NodeMaterialBlock {
  138711. /**
  138712. * Create a new DiscardBlock
  138713. * @param name defines the block name
  138714. */
  138715. constructor(name: string);
  138716. /**
  138717. * Gets the current class name
  138718. * @returns the class name
  138719. */
  138720. getClassName(): string;
  138721. /**
  138722. * Gets the color input component
  138723. */
  138724. get value(): NodeMaterialConnectionPoint;
  138725. /**
  138726. * Gets the cutoff input component
  138727. */
  138728. get cutoff(): NodeMaterialConnectionPoint;
  138729. protected _buildBlock(state: NodeMaterialBuildState): this;
  138730. }
  138731. }
  138732. declare module BABYLON {
  138733. /**
  138734. * Block used to test if the fragment shader is front facing
  138735. */
  138736. export class FrontFacingBlock extends NodeMaterialBlock {
  138737. /**
  138738. * Creates a new FrontFacingBlock
  138739. * @param name defines the block name
  138740. */
  138741. constructor(name: string);
  138742. /**
  138743. * Gets the current class name
  138744. * @returns the class name
  138745. */
  138746. getClassName(): string;
  138747. /**
  138748. * Gets the output component
  138749. */
  138750. get output(): NodeMaterialConnectionPoint;
  138751. protected _buildBlock(state: NodeMaterialBuildState): this;
  138752. }
  138753. }
  138754. declare module BABYLON {
  138755. /**
  138756. * Block used to get the derivative value on x and y of a given input
  138757. */
  138758. export class DerivativeBlock extends NodeMaterialBlock {
  138759. /**
  138760. * Create a new DerivativeBlock
  138761. * @param name defines the block name
  138762. */
  138763. constructor(name: string);
  138764. /**
  138765. * Gets the current class name
  138766. * @returns the class name
  138767. */
  138768. getClassName(): string;
  138769. /**
  138770. * Gets the input component
  138771. */
  138772. get input(): NodeMaterialConnectionPoint;
  138773. /**
  138774. * Gets the derivative output on x
  138775. */
  138776. get dx(): NodeMaterialConnectionPoint;
  138777. /**
  138778. * Gets the derivative output on y
  138779. */
  138780. get dy(): NodeMaterialConnectionPoint;
  138781. protected _buildBlock(state: NodeMaterialBuildState): this;
  138782. }
  138783. }
  138784. declare module BABYLON {
  138785. /**
  138786. * Block used to make gl_FragCoord available
  138787. */
  138788. export class FragCoordBlock extends NodeMaterialBlock {
  138789. /**
  138790. * Creates a new FragCoordBlock
  138791. * @param name defines the block name
  138792. */
  138793. constructor(name: string);
  138794. /**
  138795. * Gets the current class name
  138796. * @returns the class name
  138797. */
  138798. getClassName(): string;
  138799. /**
  138800. * Gets the xy component
  138801. */
  138802. get xy(): NodeMaterialConnectionPoint;
  138803. /**
  138804. * Gets the xyz component
  138805. */
  138806. get xyz(): NodeMaterialConnectionPoint;
  138807. /**
  138808. * Gets the xyzw component
  138809. */
  138810. get xyzw(): NodeMaterialConnectionPoint;
  138811. /**
  138812. * Gets the x component
  138813. */
  138814. get x(): NodeMaterialConnectionPoint;
  138815. /**
  138816. * Gets the y component
  138817. */
  138818. get y(): NodeMaterialConnectionPoint;
  138819. /**
  138820. * Gets the z component
  138821. */
  138822. get z(): NodeMaterialConnectionPoint;
  138823. /**
  138824. * Gets the w component
  138825. */
  138826. get output(): NodeMaterialConnectionPoint;
  138827. protected writeOutputs(state: NodeMaterialBuildState): string;
  138828. protected _buildBlock(state: NodeMaterialBuildState): this;
  138829. }
  138830. }
  138831. declare module BABYLON {
  138832. /**
  138833. * Block used to get the screen sizes
  138834. */
  138835. export class ScreenSizeBlock extends NodeMaterialBlock {
  138836. private _varName;
  138837. private _scene;
  138838. /**
  138839. * Creates a new ScreenSizeBlock
  138840. * @param name defines the block name
  138841. */
  138842. constructor(name: string);
  138843. /**
  138844. * Gets the current class name
  138845. * @returns the class name
  138846. */
  138847. getClassName(): string;
  138848. /**
  138849. * Gets the xy component
  138850. */
  138851. get xy(): NodeMaterialConnectionPoint;
  138852. /**
  138853. * Gets the x component
  138854. */
  138855. get x(): NodeMaterialConnectionPoint;
  138856. /**
  138857. * Gets the y component
  138858. */
  138859. get y(): NodeMaterialConnectionPoint;
  138860. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138861. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  138862. protected _buildBlock(state: NodeMaterialBuildState): this;
  138863. }
  138864. }
  138865. declare module BABYLON {
  138866. /**
  138867. * Block used to add support for scene fog
  138868. */
  138869. export class FogBlock extends NodeMaterialBlock {
  138870. private _fogDistanceName;
  138871. private _fogParameters;
  138872. /**
  138873. * Create a new FogBlock
  138874. * @param name defines the block name
  138875. */
  138876. constructor(name: string);
  138877. /**
  138878. * Gets the current class name
  138879. * @returns the class name
  138880. */
  138881. getClassName(): string;
  138882. /**
  138883. * Gets the world position input component
  138884. */
  138885. get worldPosition(): NodeMaterialConnectionPoint;
  138886. /**
  138887. * Gets the view input component
  138888. */
  138889. get view(): NodeMaterialConnectionPoint;
  138890. /**
  138891. * Gets the color input component
  138892. */
  138893. get input(): NodeMaterialConnectionPoint;
  138894. /**
  138895. * Gets the fog color input component
  138896. */
  138897. get fogColor(): NodeMaterialConnectionPoint;
  138898. /**
  138899. * Gets the output component
  138900. */
  138901. get output(): NodeMaterialConnectionPoint;
  138902. autoConfigure(material: NodeMaterial): void;
  138903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138905. protected _buildBlock(state: NodeMaterialBuildState): this;
  138906. }
  138907. }
  138908. declare module BABYLON {
  138909. /**
  138910. * Block used to add light in the fragment shader
  138911. */
  138912. export class LightBlock extends NodeMaterialBlock {
  138913. private _lightId;
  138914. /**
  138915. * Gets or sets the light associated with this block
  138916. */
  138917. light: Nullable<Light>;
  138918. /**
  138919. * Create a new LightBlock
  138920. * @param name defines the block name
  138921. */
  138922. constructor(name: string);
  138923. /**
  138924. * Gets the current class name
  138925. * @returns the class name
  138926. */
  138927. getClassName(): string;
  138928. /**
  138929. * Gets the world position input component
  138930. */
  138931. get worldPosition(): NodeMaterialConnectionPoint;
  138932. /**
  138933. * Gets the world normal input component
  138934. */
  138935. get worldNormal(): NodeMaterialConnectionPoint;
  138936. /**
  138937. * Gets the camera (or eye) position component
  138938. */
  138939. get cameraPosition(): NodeMaterialConnectionPoint;
  138940. /**
  138941. * Gets the glossiness component
  138942. */
  138943. get glossiness(): NodeMaterialConnectionPoint;
  138944. /**
  138945. * Gets the glossinness power component
  138946. */
  138947. get glossPower(): NodeMaterialConnectionPoint;
  138948. /**
  138949. * Gets the diffuse color component
  138950. */
  138951. get diffuseColor(): NodeMaterialConnectionPoint;
  138952. /**
  138953. * Gets the specular color component
  138954. */
  138955. get specularColor(): NodeMaterialConnectionPoint;
  138956. /**
  138957. * Gets the diffuse output component
  138958. */
  138959. get diffuseOutput(): NodeMaterialConnectionPoint;
  138960. /**
  138961. * Gets the specular output component
  138962. */
  138963. get specularOutput(): NodeMaterialConnectionPoint;
  138964. /**
  138965. * Gets the shadow output component
  138966. */
  138967. get shadow(): NodeMaterialConnectionPoint;
  138968. autoConfigure(material: NodeMaterial): void;
  138969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138970. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  138971. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138972. private _injectVertexCode;
  138973. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  138974. serialize(): any;
  138975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138976. }
  138977. }
  138978. declare module BABYLON {
  138979. /**
  138980. * Block used to read a reflection texture from a sampler
  138981. */
  138982. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  138983. /**
  138984. * Create a new ReflectionTextureBlock
  138985. * @param name defines the block name
  138986. */
  138987. constructor(name: string);
  138988. /**
  138989. * Gets the current class name
  138990. * @returns the class name
  138991. */
  138992. getClassName(): string;
  138993. /**
  138994. * Gets the world position input component
  138995. */
  138996. get position(): NodeMaterialConnectionPoint;
  138997. /**
  138998. * Gets the world position input component
  138999. */
  139000. get worldPosition(): NodeMaterialConnectionPoint;
  139001. /**
  139002. * Gets the world normal input component
  139003. */
  139004. get worldNormal(): NodeMaterialConnectionPoint;
  139005. /**
  139006. * Gets the world input component
  139007. */
  139008. get world(): NodeMaterialConnectionPoint;
  139009. /**
  139010. * Gets the camera (or eye) position component
  139011. */
  139012. get cameraPosition(): NodeMaterialConnectionPoint;
  139013. /**
  139014. * Gets the view input component
  139015. */
  139016. get view(): NodeMaterialConnectionPoint;
  139017. /**
  139018. * Gets the rgb output component
  139019. */
  139020. get rgb(): NodeMaterialConnectionPoint;
  139021. /**
  139022. * Gets the r output component
  139023. */
  139024. get r(): NodeMaterialConnectionPoint;
  139025. /**
  139026. * Gets the g output component
  139027. */
  139028. get g(): NodeMaterialConnectionPoint;
  139029. /**
  139030. * Gets the b output component
  139031. */
  139032. get b(): NodeMaterialConnectionPoint;
  139033. autoConfigure(material: NodeMaterial): void;
  139034. protected _buildBlock(state: NodeMaterialBuildState): this;
  139035. }
  139036. }
  139037. declare module BABYLON {
  139038. /**
  139039. * Block used to add 2 vectors
  139040. */
  139041. export class AddBlock extends NodeMaterialBlock {
  139042. /**
  139043. * Creates a new AddBlock
  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 left operand input component
  139054. */
  139055. get left(): NodeMaterialConnectionPoint;
  139056. /**
  139057. * Gets the right operand input component
  139058. */
  139059. get right(): NodeMaterialConnectionPoint;
  139060. /**
  139061. * Gets the output component
  139062. */
  139063. get output(): NodeMaterialConnectionPoint;
  139064. protected _buildBlock(state: NodeMaterialBuildState): this;
  139065. }
  139066. }
  139067. declare module BABYLON {
  139068. /**
  139069. * Block used to scale a vector by a float
  139070. */
  139071. export class ScaleBlock extends NodeMaterialBlock {
  139072. /**
  139073. * Creates a new ScaleBlock
  139074. * @param name defines the block name
  139075. */
  139076. constructor(name: string);
  139077. /**
  139078. * Gets the current class name
  139079. * @returns the class name
  139080. */
  139081. getClassName(): string;
  139082. /**
  139083. * Gets the input component
  139084. */
  139085. get input(): NodeMaterialConnectionPoint;
  139086. /**
  139087. * Gets the factor input component
  139088. */
  139089. get factor(): NodeMaterialConnectionPoint;
  139090. /**
  139091. * Gets the output component
  139092. */
  139093. get output(): NodeMaterialConnectionPoint;
  139094. protected _buildBlock(state: NodeMaterialBuildState): this;
  139095. }
  139096. }
  139097. declare module BABYLON {
  139098. /**
  139099. * Block used to clamp a float
  139100. */
  139101. export class ClampBlock extends NodeMaterialBlock {
  139102. /** Gets or sets the minimum range */
  139103. minimum: number;
  139104. /** Gets or sets the maximum range */
  139105. maximum: number;
  139106. /**
  139107. * Creates a new ClampBlock
  139108. * @param name defines the block name
  139109. */
  139110. constructor(name: string);
  139111. /**
  139112. * Gets the current class name
  139113. * @returns the class name
  139114. */
  139115. getClassName(): string;
  139116. /**
  139117. * Gets the value input component
  139118. */
  139119. get value(): NodeMaterialConnectionPoint;
  139120. /**
  139121. * Gets the output component
  139122. */
  139123. get output(): NodeMaterialConnectionPoint;
  139124. protected _buildBlock(state: NodeMaterialBuildState): this;
  139125. protected _dumpPropertiesCode(): string;
  139126. serialize(): any;
  139127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139128. }
  139129. }
  139130. declare module BABYLON {
  139131. /**
  139132. * Block used to apply a cross product between 2 vectors
  139133. */
  139134. export class CrossBlock extends NodeMaterialBlock {
  139135. /**
  139136. * Creates a new CrossBlock
  139137. * @param name defines the block name
  139138. */
  139139. constructor(name: string);
  139140. /**
  139141. * Gets the current class name
  139142. * @returns the class name
  139143. */
  139144. getClassName(): string;
  139145. /**
  139146. * Gets the left operand input component
  139147. */
  139148. get left(): NodeMaterialConnectionPoint;
  139149. /**
  139150. * Gets the right operand input component
  139151. */
  139152. get right(): 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 apply a dot product between 2 vectors
  139163. */
  139164. export class DotBlock extends NodeMaterialBlock {
  139165. /**
  139166. * Creates a new DotBlock
  139167. * @param name defines the block name
  139168. */
  139169. constructor(name: string);
  139170. /**
  139171. * Gets the current class name
  139172. * @returns the class name
  139173. */
  139174. getClassName(): string;
  139175. /**
  139176. * Gets the left operand input component
  139177. */
  139178. get left(): NodeMaterialConnectionPoint;
  139179. /**
  139180. * Gets the right operand input component
  139181. */
  139182. get right(): NodeMaterialConnectionPoint;
  139183. /**
  139184. * Gets the output component
  139185. */
  139186. get output(): NodeMaterialConnectionPoint;
  139187. protected _buildBlock(state: NodeMaterialBuildState): this;
  139188. }
  139189. }
  139190. declare module BABYLON {
  139191. /**
  139192. * Block used to normalize a vector
  139193. */
  139194. export class NormalizeBlock extends NodeMaterialBlock {
  139195. /**
  139196. * Creates a new NormalizeBlock
  139197. * @param name defines the block name
  139198. */
  139199. constructor(name: string);
  139200. /**
  139201. * Gets the current class name
  139202. * @returns the class name
  139203. */
  139204. getClassName(): string;
  139205. /**
  139206. * Gets the input component
  139207. */
  139208. get input(): NodeMaterialConnectionPoint;
  139209. /**
  139210. * Gets the output component
  139211. */
  139212. get output(): NodeMaterialConnectionPoint;
  139213. protected _buildBlock(state: NodeMaterialBuildState): this;
  139214. }
  139215. }
  139216. declare module BABYLON {
  139217. /**
  139218. * Operations supported by the Trigonometry block
  139219. */
  139220. export enum TrigonometryBlockOperations {
  139221. /** Cos */
  139222. Cos = 0,
  139223. /** Sin */
  139224. Sin = 1,
  139225. /** Abs */
  139226. Abs = 2,
  139227. /** Exp */
  139228. Exp = 3,
  139229. /** Exp2 */
  139230. Exp2 = 4,
  139231. /** Round */
  139232. Round = 5,
  139233. /** Floor */
  139234. Floor = 6,
  139235. /** Ceiling */
  139236. Ceiling = 7,
  139237. /** Square root */
  139238. Sqrt = 8,
  139239. /** Log */
  139240. Log = 9,
  139241. /** Tangent */
  139242. Tan = 10,
  139243. /** Arc tangent */
  139244. ArcTan = 11,
  139245. /** Arc cosinus */
  139246. ArcCos = 12,
  139247. /** Arc sinus */
  139248. ArcSin = 13,
  139249. /** Fraction */
  139250. Fract = 14,
  139251. /** Sign */
  139252. Sign = 15,
  139253. /** To radians (from degrees) */
  139254. Radians = 16,
  139255. /** To degrees (from radians) */
  139256. Degrees = 17
  139257. }
  139258. /**
  139259. * Block used to apply trigonometry operation to floats
  139260. */
  139261. export class TrigonometryBlock extends NodeMaterialBlock {
  139262. /**
  139263. * Gets or sets the operation applied by the block
  139264. */
  139265. operation: TrigonometryBlockOperations;
  139266. /**
  139267. * Creates a new TrigonometryBlock
  139268. * @param name defines the block name
  139269. */
  139270. constructor(name: string);
  139271. /**
  139272. * Gets the current class name
  139273. * @returns the class name
  139274. */
  139275. getClassName(): string;
  139276. /**
  139277. * Gets the input component
  139278. */
  139279. get input(): NodeMaterialConnectionPoint;
  139280. /**
  139281. * Gets the output component
  139282. */
  139283. get output(): NodeMaterialConnectionPoint;
  139284. protected _buildBlock(state: NodeMaterialBuildState): this;
  139285. serialize(): any;
  139286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139287. protected _dumpPropertiesCode(): string;
  139288. }
  139289. }
  139290. declare module BABYLON {
  139291. /**
  139292. * Block used to create a Color3/4 out of individual inputs (one for each component)
  139293. */
  139294. export class ColorMergerBlock extends NodeMaterialBlock {
  139295. /**
  139296. * Create a new ColorMergerBlock
  139297. * @param name defines the block name
  139298. */
  139299. constructor(name: string);
  139300. /**
  139301. * Gets the current class name
  139302. * @returns the class name
  139303. */
  139304. getClassName(): string;
  139305. /**
  139306. * Gets the rgb component (input)
  139307. */
  139308. get rgbIn(): NodeMaterialConnectionPoint;
  139309. /**
  139310. * Gets the r component (input)
  139311. */
  139312. get r(): NodeMaterialConnectionPoint;
  139313. /**
  139314. * Gets the g component (input)
  139315. */
  139316. get g(): NodeMaterialConnectionPoint;
  139317. /**
  139318. * Gets the b component (input)
  139319. */
  139320. get b(): NodeMaterialConnectionPoint;
  139321. /**
  139322. * Gets the a component (input)
  139323. */
  139324. get a(): NodeMaterialConnectionPoint;
  139325. /**
  139326. * Gets the rgba component (output)
  139327. */
  139328. get rgba(): NodeMaterialConnectionPoint;
  139329. /**
  139330. * Gets the rgb component (output)
  139331. */
  139332. get rgbOut(): NodeMaterialConnectionPoint;
  139333. /**
  139334. * Gets the rgb component (output)
  139335. * @deprecated Please use rgbOut instead.
  139336. */
  139337. get rgb(): NodeMaterialConnectionPoint;
  139338. protected _buildBlock(state: NodeMaterialBuildState): this;
  139339. }
  139340. }
  139341. declare module BABYLON {
  139342. /**
  139343. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  139344. */
  139345. export class VectorSplitterBlock extends NodeMaterialBlock {
  139346. /**
  139347. * Create a new VectorSplitterBlock
  139348. * @param name defines the block name
  139349. */
  139350. constructor(name: string);
  139351. /**
  139352. * Gets the current class name
  139353. * @returns the class name
  139354. */
  139355. getClassName(): string;
  139356. /**
  139357. * Gets the xyzw component (input)
  139358. */
  139359. get xyzw(): NodeMaterialConnectionPoint;
  139360. /**
  139361. * Gets the xyz component (input)
  139362. */
  139363. get xyzIn(): NodeMaterialConnectionPoint;
  139364. /**
  139365. * Gets the xy component (input)
  139366. */
  139367. get xyIn(): NodeMaterialConnectionPoint;
  139368. /**
  139369. * Gets the xyz component (output)
  139370. */
  139371. get xyzOut(): NodeMaterialConnectionPoint;
  139372. /**
  139373. * Gets the xy component (output)
  139374. */
  139375. get xyOut(): NodeMaterialConnectionPoint;
  139376. /**
  139377. * Gets the x component (output)
  139378. */
  139379. get x(): NodeMaterialConnectionPoint;
  139380. /**
  139381. * Gets the y component (output)
  139382. */
  139383. get y(): NodeMaterialConnectionPoint;
  139384. /**
  139385. * Gets the z component (output)
  139386. */
  139387. get z(): NodeMaterialConnectionPoint;
  139388. /**
  139389. * Gets the w component (output)
  139390. */
  139391. get w(): NodeMaterialConnectionPoint;
  139392. protected _inputRename(name: string): string;
  139393. protected _outputRename(name: string): string;
  139394. protected _buildBlock(state: NodeMaterialBuildState): this;
  139395. }
  139396. }
  139397. declare module BABYLON {
  139398. /**
  139399. * Block used to lerp between 2 values
  139400. */
  139401. export class LerpBlock extends NodeMaterialBlock {
  139402. /**
  139403. * Creates a new LerpBlock
  139404. * @param name defines the block name
  139405. */
  139406. constructor(name: string);
  139407. /**
  139408. * Gets the current class name
  139409. * @returns the class name
  139410. */
  139411. getClassName(): string;
  139412. /**
  139413. * Gets the left operand input component
  139414. */
  139415. get left(): NodeMaterialConnectionPoint;
  139416. /**
  139417. * Gets the right operand input component
  139418. */
  139419. get right(): NodeMaterialConnectionPoint;
  139420. /**
  139421. * Gets the gradient operand input component
  139422. */
  139423. get gradient(): NodeMaterialConnectionPoint;
  139424. /**
  139425. * Gets the output component
  139426. */
  139427. get output(): NodeMaterialConnectionPoint;
  139428. protected _buildBlock(state: NodeMaterialBuildState): this;
  139429. }
  139430. }
  139431. declare module BABYLON {
  139432. /**
  139433. * Block used to divide 2 vectors
  139434. */
  139435. export class DivideBlock extends NodeMaterialBlock {
  139436. /**
  139437. * Creates a new DivideBlock
  139438. * @param name defines the block name
  139439. */
  139440. constructor(name: string);
  139441. /**
  139442. * Gets the current class name
  139443. * @returns the class name
  139444. */
  139445. getClassName(): string;
  139446. /**
  139447. * Gets the left operand input component
  139448. */
  139449. get left(): NodeMaterialConnectionPoint;
  139450. /**
  139451. * Gets the right operand input component
  139452. */
  139453. get right(): NodeMaterialConnectionPoint;
  139454. /**
  139455. * Gets the output component
  139456. */
  139457. get output(): NodeMaterialConnectionPoint;
  139458. protected _buildBlock(state: NodeMaterialBuildState): this;
  139459. }
  139460. }
  139461. declare module BABYLON {
  139462. /**
  139463. * Block used to subtract 2 vectors
  139464. */
  139465. export class SubtractBlock extends NodeMaterialBlock {
  139466. /**
  139467. * Creates a new SubtractBlock
  139468. * @param name defines the block name
  139469. */
  139470. constructor(name: string);
  139471. /**
  139472. * Gets the current class name
  139473. * @returns the class name
  139474. */
  139475. getClassName(): string;
  139476. /**
  139477. * Gets the left operand input component
  139478. */
  139479. get left(): NodeMaterialConnectionPoint;
  139480. /**
  139481. * Gets the right operand input component
  139482. */
  139483. get right(): NodeMaterialConnectionPoint;
  139484. /**
  139485. * Gets the output component
  139486. */
  139487. get output(): NodeMaterialConnectionPoint;
  139488. protected _buildBlock(state: NodeMaterialBuildState): this;
  139489. }
  139490. }
  139491. declare module BABYLON {
  139492. /**
  139493. * Block used to step a value
  139494. */
  139495. export class StepBlock extends NodeMaterialBlock {
  139496. /**
  139497. * Creates a new StepBlock
  139498. * @param name defines the block name
  139499. */
  139500. constructor(name: string);
  139501. /**
  139502. * Gets the current class name
  139503. * @returns the class name
  139504. */
  139505. getClassName(): string;
  139506. /**
  139507. * Gets the value operand input component
  139508. */
  139509. get value(): NodeMaterialConnectionPoint;
  139510. /**
  139511. * Gets the edge operand input component
  139512. */
  139513. get edge(): NodeMaterialConnectionPoint;
  139514. /**
  139515. * Gets the output component
  139516. */
  139517. get output(): NodeMaterialConnectionPoint;
  139518. protected _buildBlock(state: NodeMaterialBuildState): this;
  139519. }
  139520. }
  139521. declare module BABYLON {
  139522. /**
  139523. * Block used to get the opposite (1 - x) of a value
  139524. */
  139525. export class OneMinusBlock extends NodeMaterialBlock {
  139526. /**
  139527. * Creates a new OneMinusBlock
  139528. * @param name defines the block name
  139529. */
  139530. constructor(name: string);
  139531. /**
  139532. * Gets the current class name
  139533. * @returns the class name
  139534. */
  139535. getClassName(): string;
  139536. /**
  139537. * Gets the input component
  139538. */
  139539. get input(): NodeMaterialConnectionPoint;
  139540. /**
  139541. * Gets the output component
  139542. */
  139543. get output(): NodeMaterialConnectionPoint;
  139544. protected _buildBlock(state: NodeMaterialBuildState): this;
  139545. }
  139546. }
  139547. declare module BABYLON {
  139548. /**
  139549. * Block used to get the view direction
  139550. */
  139551. export class ViewDirectionBlock extends NodeMaterialBlock {
  139552. /**
  139553. * Creates a new ViewDirectionBlock
  139554. * @param name defines the block name
  139555. */
  139556. constructor(name: string);
  139557. /**
  139558. * Gets the current class name
  139559. * @returns the class name
  139560. */
  139561. getClassName(): string;
  139562. /**
  139563. * Gets the world position component
  139564. */
  139565. get worldPosition(): NodeMaterialConnectionPoint;
  139566. /**
  139567. * Gets the camera position component
  139568. */
  139569. get cameraPosition(): NodeMaterialConnectionPoint;
  139570. /**
  139571. * Gets the output component
  139572. */
  139573. get output(): NodeMaterialConnectionPoint;
  139574. autoConfigure(material: NodeMaterial): void;
  139575. protected _buildBlock(state: NodeMaterialBuildState): this;
  139576. }
  139577. }
  139578. declare module BABYLON {
  139579. /**
  139580. * Block used to compute fresnel value
  139581. */
  139582. export class FresnelBlock extends NodeMaterialBlock {
  139583. /**
  139584. * Create a new FresnelBlock
  139585. * @param name defines the block name
  139586. */
  139587. constructor(name: string);
  139588. /**
  139589. * Gets the current class name
  139590. * @returns the class name
  139591. */
  139592. getClassName(): string;
  139593. /**
  139594. * Gets the world normal input component
  139595. */
  139596. get worldNormal(): NodeMaterialConnectionPoint;
  139597. /**
  139598. * Gets the view direction input component
  139599. */
  139600. get viewDirection(): NodeMaterialConnectionPoint;
  139601. /**
  139602. * Gets the bias input component
  139603. */
  139604. get bias(): NodeMaterialConnectionPoint;
  139605. /**
  139606. * Gets the camera (or eye) position component
  139607. */
  139608. get power(): NodeMaterialConnectionPoint;
  139609. /**
  139610. * Gets the fresnel output component
  139611. */
  139612. get fresnel(): NodeMaterialConnectionPoint;
  139613. autoConfigure(material: NodeMaterial): void;
  139614. protected _buildBlock(state: NodeMaterialBuildState): this;
  139615. }
  139616. }
  139617. declare module BABYLON {
  139618. /**
  139619. * Block used to get the max of 2 values
  139620. */
  139621. export class MaxBlock extends NodeMaterialBlock {
  139622. /**
  139623. * Creates a new MaxBlock
  139624. * @param name defines the block name
  139625. */
  139626. constructor(name: string);
  139627. /**
  139628. * Gets the current class name
  139629. * @returns the class name
  139630. */
  139631. getClassName(): string;
  139632. /**
  139633. * Gets the left operand input component
  139634. */
  139635. get left(): NodeMaterialConnectionPoint;
  139636. /**
  139637. * Gets the right operand input component
  139638. */
  139639. get right(): NodeMaterialConnectionPoint;
  139640. /**
  139641. * Gets the output component
  139642. */
  139643. get output(): NodeMaterialConnectionPoint;
  139644. protected _buildBlock(state: NodeMaterialBuildState): this;
  139645. }
  139646. }
  139647. declare module BABYLON {
  139648. /**
  139649. * Block used to get the min of 2 values
  139650. */
  139651. export class MinBlock extends NodeMaterialBlock {
  139652. /**
  139653. * Creates a new MinBlock
  139654. * @param name defines the block name
  139655. */
  139656. constructor(name: string);
  139657. /**
  139658. * Gets the current class name
  139659. * @returns the class name
  139660. */
  139661. getClassName(): string;
  139662. /**
  139663. * Gets the left operand input component
  139664. */
  139665. get left(): NodeMaterialConnectionPoint;
  139666. /**
  139667. * Gets the right operand input component
  139668. */
  139669. get right(): NodeMaterialConnectionPoint;
  139670. /**
  139671. * Gets the output component
  139672. */
  139673. get output(): NodeMaterialConnectionPoint;
  139674. protected _buildBlock(state: NodeMaterialBuildState): this;
  139675. }
  139676. }
  139677. declare module BABYLON {
  139678. /**
  139679. * Block used to get the distance between 2 values
  139680. */
  139681. export class DistanceBlock extends NodeMaterialBlock {
  139682. /**
  139683. * Creates a new DistanceBlock
  139684. * @param name defines the block name
  139685. */
  139686. constructor(name: string);
  139687. /**
  139688. * Gets the current class name
  139689. * @returns the class name
  139690. */
  139691. getClassName(): string;
  139692. /**
  139693. * Gets the left operand input component
  139694. */
  139695. get left(): NodeMaterialConnectionPoint;
  139696. /**
  139697. * Gets the right operand input component
  139698. */
  139699. get right(): NodeMaterialConnectionPoint;
  139700. /**
  139701. * Gets the output component
  139702. */
  139703. get output(): NodeMaterialConnectionPoint;
  139704. protected _buildBlock(state: NodeMaterialBuildState): this;
  139705. }
  139706. }
  139707. declare module BABYLON {
  139708. /**
  139709. * Block used to get the length of a vector
  139710. */
  139711. export class LengthBlock extends NodeMaterialBlock {
  139712. /**
  139713. * Creates a new LengthBlock
  139714. * @param name defines the block name
  139715. */
  139716. constructor(name: string);
  139717. /**
  139718. * Gets the current class name
  139719. * @returns the class name
  139720. */
  139721. getClassName(): string;
  139722. /**
  139723. * Gets the value input component
  139724. */
  139725. get value(): NodeMaterialConnectionPoint;
  139726. /**
  139727. * Gets the output component
  139728. */
  139729. get output(): NodeMaterialConnectionPoint;
  139730. protected _buildBlock(state: NodeMaterialBuildState): this;
  139731. }
  139732. }
  139733. declare module BABYLON {
  139734. /**
  139735. * Block used to get negative version of a value (i.e. x * -1)
  139736. */
  139737. export class NegateBlock extends NodeMaterialBlock {
  139738. /**
  139739. * Creates a new NegateBlock
  139740. * @param name defines the block name
  139741. */
  139742. constructor(name: string);
  139743. /**
  139744. * Gets the current class name
  139745. * @returns the class name
  139746. */
  139747. getClassName(): string;
  139748. /**
  139749. * Gets the value input component
  139750. */
  139751. get value(): NodeMaterialConnectionPoint;
  139752. /**
  139753. * Gets the output component
  139754. */
  139755. get output(): NodeMaterialConnectionPoint;
  139756. protected _buildBlock(state: NodeMaterialBuildState): this;
  139757. }
  139758. }
  139759. declare module BABYLON {
  139760. /**
  139761. * Block used to get the value of the first parameter raised to the power of the second
  139762. */
  139763. export class PowBlock extends NodeMaterialBlock {
  139764. /**
  139765. * Creates a new PowBlock
  139766. * @param name defines the block name
  139767. */
  139768. constructor(name: string);
  139769. /**
  139770. * Gets the current class name
  139771. * @returns the class name
  139772. */
  139773. getClassName(): string;
  139774. /**
  139775. * Gets the value operand input component
  139776. */
  139777. get value(): NodeMaterialConnectionPoint;
  139778. /**
  139779. * Gets the power operand input component
  139780. */
  139781. get power(): NodeMaterialConnectionPoint;
  139782. /**
  139783. * Gets the output component
  139784. */
  139785. get output(): NodeMaterialConnectionPoint;
  139786. protected _buildBlock(state: NodeMaterialBuildState): this;
  139787. }
  139788. }
  139789. declare module BABYLON {
  139790. /**
  139791. * Block used to get a random number
  139792. */
  139793. export class RandomNumberBlock extends NodeMaterialBlock {
  139794. /**
  139795. * Creates a new RandomNumberBlock
  139796. * @param name defines the block name
  139797. */
  139798. constructor(name: string);
  139799. /**
  139800. * Gets the current class name
  139801. * @returns the class name
  139802. */
  139803. getClassName(): string;
  139804. /**
  139805. * Gets the seed input component
  139806. */
  139807. get seed(): NodeMaterialConnectionPoint;
  139808. /**
  139809. * Gets the output component
  139810. */
  139811. get output(): NodeMaterialConnectionPoint;
  139812. protected _buildBlock(state: NodeMaterialBuildState): this;
  139813. }
  139814. }
  139815. declare module BABYLON {
  139816. /**
  139817. * Block used to compute arc tangent of 2 values
  139818. */
  139819. export class ArcTan2Block extends NodeMaterialBlock {
  139820. /**
  139821. * Creates a new ArcTan2Block
  139822. * @param name defines the block name
  139823. */
  139824. constructor(name: string);
  139825. /**
  139826. * Gets the current class name
  139827. * @returns the class name
  139828. */
  139829. getClassName(): string;
  139830. /**
  139831. * Gets the x operand input component
  139832. */
  139833. get x(): NodeMaterialConnectionPoint;
  139834. /**
  139835. * Gets the y operand input component
  139836. */
  139837. get y(): NodeMaterialConnectionPoint;
  139838. /**
  139839. * Gets the output component
  139840. */
  139841. get output(): NodeMaterialConnectionPoint;
  139842. protected _buildBlock(state: NodeMaterialBuildState): this;
  139843. }
  139844. }
  139845. declare module BABYLON {
  139846. /**
  139847. * Block used to smooth step a value
  139848. */
  139849. export class SmoothStepBlock extends NodeMaterialBlock {
  139850. /**
  139851. * Creates a new SmoothStepBlock
  139852. * @param name defines the block name
  139853. */
  139854. constructor(name: string);
  139855. /**
  139856. * Gets the current class name
  139857. * @returns the class name
  139858. */
  139859. getClassName(): string;
  139860. /**
  139861. * Gets the value operand input component
  139862. */
  139863. get value(): NodeMaterialConnectionPoint;
  139864. /**
  139865. * Gets the first edge operand input component
  139866. */
  139867. get edge0(): NodeMaterialConnectionPoint;
  139868. /**
  139869. * Gets the second edge operand input component
  139870. */
  139871. get edge1(): NodeMaterialConnectionPoint;
  139872. /**
  139873. * Gets the output component
  139874. */
  139875. get output(): NodeMaterialConnectionPoint;
  139876. protected _buildBlock(state: NodeMaterialBuildState): this;
  139877. }
  139878. }
  139879. declare module BABYLON {
  139880. /**
  139881. * Block used to get the reciprocal (1 / x) of a value
  139882. */
  139883. export class ReciprocalBlock extends NodeMaterialBlock {
  139884. /**
  139885. * Creates a new ReciprocalBlock
  139886. * @param name defines the block name
  139887. */
  139888. constructor(name: string);
  139889. /**
  139890. * Gets the current class name
  139891. * @returns the class name
  139892. */
  139893. getClassName(): string;
  139894. /**
  139895. * Gets the input component
  139896. */
  139897. get input(): NodeMaterialConnectionPoint;
  139898. /**
  139899. * Gets the output component
  139900. */
  139901. get output(): NodeMaterialConnectionPoint;
  139902. protected _buildBlock(state: NodeMaterialBuildState): this;
  139903. }
  139904. }
  139905. declare module BABYLON {
  139906. /**
  139907. * Block used to replace a color by another one
  139908. */
  139909. export class ReplaceColorBlock extends NodeMaterialBlock {
  139910. /**
  139911. * Creates a new ReplaceColorBlock
  139912. * @param name defines the block name
  139913. */
  139914. constructor(name: string);
  139915. /**
  139916. * Gets the current class name
  139917. * @returns the class name
  139918. */
  139919. getClassName(): string;
  139920. /**
  139921. * Gets the value input component
  139922. */
  139923. get value(): NodeMaterialConnectionPoint;
  139924. /**
  139925. * Gets the reference input component
  139926. */
  139927. get reference(): NodeMaterialConnectionPoint;
  139928. /**
  139929. * Gets the distance input component
  139930. */
  139931. get distance(): NodeMaterialConnectionPoint;
  139932. /**
  139933. * Gets the replacement input component
  139934. */
  139935. get replacement(): NodeMaterialConnectionPoint;
  139936. /**
  139937. * Gets the output component
  139938. */
  139939. get output(): NodeMaterialConnectionPoint;
  139940. protected _buildBlock(state: NodeMaterialBuildState): this;
  139941. }
  139942. }
  139943. declare module BABYLON {
  139944. /**
  139945. * Block used to posterize a value
  139946. * @see https://en.wikipedia.org/wiki/Posterization
  139947. */
  139948. export class PosterizeBlock extends NodeMaterialBlock {
  139949. /**
  139950. * Creates a new PosterizeBlock
  139951. * @param name defines the block name
  139952. */
  139953. constructor(name: string);
  139954. /**
  139955. * Gets the current class name
  139956. * @returns the class name
  139957. */
  139958. getClassName(): string;
  139959. /**
  139960. * Gets the value input component
  139961. */
  139962. get value(): NodeMaterialConnectionPoint;
  139963. /**
  139964. * Gets the steps input component
  139965. */
  139966. get steps(): NodeMaterialConnectionPoint;
  139967. /**
  139968. * Gets the output component
  139969. */
  139970. get output(): NodeMaterialConnectionPoint;
  139971. protected _buildBlock(state: NodeMaterialBuildState): this;
  139972. }
  139973. }
  139974. declare module BABYLON {
  139975. /**
  139976. * Operations supported by the Wave block
  139977. */
  139978. export enum WaveBlockKind {
  139979. /** SawTooth */
  139980. SawTooth = 0,
  139981. /** Square */
  139982. Square = 1,
  139983. /** Triangle */
  139984. Triangle = 2
  139985. }
  139986. /**
  139987. * Block used to apply wave operation to floats
  139988. */
  139989. export class WaveBlock extends NodeMaterialBlock {
  139990. /**
  139991. * Gets or sets the kibnd of wave to be applied by the block
  139992. */
  139993. kind: WaveBlockKind;
  139994. /**
  139995. * Creates a new WaveBlock
  139996. * @param name defines the block name
  139997. */
  139998. constructor(name: string);
  139999. /**
  140000. * Gets the current class name
  140001. * @returns the class name
  140002. */
  140003. getClassName(): string;
  140004. /**
  140005. * Gets the input component
  140006. */
  140007. get input(): NodeMaterialConnectionPoint;
  140008. /**
  140009. * Gets the output component
  140010. */
  140011. get output(): NodeMaterialConnectionPoint;
  140012. protected _buildBlock(state: NodeMaterialBuildState): this;
  140013. serialize(): any;
  140014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140015. }
  140016. }
  140017. declare module BABYLON {
  140018. /**
  140019. * Class used to store a color step for the GradientBlock
  140020. */
  140021. export class GradientBlockColorStep {
  140022. /**
  140023. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140024. */
  140025. step: number;
  140026. /**
  140027. * Gets or sets the color associated with this step
  140028. */
  140029. color: Color3;
  140030. /**
  140031. * Creates a new GradientBlockColorStep
  140032. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  140033. * @param color defines the color associated with this step
  140034. */
  140035. constructor(
  140036. /**
  140037. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140038. */
  140039. step: number,
  140040. /**
  140041. * Gets or sets the color associated with this step
  140042. */
  140043. color: Color3);
  140044. }
  140045. /**
  140046. * Block used to return a color from a gradient based on an input value between 0 and 1
  140047. */
  140048. export class GradientBlock extends NodeMaterialBlock {
  140049. /**
  140050. * Gets or sets the list of color steps
  140051. */
  140052. colorSteps: GradientBlockColorStep[];
  140053. /**
  140054. * Creates a new GradientBlock
  140055. * @param name defines the block name
  140056. */
  140057. constructor(name: string);
  140058. /**
  140059. * Gets the current class name
  140060. * @returns the class name
  140061. */
  140062. getClassName(): string;
  140063. /**
  140064. * Gets the gradient input component
  140065. */
  140066. get gradient(): NodeMaterialConnectionPoint;
  140067. /**
  140068. * Gets the output component
  140069. */
  140070. get output(): NodeMaterialConnectionPoint;
  140071. private _writeColorConstant;
  140072. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140073. serialize(): any;
  140074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140075. protected _dumpPropertiesCode(): string;
  140076. }
  140077. }
  140078. declare module BABYLON {
  140079. /**
  140080. * Block used to normalize lerp between 2 values
  140081. */
  140082. export class NLerpBlock extends NodeMaterialBlock {
  140083. /**
  140084. * Creates a new NLerpBlock
  140085. * @param name defines the block name
  140086. */
  140087. constructor(name: string);
  140088. /**
  140089. * Gets the current class name
  140090. * @returns the class name
  140091. */
  140092. getClassName(): string;
  140093. /**
  140094. * Gets the left operand input component
  140095. */
  140096. get left(): NodeMaterialConnectionPoint;
  140097. /**
  140098. * Gets the right operand input component
  140099. */
  140100. get right(): NodeMaterialConnectionPoint;
  140101. /**
  140102. * Gets the gradient operand input component
  140103. */
  140104. get gradient(): NodeMaterialConnectionPoint;
  140105. /**
  140106. * Gets the output component
  140107. */
  140108. get output(): NodeMaterialConnectionPoint;
  140109. protected _buildBlock(state: NodeMaterialBuildState): this;
  140110. }
  140111. }
  140112. declare module BABYLON {
  140113. /**
  140114. * block used to Generate a Worley Noise 3D Noise Pattern
  140115. */
  140116. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  140117. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140118. manhattanDistance: boolean;
  140119. /**
  140120. * Creates a new WorleyNoise3DBlock
  140121. * @param name defines the block name
  140122. */
  140123. constructor(name: string);
  140124. /**
  140125. * Gets the current class name
  140126. * @returns the class name
  140127. */
  140128. getClassName(): string;
  140129. /**
  140130. * Gets the seed input component
  140131. */
  140132. get seed(): NodeMaterialConnectionPoint;
  140133. /**
  140134. * Gets the jitter input component
  140135. */
  140136. get jitter(): NodeMaterialConnectionPoint;
  140137. /**
  140138. * Gets the output component
  140139. */
  140140. get output(): NodeMaterialConnectionPoint;
  140141. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140142. /**
  140143. * Exposes the properties to the UI?
  140144. */
  140145. protected _dumpPropertiesCode(): string;
  140146. /**
  140147. * Exposes the properties to the Seralize?
  140148. */
  140149. serialize(): any;
  140150. /**
  140151. * Exposes the properties to the deseralize?
  140152. */
  140153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140154. }
  140155. }
  140156. declare module BABYLON {
  140157. /**
  140158. * block used to Generate a Simplex Perlin 3d Noise Pattern
  140159. */
  140160. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  140161. /**
  140162. * Creates a new SimplexPerlin3DBlock
  140163. * @param name defines the block name
  140164. */
  140165. constructor(name: string);
  140166. /**
  140167. * Gets the current class name
  140168. * @returns the class name
  140169. */
  140170. getClassName(): string;
  140171. /**
  140172. * Gets the seed operand input component
  140173. */
  140174. get seed(): NodeMaterialConnectionPoint;
  140175. /**
  140176. * Gets the output component
  140177. */
  140178. get output(): NodeMaterialConnectionPoint;
  140179. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140180. }
  140181. }
  140182. declare module BABYLON {
  140183. /**
  140184. * Block used to blend normals
  140185. */
  140186. export class NormalBlendBlock extends NodeMaterialBlock {
  140187. /**
  140188. * Creates a new NormalBlendBlock
  140189. * @param name defines the block name
  140190. */
  140191. constructor(name: string);
  140192. /**
  140193. * Gets the current class name
  140194. * @returns the class name
  140195. */
  140196. getClassName(): string;
  140197. /**
  140198. * Gets the first input component
  140199. */
  140200. get normalMap0(): NodeMaterialConnectionPoint;
  140201. /**
  140202. * Gets the second input component
  140203. */
  140204. get normalMap1(): NodeMaterialConnectionPoint;
  140205. /**
  140206. * Gets the output component
  140207. */
  140208. get output(): NodeMaterialConnectionPoint;
  140209. protected _buildBlock(state: NodeMaterialBuildState): this;
  140210. }
  140211. }
  140212. declare module BABYLON {
  140213. /**
  140214. * Block used to rotate a 2d vector by a given angle
  140215. */
  140216. export class Rotate2dBlock extends NodeMaterialBlock {
  140217. /**
  140218. * Creates a new Rotate2dBlock
  140219. * @param name defines the block name
  140220. */
  140221. constructor(name: string);
  140222. /**
  140223. * Gets the current class name
  140224. * @returns the class name
  140225. */
  140226. getClassName(): string;
  140227. /**
  140228. * Gets the input vector
  140229. */
  140230. get input(): NodeMaterialConnectionPoint;
  140231. /**
  140232. * Gets the input angle
  140233. */
  140234. get angle(): NodeMaterialConnectionPoint;
  140235. /**
  140236. * Gets the output component
  140237. */
  140238. get output(): NodeMaterialConnectionPoint;
  140239. autoConfigure(material: NodeMaterial): void;
  140240. protected _buildBlock(state: NodeMaterialBuildState): this;
  140241. }
  140242. }
  140243. declare module BABYLON {
  140244. /**
  140245. * Block used to get the reflected vector from a direction and a normal
  140246. */
  140247. export class ReflectBlock extends NodeMaterialBlock {
  140248. /**
  140249. * Creates a new ReflectBlock
  140250. * @param name defines the block name
  140251. */
  140252. constructor(name: string);
  140253. /**
  140254. * Gets the current class name
  140255. * @returns the class name
  140256. */
  140257. getClassName(): string;
  140258. /**
  140259. * Gets the incident component
  140260. */
  140261. get incident(): NodeMaterialConnectionPoint;
  140262. /**
  140263. * Gets the normal component
  140264. */
  140265. get normal(): NodeMaterialConnectionPoint;
  140266. /**
  140267. * Gets the output component
  140268. */
  140269. get output(): NodeMaterialConnectionPoint;
  140270. protected _buildBlock(state: NodeMaterialBuildState): this;
  140271. }
  140272. }
  140273. declare module BABYLON {
  140274. /**
  140275. * Block used to get the refracted vector from a direction and a normal
  140276. */
  140277. export class RefractBlock extends NodeMaterialBlock {
  140278. /**
  140279. * Creates a new RefractBlock
  140280. * @param name defines the block name
  140281. */
  140282. constructor(name: string);
  140283. /**
  140284. * Gets the current class name
  140285. * @returns the class name
  140286. */
  140287. getClassName(): string;
  140288. /**
  140289. * Gets the incident component
  140290. */
  140291. get incident(): NodeMaterialConnectionPoint;
  140292. /**
  140293. * Gets the normal component
  140294. */
  140295. get normal(): NodeMaterialConnectionPoint;
  140296. /**
  140297. * Gets the index of refraction component
  140298. */
  140299. get ior(): NodeMaterialConnectionPoint;
  140300. /**
  140301. * Gets the output component
  140302. */
  140303. get output(): NodeMaterialConnectionPoint;
  140304. protected _buildBlock(state: NodeMaterialBuildState): this;
  140305. }
  140306. }
  140307. declare module BABYLON {
  140308. /**
  140309. * Block used to desaturate a color
  140310. */
  140311. export class DesaturateBlock extends NodeMaterialBlock {
  140312. /**
  140313. * Creates a new DesaturateBlock
  140314. * @param name defines the block name
  140315. */
  140316. constructor(name: string);
  140317. /**
  140318. * Gets the current class name
  140319. * @returns the class name
  140320. */
  140321. getClassName(): string;
  140322. /**
  140323. * Gets the color operand input component
  140324. */
  140325. get color(): NodeMaterialConnectionPoint;
  140326. /**
  140327. * Gets the level operand input component
  140328. */
  140329. get level(): NodeMaterialConnectionPoint;
  140330. /**
  140331. * Gets the output component
  140332. */
  140333. get output(): NodeMaterialConnectionPoint;
  140334. protected _buildBlock(state: NodeMaterialBuildState): this;
  140335. }
  140336. }
  140337. declare module BABYLON {
  140338. /**
  140339. * Block used to implement the ambient occlusion module of the PBR material
  140340. */
  140341. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  140342. /**
  140343. * Create a new AmbientOcclusionBlock
  140344. * @param name defines the block name
  140345. */
  140346. constructor(name: string);
  140347. /**
  140348. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  140349. */
  140350. useAmbientInGrayScale: boolean;
  140351. /**
  140352. * Initialize the block and prepare the context for build
  140353. * @param state defines the state that will be used for the build
  140354. */
  140355. initialize(state: NodeMaterialBuildState): void;
  140356. /**
  140357. * Gets the current class name
  140358. * @returns the class name
  140359. */
  140360. getClassName(): string;
  140361. /**
  140362. * Gets the texture input component
  140363. */
  140364. get texture(): NodeMaterialConnectionPoint;
  140365. /**
  140366. * Gets the texture intensity component
  140367. */
  140368. get intensity(): NodeMaterialConnectionPoint;
  140369. /**
  140370. * Gets the direct light intensity input component
  140371. */
  140372. get directLightIntensity(): NodeMaterialConnectionPoint;
  140373. /**
  140374. * Gets the ambient occlusion object output component
  140375. */
  140376. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140377. /**
  140378. * Gets the main code of the block (fragment side)
  140379. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  140380. * @returns the shader code
  140381. */
  140382. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  140383. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140384. protected _buildBlock(state: NodeMaterialBuildState): this;
  140385. protected _dumpPropertiesCode(): string;
  140386. serialize(): any;
  140387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140388. }
  140389. }
  140390. declare module BABYLON {
  140391. /**
  140392. * Block used to implement the reflection module of the PBR material
  140393. */
  140394. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  140395. /** @hidden */
  140396. _defineLODReflectionAlpha: string;
  140397. /** @hidden */
  140398. _defineLinearSpecularReflection: string;
  140399. private _vEnvironmentIrradianceName;
  140400. /** @hidden */
  140401. _vReflectionMicrosurfaceInfosName: string;
  140402. /** @hidden */
  140403. _vReflectionInfosName: string;
  140404. /** @hidden */
  140405. _vReflectionFilteringInfoName: string;
  140406. private _scene;
  140407. /**
  140408. * The three properties below are set by the main PBR block prior to calling methods of this class.
  140409. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140410. * It's less burden on the user side in the editor part.
  140411. */
  140412. /** @hidden */
  140413. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140414. /** @hidden */
  140415. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140416. /** @hidden */
  140417. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  140418. /**
  140419. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  140420. * diffuse part of the IBL.
  140421. */
  140422. useSphericalHarmonics: boolean;
  140423. /**
  140424. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  140425. */
  140426. forceIrradianceInFragment: boolean;
  140427. /**
  140428. * Create a new ReflectionBlock
  140429. * @param name defines the block name
  140430. */
  140431. constructor(name: string);
  140432. /**
  140433. * Gets the current class name
  140434. * @returns the class name
  140435. */
  140436. getClassName(): string;
  140437. /**
  140438. * Gets the position input component
  140439. */
  140440. get position(): NodeMaterialConnectionPoint;
  140441. /**
  140442. * Gets the world position input component
  140443. */
  140444. get worldPosition(): NodeMaterialConnectionPoint;
  140445. /**
  140446. * Gets the world normal input component
  140447. */
  140448. get worldNormal(): NodeMaterialConnectionPoint;
  140449. /**
  140450. * Gets the world input component
  140451. */
  140452. get world(): NodeMaterialConnectionPoint;
  140453. /**
  140454. * Gets the camera (or eye) position component
  140455. */
  140456. get cameraPosition(): NodeMaterialConnectionPoint;
  140457. /**
  140458. * Gets the view input component
  140459. */
  140460. get view(): NodeMaterialConnectionPoint;
  140461. /**
  140462. * Gets the color input component
  140463. */
  140464. get color(): NodeMaterialConnectionPoint;
  140465. /**
  140466. * Gets the reflection object output component
  140467. */
  140468. get reflection(): NodeMaterialConnectionPoint;
  140469. /**
  140470. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  140471. */
  140472. get hasTexture(): boolean;
  140473. /**
  140474. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  140475. */
  140476. get reflectionColor(): string;
  140477. protected _getTexture(): Nullable<BaseTexture>;
  140478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140479. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140480. /**
  140481. * Gets the code to inject in the vertex shader
  140482. * @param state current state of the node material building
  140483. * @returns the shader code
  140484. */
  140485. handleVertexSide(state: NodeMaterialBuildState): string;
  140486. /**
  140487. * Gets the main code of the block (fragment side)
  140488. * @param state current state of the node material building
  140489. * @param normalVarName name of the existing variable corresponding to the normal
  140490. * @returns the shader code
  140491. */
  140492. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  140493. protected _buildBlock(state: NodeMaterialBuildState): this;
  140494. protected _dumpPropertiesCode(): string;
  140495. serialize(): any;
  140496. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140497. }
  140498. }
  140499. declare module BABYLON {
  140500. /**
  140501. * Block used to implement the sheen module of the PBR material
  140502. */
  140503. export class SheenBlock extends NodeMaterialBlock {
  140504. /**
  140505. * Create a new SheenBlock
  140506. * @param name defines the block name
  140507. */
  140508. constructor(name: string);
  140509. /**
  140510. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  140511. * It allows the strength of the sheen effect to not depend on the base color of the material,
  140512. * making it easier to setup and tweak the effect
  140513. */
  140514. albedoScaling: boolean;
  140515. /**
  140516. * Defines if the sheen is linked to the sheen color.
  140517. */
  140518. linkSheenWithAlbedo: boolean;
  140519. /**
  140520. * Initialize the block and prepare the context for build
  140521. * @param state defines the state that will be used for the build
  140522. */
  140523. initialize(state: NodeMaterialBuildState): void;
  140524. /**
  140525. * Gets the current class name
  140526. * @returns the class name
  140527. */
  140528. getClassName(): string;
  140529. /**
  140530. * Gets the intensity input component
  140531. */
  140532. get intensity(): NodeMaterialConnectionPoint;
  140533. /**
  140534. * Gets the color input component
  140535. */
  140536. get color(): NodeMaterialConnectionPoint;
  140537. /**
  140538. * Gets the roughness input component
  140539. */
  140540. get roughness(): NodeMaterialConnectionPoint;
  140541. /**
  140542. * Gets the sheen object output component
  140543. */
  140544. get sheen(): NodeMaterialConnectionPoint;
  140545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140546. /**
  140547. * Gets the main code of the block (fragment side)
  140548. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140549. * @returns the shader code
  140550. */
  140551. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  140552. protected _buildBlock(state: NodeMaterialBuildState): this;
  140553. protected _dumpPropertiesCode(): string;
  140554. serialize(): any;
  140555. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140556. }
  140557. }
  140558. declare module BABYLON {
  140559. /**
  140560. * Block used to implement the reflectivity module of the PBR material
  140561. */
  140562. export class ReflectivityBlock extends NodeMaterialBlock {
  140563. private _metallicReflectanceColor;
  140564. private _metallicF0Factor;
  140565. /** @hidden */
  140566. _vMetallicReflectanceFactorsName: string;
  140567. /**
  140568. * The property below is set by the main PBR block prior to calling methods of this class.
  140569. */
  140570. /** @hidden */
  140571. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  140572. /**
  140573. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  140574. */
  140575. useAmbientOcclusionFromMetallicTextureRed: boolean;
  140576. /**
  140577. * Specifies if the metallic texture contains the metallness information in its blue channel.
  140578. */
  140579. useMetallnessFromMetallicTextureBlue: boolean;
  140580. /**
  140581. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  140582. */
  140583. useRoughnessFromMetallicTextureAlpha: boolean;
  140584. /**
  140585. * Specifies if the metallic texture contains the roughness information in its green channel.
  140586. */
  140587. useRoughnessFromMetallicTextureGreen: boolean;
  140588. /**
  140589. * Create a new ReflectivityBlock
  140590. * @param name defines the block name
  140591. */
  140592. constructor(name: string);
  140593. /**
  140594. * Initialize the block and prepare the context for build
  140595. * @param state defines the state that will be used for the build
  140596. */
  140597. initialize(state: NodeMaterialBuildState): void;
  140598. /**
  140599. * Gets the current class name
  140600. * @returns the class name
  140601. */
  140602. getClassName(): string;
  140603. /**
  140604. * Gets the metallic input component
  140605. */
  140606. get metallic(): NodeMaterialConnectionPoint;
  140607. /**
  140608. * Gets the roughness input component
  140609. */
  140610. get roughness(): NodeMaterialConnectionPoint;
  140611. /**
  140612. * Gets the texture input component
  140613. */
  140614. get texture(): NodeMaterialConnectionPoint;
  140615. /**
  140616. * Gets the reflectivity object output component
  140617. */
  140618. get reflectivity(): NodeMaterialConnectionPoint;
  140619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140620. /**
  140621. * Gets the main code of the block (fragment side)
  140622. * @param state current state of the node material building
  140623. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  140624. * @returns the shader code
  140625. */
  140626. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  140627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140628. protected _buildBlock(state: NodeMaterialBuildState): this;
  140629. protected _dumpPropertiesCode(): string;
  140630. serialize(): any;
  140631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140632. }
  140633. }
  140634. declare module BABYLON {
  140635. /**
  140636. * Block used to implement the anisotropy module of the PBR material
  140637. */
  140638. export class AnisotropyBlock extends NodeMaterialBlock {
  140639. /**
  140640. * The two properties below are set by the main PBR block prior to calling methods of this class.
  140641. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140642. * It's less burden on the user side in the editor part.
  140643. */
  140644. /** @hidden */
  140645. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140646. /** @hidden */
  140647. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140648. /**
  140649. * Create a new AnisotropyBlock
  140650. * @param name defines the block name
  140651. */
  140652. constructor(name: string);
  140653. /**
  140654. * Initialize the block and prepare the context for build
  140655. * @param state defines the state that will be used for the build
  140656. */
  140657. initialize(state: NodeMaterialBuildState): void;
  140658. /**
  140659. * Gets the current class name
  140660. * @returns the class name
  140661. */
  140662. getClassName(): string;
  140663. /**
  140664. * Gets the intensity input component
  140665. */
  140666. get intensity(): NodeMaterialConnectionPoint;
  140667. /**
  140668. * Gets the direction input component
  140669. */
  140670. get direction(): NodeMaterialConnectionPoint;
  140671. /**
  140672. * Gets the texture input component
  140673. */
  140674. get texture(): NodeMaterialConnectionPoint;
  140675. /**
  140676. * Gets the uv input component
  140677. */
  140678. get uv(): NodeMaterialConnectionPoint;
  140679. /**
  140680. * Gets the worldTangent input component
  140681. */
  140682. get worldTangent(): NodeMaterialConnectionPoint;
  140683. /**
  140684. * Gets the anisotropy object output component
  140685. */
  140686. get anisotropy(): NodeMaterialConnectionPoint;
  140687. private _generateTBNSpace;
  140688. /**
  140689. * Gets the main code of the block (fragment side)
  140690. * @param state current state of the node material building
  140691. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140692. * @returns the shader code
  140693. */
  140694. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  140695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140696. protected _buildBlock(state: NodeMaterialBuildState): this;
  140697. }
  140698. }
  140699. declare module BABYLON {
  140700. /**
  140701. * Block used to implement the clear coat module of the PBR material
  140702. */
  140703. export class ClearCoatBlock extends NodeMaterialBlock {
  140704. private _scene;
  140705. /**
  140706. * Create a new ClearCoatBlock
  140707. * @param name defines the block name
  140708. */
  140709. constructor(name: string);
  140710. /**
  140711. * Initialize the block and prepare the context for build
  140712. * @param state defines the state that will be used for the build
  140713. */
  140714. initialize(state: NodeMaterialBuildState): void;
  140715. /**
  140716. * Gets the current class name
  140717. * @returns the class name
  140718. */
  140719. getClassName(): string;
  140720. /**
  140721. * Gets the intensity input component
  140722. */
  140723. get intensity(): NodeMaterialConnectionPoint;
  140724. /**
  140725. * Gets the roughness input component
  140726. */
  140727. get roughness(): NodeMaterialConnectionPoint;
  140728. /**
  140729. * Gets the ior input component
  140730. */
  140731. get ior(): NodeMaterialConnectionPoint;
  140732. /**
  140733. * Gets the texture input component
  140734. */
  140735. get texture(): NodeMaterialConnectionPoint;
  140736. /**
  140737. * Gets the bump texture input component
  140738. */
  140739. get bumpTexture(): NodeMaterialConnectionPoint;
  140740. /**
  140741. * Gets the uv input component
  140742. */
  140743. get uv(): NodeMaterialConnectionPoint;
  140744. /**
  140745. * Gets the tint color input component
  140746. */
  140747. get tintColor(): NodeMaterialConnectionPoint;
  140748. /**
  140749. * Gets the tint "at distance" input component
  140750. */
  140751. get tintAtDistance(): NodeMaterialConnectionPoint;
  140752. /**
  140753. * Gets the tint thickness input component
  140754. */
  140755. get tintThickness(): NodeMaterialConnectionPoint;
  140756. /**
  140757. * Gets the world tangent input component
  140758. */
  140759. get worldTangent(): NodeMaterialConnectionPoint;
  140760. /**
  140761. * Gets the clear coat object output component
  140762. */
  140763. get clearcoat(): NodeMaterialConnectionPoint;
  140764. autoConfigure(material: NodeMaterial): void;
  140765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140767. private _generateTBNSpace;
  140768. /**
  140769. * Gets the main code of the block (fragment side)
  140770. * @param state current state of the node material building
  140771. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  140772. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140773. * @param worldPosVarName name of the variable holding the world position
  140774. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  140775. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  140776. * @param worldNormalVarName name of the variable holding the world normal
  140777. * @returns the shader code
  140778. */
  140779. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  140780. protected _buildBlock(state: NodeMaterialBuildState): this;
  140781. }
  140782. }
  140783. declare module BABYLON {
  140784. /**
  140785. * Block used to implement the sub surface module of the PBR material
  140786. */
  140787. export class SubSurfaceBlock extends NodeMaterialBlock {
  140788. /**
  140789. * Create a new SubSurfaceBlock
  140790. * @param name defines the block name
  140791. */
  140792. constructor(name: string);
  140793. /**
  140794. * Stores the intensity of the different subsurface effects in the thickness texture.
  140795. * * the green channel is the translucency intensity.
  140796. * * the blue channel is the scattering intensity.
  140797. * * the alpha channel is the refraction intensity.
  140798. */
  140799. useMaskFromThicknessTexture: boolean;
  140800. /**
  140801. * Initialize the block and prepare the context for build
  140802. * @param state defines the state that will be used for the build
  140803. */
  140804. initialize(state: NodeMaterialBuildState): void;
  140805. /**
  140806. * Gets the current class name
  140807. * @returns the class name
  140808. */
  140809. getClassName(): string;
  140810. /**
  140811. * Gets the min thickness input component
  140812. */
  140813. get minThickness(): NodeMaterialConnectionPoint;
  140814. /**
  140815. * Gets the max thickness input component
  140816. */
  140817. get maxThickness(): NodeMaterialConnectionPoint;
  140818. /**
  140819. * Gets the thickness texture component
  140820. */
  140821. get thicknessTexture(): NodeMaterialConnectionPoint;
  140822. /**
  140823. * Gets the tint color input component
  140824. */
  140825. get tintColor(): NodeMaterialConnectionPoint;
  140826. /**
  140827. * Gets the translucency intensity input component
  140828. */
  140829. get translucencyIntensity(): NodeMaterialConnectionPoint;
  140830. /**
  140831. * Gets the translucency diffusion distance input component
  140832. */
  140833. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  140834. /**
  140835. * Gets the refraction object parameters
  140836. */
  140837. get refraction(): NodeMaterialConnectionPoint;
  140838. /**
  140839. * Gets the sub surface object output component
  140840. */
  140841. get subsurface(): NodeMaterialConnectionPoint;
  140842. autoConfigure(material: NodeMaterial): void;
  140843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140844. /**
  140845. * Gets the main code of the block (fragment side)
  140846. * @param state current state of the node material building
  140847. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  140848. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140849. * @param worldPosVarName name of the variable holding the world position
  140850. * @returns the shader code
  140851. */
  140852. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  140853. protected _buildBlock(state: NodeMaterialBuildState): this;
  140854. }
  140855. }
  140856. declare module BABYLON {
  140857. /**
  140858. * Block used to implement the PBR metallic/roughness model
  140859. */
  140860. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  140861. /**
  140862. * Gets or sets the light associated with this block
  140863. */
  140864. light: Nullable<Light>;
  140865. private _lightId;
  140866. private _scene;
  140867. private _environmentBRDFTexture;
  140868. private _environmentBrdfSamplerName;
  140869. private _vNormalWName;
  140870. private _invertNormalName;
  140871. /**
  140872. * Create a new ReflectionBlock
  140873. * @param name defines the block name
  140874. */
  140875. constructor(name: string);
  140876. /**
  140877. * Intensity of the direct lights e.g. the four lights available in your scene.
  140878. * This impacts both the direct diffuse and specular highlights.
  140879. */
  140880. directIntensity: number;
  140881. /**
  140882. * Intensity of the environment e.g. how much the environment will light the object
  140883. * either through harmonics for rough material or through the refelction for shiny ones.
  140884. */
  140885. environmentIntensity: number;
  140886. /**
  140887. * This is a special control allowing the reduction of the specular highlights coming from the
  140888. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  140889. */
  140890. specularIntensity: number;
  140891. /**
  140892. * Defines the falloff type used in this material.
  140893. * It by default is Physical.
  140894. */
  140895. lightFalloff: number;
  140896. /**
  140897. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  140898. */
  140899. useAlphaFromAlbedoTexture: boolean;
  140900. /**
  140901. * Specifies that alpha test should be used
  140902. */
  140903. useAlphaTest: boolean;
  140904. /**
  140905. * Defines the alpha limits in alpha test mode.
  140906. */
  140907. alphaTestCutoff: number;
  140908. /**
  140909. * Specifies that alpha blending should be used
  140910. */
  140911. useAlphaBlending: boolean;
  140912. /**
  140913. * Defines if the alpha value should be determined via the rgb values.
  140914. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  140915. */
  140916. opacityRGB: boolean;
  140917. /**
  140918. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  140919. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  140920. */
  140921. useRadianceOverAlpha: boolean;
  140922. /**
  140923. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  140924. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  140925. */
  140926. useSpecularOverAlpha: boolean;
  140927. /**
  140928. * Enables specular anti aliasing in the PBR shader.
  140929. * It will both interacts on the Geometry for analytical and IBL lighting.
  140930. * It also prefilter the roughness map based on the bump values.
  140931. */
  140932. enableSpecularAntiAliasing: boolean;
  140933. /**
  140934. * Enables realtime filtering on the texture.
  140935. */
  140936. realTimeFiltering: boolean;
  140937. /**
  140938. * Quality switch for realtime filtering
  140939. */
  140940. realTimeFilteringQuality: number;
  140941. /**
  140942. * Defines if the material uses energy conservation.
  140943. */
  140944. useEnergyConservation: boolean;
  140945. /**
  140946. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  140947. * too much the area relying on ambient texture to define their ambient occlusion.
  140948. */
  140949. useRadianceOcclusion: boolean;
  140950. /**
  140951. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  140952. * makes the reflect vector face the model (under horizon).
  140953. */
  140954. useHorizonOcclusion: boolean;
  140955. /**
  140956. * If set to true, no lighting calculations will be applied.
  140957. */
  140958. unlit: boolean;
  140959. /**
  140960. * Force normal to face away from face.
  140961. */
  140962. forceNormalForward: boolean;
  140963. /**
  140964. * Defines the material debug mode.
  140965. * It helps seeing only some components of the material while troubleshooting.
  140966. */
  140967. debugMode: number;
  140968. /**
  140969. * Specify from where on screen the debug mode should start.
  140970. * The value goes from -1 (full screen) to 1 (not visible)
  140971. * It helps with side by side comparison against the final render
  140972. * This defaults to 0
  140973. */
  140974. debugLimit: number;
  140975. /**
  140976. * As the default viewing range might not be enough (if the ambient is really small for instance)
  140977. * You can use the factor to better multiply the final value.
  140978. */
  140979. debugFactor: number;
  140980. /**
  140981. * Initialize the block and prepare the context for build
  140982. * @param state defines the state that will be used for the build
  140983. */
  140984. initialize(state: NodeMaterialBuildState): void;
  140985. /**
  140986. * Gets the current class name
  140987. * @returns the class name
  140988. */
  140989. getClassName(): string;
  140990. /**
  140991. * Gets the world position input component
  140992. */
  140993. get worldPosition(): NodeMaterialConnectionPoint;
  140994. /**
  140995. * Gets the world normal input component
  140996. */
  140997. get worldNormal(): NodeMaterialConnectionPoint;
  140998. /**
  140999. * Gets the perturbed normal input component
  141000. */
  141001. get perturbedNormal(): NodeMaterialConnectionPoint;
  141002. /**
  141003. * Gets the camera position input component
  141004. */
  141005. get cameraPosition(): NodeMaterialConnectionPoint;
  141006. /**
  141007. * Gets the base color input component
  141008. */
  141009. get baseColor(): NodeMaterialConnectionPoint;
  141010. /**
  141011. * Gets the opacity texture input component
  141012. */
  141013. get opacityTexture(): NodeMaterialConnectionPoint;
  141014. /**
  141015. * Gets the ambient color input component
  141016. */
  141017. get ambientColor(): NodeMaterialConnectionPoint;
  141018. /**
  141019. * Gets the reflectivity object parameters
  141020. */
  141021. get reflectivity(): NodeMaterialConnectionPoint;
  141022. /**
  141023. * Gets the ambient occlusion object parameters
  141024. */
  141025. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141026. /**
  141027. * Gets the reflection object parameters
  141028. */
  141029. get reflection(): NodeMaterialConnectionPoint;
  141030. /**
  141031. * Gets the sheen object parameters
  141032. */
  141033. get sheen(): NodeMaterialConnectionPoint;
  141034. /**
  141035. * Gets the clear coat object parameters
  141036. */
  141037. get clearcoat(): NodeMaterialConnectionPoint;
  141038. /**
  141039. * Gets the sub surface object parameters
  141040. */
  141041. get subsurface(): NodeMaterialConnectionPoint;
  141042. /**
  141043. * Gets the anisotropy object parameters
  141044. */
  141045. get anisotropy(): NodeMaterialConnectionPoint;
  141046. /**
  141047. * Gets the ambient output component
  141048. */
  141049. get ambient(): NodeMaterialConnectionPoint;
  141050. /**
  141051. * Gets the diffuse output component
  141052. */
  141053. get diffuse(): NodeMaterialConnectionPoint;
  141054. /**
  141055. * Gets the specular output component
  141056. */
  141057. get specular(): NodeMaterialConnectionPoint;
  141058. /**
  141059. * Gets the sheen output component
  141060. */
  141061. get sheenDir(): NodeMaterialConnectionPoint;
  141062. /**
  141063. * Gets the clear coat output component
  141064. */
  141065. get clearcoatDir(): NodeMaterialConnectionPoint;
  141066. /**
  141067. * Gets the indirect diffuse output component
  141068. */
  141069. get diffuseIndirect(): NodeMaterialConnectionPoint;
  141070. /**
  141071. * Gets the indirect specular output component
  141072. */
  141073. get specularIndirect(): NodeMaterialConnectionPoint;
  141074. /**
  141075. * Gets the indirect sheen output component
  141076. */
  141077. get sheenIndirect(): NodeMaterialConnectionPoint;
  141078. /**
  141079. * Gets the indirect clear coat output component
  141080. */
  141081. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  141082. /**
  141083. * Gets the refraction output component
  141084. */
  141085. get refraction(): NodeMaterialConnectionPoint;
  141086. /**
  141087. * Gets the global lighting output component
  141088. */
  141089. get lighting(): NodeMaterialConnectionPoint;
  141090. /**
  141091. * Gets the shadow output component
  141092. */
  141093. get shadow(): NodeMaterialConnectionPoint;
  141094. /**
  141095. * Gets the alpha output component
  141096. */
  141097. get alpha(): NodeMaterialConnectionPoint;
  141098. autoConfigure(material: NodeMaterial): void;
  141099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141100. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141102. private _injectVertexCode;
  141103. /**
  141104. * Gets the code corresponding to the albedo/opacity module
  141105. * @returns the shader code
  141106. */
  141107. getAlbedoOpacityCode(): string;
  141108. protected _buildBlock(state: NodeMaterialBuildState): this;
  141109. protected _dumpPropertiesCode(): string;
  141110. serialize(): any;
  141111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141112. }
  141113. }
  141114. declare module BABYLON {
  141115. /**
  141116. * Block used to compute value of one parameter modulo another
  141117. */
  141118. export class ModBlock extends NodeMaterialBlock {
  141119. /**
  141120. * Creates a new ModBlock
  141121. * @param name defines the block name
  141122. */
  141123. constructor(name: string);
  141124. /**
  141125. * Gets the current class name
  141126. * @returns the class name
  141127. */
  141128. getClassName(): string;
  141129. /**
  141130. * Gets the left operand input component
  141131. */
  141132. get left(): NodeMaterialConnectionPoint;
  141133. /**
  141134. * Gets the right operand input component
  141135. */
  141136. get right(): NodeMaterialConnectionPoint;
  141137. /**
  141138. * Gets the output component
  141139. */
  141140. get output(): NodeMaterialConnectionPoint;
  141141. protected _buildBlock(state: NodeMaterialBuildState): this;
  141142. }
  141143. }
  141144. declare module BABYLON {
  141145. /**
  141146. * Helper class to push actions to a pool of workers.
  141147. */
  141148. export class WorkerPool implements IDisposable {
  141149. private _workerInfos;
  141150. private _pendingActions;
  141151. /**
  141152. * Constructor
  141153. * @param workers Array of workers to use for actions
  141154. */
  141155. constructor(workers: Array<Worker>);
  141156. /**
  141157. * Terminates all workers and clears any pending actions.
  141158. */
  141159. dispose(): void;
  141160. /**
  141161. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141162. * pended until a worker has completed its action.
  141163. * @param action The action to perform. Call onComplete when the action is complete.
  141164. */
  141165. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141166. private _execute;
  141167. }
  141168. }
  141169. declare module BABYLON {
  141170. /**
  141171. * Configuration for Draco compression
  141172. */
  141173. export interface IDracoCompressionConfiguration {
  141174. /**
  141175. * Configuration for the decoder.
  141176. */
  141177. decoder: {
  141178. /**
  141179. * The url to the WebAssembly module.
  141180. */
  141181. wasmUrl?: string;
  141182. /**
  141183. * The url to the WebAssembly binary.
  141184. */
  141185. wasmBinaryUrl?: string;
  141186. /**
  141187. * The url to the fallback JavaScript module.
  141188. */
  141189. fallbackUrl?: string;
  141190. };
  141191. }
  141192. /**
  141193. * Draco compression (https://google.github.io/draco/)
  141194. *
  141195. * This class wraps the Draco module.
  141196. *
  141197. * **Encoder**
  141198. *
  141199. * The encoder is not currently implemented.
  141200. *
  141201. * **Decoder**
  141202. *
  141203. * 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.
  141204. *
  141205. * To update the configuration, use the following code:
  141206. * ```javascript
  141207. * DracoCompression.Configuration = {
  141208. * decoder: {
  141209. * wasmUrl: "<url to the WebAssembly library>",
  141210. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  141211. * fallbackUrl: "<url to the fallback JavaScript library>",
  141212. * }
  141213. * };
  141214. * ```
  141215. *
  141216. * 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.
  141217. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  141218. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  141219. *
  141220. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  141221. * ```javascript
  141222. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  141223. * ```
  141224. *
  141225. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  141226. */
  141227. export class DracoCompression implements IDisposable {
  141228. private _workerPoolPromise?;
  141229. private _decoderModulePromise?;
  141230. /**
  141231. * The configuration. Defaults to the following urls:
  141232. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  141233. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  141234. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  141235. */
  141236. static Configuration: IDracoCompressionConfiguration;
  141237. /**
  141238. * Returns true if the decoder configuration is available.
  141239. */
  141240. static get DecoderAvailable(): boolean;
  141241. /**
  141242. * Default number of workers to create when creating the draco compression object.
  141243. */
  141244. static DefaultNumWorkers: number;
  141245. private static GetDefaultNumWorkers;
  141246. private static _Default;
  141247. /**
  141248. * Default instance for the draco compression object.
  141249. */
  141250. static get Default(): DracoCompression;
  141251. /**
  141252. * Constructor
  141253. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141254. */
  141255. constructor(numWorkers?: number);
  141256. /**
  141257. * Stop all async operations and release resources.
  141258. */
  141259. dispose(): void;
  141260. /**
  141261. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  141262. * @returns a promise that resolves when ready
  141263. */
  141264. whenReadyAsync(): Promise<void>;
  141265. /**
  141266. * Decode Draco compressed mesh data to vertex data.
  141267. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  141268. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  141269. * @returns A promise that resolves with the decoded vertex data
  141270. */
  141271. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  141272. [kind: string]: number;
  141273. }): Promise<VertexData>;
  141274. }
  141275. }
  141276. declare module BABYLON {
  141277. /**
  141278. * Class for building Constructive Solid Geometry
  141279. */
  141280. export class CSG {
  141281. private polygons;
  141282. /**
  141283. * The world matrix
  141284. */
  141285. matrix: Matrix;
  141286. /**
  141287. * Stores the position
  141288. */
  141289. position: Vector3;
  141290. /**
  141291. * Stores the rotation
  141292. */
  141293. rotation: Vector3;
  141294. /**
  141295. * Stores the rotation quaternion
  141296. */
  141297. rotationQuaternion: Nullable<Quaternion>;
  141298. /**
  141299. * Stores the scaling vector
  141300. */
  141301. scaling: Vector3;
  141302. /**
  141303. * Convert the Mesh to CSG
  141304. * @param mesh The Mesh to convert to CSG
  141305. * @returns A new CSG from the Mesh
  141306. */
  141307. static FromMesh(mesh: Mesh): CSG;
  141308. /**
  141309. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  141310. * @param polygons Polygons used to construct a CSG solid
  141311. */
  141312. private static FromPolygons;
  141313. /**
  141314. * Clones, or makes a deep copy, of the CSG
  141315. * @returns A new CSG
  141316. */
  141317. clone(): CSG;
  141318. /**
  141319. * Unions this CSG with another CSG
  141320. * @param csg The CSG to union against this CSG
  141321. * @returns The unioned CSG
  141322. */
  141323. union(csg: CSG): CSG;
  141324. /**
  141325. * Unions this CSG with another CSG in place
  141326. * @param csg The CSG to union against this CSG
  141327. */
  141328. unionInPlace(csg: CSG): void;
  141329. /**
  141330. * Subtracts this CSG with another CSG
  141331. * @param csg The CSG to subtract against this CSG
  141332. * @returns A new CSG
  141333. */
  141334. subtract(csg: CSG): CSG;
  141335. /**
  141336. * Subtracts this CSG with another CSG in place
  141337. * @param csg The CSG to subtact against this CSG
  141338. */
  141339. subtractInPlace(csg: CSG): void;
  141340. /**
  141341. * Intersect this CSG with another CSG
  141342. * @param csg The CSG to intersect against this CSG
  141343. * @returns A new CSG
  141344. */
  141345. intersect(csg: CSG): CSG;
  141346. /**
  141347. * Intersects this CSG with another CSG in place
  141348. * @param csg The CSG to intersect against this CSG
  141349. */
  141350. intersectInPlace(csg: CSG): void;
  141351. /**
  141352. * Return a new CSG solid with solid and empty space switched. This solid is
  141353. * not modified.
  141354. * @returns A new CSG solid with solid and empty space switched
  141355. */
  141356. inverse(): CSG;
  141357. /**
  141358. * Inverses the CSG in place
  141359. */
  141360. inverseInPlace(): void;
  141361. /**
  141362. * This is used to keep meshes transformations so they can be restored
  141363. * when we build back a Babylon Mesh
  141364. * NB : All CSG operations are performed in world coordinates
  141365. * @param csg The CSG to copy the transform attributes from
  141366. * @returns This CSG
  141367. */
  141368. copyTransformAttributes(csg: CSG): CSG;
  141369. /**
  141370. * Build Raw mesh from CSG
  141371. * Coordinates here are in world space
  141372. * @param name The name of the mesh geometry
  141373. * @param scene The Scene
  141374. * @param keepSubMeshes Specifies if the submeshes should be kept
  141375. * @returns A new Mesh
  141376. */
  141377. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141378. /**
  141379. * Build Mesh from CSG taking material and transforms into account
  141380. * @param name The name of the Mesh
  141381. * @param material The material of the Mesh
  141382. * @param scene The Scene
  141383. * @param keepSubMeshes Specifies if submeshes should be kept
  141384. * @returns The new Mesh
  141385. */
  141386. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141387. }
  141388. }
  141389. declare module BABYLON {
  141390. /**
  141391. * Class used to create a trail following a mesh
  141392. */
  141393. export class TrailMesh extends Mesh {
  141394. private _generator;
  141395. private _autoStart;
  141396. private _running;
  141397. private _diameter;
  141398. private _length;
  141399. private _sectionPolygonPointsCount;
  141400. private _sectionVectors;
  141401. private _sectionNormalVectors;
  141402. private _beforeRenderObserver;
  141403. /**
  141404. * @constructor
  141405. * @param name The value used by scene.getMeshByName() to do a lookup.
  141406. * @param generator The mesh or transform node to generate a trail.
  141407. * @param scene The scene to add this mesh to.
  141408. * @param diameter Diameter of trailing mesh. Default is 1.
  141409. * @param length Length of trailing mesh. Default is 60.
  141410. * @param autoStart Automatically start trailing mesh. Default true.
  141411. */
  141412. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  141413. /**
  141414. * "TrailMesh"
  141415. * @returns "TrailMesh"
  141416. */
  141417. getClassName(): string;
  141418. private _createMesh;
  141419. /**
  141420. * Start trailing mesh.
  141421. */
  141422. start(): void;
  141423. /**
  141424. * Stop trailing mesh.
  141425. */
  141426. stop(): void;
  141427. /**
  141428. * Update trailing mesh geometry.
  141429. */
  141430. update(): void;
  141431. /**
  141432. * Returns a new TrailMesh object.
  141433. * @param name is a string, the name given to the new mesh
  141434. * @param newGenerator use new generator object for cloned trail mesh
  141435. * @returns a new mesh
  141436. */
  141437. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  141438. /**
  141439. * Serializes this trail mesh
  141440. * @param serializationObject object to write serialization to
  141441. */
  141442. serialize(serializationObject: any): void;
  141443. /**
  141444. * Parses a serialized trail mesh
  141445. * @param parsedMesh the serialized mesh
  141446. * @param scene the scene to create the trail mesh in
  141447. * @returns the created trail mesh
  141448. */
  141449. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  141450. }
  141451. }
  141452. declare module BABYLON {
  141453. /**
  141454. * Class containing static functions to help procedurally build meshes
  141455. */
  141456. export class TiledBoxBuilder {
  141457. /**
  141458. * Creates a box mesh
  141459. * 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)
  141460. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141462. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141464. * @param name defines the name of the mesh
  141465. * @param options defines the options used to create the mesh
  141466. * @param scene defines the hosting scene
  141467. * @returns the box mesh
  141468. */
  141469. static CreateTiledBox(name: string, options: {
  141470. pattern?: number;
  141471. width?: number;
  141472. height?: number;
  141473. depth?: number;
  141474. tileSize?: number;
  141475. tileWidth?: number;
  141476. tileHeight?: number;
  141477. alignHorizontal?: number;
  141478. alignVertical?: number;
  141479. faceUV?: Vector4[];
  141480. faceColors?: Color4[];
  141481. sideOrientation?: number;
  141482. updatable?: boolean;
  141483. }, scene?: Nullable<Scene>): Mesh;
  141484. }
  141485. }
  141486. declare module BABYLON {
  141487. /**
  141488. * Class containing static functions to help procedurally build meshes
  141489. */
  141490. export class TorusKnotBuilder {
  141491. /**
  141492. * Creates a torus knot mesh
  141493. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141494. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141495. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141496. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141500. * @param name defines the name of the mesh
  141501. * @param options defines the options used to create the mesh
  141502. * @param scene defines the hosting scene
  141503. * @returns the torus knot mesh
  141504. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141505. */
  141506. static CreateTorusKnot(name: string, options: {
  141507. radius?: number;
  141508. tube?: number;
  141509. radialSegments?: number;
  141510. tubularSegments?: number;
  141511. p?: number;
  141512. q?: number;
  141513. updatable?: boolean;
  141514. sideOrientation?: number;
  141515. frontUVs?: Vector4;
  141516. backUVs?: Vector4;
  141517. }, scene: any): Mesh;
  141518. }
  141519. }
  141520. declare module BABYLON {
  141521. /**
  141522. * Polygon
  141523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  141524. */
  141525. export class Polygon {
  141526. /**
  141527. * Creates a rectangle
  141528. * @param xmin bottom X coord
  141529. * @param ymin bottom Y coord
  141530. * @param xmax top X coord
  141531. * @param ymax top Y coord
  141532. * @returns points that make the resulting rectation
  141533. */
  141534. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  141535. /**
  141536. * Creates a circle
  141537. * @param radius radius of circle
  141538. * @param cx scale in x
  141539. * @param cy scale in y
  141540. * @param numberOfSides number of sides that make up the circle
  141541. * @returns points that make the resulting circle
  141542. */
  141543. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  141544. /**
  141545. * Creates a polygon from input string
  141546. * @param input Input polygon data
  141547. * @returns the parsed points
  141548. */
  141549. static Parse(input: string): Vector2[];
  141550. /**
  141551. * Starts building a polygon from x and y coordinates
  141552. * @param x x coordinate
  141553. * @param y y coordinate
  141554. * @returns the started path2
  141555. */
  141556. static StartingAt(x: number, y: number): Path2;
  141557. }
  141558. /**
  141559. * Builds a polygon
  141560. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  141561. */
  141562. export class PolygonMeshBuilder {
  141563. private _points;
  141564. private _outlinepoints;
  141565. private _holes;
  141566. private _name;
  141567. private _scene;
  141568. private _epoints;
  141569. private _eholes;
  141570. private _addToepoint;
  141571. /**
  141572. * Babylon reference to the earcut plugin.
  141573. */
  141574. bjsEarcut: any;
  141575. /**
  141576. * Creates a PolygonMeshBuilder
  141577. * @param name name of the builder
  141578. * @param contours Path of the polygon
  141579. * @param scene scene to add to when creating the mesh
  141580. * @param earcutInjection can be used to inject your own earcut reference
  141581. */
  141582. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  141583. /**
  141584. * Adds a whole within the polygon
  141585. * @param hole Array of points defining the hole
  141586. * @returns this
  141587. */
  141588. addHole(hole: Vector2[]): PolygonMeshBuilder;
  141589. /**
  141590. * Creates the polygon
  141591. * @param updatable If the mesh should be updatable
  141592. * @param depth The depth of the mesh created
  141593. * @returns the created mesh
  141594. */
  141595. build(updatable?: boolean, depth?: number): Mesh;
  141596. /**
  141597. * Creates the polygon
  141598. * @param depth The depth of the mesh created
  141599. * @returns the created VertexData
  141600. */
  141601. buildVertexData(depth?: number): VertexData;
  141602. /**
  141603. * Adds a side to the polygon
  141604. * @param positions points that make the polygon
  141605. * @param normals normals of the polygon
  141606. * @param uvs uvs of the polygon
  141607. * @param indices indices of the polygon
  141608. * @param bounds bounds of the polygon
  141609. * @param points points of the polygon
  141610. * @param depth depth of the polygon
  141611. * @param flip flip of the polygon
  141612. */
  141613. private addSide;
  141614. }
  141615. }
  141616. declare module BABYLON {
  141617. /**
  141618. * Class containing static functions to help procedurally build meshes
  141619. */
  141620. export class PolygonBuilder {
  141621. /**
  141622. * Creates a polygon mesh
  141623. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141624. * * 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
  141625. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141628. * * Remember you can only change the shape positions, not their number when updating a polygon
  141629. * @param name defines the name of the mesh
  141630. * @param options defines the options used to create the mesh
  141631. * @param scene defines the hosting scene
  141632. * @param earcutInjection can be used to inject your own earcut reference
  141633. * @returns the polygon mesh
  141634. */
  141635. static CreatePolygon(name: string, options: {
  141636. shape: Vector3[];
  141637. holes?: Vector3[][];
  141638. depth?: number;
  141639. faceUV?: Vector4[];
  141640. faceColors?: Color4[];
  141641. updatable?: boolean;
  141642. sideOrientation?: number;
  141643. frontUVs?: Vector4;
  141644. backUVs?: Vector4;
  141645. wrap?: boolean;
  141646. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141647. /**
  141648. * Creates an extruded polygon mesh, with depth in the Y direction.
  141649. * * 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)
  141650. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141651. * @param name defines the name of the mesh
  141652. * @param options defines the options used to create the mesh
  141653. * @param scene defines the hosting scene
  141654. * @param earcutInjection can be used to inject your own earcut reference
  141655. * @returns the polygon mesh
  141656. */
  141657. static ExtrudePolygon(name: string, options: {
  141658. shape: Vector3[];
  141659. holes?: Vector3[][];
  141660. depth?: number;
  141661. faceUV?: Vector4[];
  141662. faceColors?: Color4[];
  141663. updatable?: boolean;
  141664. sideOrientation?: number;
  141665. frontUVs?: Vector4;
  141666. backUVs?: Vector4;
  141667. wrap?: boolean;
  141668. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141669. }
  141670. }
  141671. declare module BABYLON {
  141672. /**
  141673. * Class containing static functions to help procedurally build meshes
  141674. */
  141675. export class LatheBuilder {
  141676. /**
  141677. * Creates lathe mesh.
  141678. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  141679. * * 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
  141680. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  141681. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  141682. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  141683. * * 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
  141684. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  141685. * * 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
  141686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141688. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141690. * @param name defines the name of the mesh
  141691. * @param options defines the options used to create the mesh
  141692. * @param scene defines the hosting scene
  141693. * @returns the lathe mesh
  141694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  141695. */
  141696. static CreateLathe(name: string, options: {
  141697. shape: Vector3[];
  141698. radius?: number;
  141699. tessellation?: number;
  141700. clip?: number;
  141701. arc?: number;
  141702. closed?: boolean;
  141703. updatable?: boolean;
  141704. sideOrientation?: number;
  141705. frontUVs?: Vector4;
  141706. backUVs?: Vector4;
  141707. cap?: number;
  141708. invertUV?: boolean;
  141709. }, scene?: Nullable<Scene>): Mesh;
  141710. }
  141711. }
  141712. declare module BABYLON {
  141713. /**
  141714. * Class containing static functions to help procedurally build meshes
  141715. */
  141716. export class TiledPlaneBuilder {
  141717. /**
  141718. * Creates a tiled plane mesh
  141719. * * The parameter `pattern` will, depending on value, do nothing or
  141720. * * * flip (reflect about central vertical) alternate tiles across and up
  141721. * * * flip every tile on alternate rows
  141722. * * * rotate (180 degs) alternate tiles across and up
  141723. * * * rotate every tile on alternate rows
  141724. * * * flip and rotate alternate tiles across and up
  141725. * * * flip and rotate every tile on alternate rows
  141726. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  141727. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  141728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141730. * * 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)
  141731. * * 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)
  141732. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141733. * @param name defines the name of the mesh
  141734. * @param options defines the options used to create the mesh
  141735. * @param scene defines the hosting scene
  141736. * @returns the box mesh
  141737. */
  141738. static CreateTiledPlane(name: string, options: {
  141739. pattern?: number;
  141740. tileSize?: number;
  141741. tileWidth?: number;
  141742. tileHeight?: number;
  141743. size?: number;
  141744. width?: number;
  141745. height?: number;
  141746. alignHorizontal?: number;
  141747. alignVertical?: number;
  141748. sideOrientation?: number;
  141749. frontUVs?: Vector4;
  141750. backUVs?: Vector4;
  141751. updatable?: boolean;
  141752. }, scene?: Nullable<Scene>): Mesh;
  141753. }
  141754. }
  141755. declare module BABYLON {
  141756. /**
  141757. * Class containing static functions to help procedurally build meshes
  141758. */
  141759. export class TubeBuilder {
  141760. /**
  141761. * Creates a tube mesh.
  141762. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  141763. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  141764. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  141765. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  141766. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  141767. * * 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)
  141768. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  141769. * * 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
  141770. * * 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
  141771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  141774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141775. * @param name defines the name of the mesh
  141776. * @param options defines the options used to create the mesh
  141777. * @param scene defines the hosting scene
  141778. * @returns the tube mesh
  141779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  141780. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  141781. */
  141782. static CreateTube(name: string, options: {
  141783. path: Vector3[];
  141784. radius?: number;
  141785. tessellation?: number;
  141786. radiusFunction?: {
  141787. (i: number, distance: number): number;
  141788. };
  141789. cap?: number;
  141790. arc?: number;
  141791. updatable?: boolean;
  141792. sideOrientation?: number;
  141793. frontUVs?: Vector4;
  141794. backUVs?: Vector4;
  141795. instance?: Mesh;
  141796. invertUV?: boolean;
  141797. }, scene?: Nullable<Scene>): Mesh;
  141798. }
  141799. }
  141800. declare module BABYLON {
  141801. /**
  141802. * Class containing static functions to help procedurally build meshes
  141803. */
  141804. export class IcoSphereBuilder {
  141805. /**
  141806. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141807. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141808. * * 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`)
  141809. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141810. * * 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
  141811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141814. * @param name defines the name of the mesh
  141815. * @param options defines the options used to create the mesh
  141816. * @param scene defines the hosting scene
  141817. * @returns the icosahedron mesh
  141818. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141819. */
  141820. static CreateIcoSphere(name: string, options: {
  141821. radius?: number;
  141822. radiusX?: number;
  141823. radiusY?: number;
  141824. radiusZ?: number;
  141825. flat?: boolean;
  141826. subdivisions?: number;
  141827. sideOrientation?: number;
  141828. frontUVs?: Vector4;
  141829. backUVs?: Vector4;
  141830. updatable?: boolean;
  141831. }, scene?: Nullable<Scene>): Mesh;
  141832. }
  141833. }
  141834. declare module BABYLON {
  141835. /**
  141836. * Class containing static functions to help procedurally build meshes
  141837. */
  141838. export class DecalBuilder {
  141839. /**
  141840. * Creates a decal mesh.
  141841. * 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
  141842. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  141843. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  141844. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  141845. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  141846. * @param name defines the name of the mesh
  141847. * @param sourceMesh defines the mesh where the decal must be applied
  141848. * @param options defines the options used to create the mesh
  141849. * @param scene defines the hosting scene
  141850. * @returns the decal mesh
  141851. * @see https://doc.babylonjs.com/how_to/decals
  141852. */
  141853. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  141854. position?: Vector3;
  141855. normal?: Vector3;
  141856. size?: Vector3;
  141857. angle?: number;
  141858. }): Mesh;
  141859. }
  141860. }
  141861. declare module BABYLON {
  141862. /**
  141863. * Class containing static functions to help procedurally build meshes
  141864. */
  141865. export class MeshBuilder {
  141866. /**
  141867. * Creates a box mesh
  141868. * * The parameter `size` sets the size (float) of each box side (default 1)
  141869. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  141870. * * 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)
  141871. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141875. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  141876. * @param name defines the name of the mesh
  141877. * @param options defines the options used to create the mesh
  141878. * @param scene defines the hosting scene
  141879. * @returns the box mesh
  141880. */
  141881. static CreateBox(name: string, options: {
  141882. size?: number;
  141883. width?: number;
  141884. height?: number;
  141885. depth?: number;
  141886. faceUV?: Vector4[];
  141887. faceColors?: Color4[];
  141888. sideOrientation?: number;
  141889. frontUVs?: Vector4;
  141890. backUVs?: Vector4;
  141891. wrap?: boolean;
  141892. topBaseAt?: number;
  141893. bottomBaseAt?: number;
  141894. updatable?: boolean;
  141895. }, scene?: Nullable<Scene>): Mesh;
  141896. /**
  141897. * Creates a tiled box mesh
  141898. * * faceTiles sets the pattern, tile size and number of tiles for a face
  141899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141900. * @param name defines the name of the mesh
  141901. * @param options defines the options used to create the mesh
  141902. * @param scene defines the hosting scene
  141903. * @returns the tiled box mesh
  141904. */
  141905. static CreateTiledBox(name: string, options: {
  141906. pattern?: number;
  141907. size?: number;
  141908. width?: number;
  141909. height?: number;
  141910. depth: number;
  141911. tileSize?: number;
  141912. tileWidth?: number;
  141913. tileHeight?: number;
  141914. faceUV?: Vector4[];
  141915. faceColors?: Color4[];
  141916. alignHorizontal?: number;
  141917. alignVertical?: number;
  141918. sideOrientation?: number;
  141919. updatable?: boolean;
  141920. }, scene?: Nullable<Scene>): Mesh;
  141921. /**
  141922. * Creates a sphere mesh
  141923. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  141924. * * 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`)
  141925. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  141926. * * 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
  141927. * * 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)
  141928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141931. * @param name defines the name of the mesh
  141932. * @param options defines the options used to create the mesh
  141933. * @param scene defines the hosting scene
  141934. * @returns the sphere mesh
  141935. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  141936. */
  141937. static CreateSphere(name: string, options: {
  141938. segments?: number;
  141939. diameter?: number;
  141940. diameterX?: number;
  141941. diameterY?: number;
  141942. diameterZ?: number;
  141943. arc?: number;
  141944. slice?: number;
  141945. sideOrientation?: number;
  141946. frontUVs?: Vector4;
  141947. backUVs?: Vector4;
  141948. updatable?: boolean;
  141949. }, scene?: Nullable<Scene>): Mesh;
  141950. /**
  141951. * Creates a plane polygonal mesh. By default, this is a disc
  141952. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  141953. * * 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
  141954. * * 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
  141955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141958. * @param name defines the name of the mesh
  141959. * @param options defines the options used to create the mesh
  141960. * @param scene defines the hosting scene
  141961. * @returns the plane polygonal mesh
  141962. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  141963. */
  141964. static CreateDisc(name: string, options: {
  141965. radius?: number;
  141966. tessellation?: number;
  141967. arc?: number;
  141968. updatable?: boolean;
  141969. sideOrientation?: number;
  141970. frontUVs?: Vector4;
  141971. backUVs?: Vector4;
  141972. }, scene?: Nullable<Scene>): Mesh;
  141973. /**
  141974. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  141975. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  141976. * * 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`)
  141977. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  141978. * * 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
  141979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141982. * @param name defines the name of the mesh
  141983. * @param options defines the options used to create the mesh
  141984. * @param scene defines the hosting scene
  141985. * @returns the icosahedron mesh
  141986. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  141987. */
  141988. static CreateIcoSphere(name: string, options: {
  141989. radius?: number;
  141990. radiusX?: number;
  141991. radiusY?: number;
  141992. radiusZ?: number;
  141993. flat?: boolean;
  141994. subdivisions?: number;
  141995. sideOrientation?: number;
  141996. frontUVs?: Vector4;
  141997. backUVs?: Vector4;
  141998. updatable?: boolean;
  141999. }, scene?: Nullable<Scene>): Mesh;
  142000. /**
  142001. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142002. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142003. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142004. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142005. * * 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
  142006. * * 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
  142007. * * 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
  142008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142011. * * 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
  142012. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142013. * * 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
  142014. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142016. * @param name defines the name of the mesh
  142017. * @param options defines the options used to create the mesh
  142018. * @param scene defines the hosting scene
  142019. * @returns the ribbon mesh
  142020. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142022. */
  142023. static CreateRibbon(name: string, options: {
  142024. pathArray: Vector3[][];
  142025. closeArray?: boolean;
  142026. closePath?: boolean;
  142027. offset?: number;
  142028. updatable?: boolean;
  142029. sideOrientation?: number;
  142030. frontUVs?: Vector4;
  142031. backUVs?: Vector4;
  142032. instance?: Mesh;
  142033. invertUV?: boolean;
  142034. uvs?: Vector2[];
  142035. colors?: Color4[];
  142036. }, scene?: Nullable<Scene>): Mesh;
  142037. /**
  142038. * Creates a cylinder or a cone mesh
  142039. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  142040. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  142041. * * 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.
  142042. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  142043. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  142044. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  142045. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  142046. * * 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).
  142047. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  142048. * * 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).
  142049. * * 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
  142050. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  142051. * * 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
  142052. * * 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.
  142053. * * If `enclose` is false, a ring surface is one element.
  142054. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  142055. * * 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
  142056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142059. * @param name defines the name of the mesh
  142060. * @param options defines the options used to create the mesh
  142061. * @param scene defines the hosting scene
  142062. * @returns the cylinder mesh
  142063. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  142064. */
  142065. static CreateCylinder(name: string, options: {
  142066. height?: number;
  142067. diameterTop?: number;
  142068. diameterBottom?: number;
  142069. diameter?: number;
  142070. tessellation?: number;
  142071. subdivisions?: number;
  142072. arc?: number;
  142073. faceColors?: Color4[];
  142074. faceUV?: Vector4[];
  142075. updatable?: boolean;
  142076. hasRings?: boolean;
  142077. enclose?: boolean;
  142078. cap?: number;
  142079. sideOrientation?: number;
  142080. frontUVs?: Vector4;
  142081. backUVs?: Vector4;
  142082. }, scene?: Nullable<Scene>): Mesh;
  142083. /**
  142084. * Creates a torus mesh
  142085. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  142086. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  142087. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  142088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142091. * @param name defines the name of the mesh
  142092. * @param options defines the options used to create the mesh
  142093. * @param scene defines the hosting scene
  142094. * @returns the torus mesh
  142095. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  142096. */
  142097. static CreateTorus(name: string, options: {
  142098. diameter?: number;
  142099. thickness?: number;
  142100. tessellation?: number;
  142101. updatable?: boolean;
  142102. sideOrientation?: number;
  142103. frontUVs?: Vector4;
  142104. backUVs?: Vector4;
  142105. }, scene?: Nullable<Scene>): Mesh;
  142106. /**
  142107. * Creates a torus knot mesh
  142108. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142109. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142110. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142111. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142115. * @param name defines the name of the mesh
  142116. * @param options defines the options used to create the mesh
  142117. * @param scene defines the hosting scene
  142118. * @returns the torus knot mesh
  142119. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142120. */
  142121. static CreateTorusKnot(name: string, options: {
  142122. radius?: number;
  142123. tube?: number;
  142124. radialSegments?: number;
  142125. tubularSegments?: number;
  142126. p?: number;
  142127. q?: number;
  142128. updatable?: boolean;
  142129. sideOrientation?: number;
  142130. frontUVs?: Vector4;
  142131. backUVs?: Vector4;
  142132. }, scene?: Nullable<Scene>): Mesh;
  142133. /**
  142134. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  142135. * * 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
  142136. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  142137. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  142138. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  142139. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  142140. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  142141. * * 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
  142142. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  142143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  142145. * @param name defines the name of the new line system
  142146. * @param options defines the options used to create the line system
  142147. * @param scene defines the hosting scene
  142148. * @returns a new line system mesh
  142149. */
  142150. static CreateLineSystem(name: string, options: {
  142151. lines: Vector3[][];
  142152. updatable?: boolean;
  142153. instance?: Nullable<LinesMesh>;
  142154. colors?: Nullable<Color4[][]>;
  142155. useVertexAlpha?: boolean;
  142156. }, scene: Nullable<Scene>): LinesMesh;
  142157. /**
  142158. * Creates a line mesh
  142159. * 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
  142160. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142161. * * The parameter `points` is an array successive Vector3
  142162. * * 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
  142163. * * The optional parameter `colors` is an array of successive Color4, one per line point
  142164. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  142165. * * When updating an instance, remember that only point positions can change, not the number of points
  142166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  142168. * @param name defines the name of the new line system
  142169. * @param options defines the options used to create the line system
  142170. * @param scene defines the hosting scene
  142171. * @returns a new line mesh
  142172. */
  142173. static CreateLines(name: string, options: {
  142174. points: Vector3[];
  142175. updatable?: boolean;
  142176. instance?: Nullable<LinesMesh>;
  142177. colors?: Color4[];
  142178. useVertexAlpha?: boolean;
  142179. }, scene?: Nullable<Scene>): LinesMesh;
  142180. /**
  142181. * Creates a dashed line mesh
  142182. * * 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
  142183. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142184. * * The parameter `points` is an array successive Vector3
  142185. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  142186. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  142187. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  142188. * * 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
  142189. * * When updating an instance, remember that only point positions can change, not the number of points
  142190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142191. * @param name defines the name of the mesh
  142192. * @param options defines the options used to create the mesh
  142193. * @param scene defines the hosting scene
  142194. * @returns the dashed line mesh
  142195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  142196. */
  142197. static CreateDashedLines(name: string, options: {
  142198. points: Vector3[];
  142199. dashSize?: number;
  142200. gapSize?: number;
  142201. dashNb?: number;
  142202. updatable?: boolean;
  142203. instance?: LinesMesh;
  142204. }, scene?: Nullable<Scene>): LinesMesh;
  142205. /**
  142206. * 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.
  142207. * * 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.
  142208. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142209. * * 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.
  142210. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142211. * * 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
  142212. * * 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
  142213. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142218. * @param name defines the name of the mesh
  142219. * @param options defines the options used to create the mesh
  142220. * @param scene defines the hosting scene
  142221. * @returns the extruded shape mesh
  142222. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142224. */
  142225. static ExtrudeShape(name: string, options: {
  142226. shape: Vector3[];
  142227. path: Vector3[];
  142228. scale?: number;
  142229. rotation?: number;
  142230. cap?: number;
  142231. updatable?: boolean;
  142232. sideOrientation?: number;
  142233. frontUVs?: Vector4;
  142234. backUVs?: Vector4;
  142235. instance?: Mesh;
  142236. invertUV?: boolean;
  142237. }, scene?: Nullable<Scene>): Mesh;
  142238. /**
  142239. * Creates an custom extruded shape mesh.
  142240. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142241. * * 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.
  142242. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142243. * * 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
  142244. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142245. * * 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
  142246. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142247. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142248. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142249. * * 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
  142250. * * 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
  142251. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142256. * @param name defines the name of the mesh
  142257. * @param options defines the options used to create the mesh
  142258. * @param scene defines the hosting scene
  142259. * @returns the custom extruded shape mesh
  142260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142262. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142263. */
  142264. static ExtrudeShapeCustom(name: string, options: {
  142265. shape: Vector3[];
  142266. path: Vector3[];
  142267. scaleFunction?: any;
  142268. rotationFunction?: any;
  142269. ribbonCloseArray?: boolean;
  142270. ribbonClosePath?: boolean;
  142271. cap?: number;
  142272. updatable?: boolean;
  142273. sideOrientation?: number;
  142274. frontUVs?: Vector4;
  142275. backUVs?: Vector4;
  142276. instance?: Mesh;
  142277. invertUV?: boolean;
  142278. }, scene?: Nullable<Scene>): Mesh;
  142279. /**
  142280. * Creates lathe mesh.
  142281. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142282. * * 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
  142283. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142284. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142285. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142286. * * 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
  142287. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142288. * * 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
  142289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142293. * @param name defines the name of the mesh
  142294. * @param options defines the options used to create the mesh
  142295. * @param scene defines the hosting scene
  142296. * @returns the lathe mesh
  142297. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142298. */
  142299. static CreateLathe(name: string, options: {
  142300. shape: Vector3[];
  142301. radius?: number;
  142302. tessellation?: number;
  142303. clip?: number;
  142304. arc?: number;
  142305. closed?: boolean;
  142306. updatable?: boolean;
  142307. sideOrientation?: number;
  142308. frontUVs?: Vector4;
  142309. backUVs?: Vector4;
  142310. cap?: number;
  142311. invertUV?: boolean;
  142312. }, scene?: Nullable<Scene>): Mesh;
  142313. /**
  142314. * Creates a tiled plane mesh
  142315. * * You can set a limited pattern arrangement with the tiles
  142316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142319. * @param name defines the name of the mesh
  142320. * @param options defines the options used to create the mesh
  142321. * @param scene defines the hosting scene
  142322. * @returns the plane mesh
  142323. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142324. */
  142325. static CreateTiledPlane(name: string, options: {
  142326. pattern?: number;
  142327. tileSize?: number;
  142328. tileWidth?: number;
  142329. tileHeight?: number;
  142330. size?: number;
  142331. width?: number;
  142332. height?: number;
  142333. alignHorizontal?: number;
  142334. alignVertical?: number;
  142335. sideOrientation?: number;
  142336. frontUVs?: Vector4;
  142337. backUVs?: Vector4;
  142338. updatable?: boolean;
  142339. }, scene?: Nullable<Scene>): Mesh;
  142340. /**
  142341. * Creates a plane mesh
  142342. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  142343. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  142344. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  142345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142348. * @param name defines the name of the mesh
  142349. * @param options defines the options used to create the mesh
  142350. * @param scene defines the hosting scene
  142351. * @returns the plane mesh
  142352. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142353. */
  142354. static CreatePlane(name: string, options: {
  142355. size?: number;
  142356. width?: number;
  142357. height?: number;
  142358. sideOrientation?: number;
  142359. frontUVs?: Vector4;
  142360. backUVs?: Vector4;
  142361. updatable?: boolean;
  142362. sourcePlane?: Plane;
  142363. }, scene?: Nullable<Scene>): Mesh;
  142364. /**
  142365. * Creates a ground mesh
  142366. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  142367. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  142368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142369. * @param name defines the name of the mesh
  142370. * @param options defines the options used to create the mesh
  142371. * @param scene defines the hosting scene
  142372. * @returns the ground mesh
  142373. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  142374. */
  142375. static CreateGround(name: string, options: {
  142376. width?: number;
  142377. height?: number;
  142378. subdivisions?: number;
  142379. subdivisionsX?: number;
  142380. subdivisionsY?: number;
  142381. updatable?: boolean;
  142382. }, scene?: Nullable<Scene>): Mesh;
  142383. /**
  142384. * Creates a tiled ground mesh
  142385. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  142386. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  142387. * * 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
  142388. * * 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
  142389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142390. * @param name defines the name of the mesh
  142391. * @param options defines the options used to create the mesh
  142392. * @param scene defines the hosting scene
  142393. * @returns the tiled ground mesh
  142394. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  142395. */
  142396. static CreateTiledGround(name: string, options: {
  142397. xmin: number;
  142398. zmin: number;
  142399. xmax: number;
  142400. zmax: number;
  142401. subdivisions?: {
  142402. w: number;
  142403. h: number;
  142404. };
  142405. precision?: {
  142406. w: number;
  142407. h: number;
  142408. };
  142409. updatable?: boolean;
  142410. }, scene?: Nullable<Scene>): Mesh;
  142411. /**
  142412. * Creates a ground mesh from a height map
  142413. * * The parameter `url` sets the URL of the height map image resource.
  142414. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  142415. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  142416. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  142417. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  142418. * * 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.
  142419. * * 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).
  142420. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  142421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142422. * @param name defines the name of the mesh
  142423. * @param url defines the url to the height map
  142424. * @param options defines the options used to create the mesh
  142425. * @param scene defines the hosting scene
  142426. * @returns the ground mesh
  142427. * @see https://doc.babylonjs.com/babylon101/height_map
  142428. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  142429. */
  142430. static CreateGroundFromHeightMap(name: string, url: string, options: {
  142431. width?: number;
  142432. height?: number;
  142433. subdivisions?: number;
  142434. minHeight?: number;
  142435. maxHeight?: number;
  142436. colorFilter?: Color3;
  142437. alphaFilter?: number;
  142438. updatable?: boolean;
  142439. onReady?: (mesh: GroundMesh) => void;
  142440. }, scene?: Nullable<Scene>): GroundMesh;
  142441. /**
  142442. * Creates a polygon mesh
  142443. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142444. * * 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
  142445. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142448. * * Remember you can only change the shape positions, not their number when updating a polygon
  142449. * @param name defines the name of the mesh
  142450. * @param options defines the options used to create the mesh
  142451. * @param scene defines the hosting scene
  142452. * @param earcutInjection can be used to inject your own earcut reference
  142453. * @returns the polygon mesh
  142454. */
  142455. static CreatePolygon(name: string, options: {
  142456. shape: Vector3[];
  142457. holes?: Vector3[][];
  142458. depth?: number;
  142459. faceUV?: Vector4[];
  142460. faceColors?: Color4[];
  142461. updatable?: boolean;
  142462. sideOrientation?: number;
  142463. frontUVs?: Vector4;
  142464. backUVs?: Vector4;
  142465. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142466. /**
  142467. * Creates an extruded polygon mesh, with depth in the Y direction.
  142468. * * 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)
  142469. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142470. * @param name defines the name of the mesh
  142471. * @param options defines the options used to create the mesh
  142472. * @param scene defines the hosting scene
  142473. * @param earcutInjection can be used to inject your own earcut reference
  142474. * @returns the polygon mesh
  142475. */
  142476. static ExtrudePolygon(name: string, options: {
  142477. shape: Vector3[];
  142478. holes?: Vector3[][];
  142479. depth?: number;
  142480. faceUV?: Vector4[];
  142481. faceColors?: Color4[];
  142482. updatable?: boolean;
  142483. sideOrientation?: number;
  142484. frontUVs?: Vector4;
  142485. backUVs?: Vector4;
  142486. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142487. /**
  142488. * Creates a tube mesh.
  142489. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142490. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142491. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142492. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142493. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142494. * * 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)
  142495. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142496. * * 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
  142497. * * 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
  142498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142502. * @param name defines the name of the mesh
  142503. * @param options defines the options used to create the mesh
  142504. * @param scene defines the hosting scene
  142505. * @returns the tube mesh
  142506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142507. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142508. */
  142509. static CreateTube(name: string, options: {
  142510. path: Vector3[];
  142511. radius?: number;
  142512. tessellation?: number;
  142513. radiusFunction?: {
  142514. (i: number, distance: number): number;
  142515. };
  142516. cap?: number;
  142517. arc?: number;
  142518. updatable?: boolean;
  142519. sideOrientation?: number;
  142520. frontUVs?: Vector4;
  142521. backUVs?: Vector4;
  142522. instance?: Mesh;
  142523. invertUV?: boolean;
  142524. }, scene?: Nullable<Scene>): Mesh;
  142525. /**
  142526. * Creates a polyhedron mesh
  142527. * * 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
  142528. * * The parameter `size` (positive float, default 1) sets the polygon size
  142529. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142530. * * 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`
  142531. * * 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
  142532. * * 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)`)
  142533. * * 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
  142534. * * 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
  142535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142538. * @param name defines the name of the mesh
  142539. * @param options defines the options used to create the mesh
  142540. * @param scene defines the hosting scene
  142541. * @returns the polyhedron mesh
  142542. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142543. */
  142544. static CreatePolyhedron(name: string, options: {
  142545. type?: number;
  142546. size?: number;
  142547. sizeX?: number;
  142548. sizeY?: number;
  142549. sizeZ?: number;
  142550. custom?: any;
  142551. faceUV?: Vector4[];
  142552. faceColors?: Color4[];
  142553. flat?: boolean;
  142554. updatable?: boolean;
  142555. sideOrientation?: number;
  142556. frontUVs?: Vector4;
  142557. backUVs?: Vector4;
  142558. }, scene?: Nullable<Scene>): Mesh;
  142559. /**
  142560. * Creates a decal mesh.
  142561. * 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
  142562. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142563. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142564. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142565. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142566. * @param name defines the name of the mesh
  142567. * @param sourceMesh defines the mesh where the decal must be applied
  142568. * @param options defines the options used to create the mesh
  142569. * @param scene defines the hosting scene
  142570. * @returns the decal mesh
  142571. * @see https://doc.babylonjs.com/how_to/decals
  142572. */
  142573. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142574. position?: Vector3;
  142575. normal?: Vector3;
  142576. size?: Vector3;
  142577. angle?: number;
  142578. }): Mesh;
  142579. }
  142580. }
  142581. declare module BABYLON {
  142582. /**
  142583. * A simplifier interface for future simplification implementations
  142584. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142585. */
  142586. export interface ISimplifier {
  142587. /**
  142588. * Simplification of a given mesh according to the given settings.
  142589. * Since this requires computation, it is assumed that the function runs async.
  142590. * @param settings The settings of the simplification, including quality and distance
  142591. * @param successCallback A callback that will be called after the mesh was simplified.
  142592. * @param errorCallback in case of an error, this callback will be called. optional.
  142593. */
  142594. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  142595. }
  142596. /**
  142597. * Expected simplification settings.
  142598. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  142599. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142600. */
  142601. export interface ISimplificationSettings {
  142602. /**
  142603. * Gets or sets the expected quality
  142604. */
  142605. quality: number;
  142606. /**
  142607. * Gets or sets the distance when this optimized version should be used
  142608. */
  142609. distance: number;
  142610. /**
  142611. * Gets an already optimized mesh
  142612. */
  142613. optimizeMesh?: boolean;
  142614. }
  142615. /**
  142616. * Class used to specify simplification options
  142617. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142618. */
  142619. export class SimplificationSettings implements ISimplificationSettings {
  142620. /** expected quality */
  142621. quality: number;
  142622. /** distance when this optimized version should be used */
  142623. distance: number;
  142624. /** already optimized mesh */
  142625. optimizeMesh?: boolean | undefined;
  142626. /**
  142627. * Creates a SimplificationSettings
  142628. * @param quality expected quality
  142629. * @param distance distance when this optimized version should be used
  142630. * @param optimizeMesh already optimized mesh
  142631. */
  142632. constructor(
  142633. /** expected quality */
  142634. quality: number,
  142635. /** distance when this optimized version should be used */
  142636. distance: number,
  142637. /** already optimized mesh */
  142638. optimizeMesh?: boolean | undefined);
  142639. }
  142640. /**
  142641. * Interface used to define a simplification task
  142642. */
  142643. export interface ISimplificationTask {
  142644. /**
  142645. * Array of settings
  142646. */
  142647. settings: Array<ISimplificationSettings>;
  142648. /**
  142649. * Simplification type
  142650. */
  142651. simplificationType: SimplificationType;
  142652. /**
  142653. * Mesh to simplify
  142654. */
  142655. mesh: Mesh;
  142656. /**
  142657. * Callback called on success
  142658. */
  142659. successCallback?: () => void;
  142660. /**
  142661. * Defines if parallel processing can be used
  142662. */
  142663. parallelProcessing: boolean;
  142664. }
  142665. /**
  142666. * Queue used to order the simplification tasks
  142667. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142668. */
  142669. export class SimplificationQueue {
  142670. private _simplificationArray;
  142671. /**
  142672. * Gets a boolean indicating that the process is still running
  142673. */
  142674. running: boolean;
  142675. /**
  142676. * Creates a new queue
  142677. */
  142678. constructor();
  142679. /**
  142680. * Adds a new simplification task
  142681. * @param task defines a task to add
  142682. */
  142683. addTask(task: ISimplificationTask): void;
  142684. /**
  142685. * Execute next task
  142686. */
  142687. executeNext(): void;
  142688. /**
  142689. * Execute a simplification task
  142690. * @param task defines the task to run
  142691. */
  142692. runSimplification(task: ISimplificationTask): void;
  142693. private getSimplifier;
  142694. }
  142695. /**
  142696. * The implemented types of simplification
  142697. * At the moment only Quadratic Error Decimation is implemented
  142698. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142699. */
  142700. export enum SimplificationType {
  142701. /** Quadratic error decimation */
  142702. QUADRATIC = 0
  142703. }
  142704. /**
  142705. * An implementation of the Quadratic Error simplification algorithm.
  142706. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  142707. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  142708. * @author RaananW
  142709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142710. */
  142711. export class QuadraticErrorSimplification implements ISimplifier {
  142712. private _mesh;
  142713. private triangles;
  142714. private vertices;
  142715. private references;
  142716. private _reconstructedMesh;
  142717. /** Gets or sets the number pf sync interations */
  142718. syncIterations: number;
  142719. /** Gets or sets the aggressiveness of the simplifier */
  142720. aggressiveness: number;
  142721. /** Gets or sets the number of allowed iterations for decimation */
  142722. decimationIterations: number;
  142723. /** Gets or sets the espilon to use for bounding box computation */
  142724. boundingBoxEpsilon: number;
  142725. /**
  142726. * Creates a new QuadraticErrorSimplification
  142727. * @param _mesh defines the target mesh
  142728. */
  142729. constructor(_mesh: Mesh);
  142730. /**
  142731. * Simplification of a given mesh according to the given settings.
  142732. * Since this requires computation, it is assumed that the function runs async.
  142733. * @param settings The settings of the simplification, including quality and distance
  142734. * @param successCallback A callback that will be called after the mesh was simplified.
  142735. */
  142736. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  142737. private runDecimation;
  142738. private initWithMesh;
  142739. private init;
  142740. private reconstructMesh;
  142741. private initDecimatedMesh;
  142742. private isFlipped;
  142743. private updateTriangles;
  142744. private identifyBorder;
  142745. private updateMesh;
  142746. private vertexError;
  142747. private calculateError;
  142748. }
  142749. }
  142750. declare module BABYLON {
  142751. interface Scene {
  142752. /** @hidden (Backing field) */
  142753. _simplificationQueue: SimplificationQueue;
  142754. /**
  142755. * Gets or sets the simplification queue attached to the scene
  142756. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142757. */
  142758. simplificationQueue: SimplificationQueue;
  142759. }
  142760. interface Mesh {
  142761. /**
  142762. * Simplify the mesh according to the given array of settings.
  142763. * Function will return immediately and will simplify async
  142764. * @param settings a collection of simplification settings
  142765. * @param parallelProcessing should all levels calculate parallel or one after the other
  142766. * @param simplificationType the type of simplification to run
  142767. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  142768. * @returns the current mesh
  142769. */
  142770. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  142771. }
  142772. /**
  142773. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  142774. * created in a scene
  142775. */
  142776. export class SimplicationQueueSceneComponent implements ISceneComponent {
  142777. /**
  142778. * The component name helpfull to identify the component in the list of scene components.
  142779. */
  142780. readonly name: string;
  142781. /**
  142782. * The scene the component belongs to.
  142783. */
  142784. scene: Scene;
  142785. /**
  142786. * Creates a new instance of the component for the given scene
  142787. * @param scene Defines the scene to register the component in
  142788. */
  142789. constructor(scene: Scene);
  142790. /**
  142791. * Registers the component in a given scene
  142792. */
  142793. register(): void;
  142794. /**
  142795. * Rebuilds the elements related to this component in case of
  142796. * context lost for instance.
  142797. */
  142798. rebuild(): void;
  142799. /**
  142800. * Disposes the component and the associated ressources
  142801. */
  142802. dispose(): void;
  142803. private _beforeCameraUpdate;
  142804. }
  142805. }
  142806. declare module BABYLON {
  142807. interface Mesh {
  142808. /**
  142809. * Creates a new thin instance
  142810. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  142811. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142812. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  142813. */
  142814. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  142815. /**
  142816. * Adds the transformation (matrix) of the current mesh as a thin instance
  142817. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142818. * @returns the thin instance index number
  142819. */
  142820. thinInstanceAddSelf(refresh: boolean): number;
  142821. /**
  142822. * Registers a custom attribute to be used with thin instances
  142823. * @param kind name of the attribute
  142824. * @param stride size in floats of the attribute
  142825. */
  142826. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  142827. /**
  142828. * Sets the matrix of a thin instance
  142829. * @param index index of the thin instance
  142830. * @param matrix matrix to set
  142831. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142832. */
  142833. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  142834. /**
  142835. * Sets the value of a custom attribute for a thin instance
  142836. * @param kind name of the attribute
  142837. * @param index index of the thin instance
  142838. * @param value value to set
  142839. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  142840. */
  142841. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  142842. /**
  142843. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  142844. */
  142845. thinInstanceCount: number;
  142846. /**
  142847. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  142848. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  142849. * @param buffer buffer to set
  142850. * @param stride size in floats of each value of the buffer
  142851. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  142852. */
  142853. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  142854. /**
  142855. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  142856. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  142857. */
  142858. thinInstanceBufferUpdated(kind: string): void;
  142859. /**
  142860. * Refreshes the bounding info, taking into account all the thin instances defined
  142861. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  142862. */
  142863. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  142864. /** @hidden */
  142865. _thinInstanceInitializeUserStorage(): void;
  142866. /** @hidden */
  142867. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  142868. /** @hidden */
  142869. _userThinInstanceBuffersStorage: {
  142870. data: {
  142871. [key: string]: Float32Array;
  142872. };
  142873. sizes: {
  142874. [key: string]: number;
  142875. };
  142876. vertexBuffers: {
  142877. [key: string]: Nullable<VertexBuffer>;
  142878. };
  142879. strides: {
  142880. [key: string]: number;
  142881. };
  142882. };
  142883. }
  142884. }
  142885. declare module BABYLON {
  142886. /**
  142887. * Navigation plugin interface to add navigation constrained by a navigation mesh
  142888. */
  142889. export interface INavigationEnginePlugin {
  142890. /**
  142891. * plugin name
  142892. */
  142893. name: string;
  142894. /**
  142895. * Creates a navigation mesh
  142896. * @param meshes array of all the geometry used to compute the navigatio mesh
  142897. * @param parameters bunch of parameters used to filter geometry
  142898. */
  142899. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  142900. /**
  142901. * Create a navigation mesh debug mesh
  142902. * @param scene is where the mesh will be added
  142903. * @returns debug display mesh
  142904. */
  142905. createDebugNavMesh(scene: Scene): Mesh;
  142906. /**
  142907. * Get a navigation mesh constrained position, closest to the parameter position
  142908. * @param position world position
  142909. * @returns the closest point to position constrained by the navigation mesh
  142910. */
  142911. getClosestPoint(position: Vector3): Vector3;
  142912. /**
  142913. * Get a navigation mesh constrained position, closest to the parameter position
  142914. * @param position world position
  142915. * @param result output the closest point to position constrained by the navigation mesh
  142916. */
  142917. getClosestPointToRef(position: Vector3, result: Vector3): void;
  142918. /**
  142919. * Get a navigation mesh constrained position, within a particular radius
  142920. * @param position world position
  142921. * @param maxRadius the maximum distance to the constrained world position
  142922. * @returns the closest point to position constrained by the navigation mesh
  142923. */
  142924. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  142925. /**
  142926. * Get a navigation mesh constrained position, within a particular radius
  142927. * @param position world position
  142928. * @param maxRadius the maximum distance to the constrained world position
  142929. * @param result output the closest point to position constrained by the navigation mesh
  142930. */
  142931. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  142932. /**
  142933. * Compute the final position from a segment made of destination-position
  142934. * @param position world position
  142935. * @param destination world position
  142936. * @returns the resulting point along the navmesh
  142937. */
  142938. moveAlong(position: Vector3, destination: Vector3): Vector3;
  142939. /**
  142940. * Compute the final position from a segment made of destination-position
  142941. * @param position world position
  142942. * @param destination world position
  142943. * @param result output the resulting point along the navmesh
  142944. */
  142945. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  142946. /**
  142947. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  142948. * @param start world position
  142949. * @param end world position
  142950. * @returns array containing world position composing the path
  142951. */
  142952. computePath(start: Vector3, end: Vector3): Vector3[];
  142953. /**
  142954. * If this plugin is supported
  142955. * @returns true if plugin is supported
  142956. */
  142957. isSupported(): boolean;
  142958. /**
  142959. * Create a new Crowd so you can add agents
  142960. * @param maxAgents the maximum agent count in the crowd
  142961. * @param maxAgentRadius the maximum radius an agent can have
  142962. * @param scene to attach the crowd to
  142963. * @returns the crowd you can add agents to
  142964. */
  142965. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  142966. /**
  142967. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  142968. * The queries will try to find a solution within those bounds
  142969. * default is (1,1,1)
  142970. * @param extent x,y,z value that define the extent around the queries point of reference
  142971. */
  142972. setDefaultQueryExtent(extent: Vector3): void;
  142973. /**
  142974. * Get the Bounding box extent specified by setDefaultQueryExtent
  142975. * @returns the box extent values
  142976. */
  142977. getDefaultQueryExtent(): Vector3;
  142978. /**
  142979. * build the navmesh from a previously saved state using getNavmeshData
  142980. * @param data the Uint8Array returned by getNavmeshData
  142981. */
  142982. buildFromNavmeshData(data: Uint8Array): void;
  142983. /**
  142984. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  142985. * @returns data the Uint8Array that can be saved and reused
  142986. */
  142987. getNavmeshData(): Uint8Array;
  142988. /**
  142989. * Get the Bounding box extent result specified by setDefaultQueryExtent
  142990. * @param result output the box extent values
  142991. */
  142992. getDefaultQueryExtentToRef(result: Vector3): void;
  142993. /**
  142994. * Release all resources
  142995. */
  142996. dispose(): void;
  142997. }
  142998. /**
  142999. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  143000. */
  143001. export interface ICrowd {
  143002. /**
  143003. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143004. * You can attach anything to that node. The node position is updated in the scene update tick.
  143005. * @param pos world position that will be constrained by the navigation mesh
  143006. * @param parameters agent parameters
  143007. * @param transform hooked to the agent that will be update by the scene
  143008. * @returns agent index
  143009. */
  143010. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143011. /**
  143012. * Returns the agent position in world space
  143013. * @param index agent index returned by addAgent
  143014. * @returns world space position
  143015. */
  143016. getAgentPosition(index: number): Vector3;
  143017. /**
  143018. * Gets the agent position result in world space
  143019. * @param index agent index returned by addAgent
  143020. * @param result output world space position
  143021. */
  143022. getAgentPositionToRef(index: number, result: Vector3): void;
  143023. /**
  143024. * Gets the agent velocity in world space
  143025. * @param index agent index returned by addAgent
  143026. * @returns world space velocity
  143027. */
  143028. getAgentVelocity(index: number): Vector3;
  143029. /**
  143030. * Gets the agent velocity result in world space
  143031. * @param index agent index returned by addAgent
  143032. * @param result output world space velocity
  143033. */
  143034. getAgentVelocityToRef(index: number, result: Vector3): void;
  143035. /**
  143036. * remove a particular agent previously created
  143037. * @param index agent index returned by addAgent
  143038. */
  143039. removeAgent(index: number): void;
  143040. /**
  143041. * get the list of all agents attached to this crowd
  143042. * @returns list of agent indices
  143043. */
  143044. getAgents(): number[];
  143045. /**
  143046. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143047. * @param deltaTime in seconds
  143048. */
  143049. update(deltaTime: number): void;
  143050. /**
  143051. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143052. * @param index agent index returned by addAgent
  143053. * @param destination targeted world position
  143054. */
  143055. agentGoto(index: number, destination: Vector3): void;
  143056. /**
  143057. * Teleport the agent to a new position
  143058. * @param index agent index returned by addAgent
  143059. * @param destination targeted world position
  143060. */
  143061. agentTeleport(index: number, destination: Vector3): void;
  143062. /**
  143063. * Update agent parameters
  143064. * @param index agent index returned by addAgent
  143065. * @param parameters agent parameters
  143066. */
  143067. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143068. /**
  143069. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143070. * The queries will try to find a solution within those bounds
  143071. * default is (1,1,1)
  143072. * @param extent x,y,z value that define the extent around the queries point of reference
  143073. */
  143074. setDefaultQueryExtent(extent: Vector3): void;
  143075. /**
  143076. * Get the Bounding box extent specified by setDefaultQueryExtent
  143077. * @returns the box extent values
  143078. */
  143079. getDefaultQueryExtent(): Vector3;
  143080. /**
  143081. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143082. * @param result output the box extent values
  143083. */
  143084. getDefaultQueryExtentToRef(result: Vector3): void;
  143085. /**
  143086. * Release all resources
  143087. */
  143088. dispose(): void;
  143089. }
  143090. /**
  143091. * Configures an agent
  143092. */
  143093. export interface IAgentParameters {
  143094. /**
  143095. * Agent radius. [Limit: >= 0]
  143096. */
  143097. radius: number;
  143098. /**
  143099. * Agent height. [Limit: > 0]
  143100. */
  143101. height: number;
  143102. /**
  143103. * Maximum allowed acceleration. [Limit: >= 0]
  143104. */
  143105. maxAcceleration: number;
  143106. /**
  143107. * Maximum allowed speed. [Limit: >= 0]
  143108. */
  143109. maxSpeed: number;
  143110. /**
  143111. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  143112. */
  143113. collisionQueryRange: number;
  143114. /**
  143115. * The path visibility optimization range. [Limit: > 0]
  143116. */
  143117. pathOptimizationRange: number;
  143118. /**
  143119. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  143120. */
  143121. separationWeight: number;
  143122. }
  143123. /**
  143124. * Configures the navigation mesh creation
  143125. */
  143126. export interface INavMeshParameters {
  143127. /**
  143128. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  143129. */
  143130. cs: number;
  143131. /**
  143132. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  143133. */
  143134. ch: number;
  143135. /**
  143136. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  143137. */
  143138. walkableSlopeAngle: number;
  143139. /**
  143140. * Minimum floor to 'ceiling' height that will still allow the floor area to
  143141. * be considered walkable. [Limit: >= 3] [Units: vx]
  143142. */
  143143. walkableHeight: number;
  143144. /**
  143145. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  143146. */
  143147. walkableClimb: number;
  143148. /**
  143149. * The distance to erode/shrink the walkable area of the heightfield away from
  143150. * obstructions. [Limit: >=0] [Units: vx]
  143151. */
  143152. walkableRadius: number;
  143153. /**
  143154. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  143155. */
  143156. maxEdgeLen: number;
  143157. /**
  143158. * The maximum distance a simplfied contour's border edges should deviate
  143159. * the original raw contour. [Limit: >=0] [Units: vx]
  143160. */
  143161. maxSimplificationError: number;
  143162. /**
  143163. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  143164. */
  143165. minRegionArea: number;
  143166. /**
  143167. * Any regions with a span count smaller than this value will, if possible,
  143168. * be merged with larger regions. [Limit: >=0] [Units: vx]
  143169. */
  143170. mergeRegionArea: number;
  143171. /**
  143172. * The maximum number of vertices allowed for polygons generated during the
  143173. * contour to polygon conversion process. [Limit: >= 3]
  143174. */
  143175. maxVertsPerPoly: number;
  143176. /**
  143177. * Sets the sampling distance to use when generating the detail mesh.
  143178. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  143179. */
  143180. detailSampleDist: number;
  143181. /**
  143182. * The maximum distance the detail mesh surface should deviate from heightfield
  143183. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  143184. */
  143185. detailSampleMaxError: number;
  143186. }
  143187. }
  143188. declare module BABYLON {
  143189. /**
  143190. * RecastJS navigation plugin
  143191. */
  143192. export class RecastJSPlugin implements INavigationEnginePlugin {
  143193. /**
  143194. * Reference to the Recast library
  143195. */
  143196. bjsRECAST: any;
  143197. /**
  143198. * plugin name
  143199. */
  143200. name: string;
  143201. /**
  143202. * the first navmesh created. We might extend this to support multiple navmeshes
  143203. */
  143204. navMesh: any;
  143205. /**
  143206. * Initializes the recastJS plugin
  143207. * @param recastInjection can be used to inject your own recast reference
  143208. */
  143209. constructor(recastInjection?: any);
  143210. /**
  143211. * Creates a navigation mesh
  143212. * @param meshes array of all the geometry used to compute the navigatio mesh
  143213. * @param parameters bunch of parameters used to filter geometry
  143214. */
  143215. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143216. /**
  143217. * Create a navigation mesh debug mesh
  143218. * @param scene is where the mesh will be added
  143219. * @returns debug display mesh
  143220. */
  143221. createDebugNavMesh(scene: Scene): Mesh;
  143222. /**
  143223. * Get a navigation mesh constrained position, closest to the parameter position
  143224. * @param position world position
  143225. * @returns the closest point to position constrained by the navigation mesh
  143226. */
  143227. getClosestPoint(position: Vector3): Vector3;
  143228. /**
  143229. * Get a navigation mesh constrained position, closest to the parameter position
  143230. * @param position world position
  143231. * @param result output the closest point to position constrained by the navigation mesh
  143232. */
  143233. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143234. /**
  143235. * Get a navigation mesh constrained position, within a particular radius
  143236. * @param position world position
  143237. * @param maxRadius the maximum distance to the constrained world position
  143238. * @returns the closest point to position constrained by the navigation mesh
  143239. */
  143240. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143241. /**
  143242. * Get a navigation mesh constrained position, within a particular radius
  143243. * @param position world position
  143244. * @param maxRadius the maximum distance to the constrained world position
  143245. * @param result output the closest point to position constrained by the navigation mesh
  143246. */
  143247. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143248. /**
  143249. * Compute the final position from a segment made of destination-position
  143250. * @param position world position
  143251. * @param destination world position
  143252. * @returns the resulting point along the navmesh
  143253. */
  143254. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143255. /**
  143256. * Compute the final position from a segment made of destination-position
  143257. * @param position world position
  143258. * @param destination world position
  143259. * @param result output the resulting point along the navmesh
  143260. */
  143261. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143262. /**
  143263. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143264. * @param start world position
  143265. * @param end world position
  143266. * @returns array containing world position composing the path
  143267. */
  143268. computePath(start: Vector3, end: Vector3): Vector3[];
  143269. /**
  143270. * Create a new Crowd so you can add agents
  143271. * @param maxAgents the maximum agent count in the crowd
  143272. * @param maxAgentRadius the maximum radius an agent can have
  143273. * @param scene to attach the crowd to
  143274. * @returns the crowd you can add agents to
  143275. */
  143276. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143277. /**
  143278. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143279. * The queries will try to find a solution within those bounds
  143280. * default is (1,1,1)
  143281. * @param extent x,y,z value that define the extent around the queries point of reference
  143282. */
  143283. setDefaultQueryExtent(extent: Vector3): void;
  143284. /**
  143285. * Get the Bounding box extent specified by setDefaultQueryExtent
  143286. * @returns the box extent values
  143287. */
  143288. getDefaultQueryExtent(): Vector3;
  143289. /**
  143290. * build the navmesh from a previously saved state using getNavmeshData
  143291. * @param data the Uint8Array returned by getNavmeshData
  143292. */
  143293. buildFromNavmeshData(data: Uint8Array): void;
  143294. /**
  143295. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143296. * @returns data the Uint8Array that can be saved and reused
  143297. */
  143298. getNavmeshData(): Uint8Array;
  143299. /**
  143300. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143301. * @param result output the box extent values
  143302. */
  143303. getDefaultQueryExtentToRef(result: Vector3): void;
  143304. /**
  143305. * Disposes
  143306. */
  143307. dispose(): void;
  143308. /**
  143309. * If this plugin is supported
  143310. * @returns true if plugin is supported
  143311. */
  143312. isSupported(): boolean;
  143313. }
  143314. /**
  143315. * Recast detour crowd implementation
  143316. */
  143317. export class RecastJSCrowd implements ICrowd {
  143318. /**
  143319. * Recast/detour plugin
  143320. */
  143321. bjsRECASTPlugin: RecastJSPlugin;
  143322. /**
  143323. * Link to the detour crowd
  143324. */
  143325. recastCrowd: any;
  143326. /**
  143327. * One transform per agent
  143328. */
  143329. transforms: TransformNode[];
  143330. /**
  143331. * All agents created
  143332. */
  143333. agents: number[];
  143334. /**
  143335. * Link to the scene is kept to unregister the crowd from the scene
  143336. */
  143337. private _scene;
  143338. /**
  143339. * Observer for crowd updates
  143340. */
  143341. private _onBeforeAnimationsObserver;
  143342. /**
  143343. * Constructor
  143344. * @param plugin recastJS plugin
  143345. * @param maxAgents the maximum agent count in the crowd
  143346. * @param maxAgentRadius the maximum radius an agent can have
  143347. * @param scene to attach the crowd to
  143348. * @returns the crowd you can add agents to
  143349. */
  143350. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  143351. /**
  143352. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143353. * You can attach anything to that node. The node position is updated in the scene update tick.
  143354. * @param pos world position that will be constrained by the navigation mesh
  143355. * @param parameters agent parameters
  143356. * @param transform hooked to the agent that will be update by the scene
  143357. * @returns agent index
  143358. */
  143359. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143360. /**
  143361. * Returns the agent position in world space
  143362. * @param index agent index returned by addAgent
  143363. * @returns world space position
  143364. */
  143365. getAgentPosition(index: number): Vector3;
  143366. /**
  143367. * Returns the agent position result in world space
  143368. * @param index agent index returned by addAgent
  143369. * @param result output world space position
  143370. */
  143371. getAgentPositionToRef(index: number, result: Vector3): void;
  143372. /**
  143373. * Returns the agent velocity in world space
  143374. * @param index agent index returned by addAgent
  143375. * @returns world space velocity
  143376. */
  143377. getAgentVelocity(index: number): Vector3;
  143378. /**
  143379. * Returns the agent velocity result in world space
  143380. * @param index agent index returned by addAgent
  143381. * @param result output world space velocity
  143382. */
  143383. getAgentVelocityToRef(index: number, result: Vector3): void;
  143384. /**
  143385. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143386. * @param index agent index returned by addAgent
  143387. * @param destination targeted world position
  143388. */
  143389. agentGoto(index: number, destination: Vector3): void;
  143390. /**
  143391. * Teleport the agent to a new position
  143392. * @param index agent index returned by addAgent
  143393. * @param destination targeted world position
  143394. */
  143395. agentTeleport(index: number, destination: Vector3): void;
  143396. /**
  143397. * Update agent parameters
  143398. * @param index agent index returned by addAgent
  143399. * @param parameters agent parameters
  143400. */
  143401. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143402. /**
  143403. * remove a particular agent previously created
  143404. * @param index agent index returned by addAgent
  143405. */
  143406. removeAgent(index: number): void;
  143407. /**
  143408. * get the list of all agents attached to this crowd
  143409. * @returns list of agent indices
  143410. */
  143411. getAgents(): number[];
  143412. /**
  143413. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143414. * @param deltaTime in seconds
  143415. */
  143416. update(deltaTime: number): void;
  143417. /**
  143418. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143419. * The queries will try to find a solution within those bounds
  143420. * default is (1,1,1)
  143421. * @param extent x,y,z value that define the extent around the queries point of reference
  143422. */
  143423. setDefaultQueryExtent(extent: Vector3): void;
  143424. /**
  143425. * Get the Bounding box extent specified by setDefaultQueryExtent
  143426. * @returns the box extent values
  143427. */
  143428. getDefaultQueryExtent(): Vector3;
  143429. /**
  143430. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143431. * @param result output the box extent values
  143432. */
  143433. getDefaultQueryExtentToRef(result: Vector3): void;
  143434. /**
  143435. * Release all resources
  143436. */
  143437. dispose(): void;
  143438. }
  143439. }
  143440. declare module BABYLON {
  143441. /**
  143442. * Class used to enable access to IndexedDB
  143443. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  143444. */
  143445. export class Database implements IOfflineProvider {
  143446. private _callbackManifestChecked;
  143447. private _currentSceneUrl;
  143448. private _db;
  143449. private _enableSceneOffline;
  143450. private _enableTexturesOffline;
  143451. private _manifestVersionFound;
  143452. private _mustUpdateRessources;
  143453. private _hasReachedQuota;
  143454. private _isSupported;
  143455. private _idbFactory;
  143456. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  143457. private static IsUASupportingBlobStorage;
  143458. /**
  143459. * Gets a boolean indicating if Database storate is enabled (off by default)
  143460. */
  143461. static IDBStorageEnabled: boolean;
  143462. /**
  143463. * Gets a boolean indicating if scene must be saved in the database
  143464. */
  143465. get enableSceneOffline(): boolean;
  143466. /**
  143467. * Gets a boolean indicating if textures must be saved in the database
  143468. */
  143469. get enableTexturesOffline(): boolean;
  143470. /**
  143471. * Creates a new Database
  143472. * @param urlToScene defines the url to load the scene
  143473. * @param callbackManifestChecked defines the callback to use when manifest is checked
  143474. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  143475. */
  143476. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  143477. private static _ParseURL;
  143478. private static _ReturnFullUrlLocation;
  143479. private _checkManifestFile;
  143480. /**
  143481. * Open the database and make it available
  143482. * @param successCallback defines the callback to call on success
  143483. * @param errorCallback defines the callback to call on error
  143484. */
  143485. open(successCallback: () => void, errorCallback: () => void): void;
  143486. /**
  143487. * Loads an image from the database
  143488. * @param url defines the url to load from
  143489. * @param image defines the target DOM image
  143490. */
  143491. loadImage(url: string, image: HTMLImageElement): void;
  143492. private _loadImageFromDBAsync;
  143493. private _saveImageIntoDBAsync;
  143494. private _checkVersionFromDB;
  143495. private _loadVersionFromDBAsync;
  143496. private _saveVersionIntoDBAsync;
  143497. /**
  143498. * Loads a file from database
  143499. * @param url defines the URL to load from
  143500. * @param sceneLoaded defines a callback to call on success
  143501. * @param progressCallBack defines a callback to call when progress changed
  143502. * @param errorCallback defines a callback to call on error
  143503. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  143504. */
  143505. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  143506. private _loadFileAsync;
  143507. private _saveFileAsync;
  143508. /**
  143509. * Validates if xhr data is correct
  143510. * @param xhr defines the request to validate
  143511. * @param dataType defines the expected data type
  143512. * @returns true if data is correct
  143513. */
  143514. private static _ValidateXHRData;
  143515. }
  143516. }
  143517. declare module BABYLON {
  143518. /** @hidden */
  143519. export var gpuUpdateParticlesPixelShader: {
  143520. name: string;
  143521. shader: string;
  143522. };
  143523. }
  143524. declare module BABYLON {
  143525. /** @hidden */
  143526. export var gpuUpdateParticlesVertexShader: {
  143527. name: string;
  143528. shader: string;
  143529. };
  143530. }
  143531. declare module BABYLON {
  143532. /** @hidden */
  143533. export var clipPlaneFragmentDeclaration2: {
  143534. name: string;
  143535. shader: string;
  143536. };
  143537. }
  143538. declare module BABYLON {
  143539. /** @hidden */
  143540. export var gpuRenderParticlesPixelShader: {
  143541. name: string;
  143542. shader: string;
  143543. };
  143544. }
  143545. declare module BABYLON {
  143546. /** @hidden */
  143547. export var clipPlaneVertexDeclaration2: {
  143548. name: string;
  143549. shader: string;
  143550. };
  143551. }
  143552. declare module BABYLON {
  143553. /** @hidden */
  143554. export var gpuRenderParticlesVertexShader: {
  143555. name: string;
  143556. shader: string;
  143557. };
  143558. }
  143559. declare module BABYLON {
  143560. /**
  143561. * This represents a GPU particle system in Babylon
  143562. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  143563. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  143564. */
  143565. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  143566. /**
  143567. * The layer mask we are rendering the particles through.
  143568. */
  143569. layerMask: number;
  143570. private _capacity;
  143571. private _activeCount;
  143572. private _currentActiveCount;
  143573. private _accumulatedCount;
  143574. private _renderEffect;
  143575. private _updateEffect;
  143576. private _buffer0;
  143577. private _buffer1;
  143578. private _spriteBuffer;
  143579. private _updateVAO;
  143580. private _renderVAO;
  143581. private _targetIndex;
  143582. private _sourceBuffer;
  143583. private _targetBuffer;
  143584. private _engine;
  143585. private _currentRenderId;
  143586. private _started;
  143587. private _stopped;
  143588. private _timeDelta;
  143589. private _randomTexture;
  143590. private _randomTexture2;
  143591. private _attributesStrideSize;
  143592. private _updateEffectOptions;
  143593. private _randomTextureSize;
  143594. private _actualFrame;
  143595. private _customEffect;
  143596. private readonly _rawTextureWidth;
  143597. /**
  143598. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  143599. */
  143600. static get IsSupported(): boolean;
  143601. /**
  143602. * An event triggered when the system is disposed.
  143603. */
  143604. onDisposeObservable: Observable<IParticleSystem>;
  143605. /**
  143606. * Gets the maximum number of particles active at the same time.
  143607. * @returns The max number of active particles.
  143608. */
  143609. getCapacity(): number;
  143610. /**
  143611. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  143612. * to override the particles.
  143613. */
  143614. forceDepthWrite: boolean;
  143615. /**
  143616. * Gets or set the number of active particles
  143617. */
  143618. get activeParticleCount(): number;
  143619. set activeParticleCount(value: number);
  143620. private _preWarmDone;
  143621. /**
  143622. * Specifies if the particles are updated in emitter local space or world space.
  143623. */
  143624. isLocal: boolean;
  143625. /**
  143626. * Is this system ready to be used/rendered
  143627. * @return true if the system is ready
  143628. */
  143629. isReady(): boolean;
  143630. /**
  143631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  143632. * @returns True if it has been started, otherwise false.
  143633. */
  143634. isStarted(): boolean;
  143635. /**
  143636. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  143637. * @returns True if it has been stopped, otherwise false.
  143638. */
  143639. isStopped(): boolean;
  143640. /**
  143641. * Gets a boolean indicating that the system is stopping
  143642. * @returns true if the system is currently stopping
  143643. */
  143644. isStopping(): boolean;
  143645. /**
  143646. * Gets the number of particles active at the same time.
  143647. * @returns The number of active particles.
  143648. */
  143649. getActiveCount(): number;
  143650. /**
  143651. * Starts the particle system and begins to emit
  143652. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  143653. */
  143654. start(delay?: number): void;
  143655. /**
  143656. * Stops the particle system.
  143657. */
  143658. stop(): void;
  143659. /**
  143660. * Remove all active particles
  143661. */
  143662. reset(): void;
  143663. /**
  143664. * Returns the string "GPUParticleSystem"
  143665. * @returns a string containing the class name
  143666. */
  143667. getClassName(): string;
  143668. /**
  143669. * Gets the custom effect used to render the particles
  143670. * @param blendMode Blend mode for which the effect should be retrieved
  143671. * @returns The effect
  143672. */
  143673. getCustomEffect(blendMode?: number): Nullable<Effect>;
  143674. /**
  143675. * Sets the custom effect used to render the particles
  143676. * @param effect The effect to set
  143677. * @param blendMode Blend mode for which the effect should be set
  143678. */
  143679. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  143680. /** @hidden */
  143681. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  143682. /**
  143683. * Observable that will be called just before the particles are drawn
  143684. */
  143685. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  143686. /**
  143687. * Gets the name of the particle vertex shader
  143688. */
  143689. get vertexShaderName(): string;
  143690. private _colorGradientsTexture;
  143691. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  143692. /**
  143693. * Adds a new color gradient
  143694. * @param gradient defines the gradient to use (between 0 and 1)
  143695. * @param color1 defines the color to affect to the specified gradient
  143696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  143697. * @returns the current particle system
  143698. */
  143699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  143700. private _refreshColorGradient;
  143701. /** Force the system to rebuild all gradients that need to be resync */
  143702. forceRefreshGradients(): void;
  143703. /**
  143704. * Remove a specific color gradient
  143705. * @param gradient defines the gradient to remove
  143706. * @returns the current particle system
  143707. */
  143708. removeColorGradient(gradient: number): GPUParticleSystem;
  143709. private _angularSpeedGradientsTexture;
  143710. private _sizeGradientsTexture;
  143711. private _velocityGradientsTexture;
  143712. private _limitVelocityGradientsTexture;
  143713. private _dragGradientsTexture;
  143714. private _addFactorGradient;
  143715. /**
  143716. * Adds a new size gradient
  143717. * @param gradient defines the gradient to use (between 0 and 1)
  143718. * @param factor defines the size factor to affect to the specified gradient
  143719. * @returns the current particle system
  143720. */
  143721. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  143722. /**
  143723. * Remove a specific size gradient
  143724. * @param gradient defines the gradient to remove
  143725. * @returns the current particle system
  143726. */
  143727. removeSizeGradient(gradient: number): GPUParticleSystem;
  143728. private _refreshFactorGradient;
  143729. /**
  143730. * Adds a new angular speed gradient
  143731. * @param gradient defines the gradient to use (between 0 and 1)
  143732. * @param factor defines the angular speed to affect to the specified gradient
  143733. * @returns the current particle system
  143734. */
  143735. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  143736. /**
  143737. * Remove a specific angular speed gradient
  143738. * @param gradient defines the gradient to remove
  143739. * @returns the current particle system
  143740. */
  143741. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  143742. /**
  143743. * Adds a new velocity gradient
  143744. * @param gradient defines the gradient to use (between 0 and 1)
  143745. * @param factor defines the velocity to affect to the specified gradient
  143746. * @returns the current particle system
  143747. */
  143748. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143749. /**
  143750. * Remove a specific velocity gradient
  143751. * @param gradient defines the gradient to remove
  143752. * @returns the current particle system
  143753. */
  143754. removeVelocityGradient(gradient: number): GPUParticleSystem;
  143755. /**
  143756. * Adds a new limit velocity gradient
  143757. * @param gradient defines the gradient to use (between 0 and 1)
  143758. * @param factor defines the limit velocity value to affect to the specified gradient
  143759. * @returns the current particle system
  143760. */
  143761. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  143762. /**
  143763. * Remove a specific limit velocity gradient
  143764. * @param gradient defines the gradient to remove
  143765. * @returns the current particle system
  143766. */
  143767. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  143768. /**
  143769. * Adds a new drag gradient
  143770. * @param gradient defines the gradient to use (between 0 and 1)
  143771. * @param factor defines the drag value to affect to the specified gradient
  143772. * @returns the current particle system
  143773. */
  143774. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  143775. /**
  143776. * Remove a specific drag gradient
  143777. * @param gradient defines the gradient to remove
  143778. * @returns the current particle system
  143779. */
  143780. removeDragGradient(gradient: number): GPUParticleSystem;
  143781. /**
  143782. * Not supported by GPUParticleSystem
  143783. * @param gradient defines the gradient to use (between 0 and 1)
  143784. * @param factor defines the emit rate value to affect to the specified gradient
  143785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143786. * @returns the current particle system
  143787. */
  143788. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143789. /**
  143790. * Not supported by GPUParticleSystem
  143791. * @param gradient defines the gradient to remove
  143792. * @returns the current particle system
  143793. */
  143794. removeEmitRateGradient(gradient: number): IParticleSystem;
  143795. /**
  143796. * Not supported by GPUParticleSystem
  143797. * @param gradient defines the gradient to use (between 0 and 1)
  143798. * @param factor defines the start size value to affect to the specified gradient
  143799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143800. * @returns the current particle system
  143801. */
  143802. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143803. /**
  143804. * Not supported by GPUParticleSystem
  143805. * @param gradient defines the gradient to remove
  143806. * @returns the current particle system
  143807. */
  143808. removeStartSizeGradient(gradient: number): IParticleSystem;
  143809. /**
  143810. * Not supported by GPUParticleSystem
  143811. * @param gradient defines the gradient to use (between 0 and 1)
  143812. * @param min defines the color remap minimal range
  143813. * @param max defines the color remap maximal range
  143814. * @returns the current particle system
  143815. */
  143816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143817. /**
  143818. * Not supported by GPUParticleSystem
  143819. * @param gradient defines the gradient to remove
  143820. * @returns the current particle system
  143821. */
  143822. removeColorRemapGradient(): IParticleSystem;
  143823. /**
  143824. * Not supported by GPUParticleSystem
  143825. * @param gradient defines the gradient to use (between 0 and 1)
  143826. * @param min defines the alpha remap minimal range
  143827. * @param max defines the alpha remap maximal range
  143828. * @returns the current particle system
  143829. */
  143830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  143831. /**
  143832. * Not supported by GPUParticleSystem
  143833. * @param gradient defines the gradient to remove
  143834. * @returns the current particle system
  143835. */
  143836. removeAlphaRemapGradient(): IParticleSystem;
  143837. /**
  143838. * Not supported by GPUParticleSystem
  143839. * @param gradient defines the gradient to use (between 0 and 1)
  143840. * @param color defines the color to affect to the specified gradient
  143841. * @returns the current particle system
  143842. */
  143843. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  143844. /**
  143845. * Not supported by GPUParticleSystem
  143846. * @param gradient defines the gradient to remove
  143847. * @returns the current particle system
  143848. */
  143849. removeRampGradient(): IParticleSystem;
  143850. /**
  143851. * Not supported by GPUParticleSystem
  143852. * @returns the list of ramp gradients
  143853. */
  143854. getRampGradients(): Nullable<Array<Color3Gradient>>;
  143855. /**
  143856. * Not supported by GPUParticleSystem
  143857. * Gets or sets a boolean indicating that ramp gradients must be used
  143858. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  143859. */
  143860. get useRampGradients(): boolean;
  143861. set useRampGradients(value: boolean);
  143862. /**
  143863. * Not supported by GPUParticleSystem
  143864. * @param gradient defines the gradient to use (between 0 and 1)
  143865. * @param factor defines the life time factor to affect to the specified gradient
  143866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  143867. * @returns the current particle system
  143868. */
  143869. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  143870. /**
  143871. * Not supported by GPUParticleSystem
  143872. * @param gradient defines the gradient to remove
  143873. * @returns the current particle system
  143874. */
  143875. removeLifeTimeGradient(gradient: number): IParticleSystem;
  143876. /**
  143877. * Instantiates a GPU particle system.
  143878. * 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.
  143879. * @param name The name of the particle system
  143880. * @param options The options used to create the system
  143881. * @param scene The scene the particle system belongs to
  143882. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  143883. * @param customEffect a custom effect used to change the way particles are rendered by default
  143884. */
  143885. constructor(name: string, options: Partial<{
  143886. capacity: number;
  143887. randomTextureSize: number;
  143888. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  143889. protected _reset(): void;
  143890. private _createUpdateVAO;
  143891. private _createRenderVAO;
  143892. private _initialize;
  143893. /** @hidden */
  143894. _recreateUpdateEffect(): void;
  143895. private _getEffect;
  143896. /**
  143897. * Fill the defines array according to the current settings of the particle system
  143898. * @param defines Array to be updated
  143899. * @param blendMode blend mode to take into account when updating the array
  143900. */
  143901. fillDefines(defines: Array<string>, blendMode?: number): void;
  143902. /**
  143903. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  143904. * @param uniforms Uniforms array to fill
  143905. * @param attributes Attributes array to fill
  143906. * @param samplers Samplers array to fill
  143907. */
  143908. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  143909. /** @hidden */
  143910. _recreateRenderEffect(): Effect;
  143911. /**
  143912. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  143913. * @param preWarm defines if we are in the pre-warmimg phase
  143914. */
  143915. animate(preWarm?: boolean): void;
  143916. private _createFactorGradientTexture;
  143917. private _createSizeGradientTexture;
  143918. private _createAngularSpeedGradientTexture;
  143919. private _createVelocityGradientTexture;
  143920. private _createLimitVelocityGradientTexture;
  143921. private _createDragGradientTexture;
  143922. private _createColorGradientTexture;
  143923. /**
  143924. * Renders the particle system in its current state
  143925. * @param preWarm defines if the system should only update the particles but not render them
  143926. * @returns the current number of particles
  143927. */
  143928. render(preWarm?: boolean): number;
  143929. /**
  143930. * Rebuilds the particle system
  143931. */
  143932. rebuild(): void;
  143933. private _releaseBuffers;
  143934. private _releaseVAOs;
  143935. /**
  143936. * Disposes the particle system and free the associated resources
  143937. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  143938. */
  143939. dispose(disposeTexture?: boolean): void;
  143940. /**
  143941. * Clones the particle system.
  143942. * @param name The name of the cloned object
  143943. * @param newEmitter The new emitter to use
  143944. * @returns the cloned particle system
  143945. */
  143946. clone(name: string, newEmitter: any): GPUParticleSystem;
  143947. /**
  143948. * Serializes the particle system to a JSON object
  143949. * @param serializeTexture defines if the texture must be serialized as well
  143950. * @returns the JSON object
  143951. */
  143952. serialize(serializeTexture?: boolean): any;
  143953. /**
  143954. * Parses a JSON object to create a GPU particle system.
  143955. * @param parsedParticleSystem The JSON object to parse
  143956. * @param scene The scene to create the particle system in
  143957. * @param rootUrl The root url to use to load external dependencies like texture
  143958. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  143959. * @returns the parsed GPU particle system
  143960. */
  143961. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  143962. }
  143963. }
  143964. declare module BABYLON {
  143965. /**
  143966. * Represents a set of particle systems working together to create a specific effect
  143967. */
  143968. export class ParticleSystemSet implements IDisposable {
  143969. /**
  143970. * Gets or sets base Assets URL
  143971. */
  143972. static BaseAssetsUrl: string;
  143973. private _emitterCreationOptions;
  143974. private _emitterNode;
  143975. /**
  143976. * Gets the particle system list
  143977. */
  143978. systems: IParticleSystem[];
  143979. /**
  143980. * Gets the emitter node used with this set
  143981. */
  143982. get emitterNode(): Nullable<TransformNode>;
  143983. /**
  143984. * Creates a new emitter mesh as a sphere
  143985. * @param options defines the options used to create the sphere
  143986. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  143987. * @param scene defines the hosting scene
  143988. */
  143989. setEmitterAsSphere(options: {
  143990. diameter: number;
  143991. segments: number;
  143992. color: Color3;
  143993. }, renderingGroupId: number, scene: Scene): void;
  143994. /**
  143995. * Starts all particle systems of the set
  143996. * @param emitter defines an optional mesh to use as emitter for the particle systems
  143997. */
  143998. start(emitter?: AbstractMesh): void;
  143999. /**
  144000. * Release all associated resources
  144001. */
  144002. dispose(): void;
  144003. /**
  144004. * Serialize the set into a JSON compatible object
  144005. * @param serializeTexture defines if the texture must be serialized as well
  144006. * @returns a JSON compatible representation of the set
  144007. */
  144008. serialize(serializeTexture?: boolean): any;
  144009. /**
  144010. * Parse a new ParticleSystemSet from a serialized source
  144011. * @param data defines a JSON compatible representation of the set
  144012. * @param scene defines the hosting scene
  144013. * @param gpu defines if we want GPU particles or CPU particles
  144014. * @returns a new ParticleSystemSet
  144015. */
  144016. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  144017. }
  144018. }
  144019. declare module BABYLON {
  144020. /**
  144021. * This class is made for on one-liner static method to help creating particle system set.
  144022. */
  144023. export class ParticleHelper {
  144024. /**
  144025. * Gets or sets base Assets URL
  144026. */
  144027. static BaseAssetsUrl: string;
  144028. /** Define the Url to load snippets */
  144029. static SnippetUrl: string;
  144030. /**
  144031. * Create a default particle system that you can tweak
  144032. * @param emitter defines the emitter to use
  144033. * @param capacity defines the system capacity (default is 500 particles)
  144034. * @param scene defines the hosting scene
  144035. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  144036. * @returns the new Particle system
  144037. */
  144038. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  144039. /**
  144040. * This is the main static method (one-liner) of this helper to create different particle systems
  144041. * @param type This string represents the type to the particle system to create
  144042. * @param scene The scene where the particle system should live
  144043. * @param gpu If the system will use gpu
  144044. * @returns the ParticleSystemSet created
  144045. */
  144046. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  144047. /**
  144048. * Static function used to export a particle system to a ParticleSystemSet variable.
  144049. * Please note that the emitter shape is not exported
  144050. * @param systems defines the particle systems to export
  144051. * @returns the created particle system set
  144052. */
  144053. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  144054. /**
  144055. * Creates a particle system from a snippet saved in a remote file
  144056. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  144057. * @param url defines the url to load from
  144058. * @param scene defines the hosting scene
  144059. * @param gpu If the system will use gpu
  144060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144061. * @returns a promise that will resolve to the new particle system
  144062. */
  144063. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144064. /**
  144065. * Creates a particle system from a snippet saved by the particle system editor
  144066. * @param snippetId defines the snippet to load
  144067. * @param scene defines the hosting scene
  144068. * @param gpu If the system will use gpu
  144069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144070. * @returns a promise that will resolve to the new particle system
  144071. */
  144072. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144073. }
  144074. }
  144075. declare module BABYLON {
  144076. interface Engine {
  144077. /**
  144078. * Create an effect to use with particle systems.
  144079. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  144080. * the particle system for which you want to create a custom effect in the last parameter
  144081. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  144082. * @param uniformsNames defines a list of attribute names
  144083. * @param samplers defines an array of string used to represent textures
  144084. * @param defines defines the string containing the defines to use to compile the shaders
  144085. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  144086. * @param onCompiled defines a function to call when the effect creation is successful
  144087. * @param onError defines a function to call when the effect creation has failed
  144088. * @param particleSystem the particle system you want to create the effect for
  144089. * @returns the new Effect
  144090. */
  144091. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  144092. }
  144093. interface Mesh {
  144094. /**
  144095. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  144096. * @returns an array of IParticleSystem
  144097. */
  144098. getEmittedParticleSystems(): IParticleSystem[];
  144099. /**
  144100. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  144101. * @returns an array of IParticleSystem
  144102. */
  144103. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  144104. }
  144105. }
  144106. declare module BABYLON {
  144107. /** Defines the 4 color options */
  144108. export enum PointColor {
  144109. /** color value */
  144110. Color = 2,
  144111. /** uv value */
  144112. UV = 1,
  144113. /** random value */
  144114. Random = 0,
  144115. /** stated value */
  144116. Stated = 3
  144117. }
  144118. /**
  144119. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  144120. * 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.
  144121. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  144122. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  144123. *
  144124. * Full documentation here : TO BE ENTERED
  144125. */
  144126. export class PointsCloudSystem implements IDisposable {
  144127. /**
  144128. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  144129. * Example : var p = SPS.particles[i];
  144130. */
  144131. particles: CloudPoint[];
  144132. /**
  144133. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  144134. */
  144135. nbParticles: number;
  144136. /**
  144137. * This a counter for your own usage. It's not set by any SPS functions.
  144138. */
  144139. counter: number;
  144140. /**
  144141. * The PCS name. This name is also given to the underlying mesh.
  144142. */
  144143. name: string;
  144144. /**
  144145. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  144146. */
  144147. mesh: Mesh;
  144148. /**
  144149. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  144150. * Please read :
  144151. */
  144152. vars: any;
  144153. /**
  144154. * @hidden
  144155. */
  144156. _size: number;
  144157. private _scene;
  144158. private _promises;
  144159. private _positions;
  144160. private _indices;
  144161. private _normals;
  144162. private _colors;
  144163. private _uvs;
  144164. private _indices32;
  144165. private _positions32;
  144166. private _colors32;
  144167. private _uvs32;
  144168. private _updatable;
  144169. private _isVisibilityBoxLocked;
  144170. private _alwaysVisible;
  144171. private _groups;
  144172. private _groupCounter;
  144173. private _computeParticleColor;
  144174. private _computeParticleTexture;
  144175. private _computeParticleRotation;
  144176. private _computeBoundingBox;
  144177. private _isReady;
  144178. /**
  144179. * Creates a PCS (Points Cloud System) object
  144180. * @param name (String) is the PCS name, this will be the underlying mesh name
  144181. * @param pointSize (number) is the size for each point
  144182. * @param scene (Scene) is the scene in which the PCS is added
  144183. * @param options defines the options of the PCS e.g.
  144184. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  144185. */
  144186. constructor(name: string, pointSize: number, scene: Scene, options?: {
  144187. updatable?: boolean;
  144188. });
  144189. /**
  144190. * Builds the PCS underlying mesh. Returns a standard Mesh.
  144191. * If no points were added to the PCS, the returned mesh is just a single point.
  144192. * @returns a promise for the created mesh
  144193. */
  144194. buildMeshAsync(): Promise<Mesh>;
  144195. /**
  144196. * @hidden
  144197. */
  144198. private _buildMesh;
  144199. private _addParticle;
  144200. private _randomUnitVector;
  144201. private _getColorIndicesForCoord;
  144202. private _setPointsColorOrUV;
  144203. private _colorFromTexture;
  144204. private _calculateDensity;
  144205. /**
  144206. * Adds points to the PCS in random positions within a unit sphere
  144207. * @param nb (positive integer) the number of particles to be created from this model
  144208. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  144209. * @returns the number of groups in the system
  144210. */
  144211. addPoints(nb: number, pointFunction?: any): number;
  144212. /**
  144213. * Adds points to the PCS from the surface of the model shape
  144214. * @param mesh is any Mesh object that will be used as a surface model for the points
  144215. * @param nb (positive integer) the number of particles to be created from this model
  144216. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144217. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144218. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144219. * @returns the number of groups in the system
  144220. */
  144221. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144222. /**
  144223. * Adds points to the PCS inside the model shape
  144224. * @param mesh is any Mesh object that will be used as a surface model for the points
  144225. * @param nb (positive integer) the number of particles to be created from this model
  144226. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144227. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144228. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144229. * @returns the number of groups in the system
  144230. */
  144231. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144232. /**
  144233. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  144234. * This method calls `updateParticle()` for each particle of the SPS.
  144235. * For an animated SPS, it is usually called within the render loop.
  144236. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  144237. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  144238. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  144239. * @returns the PCS.
  144240. */
  144241. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  144242. /**
  144243. * Disposes the PCS.
  144244. */
  144245. dispose(): void;
  144246. /**
  144247. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  144248. * doc :
  144249. * @returns the PCS.
  144250. */
  144251. refreshVisibleSize(): PointsCloudSystem;
  144252. /**
  144253. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  144254. * @param size the size (float) of the visibility box
  144255. * note : this doesn't lock the PCS mesh bounding box.
  144256. * doc :
  144257. */
  144258. setVisibilityBox(size: number): void;
  144259. /**
  144260. * Gets whether the PCS is always visible or not
  144261. * doc :
  144262. */
  144263. get isAlwaysVisible(): boolean;
  144264. /**
  144265. * Sets the PCS as always visible or not
  144266. * doc :
  144267. */
  144268. set isAlwaysVisible(val: boolean);
  144269. /**
  144270. * Tells to `setParticles()` to compute the particle rotations or not
  144271. * Default value : false. The PCS is faster when it's set to false
  144272. * Note : particle rotations are only applied to parent particles
  144273. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  144274. */
  144275. set computeParticleRotation(val: boolean);
  144276. /**
  144277. * Tells to `setParticles()` to compute the particle colors or not.
  144278. * Default value : true. The PCS is faster when it's set to false.
  144279. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144280. */
  144281. set computeParticleColor(val: boolean);
  144282. set computeParticleTexture(val: boolean);
  144283. /**
  144284. * Gets if `setParticles()` computes the particle colors or not.
  144285. * Default value : false. The PCS is faster when it's set to false.
  144286. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144287. */
  144288. get computeParticleColor(): boolean;
  144289. /**
  144290. * Gets if `setParticles()` computes the particle textures or not.
  144291. * Default value : false. The PCS is faster when it's set to false.
  144292. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  144293. */
  144294. get computeParticleTexture(): boolean;
  144295. /**
  144296. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  144297. */
  144298. set computeBoundingBox(val: boolean);
  144299. /**
  144300. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  144301. */
  144302. get computeBoundingBox(): boolean;
  144303. /**
  144304. * This function does nothing. It may be overwritten to set all the particle first values.
  144305. * The PCS doesn't call this function, you may have to call it by your own.
  144306. * doc :
  144307. */
  144308. initParticles(): void;
  144309. /**
  144310. * This function does nothing. It may be overwritten to recycle a particle
  144311. * The PCS doesn't call this function, you can to call it
  144312. * doc :
  144313. * @param particle The particle to recycle
  144314. * @returns the recycled particle
  144315. */
  144316. recycleParticle(particle: CloudPoint): CloudPoint;
  144317. /**
  144318. * Updates a particle : this function should be overwritten by the user.
  144319. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  144320. * doc :
  144321. * @example : just set a particle position or velocity and recycle conditions
  144322. * @param particle The particle to update
  144323. * @returns the updated particle
  144324. */
  144325. updateParticle(particle: CloudPoint): CloudPoint;
  144326. /**
  144327. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  144328. * This does nothing and may be overwritten by the user.
  144329. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144330. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144331. * @param update the boolean update value actually passed to setParticles()
  144332. */
  144333. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144334. /**
  144335. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  144336. * This will be passed three parameters.
  144337. * This does nothing and may be overwritten by the user.
  144338. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144339. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144340. * @param update the boolean update value actually passed to setParticles()
  144341. */
  144342. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144343. }
  144344. }
  144345. declare module BABYLON {
  144346. /**
  144347. * Represents one particle of a points cloud system.
  144348. */
  144349. export class CloudPoint {
  144350. /**
  144351. * particle global index
  144352. */
  144353. idx: number;
  144354. /**
  144355. * The color of the particle
  144356. */
  144357. color: Nullable<Color4>;
  144358. /**
  144359. * The world space position of the particle.
  144360. */
  144361. position: Vector3;
  144362. /**
  144363. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  144364. */
  144365. rotation: Vector3;
  144366. /**
  144367. * The world space rotation quaternion of the particle.
  144368. */
  144369. rotationQuaternion: Nullable<Quaternion>;
  144370. /**
  144371. * The uv of the particle.
  144372. */
  144373. uv: Nullable<Vector2>;
  144374. /**
  144375. * The current speed of the particle.
  144376. */
  144377. velocity: Vector3;
  144378. /**
  144379. * The pivot point in the particle local space.
  144380. */
  144381. pivot: Vector3;
  144382. /**
  144383. * Must the particle be translated from its pivot point in its local space ?
  144384. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  144385. * Default : false
  144386. */
  144387. translateFromPivot: boolean;
  144388. /**
  144389. * Index of this particle in the global "positions" array (Internal use)
  144390. * @hidden
  144391. */
  144392. _pos: number;
  144393. /**
  144394. * @hidden Index of this particle in the global "indices" array (Internal use)
  144395. */
  144396. _ind: number;
  144397. /**
  144398. * Group this particle belongs to
  144399. */
  144400. _group: PointsGroup;
  144401. /**
  144402. * Group id of this particle
  144403. */
  144404. groupId: number;
  144405. /**
  144406. * Index of the particle in its group id (Internal use)
  144407. */
  144408. idxInGroup: number;
  144409. /**
  144410. * @hidden Particle BoundingInfo object (Internal use)
  144411. */
  144412. _boundingInfo: BoundingInfo;
  144413. /**
  144414. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  144415. */
  144416. _pcs: PointsCloudSystem;
  144417. /**
  144418. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  144419. */
  144420. _stillInvisible: boolean;
  144421. /**
  144422. * @hidden Last computed particle rotation matrix
  144423. */
  144424. _rotationMatrix: number[];
  144425. /**
  144426. * Parent particle Id, if any.
  144427. * Default null.
  144428. */
  144429. parentId: Nullable<number>;
  144430. /**
  144431. * @hidden Internal global position in the PCS.
  144432. */
  144433. _globalPosition: Vector3;
  144434. /**
  144435. * Creates a Point Cloud object.
  144436. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  144437. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  144438. * @param group (PointsGroup) is the group the particle belongs to
  144439. * @param groupId (integer) is the group identifier in the PCS.
  144440. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  144441. * @param pcs defines the PCS it is associated to
  144442. */
  144443. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  144444. /**
  144445. * get point size
  144446. */
  144447. get size(): Vector3;
  144448. /**
  144449. * Set point size
  144450. */
  144451. set size(scale: Vector3);
  144452. /**
  144453. * Legacy support, changed quaternion to rotationQuaternion
  144454. */
  144455. get quaternion(): Nullable<Quaternion>;
  144456. /**
  144457. * Legacy support, changed quaternion to rotationQuaternion
  144458. */
  144459. set quaternion(q: Nullable<Quaternion>);
  144460. /**
  144461. * Returns a boolean. True if the particle intersects a mesh, else false
  144462. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  144463. * @param target is the object (point or mesh) what the intersection is computed against
  144464. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  144465. * @returns true if it intersects
  144466. */
  144467. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  144468. /**
  144469. * get the rotation matrix of the particle
  144470. * @hidden
  144471. */
  144472. getRotationMatrix(m: Matrix): void;
  144473. }
  144474. /**
  144475. * Represents a group of points in a points cloud system
  144476. * * PCS internal tool, don't use it manually.
  144477. */
  144478. export class PointsGroup {
  144479. /**
  144480. * The group id
  144481. * @hidden
  144482. */
  144483. groupID: number;
  144484. /**
  144485. * image data for group (internal use)
  144486. * @hidden
  144487. */
  144488. _groupImageData: Nullable<ArrayBufferView>;
  144489. /**
  144490. * Image Width (internal use)
  144491. * @hidden
  144492. */
  144493. _groupImgWidth: number;
  144494. /**
  144495. * Image Height (internal use)
  144496. * @hidden
  144497. */
  144498. _groupImgHeight: number;
  144499. /**
  144500. * Custom position function (internal use)
  144501. * @hidden
  144502. */
  144503. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  144504. /**
  144505. * density per facet for surface points
  144506. * @hidden
  144507. */
  144508. _groupDensity: number[];
  144509. /**
  144510. * Only when points are colored by texture carries pointer to texture list array
  144511. * @hidden
  144512. */
  144513. _textureNb: number;
  144514. /**
  144515. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  144516. * PCS internal tool, don't use it manually.
  144517. * @hidden
  144518. */
  144519. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  144520. }
  144521. }
  144522. declare module BABYLON {
  144523. interface Scene {
  144524. /** @hidden (Backing field) */
  144525. _physicsEngine: Nullable<IPhysicsEngine>;
  144526. /** @hidden */
  144527. _physicsTimeAccumulator: number;
  144528. /**
  144529. * Gets the current physics engine
  144530. * @returns a IPhysicsEngine or null if none attached
  144531. */
  144532. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  144533. /**
  144534. * Enables physics to the current scene
  144535. * @param gravity defines the scene's gravity for the physics engine
  144536. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  144537. * @return a boolean indicating if the physics engine was initialized
  144538. */
  144539. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  144540. /**
  144541. * Disables and disposes the physics engine associated with the scene
  144542. */
  144543. disablePhysicsEngine(): void;
  144544. /**
  144545. * Gets a boolean indicating if there is an active physics engine
  144546. * @returns a boolean indicating if there is an active physics engine
  144547. */
  144548. isPhysicsEnabled(): boolean;
  144549. /**
  144550. * Deletes a physics compound impostor
  144551. * @param compound defines the compound to delete
  144552. */
  144553. deleteCompoundImpostor(compound: any): void;
  144554. /**
  144555. * An event triggered when physic simulation is about to be run
  144556. */
  144557. onBeforePhysicsObservable: Observable<Scene>;
  144558. /**
  144559. * An event triggered when physic simulation has been done
  144560. */
  144561. onAfterPhysicsObservable: Observable<Scene>;
  144562. }
  144563. interface AbstractMesh {
  144564. /** @hidden */
  144565. _physicsImpostor: Nullable<PhysicsImpostor>;
  144566. /**
  144567. * Gets or sets impostor used for physic simulation
  144568. * @see http://doc.babylonjs.com/features/physics_engine
  144569. */
  144570. physicsImpostor: Nullable<PhysicsImpostor>;
  144571. /**
  144572. * Gets the current physics impostor
  144573. * @see http://doc.babylonjs.com/features/physics_engine
  144574. * @returns a physics impostor or null
  144575. */
  144576. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  144577. /** Apply a physic impulse to the mesh
  144578. * @param force defines the force to apply
  144579. * @param contactPoint defines where to apply the force
  144580. * @returns the current mesh
  144581. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  144582. */
  144583. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  144584. /**
  144585. * Creates a physic joint between two meshes
  144586. * @param otherMesh defines the other mesh to use
  144587. * @param pivot1 defines the pivot to use on this mesh
  144588. * @param pivot2 defines the pivot to use on the other mesh
  144589. * @param options defines additional options (can be plugin dependent)
  144590. * @returns the current mesh
  144591. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  144592. */
  144593. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  144594. /** @hidden */
  144595. _disposePhysicsObserver: Nullable<Observer<Node>>;
  144596. }
  144597. /**
  144598. * Defines the physics engine scene component responsible to manage a physics engine
  144599. */
  144600. export class PhysicsEngineSceneComponent implements ISceneComponent {
  144601. /**
  144602. * The component name helpful to identify the component in the list of scene components.
  144603. */
  144604. readonly name: string;
  144605. /**
  144606. * The scene the component belongs to.
  144607. */
  144608. scene: Scene;
  144609. /**
  144610. * Creates a new instance of the component for the given scene
  144611. * @param scene Defines the scene to register the component in
  144612. */
  144613. constructor(scene: Scene);
  144614. /**
  144615. * Registers the component in a given scene
  144616. */
  144617. register(): void;
  144618. /**
  144619. * Rebuilds the elements related to this component in case of
  144620. * context lost for instance.
  144621. */
  144622. rebuild(): void;
  144623. /**
  144624. * Disposes the component and the associated ressources
  144625. */
  144626. dispose(): void;
  144627. }
  144628. }
  144629. declare module BABYLON {
  144630. /**
  144631. * A helper for physics simulations
  144632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144633. */
  144634. export class PhysicsHelper {
  144635. private _scene;
  144636. private _physicsEngine;
  144637. /**
  144638. * Initializes the Physics helper
  144639. * @param scene Babylon.js scene
  144640. */
  144641. constructor(scene: Scene);
  144642. /**
  144643. * Applies a radial explosion impulse
  144644. * @param origin the origin of the explosion
  144645. * @param radiusOrEventOptions the radius or the options of radial explosion
  144646. * @param strength the explosion strength
  144647. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144648. * @returns A physics radial explosion event, or null
  144649. */
  144650. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  144651. /**
  144652. * Applies a radial explosion force
  144653. * @param origin the origin of the explosion
  144654. * @param radiusOrEventOptions the radius or the options of radial explosion
  144655. * @param strength the explosion strength
  144656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144657. * @returns A physics radial explosion event, or null
  144658. */
  144659. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  144660. /**
  144661. * Creates a gravitational field
  144662. * @param origin the origin of the explosion
  144663. * @param radiusOrEventOptions the radius or the options of radial explosion
  144664. * @param strength the explosion strength
  144665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144666. * @returns A physics gravitational field event, or null
  144667. */
  144668. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  144669. /**
  144670. * Creates a physics updraft event
  144671. * @param origin the origin of the updraft
  144672. * @param radiusOrEventOptions the radius or the options of the updraft
  144673. * @param strength the strength of the updraft
  144674. * @param height the height of the updraft
  144675. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  144676. * @returns A physics updraft event, or null
  144677. */
  144678. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  144679. /**
  144680. * Creates a physics vortex event
  144681. * @param origin the of the vortex
  144682. * @param radiusOrEventOptions the radius or the options of the vortex
  144683. * @param strength the strength of the vortex
  144684. * @param height the height of the vortex
  144685. * @returns a Physics vortex event, or null
  144686. * A physics vortex event or null
  144687. */
  144688. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  144689. }
  144690. /**
  144691. * Represents a physics radial explosion event
  144692. */
  144693. class PhysicsRadialExplosionEvent {
  144694. private _scene;
  144695. private _options;
  144696. private _sphere;
  144697. private _dataFetched;
  144698. /**
  144699. * Initializes a radial explosioin event
  144700. * @param _scene BabylonJS scene
  144701. * @param _options The options for the vortex event
  144702. */
  144703. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  144704. /**
  144705. * Returns the data related to the radial explosion event (sphere).
  144706. * @returns The radial explosion event data
  144707. */
  144708. getData(): PhysicsRadialExplosionEventData;
  144709. /**
  144710. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  144711. * @param impostor A physics imposter
  144712. * @param origin the origin of the explosion
  144713. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  144714. */
  144715. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  144716. /**
  144717. * Triggers affecterd impostors callbacks
  144718. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  144719. */
  144720. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  144721. /**
  144722. * Disposes the sphere.
  144723. * @param force Specifies if the sphere should be disposed by force
  144724. */
  144725. dispose(force?: boolean): void;
  144726. /*** Helpers ***/
  144727. private _prepareSphere;
  144728. private _intersectsWithSphere;
  144729. }
  144730. /**
  144731. * Represents a gravitational field event
  144732. */
  144733. class PhysicsGravitationalFieldEvent {
  144734. private _physicsHelper;
  144735. private _scene;
  144736. private _origin;
  144737. private _options;
  144738. private _tickCallback;
  144739. private _sphere;
  144740. private _dataFetched;
  144741. /**
  144742. * Initializes the physics gravitational field event
  144743. * @param _physicsHelper A physics helper
  144744. * @param _scene BabylonJS scene
  144745. * @param _origin The origin position of the gravitational field event
  144746. * @param _options The options for the vortex event
  144747. */
  144748. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  144749. /**
  144750. * Returns the data related to the gravitational field event (sphere).
  144751. * @returns A gravitational field event
  144752. */
  144753. getData(): PhysicsGravitationalFieldEventData;
  144754. /**
  144755. * Enables the gravitational field.
  144756. */
  144757. enable(): void;
  144758. /**
  144759. * Disables the gravitational field.
  144760. */
  144761. disable(): void;
  144762. /**
  144763. * Disposes the sphere.
  144764. * @param force The force to dispose from the gravitational field event
  144765. */
  144766. dispose(force?: boolean): void;
  144767. private _tick;
  144768. }
  144769. /**
  144770. * Represents a physics updraft event
  144771. */
  144772. class PhysicsUpdraftEvent {
  144773. private _scene;
  144774. private _origin;
  144775. private _options;
  144776. private _physicsEngine;
  144777. private _originTop;
  144778. private _originDirection;
  144779. private _tickCallback;
  144780. private _cylinder;
  144781. private _cylinderPosition;
  144782. private _dataFetched;
  144783. /**
  144784. * Initializes the physics updraft event
  144785. * @param _scene BabylonJS scene
  144786. * @param _origin The origin position of the updraft
  144787. * @param _options The options for the updraft event
  144788. */
  144789. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  144790. /**
  144791. * Returns the data related to the updraft event (cylinder).
  144792. * @returns A physics updraft event
  144793. */
  144794. getData(): PhysicsUpdraftEventData;
  144795. /**
  144796. * Enables the updraft.
  144797. */
  144798. enable(): void;
  144799. /**
  144800. * Disables the updraft.
  144801. */
  144802. disable(): void;
  144803. /**
  144804. * Disposes the cylinder.
  144805. * @param force Specifies if the updraft should be disposed by force
  144806. */
  144807. dispose(force?: boolean): void;
  144808. private getImpostorHitData;
  144809. private _tick;
  144810. /*** Helpers ***/
  144811. private _prepareCylinder;
  144812. private _intersectsWithCylinder;
  144813. }
  144814. /**
  144815. * Represents a physics vortex event
  144816. */
  144817. class PhysicsVortexEvent {
  144818. private _scene;
  144819. private _origin;
  144820. private _options;
  144821. private _physicsEngine;
  144822. private _originTop;
  144823. private _tickCallback;
  144824. private _cylinder;
  144825. private _cylinderPosition;
  144826. private _dataFetched;
  144827. /**
  144828. * Initializes the physics vortex event
  144829. * @param _scene The BabylonJS scene
  144830. * @param _origin The origin position of the vortex
  144831. * @param _options The options for the vortex event
  144832. */
  144833. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  144834. /**
  144835. * Returns the data related to the vortex event (cylinder).
  144836. * @returns The physics vortex event data
  144837. */
  144838. getData(): PhysicsVortexEventData;
  144839. /**
  144840. * Enables the vortex.
  144841. */
  144842. enable(): void;
  144843. /**
  144844. * Disables the cortex.
  144845. */
  144846. disable(): void;
  144847. /**
  144848. * Disposes the sphere.
  144849. * @param force
  144850. */
  144851. dispose(force?: boolean): void;
  144852. private getImpostorHitData;
  144853. private _tick;
  144854. /*** Helpers ***/
  144855. private _prepareCylinder;
  144856. private _intersectsWithCylinder;
  144857. }
  144858. /**
  144859. * Options fot the radial explosion event
  144860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144861. */
  144862. export class PhysicsRadialExplosionEventOptions {
  144863. /**
  144864. * The radius of the sphere for the radial explosion.
  144865. */
  144866. radius: number;
  144867. /**
  144868. * The strenth of the explosion.
  144869. */
  144870. strength: number;
  144871. /**
  144872. * The strenght of the force in correspondence to the distance of the affected object
  144873. */
  144874. falloff: PhysicsRadialImpulseFalloff;
  144875. /**
  144876. * Sphere options for the radial explosion.
  144877. */
  144878. sphere: {
  144879. segments: number;
  144880. diameter: number;
  144881. };
  144882. /**
  144883. * Sphere options for the radial explosion.
  144884. */
  144885. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  144886. }
  144887. /**
  144888. * Options fot the updraft event
  144889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144890. */
  144891. export class PhysicsUpdraftEventOptions {
  144892. /**
  144893. * The radius of the cylinder for the vortex
  144894. */
  144895. radius: number;
  144896. /**
  144897. * The strenth of the updraft.
  144898. */
  144899. strength: number;
  144900. /**
  144901. * The height of the cylinder for the updraft.
  144902. */
  144903. height: number;
  144904. /**
  144905. * The mode for the the updraft.
  144906. */
  144907. updraftMode: PhysicsUpdraftMode;
  144908. }
  144909. /**
  144910. * Options fot the vortex event
  144911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144912. */
  144913. export class PhysicsVortexEventOptions {
  144914. /**
  144915. * The radius of the cylinder for the vortex
  144916. */
  144917. radius: number;
  144918. /**
  144919. * The strenth of the vortex.
  144920. */
  144921. strength: number;
  144922. /**
  144923. * The height of the cylinder for the vortex.
  144924. */
  144925. height: number;
  144926. /**
  144927. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  144928. */
  144929. centripetalForceThreshold: number;
  144930. /**
  144931. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  144932. */
  144933. centripetalForceMultiplier: number;
  144934. /**
  144935. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  144936. */
  144937. centrifugalForceMultiplier: number;
  144938. /**
  144939. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  144940. */
  144941. updraftForceMultiplier: number;
  144942. }
  144943. /**
  144944. * The strenght of the force in correspondence to the distance of the affected object
  144945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144946. */
  144947. export enum PhysicsRadialImpulseFalloff {
  144948. /** Defines that impulse is constant in strength across it's whole radius */
  144949. Constant = 0,
  144950. /** Defines that impulse gets weaker if it's further from the origin */
  144951. Linear = 1
  144952. }
  144953. /**
  144954. * The strength of the force in correspondence to the distance of the affected object
  144955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144956. */
  144957. export enum PhysicsUpdraftMode {
  144958. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  144959. Center = 0,
  144960. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  144961. Perpendicular = 1
  144962. }
  144963. /**
  144964. * Interface for a physics hit data
  144965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144966. */
  144967. export interface PhysicsHitData {
  144968. /**
  144969. * The force applied at the contact point
  144970. */
  144971. force: Vector3;
  144972. /**
  144973. * The contact point
  144974. */
  144975. contactPoint: Vector3;
  144976. /**
  144977. * The distance from the origin to the contact point
  144978. */
  144979. distanceFromOrigin: number;
  144980. }
  144981. /**
  144982. * Interface for radial explosion event data
  144983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144984. */
  144985. export interface PhysicsRadialExplosionEventData {
  144986. /**
  144987. * A sphere used for the radial explosion event
  144988. */
  144989. sphere: Mesh;
  144990. }
  144991. /**
  144992. * Interface for gravitational field event data
  144993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144994. */
  144995. export interface PhysicsGravitationalFieldEventData {
  144996. /**
  144997. * A sphere mesh used for the gravitational field event
  144998. */
  144999. sphere: Mesh;
  145000. }
  145001. /**
  145002. * Interface for updraft event data
  145003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145004. */
  145005. export interface PhysicsUpdraftEventData {
  145006. /**
  145007. * A cylinder used for the updraft event
  145008. */
  145009. cylinder: Mesh;
  145010. }
  145011. /**
  145012. * Interface for vortex event data
  145013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145014. */
  145015. export interface PhysicsVortexEventData {
  145016. /**
  145017. * A cylinder used for the vortex event
  145018. */
  145019. cylinder: Mesh;
  145020. }
  145021. /**
  145022. * Interface for an affected physics impostor
  145023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145024. */
  145025. export interface PhysicsAffectedImpostorWithData {
  145026. /**
  145027. * The impostor affected by the effect
  145028. */
  145029. impostor: PhysicsImpostor;
  145030. /**
  145031. * The data about the hit/horce from the explosion
  145032. */
  145033. hitData: PhysicsHitData;
  145034. }
  145035. }
  145036. declare module BABYLON {
  145037. /** @hidden */
  145038. export var blackAndWhitePixelShader: {
  145039. name: string;
  145040. shader: string;
  145041. };
  145042. }
  145043. declare module BABYLON {
  145044. /**
  145045. * Post process used to render in black and white
  145046. */
  145047. export class BlackAndWhitePostProcess extends PostProcess {
  145048. /**
  145049. * Linear about to convert he result to black and white (default: 1)
  145050. */
  145051. degree: number;
  145052. /**
  145053. * Creates a black and white post process
  145054. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  145055. * @param name The name of the effect.
  145056. * @param options The required width/height ratio to downsize to before computing the render pass.
  145057. * @param camera The camera to apply the render pass to.
  145058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145059. * @param engine The engine which the post process will be applied. (default: current engine)
  145060. * @param reusable If the post process can be reused on the same frame. (default: false)
  145061. */
  145062. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145063. }
  145064. }
  145065. declare module BABYLON {
  145066. /**
  145067. * This represents a set of one or more post processes in Babylon.
  145068. * A post process can be used to apply a shader to a texture after it is rendered.
  145069. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145070. */
  145071. export class PostProcessRenderEffect {
  145072. private _postProcesses;
  145073. private _getPostProcesses;
  145074. private _singleInstance;
  145075. private _cameras;
  145076. private _indicesForCamera;
  145077. /**
  145078. * Name of the effect
  145079. * @hidden
  145080. */
  145081. _name: string;
  145082. /**
  145083. * Instantiates a post process render effect.
  145084. * A post process can be used to apply a shader to a texture after it is rendered.
  145085. * @param engine The engine the effect is tied to
  145086. * @param name The name of the effect
  145087. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  145088. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  145089. */
  145090. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  145091. /**
  145092. * Checks if all the post processes in the effect are supported.
  145093. */
  145094. get isSupported(): boolean;
  145095. /**
  145096. * Updates the current state of the effect
  145097. * @hidden
  145098. */
  145099. _update(): void;
  145100. /**
  145101. * Attaches the effect on cameras
  145102. * @param cameras The camera to attach to.
  145103. * @hidden
  145104. */
  145105. _attachCameras(cameras: Camera): void;
  145106. /**
  145107. * Attaches the effect on cameras
  145108. * @param cameras The camera to attach to.
  145109. * @hidden
  145110. */
  145111. _attachCameras(cameras: Camera[]): void;
  145112. /**
  145113. * Detaches the effect on cameras
  145114. * @param cameras The camera to detatch from.
  145115. * @hidden
  145116. */
  145117. _detachCameras(cameras: Camera): void;
  145118. /**
  145119. * Detatches the effect on cameras
  145120. * @param cameras The camera to detatch from.
  145121. * @hidden
  145122. */
  145123. _detachCameras(cameras: Camera[]): void;
  145124. /**
  145125. * Enables the effect on given cameras
  145126. * @param cameras The camera to enable.
  145127. * @hidden
  145128. */
  145129. _enable(cameras: Camera): void;
  145130. /**
  145131. * Enables the effect on given cameras
  145132. * @param cameras The camera to enable.
  145133. * @hidden
  145134. */
  145135. _enable(cameras: Nullable<Camera[]>): void;
  145136. /**
  145137. * Disables the effect on the given cameras
  145138. * @param cameras The camera to disable.
  145139. * @hidden
  145140. */
  145141. _disable(cameras: Camera): void;
  145142. /**
  145143. * Disables the effect on the given cameras
  145144. * @param cameras The camera to disable.
  145145. * @hidden
  145146. */
  145147. _disable(cameras: Nullable<Camera[]>): void;
  145148. /**
  145149. * Gets a list of the post processes contained in the effect.
  145150. * @param camera The camera to get the post processes on.
  145151. * @returns The list of the post processes in the effect.
  145152. */
  145153. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  145154. }
  145155. }
  145156. declare module BABYLON {
  145157. /** @hidden */
  145158. export var extractHighlightsPixelShader: {
  145159. name: string;
  145160. shader: string;
  145161. };
  145162. }
  145163. declare module BABYLON {
  145164. /**
  145165. * 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.
  145166. */
  145167. export class ExtractHighlightsPostProcess extends PostProcess {
  145168. /**
  145169. * The luminance threshold, pixels below this value will be set to black.
  145170. */
  145171. threshold: number;
  145172. /** @hidden */
  145173. _exposure: number;
  145174. /**
  145175. * Post process which has the input texture to be used when performing highlight extraction
  145176. * @hidden
  145177. */
  145178. _inputPostProcess: Nullable<PostProcess>;
  145179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145180. }
  145181. }
  145182. declare module BABYLON {
  145183. /** @hidden */
  145184. export var bloomMergePixelShader: {
  145185. name: string;
  145186. shader: string;
  145187. };
  145188. }
  145189. declare module BABYLON {
  145190. /**
  145191. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145192. */
  145193. export class BloomMergePostProcess extends PostProcess {
  145194. /** Weight of the bloom to be added to the original input. */
  145195. weight: number;
  145196. /**
  145197. * Creates a new instance of @see BloomMergePostProcess
  145198. * @param name The name of the effect.
  145199. * @param originalFromInput Post process which's input will be used for the merge.
  145200. * @param blurred Blurred highlights post process which's output will be used.
  145201. * @param weight Weight of the bloom to be added to the original input.
  145202. * @param options The required width/height ratio to downsize to before computing the render pass.
  145203. * @param camera The camera to apply the render pass to.
  145204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145205. * @param engine The engine which the post process will be applied. (default: current engine)
  145206. * @param reusable If the post process can be reused on the same frame. (default: false)
  145207. * @param textureType Type of textures used when performing the post process. (default: 0)
  145208. * @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)
  145209. */
  145210. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  145211. /** Weight of the bloom to be added to the original input. */
  145212. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145213. }
  145214. }
  145215. declare module BABYLON {
  145216. /**
  145217. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  145218. */
  145219. export class BloomEffect extends PostProcessRenderEffect {
  145220. private bloomScale;
  145221. /**
  145222. * @hidden Internal
  145223. */
  145224. _effects: Array<PostProcess>;
  145225. /**
  145226. * @hidden Internal
  145227. */
  145228. _downscale: ExtractHighlightsPostProcess;
  145229. private _blurX;
  145230. private _blurY;
  145231. private _merge;
  145232. /**
  145233. * The luminance threshold to find bright areas of the image to bloom.
  145234. */
  145235. get threshold(): number;
  145236. set threshold(value: number);
  145237. /**
  145238. * The strength of the bloom.
  145239. */
  145240. get weight(): number;
  145241. set weight(value: number);
  145242. /**
  145243. * Specifies the size of the bloom blur kernel, relative to the final output size
  145244. */
  145245. get kernel(): number;
  145246. set kernel(value: number);
  145247. /**
  145248. * Creates a new instance of @see BloomEffect
  145249. * @param scene The scene the effect belongs to.
  145250. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  145251. * @param bloomKernel The size of the kernel to be used when applying the blur.
  145252. * @param bloomWeight The the strength of bloom.
  145253. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145254. * @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)
  145255. */
  145256. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  145257. /**
  145258. * Disposes each of the internal effects for a given camera.
  145259. * @param camera The camera to dispose the effect on.
  145260. */
  145261. disposeEffects(camera: Camera): void;
  145262. /**
  145263. * @hidden Internal
  145264. */
  145265. _updateEffects(): void;
  145266. /**
  145267. * Internal
  145268. * @returns if all the contained post processes are ready.
  145269. * @hidden
  145270. */
  145271. _isReady(): boolean;
  145272. }
  145273. }
  145274. declare module BABYLON {
  145275. /** @hidden */
  145276. export var chromaticAberrationPixelShader: {
  145277. name: string;
  145278. shader: string;
  145279. };
  145280. }
  145281. declare module BABYLON {
  145282. /**
  145283. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  145284. */
  145285. export class ChromaticAberrationPostProcess extends PostProcess {
  145286. /**
  145287. * The amount of seperation of rgb channels (default: 30)
  145288. */
  145289. aberrationAmount: number;
  145290. /**
  145291. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  145292. */
  145293. radialIntensity: number;
  145294. /**
  145295. * 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))
  145296. */
  145297. direction: Vector2;
  145298. /**
  145299. * 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))
  145300. */
  145301. centerPosition: Vector2;
  145302. /**
  145303. * Creates a new instance ChromaticAberrationPostProcess
  145304. * @param name The name of the effect.
  145305. * @param screenWidth The width of the screen to apply the effect on.
  145306. * @param screenHeight The height of the screen to apply the effect on.
  145307. * @param options The required width/height ratio to downsize to before computing the render pass.
  145308. * @param camera The camera to apply the render pass to.
  145309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145310. * @param engine The engine which the post process will be applied. (default: current engine)
  145311. * @param reusable If the post process can be reused on the same frame. (default: false)
  145312. * @param textureType Type of textures used when performing the post process. (default: 0)
  145313. * @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)
  145314. */
  145315. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145316. }
  145317. }
  145318. declare module BABYLON {
  145319. /** @hidden */
  145320. export var circleOfConfusionPixelShader: {
  145321. name: string;
  145322. shader: string;
  145323. };
  145324. }
  145325. declare module BABYLON {
  145326. /**
  145327. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  145328. */
  145329. export class CircleOfConfusionPostProcess extends PostProcess {
  145330. /**
  145331. * 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.
  145332. */
  145333. lensSize: number;
  145334. /**
  145335. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145336. */
  145337. fStop: number;
  145338. /**
  145339. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145340. */
  145341. focusDistance: number;
  145342. /**
  145343. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  145344. */
  145345. focalLength: number;
  145346. private _depthTexture;
  145347. /**
  145348. * Creates a new instance CircleOfConfusionPostProcess
  145349. * @param name The name of the effect.
  145350. * @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.
  145351. * @param options The required width/height ratio to downsize to before computing the render pass.
  145352. * @param camera The camera to apply the render pass to.
  145353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145354. * @param engine The engine which the post process will be applied. (default: current engine)
  145355. * @param reusable If the post process can be reused on the same frame. (default: false)
  145356. * @param textureType Type of textures used when performing the post process. (default: 0)
  145357. * @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)
  145358. */
  145359. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145360. /**
  145361. * 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.
  145362. */
  145363. set depthTexture(value: RenderTargetTexture);
  145364. }
  145365. }
  145366. declare module BABYLON {
  145367. /** @hidden */
  145368. export var colorCorrectionPixelShader: {
  145369. name: string;
  145370. shader: string;
  145371. };
  145372. }
  145373. declare module BABYLON {
  145374. /**
  145375. *
  145376. * This post-process allows the modification of rendered colors by using
  145377. * a 'look-up table' (LUT). This effect is also called Color Grading.
  145378. *
  145379. * The object needs to be provided an url to a texture containing the color
  145380. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  145381. * Use an image editing software to tweak the LUT to match your needs.
  145382. *
  145383. * For an example of a color LUT, see here:
  145384. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  145385. * For explanations on color grading, see here:
  145386. * @see http://udn.epicgames.com/Three/ColorGrading.html
  145387. *
  145388. */
  145389. export class ColorCorrectionPostProcess extends PostProcess {
  145390. private _colorTableTexture;
  145391. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145392. }
  145393. }
  145394. declare module BABYLON {
  145395. /** @hidden */
  145396. export var convolutionPixelShader: {
  145397. name: string;
  145398. shader: string;
  145399. };
  145400. }
  145401. declare module BABYLON {
  145402. /**
  145403. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  145404. * input texture to perform effects such as edge detection or sharpening
  145405. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145406. */
  145407. export class ConvolutionPostProcess extends PostProcess {
  145408. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145409. kernel: number[];
  145410. /**
  145411. * Creates a new instance ConvolutionPostProcess
  145412. * @param name The name of the effect.
  145413. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  145414. * @param options The required width/height ratio to downsize to before computing the render pass.
  145415. * @param camera The camera to apply the render pass to.
  145416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145417. * @param engine The engine which the post process will be applied. (default: current engine)
  145418. * @param reusable If the post process can be reused on the same frame. (default: false)
  145419. * @param textureType Type of textures used when performing the post process. (default: 0)
  145420. */
  145421. constructor(name: string,
  145422. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145423. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145424. /**
  145425. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145426. */
  145427. static EdgeDetect0Kernel: number[];
  145428. /**
  145429. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145430. */
  145431. static EdgeDetect1Kernel: number[];
  145432. /**
  145433. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145434. */
  145435. static EdgeDetect2Kernel: number[];
  145436. /**
  145437. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145438. */
  145439. static SharpenKernel: number[];
  145440. /**
  145441. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145442. */
  145443. static EmbossKernel: number[];
  145444. /**
  145445. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145446. */
  145447. static GaussianKernel: number[];
  145448. }
  145449. }
  145450. declare module BABYLON {
  145451. /**
  145452. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  145453. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  145454. * based on samples that have a large difference in distance than the center pixel.
  145455. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  145456. */
  145457. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  145458. direction: Vector2;
  145459. /**
  145460. * Creates a new instance CircleOfConfusionPostProcess
  145461. * @param name The name of the effect.
  145462. * @param scene The scene the effect belongs to.
  145463. * @param direction The direction the blur should be applied.
  145464. * @param kernel The size of the kernel used to blur.
  145465. * @param options The required width/height ratio to downsize to before computing the render pass.
  145466. * @param camera The camera to apply the render pass to.
  145467. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  145468. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  145469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145470. * @param engine The engine which the post process will be applied. (default: current engine)
  145471. * @param reusable If the post process can be reused on the same frame. (default: false)
  145472. * @param textureType Type of textures used when performing the post process. (default: 0)
  145473. * @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)
  145474. */
  145475. 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);
  145476. }
  145477. }
  145478. declare module BABYLON {
  145479. /** @hidden */
  145480. export var depthOfFieldMergePixelShader: {
  145481. name: string;
  145482. shader: string;
  145483. };
  145484. }
  145485. declare module BABYLON {
  145486. /**
  145487. * Options to be set when merging outputs from the default pipeline.
  145488. */
  145489. export class DepthOfFieldMergePostProcessOptions {
  145490. /**
  145491. * The original image to merge on top of
  145492. */
  145493. originalFromInput: PostProcess;
  145494. /**
  145495. * Parameters to perform the merge of the depth of field effect
  145496. */
  145497. depthOfField?: {
  145498. circleOfConfusion: PostProcess;
  145499. blurSteps: Array<PostProcess>;
  145500. };
  145501. /**
  145502. * Parameters to perform the merge of bloom effect
  145503. */
  145504. bloom?: {
  145505. blurred: PostProcess;
  145506. weight: number;
  145507. };
  145508. }
  145509. /**
  145510. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145511. */
  145512. export class DepthOfFieldMergePostProcess extends PostProcess {
  145513. private blurSteps;
  145514. /**
  145515. * Creates a new instance of DepthOfFieldMergePostProcess
  145516. * @param name The name of the effect.
  145517. * @param originalFromInput Post process which's input will be used for the merge.
  145518. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  145519. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  145520. * @param options The required width/height ratio to downsize to before computing the render pass.
  145521. * @param camera The camera to apply the render pass to.
  145522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145523. * @param engine The engine which the post process will be applied. (default: current engine)
  145524. * @param reusable If the post process can be reused on the same frame. (default: false)
  145525. * @param textureType Type of textures used when performing the post process. (default: 0)
  145526. * @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)
  145527. */
  145528. 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);
  145529. /**
  145530. * Updates the effect with the current post process compile time values and recompiles the shader.
  145531. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  145532. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  145533. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  145534. * @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
  145535. * @param onCompiled Called when the shader has been compiled.
  145536. * @param onError Called if there is an error when compiling a shader.
  145537. */
  145538. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  145539. }
  145540. }
  145541. declare module BABYLON {
  145542. /**
  145543. * Specifies the level of max blur that should be applied when using the depth of field effect
  145544. */
  145545. export enum DepthOfFieldEffectBlurLevel {
  145546. /**
  145547. * Subtle blur
  145548. */
  145549. Low = 0,
  145550. /**
  145551. * Medium blur
  145552. */
  145553. Medium = 1,
  145554. /**
  145555. * Large blur
  145556. */
  145557. High = 2
  145558. }
  145559. /**
  145560. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  145561. */
  145562. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  145563. private _circleOfConfusion;
  145564. /**
  145565. * @hidden Internal, blurs from high to low
  145566. */
  145567. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  145568. private _depthOfFieldBlurY;
  145569. private _dofMerge;
  145570. /**
  145571. * @hidden Internal post processes in depth of field effect
  145572. */
  145573. _effects: Array<PostProcess>;
  145574. /**
  145575. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  145576. */
  145577. set focalLength(value: number);
  145578. get focalLength(): number;
  145579. /**
  145580. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145581. */
  145582. set fStop(value: number);
  145583. get fStop(): number;
  145584. /**
  145585. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145586. */
  145587. set focusDistance(value: number);
  145588. get focusDistance(): number;
  145589. /**
  145590. * 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.
  145591. */
  145592. set lensSize(value: number);
  145593. get lensSize(): number;
  145594. /**
  145595. * Creates a new instance DepthOfFieldEffect
  145596. * @param scene The scene the effect belongs to.
  145597. * @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.
  145598. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145599. * @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)
  145600. */
  145601. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  145602. /**
  145603. * Get the current class name of the current effet
  145604. * @returns "DepthOfFieldEffect"
  145605. */
  145606. getClassName(): string;
  145607. /**
  145608. * 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.
  145609. */
  145610. set depthTexture(value: RenderTargetTexture);
  145611. /**
  145612. * Disposes each of the internal effects for a given camera.
  145613. * @param camera The camera to dispose the effect on.
  145614. */
  145615. disposeEffects(camera: Camera): void;
  145616. /**
  145617. * @hidden Internal
  145618. */
  145619. _updateEffects(): void;
  145620. /**
  145621. * Internal
  145622. * @returns if all the contained post processes are ready.
  145623. * @hidden
  145624. */
  145625. _isReady(): boolean;
  145626. }
  145627. }
  145628. declare module BABYLON {
  145629. /** @hidden */
  145630. export var displayPassPixelShader: {
  145631. name: string;
  145632. shader: string;
  145633. };
  145634. }
  145635. declare module BABYLON {
  145636. /**
  145637. * DisplayPassPostProcess which produces an output the same as it's input
  145638. */
  145639. export class DisplayPassPostProcess extends PostProcess {
  145640. /**
  145641. * Creates the DisplayPassPostProcess
  145642. * @param name The name of the effect.
  145643. * @param options The required width/height ratio to downsize to before computing the render pass.
  145644. * @param camera The camera to apply the render pass to.
  145645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145646. * @param engine The engine which the post process will be applied. (default: current engine)
  145647. * @param reusable If the post process can be reused on the same frame. (default: false)
  145648. */
  145649. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145650. }
  145651. }
  145652. declare module BABYLON {
  145653. /** @hidden */
  145654. export var filterPixelShader: {
  145655. name: string;
  145656. shader: string;
  145657. };
  145658. }
  145659. declare module BABYLON {
  145660. /**
  145661. * Applies a kernel filter to the image
  145662. */
  145663. export class FilterPostProcess extends PostProcess {
  145664. /** The matrix to be applied to the image */
  145665. kernelMatrix: Matrix;
  145666. /**
  145667. *
  145668. * @param name The name of the effect.
  145669. * @param kernelMatrix The matrix to be applied to the image
  145670. * @param options The required width/height ratio to downsize to before computing the render pass.
  145671. * @param camera The camera to apply the render pass to.
  145672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145673. * @param engine The engine which the post process will be applied. (default: current engine)
  145674. * @param reusable If the post process can be reused on the same frame. (default: false)
  145675. */
  145676. constructor(name: string,
  145677. /** The matrix to be applied to the image */
  145678. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145679. }
  145680. }
  145681. declare module BABYLON {
  145682. /** @hidden */
  145683. export var fxaaPixelShader: {
  145684. name: string;
  145685. shader: string;
  145686. };
  145687. }
  145688. declare module BABYLON {
  145689. /** @hidden */
  145690. export var fxaaVertexShader: {
  145691. name: string;
  145692. shader: string;
  145693. };
  145694. }
  145695. declare module BABYLON {
  145696. /**
  145697. * Fxaa post process
  145698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  145699. */
  145700. export class FxaaPostProcess extends PostProcess {
  145701. /** @hidden */
  145702. texelWidth: number;
  145703. /** @hidden */
  145704. texelHeight: number;
  145705. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145706. private _getDefines;
  145707. }
  145708. }
  145709. declare module BABYLON {
  145710. /** @hidden */
  145711. export var grainPixelShader: {
  145712. name: string;
  145713. shader: string;
  145714. };
  145715. }
  145716. declare module BABYLON {
  145717. /**
  145718. * The GrainPostProcess adds noise to the image at mid luminance levels
  145719. */
  145720. export class GrainPostProcess extends PostProcess {
  145721. /**
  145722. * The intensity of the grain added (default: 30)
  145723. */
  145724. intensity: number;
  145725. /**
  145726. * If the grain should be randomized on every frame
  145727. */
  145728. animated: boolean;
  145729. /**
  145730. * Creates a new instance of @see GrainPostProcess
  145731. * @param name The name of the effect.
  145732. * @param options The required width/height ratio to downsize to before computing the render pass.
  145733. * @param camera The camera to apply the render pass to.
  145734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145735. * @param engine The engine which the post process will be applied. (default: current engine)
  145736. * @param reusable If the post process can be reused on the same frame. (default: false)
  145737. * @param textureType Type of textures used when performing the post process. (default: 0)
  145738. * @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)
  145739. */
  145740. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145741. }
  145742. }
  145743. declare module BABYLON {
  145744. /** @hidden */
  145745. export var highlightsPixelShader: {
  145746. name: string;
  145747. shader: string;
  145748. };
  145749. }
  145750. declare module BABYLON {
  145751. /**
  145752. * Extracts highlights from the image
  145753. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145754. */
  145755. export class HighlightsPostProcess extends PostProcess {
  145756. /**
  145757. * Extracts highlights from the image
  145758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  145759. * @param name The name of the effect.
  145760. * @param options The required width/height ratio to downsize to before computing the render pass.
  145761. * @param camera The camera to apply the render pass to.
  145762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145763. * @param engine The engine which the post process will be applied. (default: current engine)
  145764. * @param reusable If the post process can be reused on the same frame. (default: false)
  145765. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  145766. */
  145767. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145768. }
  145769. }
  145770. declare module BABYLON {
  145771. /** @hidden */
  145772. export var mrtFragmentDeclaration: {
  145773. name: string;
  145774. shader: string;
  145775. };
  145776. }
  145777. declare module BABYLON {
  145778. /** @hidden */
  145779. export var geometryPixelShader: {
  145780. name: string;
  145781. shader: string;
  145782. };
  145783. }
  145784. declare module BABYLON {
  145785. /** @hidden */
  145786. export var geometryVertexShader: {
  145787. name: string;
  145788. shader: string;
  145789. };
  145790. }
  145791. declare module BABYLON {
  145792. /** @hidden */
  145793. interface ISavedTransformationMatrix {
  145794. world: Matrix;
  145795. viewProjection: Matrix;
  145796. }
  145797. /**
  145798. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  145799. */
  145800. export class GeometryBufferRenderer {
  145801. /**
  145802. * Constant used to retrieve the position texture index in the G-Buffer textures array
  145803. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  145804. */
  145805. static readonly POSITION_TEXTURE_TYPE: number;
  145806. /**
  145807. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  145808. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  145809. */
  145810. static readonly VELOCITY_TEXTURE_TYPE: number;
  145811. /**
  145812. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  145813. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  145814. */
  145815. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  145816. /**
  145817. * Dictionary used to store the previous transformation matrices of each rendered mesh
  145818. * in order to compute objects velocities when enableVelocity is set to "true"
  145819. * @hidden
  145820. */
  145821. _previousTransformationMatrices: {
  145822. [index: number]: ISavedTransformationMatrix;
  145823. };
  145824. /**
  145825. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  145826. * in order to compute objects velocities when enableVelocity is set to "true"
  145827. * @hidden
  145828. */
  145829. _previousBonesTransformationMatrices: {
  145830. [index: number]: Float32Array;
  145831. };
  145832. /**
  145833. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  145834. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  145835. */
  145836. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  145837. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  145838. renderTransparentMeshes: boolean;
  145839. private _scene;
  145840. private _multiRenderTarget;
  145841. private _ratio;
  145842. private _enablePosition;
  145843. private _enableVelocity;
  145844. private _enableReflectivity;
  145845. private _positionIndex;
  145846. private _velocityIndex;
  145847. private _reflectivityIndex;
  145848. protected _effect: Effect;
  145849. protected _cachedDefines: string;
  145850. /**
  145851. * Set the render list (meshes to be rendered) used in the G buffer.
  145852. */
  145853. set renderList(meshes: Mesh[]);
  145854. /**
  145855. * Gets wether or not G buffer are supported by the running hardware.
  145856. * This requires draw buffer supports
  145857. */
  145858. get isSupported(): boolean;
  145859. /**
  145860. * Returns the index of the given texture type in the G-Buffer textures array
  145861. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  145862. * @returns the index of the given texture type in the G-Buffer textures array
  145863. */
  145864. getTextureIndex(textureType: number): number;
  145865. /**
  145866. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  145867. */
  145868. get enablePosition(): boolean;
  145869. /**
  145870. * Sets whether or not objects positions are enabled for the G buffer.
  145871. */
  145872. set enablePosition(enable: boolean);
  145873. /**
  145874. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  145875. */
  145876. get enableVelocity(): boolean;
  145877. /**
  145878. * Sets wether or not objects velocities are enabled for the G buffer.
  145879. */
  145880. set enableVelocity(enable: boolean);
  145881. /**
  145882. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  145883. */
  145884. get enableReflectivity(): boolean;
  145885. /**
  145886. * Sets wether or not objects roughness are enabled for the G buffer.
  145887. */
  145888. set enableReflectivity(enable: boolean);
  145889. /**
  145890. * Gets the scene associated with the buffer.
  145891. */
  145892. get scene(): Scene;
  145893. /**
  145894. * Gets the ratio used by the buffer during its creation.
  145895. * How big is the buffer related to the main canvas.
  145896. */
  145897. get ratio(): number;
  145898. /** @hidden */
  145899. static _SceneComponentInitialization: (scene: Scene) => void;
  145900. /**
  145901. * Creates a new G Buffer for the scene
  145902. * @param scene The scene the buffer belongs to
  145903. * @param ratio How big is the buffer related to the main canvas.
  145904. */
  145905. constructor(scene: Scene, ratio?: number);
  145906. /**
  145907. * Checks wether everything is ready to render a submesh to the G buffer.
  145908. * @param subMesh the submesh to check readiness for
  145909. * @param useInstances is the mesh drawn using instance or not
  145910. * @returns true if ready otherwise false
  145911. */
  145912. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  145913. /**
  145914. * Gets the current underlying G Buffer.
  145915. * @returns the buffer
  145916. */
  145917. getGBuffer(): MultiRenderTarget;
  145918. /**
  145919. * Gets the number of samples used to render the buffer (anti aliasing).
  145920. */
  145921. get samples(): number;
  145922. /**
  145923. * Sets the number of samples used to render the buffer (anti aliasing).
  145924. */
  145925. set samples(value: number);
  145926. /**
  145927. * Disposes the renderer and frees up associated resources.
  145928. */
  145929. dispose(): void;
  145930. protected _createRenderTargets(): void;
  145931. private _copyBonesTransformationMatrices;
  145932. }
  145933. }
  145934. declare module BABYLON {
  145935. interface Scene {
  145936. /** @hidden (Backing field) */
  145937. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145938. /**
  145939. * Gets or Sets the current geometry buffer associated to the scene.
  145940. */
  145941. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  145942. /**
  145943. * Enables a GeometryBufferRender and associates it with the scene
  145944. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  145945. * @returns the GeometryBufferRenderer
  145946. */
  145947. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  145948. /**
  145949. * Disables the GeometryBufferRender associated with the scene
  145950. */
  145951. disableGeometryBufferRenderer(): void;
  145952. }
  145953. /**
  145954. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  145955. * in several rendering techniques.
  145956. */
  145957. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  145958. /**
  145959. * The component name helpful to identify the component in the list of scene components.
  145960. */
  145961. readonly name: string;
  145962. /**
  145963. * The scene the component belongs to.
  145964. */
  145965. scene: Scene;
  145966. /**
  145967. * Creates a new instance of the component for the given scene
  145968. * @param scene Defines the scene to register the component in
  145969. */
  145970. constructor(scene: Scene);
  145971. /**
  145972. * Registers the component in a given scene
  145973. */
  145974. register(): void;
  145975. /**
  145976. * Rebuilds the elements related to this component in case of
  145977. * context lost for instance.
  145978. */
  145979. rebuild(): void;
  145980. /**
  145981. * Disposes the component and the associated ressources
  145982. */
  145983. dispose(): void;
  145984. private _gatherRenderTargets;
  145985. }
  145986. }
  145987. declare module BABYLON {
  145988. /** @hidden */
  145989. export var motionBlurPixelShader: {
  145990. name: string;
  145991. shader: string;
  145992. };
  145993. }
  145994. declare module BABYLON {
  145995. /**
  145996. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  145997. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  145998. * As an example, all you have to do is to create the post-process:
  145999. * var mb = new BABYLON.MotionBlurPostProcess(
  146000. * 'mb', // The name of the effect.
  146001. * scene, // The scene containing the objects to blur according to their velocity.
  146002. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  146003. * camera // The camera to apply the render pass to.
  146004. * );
  146005. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  146006. */
  146007. export class MotionBlurPostProcess extends PostProcess {
  146008. /**
  146009. * Defines how much the image is blurred by the movement. Default value is equal to 1
  146010. */
  146011. motionStrength: number;
  146012. /**
  146013. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  146014. */
  146015. get motionBlurSamples(): number;
  146016. /**
  146017. * Sets the number of iterations to be used for motion blur quality
  146018. */
  146019. set motionBlurSamples(samples: number);
  146020. private _motionBlurSamples;
  146021. private _geometryBufferRenderer;
  146022. /**
  146023. * Creates a new instance MotionBlurPostProcess
  146024. * @param name The name of the effect.
  146025. * @param scene The scene containing the objects to blur according to their velocity.
  146026. * @param options The required width/height ratio to downsize to before computing the render pass.
  146027. * @param camera The camera to apply the render pass to.
  146028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146029. * @param engine The engine which the post process will be applied. (default: current engine)
  146030. * @param reusable If the post process can be reused on the same frame. (default: false)
  146031. * @param textureType Type of textures used when performing the post process. (default: 0)
  146032. * @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)
  146033. */
  146034. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146035. /**
  146036. * Excludes the given skinned mesh from computing bones velocities.
  146037. * 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.
  146038. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  146039. */
  146040. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146041. /**
  146042. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  146043. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  146044. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  146045. */
  146046. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146047. /**
  146048. * Disposes the post process.
  146049. * @param camera The camera to dispose the post process on.
  146050. */
  146051. dispose(camera?: Camera): void;
  146052. }
  146053. }
  146054. declare module BABYLON {
  146055. /** @hidden */
  146056. export var refractionPixelShader: {
  146057. name: string;
  146058. shader: string;
  146059. };
  146060. }
  146061. declare module BABYLON {
  146062. /**
  146063. * Post process which applies a refractin texture
  146064. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146065. */
  146066. export class RefractionPostProcess extends PostProcess {
  146067. /** the base color of the refraction (used to taint the rendering) */
  146068. color: Color3;
  146069. /** simulated refraction depth */
  146070. depth: number;
  146071. /** the coefficient of the base color (0 to remove base color tainting) */
  146072. colorLevel: number;
  146073. private _refTexture;
  146074. private _ownRefractionTexture;
  146075. /**
  146076. * Gets or sets the refraction texture
  146077. * Please note that you are responsible for disposing the texture if you set it manually
  146078. */
  146079. get refractionTexture(): Texture;
  146080. set refractionTexture(value: Texture);
  146081. /**
  146082. * Initializes the RefractionPostProcess
  146083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146084. * @param name The name of the effect.
  146085. * @param refractionTextureUrl Url of the refraction texture to use
  146086. * @param color the base color of the refraction (used to taint the rendering)
  146087. * @param depth simulated refraction depth
  146088. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  146089. * @param camera The camera to apply the render pass to.
  146090. * @param options The required width/height ratio to downsize to before computing the render pass.
  146091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146092. * @param engine The engine which the post process will be applied. (default: current engine)
  146093. * @param reusable If the post process can be reused on the same frame. (default: false)
  146094. */
  146095. constructor(name: string, refractionTextureUrl: string,
  146096. /** the base color of the refraction (used to taint the rendering) */
  146097. color: Color3,
  146098. /** simulated refraction depth */
  146099. depth: number,
  146100. /** the coefficient of the base color (0 to remove base color tainting) */
  146101. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146102. /**
  146103. * Disposes of the post process
  146104. * @param camera Camera to dispose post process on
  146105. */
  146106. dispose(camera: Camera): void;
  146107. }
  146108. }
  146109. declare module BABYLON {
  146110. /** @hidden */
  146111. export var sharpenPixelShader: {
  146112. name: string;
  146113. shader: string;
  146114. };
  146115. }
  146116. declare module BABYLON {
  146117. /**
  146118. * The SharpenPostProcess applies a sharpen kernel to every pixel
  146119. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146120. */
  146121. export class SharpenPostProcess extends PostProcess {
  146122. /**
  146123. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  146124. */
  146125. colorAmount: number;
  146126. /**
  146127. * How much sharpness should be applied (default: 0.3)
  146128. */
  146129. edgeAmount: number;
  146130. /**
  146131. * Creates a new instance ConvolutionPostProcess
  146132. * @param name The name of the effect.
  146133. * @param options The required width/height ratio to downsize to before computing the render pass.
  146134. * @param camera The camera to apply the render pass to.
  146135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146136. * @param engine The engine which the post process will be applied. (default: current engine)
  146137. * @param reusable If the post process can be reused on the same frame. (default: false)
  146138. * @param textureType Type of textures used when performing the post process. (default: 0)
  146139. * @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)
  146140. */
  146141. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146142. }
  146143. }
  146144. declare module BABYLON {
  146145. /**
  146146. * PostProcessRenderPipeline
  146147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146148. */
  146149. export class PostProcessRenderPipeline {
  146150. private engine;
  146151. private _renderEffects;
  146152. private _renderEffectsForIsolatedPass;
  146153. /**
  146154. * List of inspectable custom properties (used by the Inspector)
  146155. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  146156. */
  146157. inspectableCustomProperties: IInspectable[];
  146158. /**
  146159. * @hidden
  146160. */
  146161. protected _cameras: Camera[];
  146162. /** @hidden */
  146163. _name: string;
  146164. /**
  146165. * Gets pipeline name
  146166. */
  146167. get name(): string;
  146168. /** Gets the list of attached cameras */
  146169. get cameras(): Camera[];
  146170. /**
  146171. * Initializes a PostProcessRenderPipeline
  146172. * @param engine engine to add the pipeline to
  146173. * @param name name of the pipeline
  146174. */
  146175. constructor(engine: Engine, name: string);
  146176. /**
  146177. * Gets the class name
  146178. * @returns "PostProcessRenderPipeline"
  146179. */
  146180. getClassName(): string;
  146181. /**
  146182. * If all the render effects in the pipeline are supported
  146183. */
  146184. get isSupported(): boolean;
  146185. /**
  146186. * Adds an effect to the pipeline
  146187. * @param renderEffect the effect to add
  146188. */
  146189. addEffect(renderEffect: PostProcessRenderEffect): void;
  146190. /** @hidden */
  146191. _rebuild(): void;
  146192. /** @hidden */
  146193. _enableEffect(renderEffectName: string, cameras: Camera): void;
  146194. /** @hidden */
  146195. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  146196. /** @hidden */
  146197. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146198. /** @hidden */
  146199. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146200. /** @hidden */
  146201. _attachCameras(cameras: Camera, unique: boolean): void;
  146202. /** @hidden */
  146203. _attachCameras(cameras: Camera[], unique: boolean): void;
  146204. /** @hidden */
  146205. _detachCameras(cameras: Camera): void;
  146206. /** @hidden */
  146207. _detachCameras(cameras: Nullable<Camera[]>): void;
  146208. /** @hidden */
  146209. _update(): void;
  146210. /** @hidden */
  146211. _reset(): void;
  146212. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  146213. /**
  146214. * Disposes of the pipeline
  146215. */
  146216. dispose(): void;
  146217. }
  146218. }
  146219. declare module BABYLON {
  146220. /**
  146221. * PostProcessRenderPipelineManager class
  146222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146223. */
  146224. export class PostProcessRenderPipelineManager {
  146225. private _renderPipelines;
  146226. /**
  146227. * Initializes a PostProcessRenderPipelineManager
  146228. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146229. */
  146230. constructor();
  146231. /**
  146232. * Gets the list of supported render pipelines
  146233. */
  146234. get supportedPipelines(): PostProcessRenderPipeline[];
  146235. /**
  146236. * Adds a pipeline to the manager
  146237. * @param renderPipeline The pipeline to add
  146238. */
  146239. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  146240. /**
  146241. * Attaches a camera to the pipeline
  146242. * @param renderPipelineName The name of the pipeline to attach to
  146243. * @param cameras the camera to attach
  146244. * @param unique if the camera can be attached multiple times to the pipeline
  146245. */
  146246. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  146247. /**
  146248. * Detaches a camera from the pipeline
  146249. * @param renderPipelineName The name of the pipeline to detach from
  146250. * @param cameras the camera to detach
  146251. */
  146252. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  146253. /**
  146254. * Enables an effect by name on a pipeline
  146255. * @param renderPipelineName the name of the pipeline to enable the effect in
  146256. * @param renderEffectName the name of the effect to enable
  146257. * @param cameras the cameras that the effect should be enabled on
  146258. */
  146259. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146260. /**
  146261. * Disables an effect by name on a pipeline
  146262. * @param renderPipelineName the name of the pipeline to disable the effect in
  146263. * @param renderEffectName the name of the effect to disable
  146264. * @param cameras the cameras that the effect should be disabled on
  146265. */
  146266. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146267. /**
  146268. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  146269. */
  146270. update(): void;
  146271. /** @hidden */
  146272. _rebuild(): void;
  146273. /**
  146274. * Disposes of the manager and pipelines
  146275. */
  146276. dispose(): void;
  146277. }
  146278. }
  146279. declare module BABYLON {
  146280. interface Scene {
  146281. /** @hidden (Backing field) */
  146282. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146283. /**
  146284. * Gets the postprocess render pipeline manager
  146285. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146286. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146287. */
  146288. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146289. }
  146290. /**
  146291. * Defines the Render Pipeline scene component responsible to rendering pipelines
  146292. */
  146293. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  146294. /**
  146295. * The component name helpfull to identify the component in the list of scene components.
  146296. */
  146297. readonly name: string;
  146298. /**
  146299. * The scene the component belongs to.
  146300. */
  146301. scene: Scene;
  146302. /**
  146303. * Creates a new instance of the component for the given scene
  146304. * @param scene Defines the scene to register the component in
  146305. */
  146306. constructor(scene: Scene);
  146307. /**
  146308. * Registers the component in a given scene
  146309. */
  146310. register(): void;
  146311. /**
  146312. * Rebuilds the elements related to this component in case of
  146313. * context lost for instance.
  146314. */
  146315. rebuild(): void;
  146316. /**
  146317. * Disposes the component and the associated ressources
  146318. */
  146319. dispose(): void;
  146320. private _gatherRenderTargets;
  146321. }
  146322. }
  146323. declare module BABYLON {
  146324. /**
  146325. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  146326. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146327. */
  146328. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146329. private _scene;
  146330. private _camerasToBeAttached;
  146331. /**
  146332. * ID of the sharpen post process,
  146333. */
  146334. private readonly SharpenPostProcessId;
  146335. /**
  146336. * @ignore
  146337. * ID of the image processing post process;
  146338. */
  146339. readonly ImageProcessingPostProcessId: string;
  146340. /**
  146341. * @ignore
  146342. * ID of the Fast Approximate Anti-Aliasing post process;
  146343. */
  146344. readonly FxaaPostProcessId: string;
  146345. /**
  146346. * ID of the chromatic aberration post process,
  146347. */
  146348. private readonly ChromaticAberrationPostProcessId;
  146349. /**
  146350. * ID of the grain post process
  146351. */
  146352. private readonly GrainPostProcessId;
  146353. /**
  146354. * Sharpen post process which will apply a sharpen convolution to enhance edges
  146355. */
  146356. sharpen: SharpenPostProcess;
  146357. private _sharpenEffect;
  146358. private bloom;
  146359. /**
  146360. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  146361. */
  146362. depthOfField: DepthOfFieldEffect;
  146363. /**
  146364. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146365. */
  146366. fxaa: FxaaPostProcess;
  146367. /**
  146368. * Image post processing pass used to perform operations such as tone mapping or color grading.
  146369. */
  146370. imageProcessing: ImageProcessingPostProcess;
  146371. /**
  146372. * Chromatic aberration post process which will shift rgb colors in the image
  146373. */
  146374. chromaticAberration: ChromaticAberrationPostProcess;
  146375. private _chromaticAberrationEffect;
  146376. /**
  146377. * Grain post process which add noise to the image
  146378. */
  146379. grain: GrainPostProcess;
  146380. private _grainEffect;
  146381. /**
  146382. * Glow post process which adds a glow to emissive areas of the image
  146383. */
  146384. private _glowLayer;
  146385. /**
  146386. * Animations which can be used to tweak settings over a period of time
  146387. */
  146388. animations: Animation[];
  146389. private _imageProcessingConfigurationObserver;
  146390. private _sharpenEnabled;
  146391. private _bloomEnabled;
  146392. private _depthOfFieldEnabled;
  146393. private _depthOfFieldBlurLevel;
  146394. private _fxaaEnabled;
  146395. private _imageProcessingEnabled;
  146396. private _defaultPipelineTextureType;
  146397. private _bloomScale;
  146398. private _chromaticAberrationEnabled;
  146399. private _grainEnabled;
  146400. private _buildAllowed;
  146401. /**
  146402. * Gets active scene
  146403. */
  146404. get scene(): Scene;
  146405. /**
  146406. * Enable or disable the sharpen process from the pipeline
  146407. */
  146408. set sharpenEnabled(enabled: boolean);
  146409. get sharpenEnabled(): boolean;
  146410. private _resizeObserver;
  146411. private _hardwareScaleLevel;
  146412. private _bloomKernel;
  146413. /**
  146414. * Specifies the size of the bloom blur kernel, relative to the final output size
  146415. */
  146416. get bloomKernel(): number;
  146417. set bloomKernel(value: number);
  146418. /**
  146419. * Specifies the weight of the bloom in the final rendering
  146420. */
  146421. private _bloomWeight;
  146422. /**
  146423. * Specifies the luma threshold for the area that will be blurred by the bloom
  146424. */
  146425. private _bloomThreshold;
  146426. private _hdr;
  146427. /**
  146428. * The strength of the bloom.
  146429. */
  146430. set bloomWeight(value: number);
  146431. get bloomWeight(): number;
  146432. /**
  146433. * The strength of the bloom.
  146434. */
  146435. set bloomThreshold(value: number);
  146436. get bloomThreshold(): number;
  146437. /**
  146438. * The scale of the bloom, lower value will provide better performance.
  146439. */
  146440. set bloomScale(value: number);
  146441. get bloomScale(): number;
  146442. /**
  146443. * Enable or disable the bloom from the pipeline
  146444. */
  146445. set bloomEnabled(enabled: boolean);
  146446. get bloomEnabled(): boolean;
  146447. private _rebuildBloom;
  146448. /**
  146449. * If the depth of field is enabled.
  146450. */
  146451. get depthOfFieldEnabled(): boolean;
  146452. set depthOfFieldEnabled(enabled: boolean);
  146453. /**
  146454. * Blur level of the depth of field effect. (Higher blur will effect performance)
  146455. */
  146456. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  146457. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  146458. /**
  146459. * If the anti aliasing is enabled.
  146460. */
  146461. set fxaaEnabled(enabled: boolean);
  146462. get fxaaEnabled(): boolean;
  146463. private _samples;
  146464. /**
  146465. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146466. */
  146467. set samples(sampleCount: number);
  146468. get samples(): number;
  146469. /**
  146470. * If image processing is enabled.
  146471. */
  146472. set imageProcessingEnabled(enabled: boolean);
  146473. get imageProcessingEnabled(): boolean;
  146474. /**
  146475. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  146476. */
  146477. set glowLayerEnabled(enabled: boolean);
  146478. get glowLayerEnabled(): boolean;
  146479. /**
  146480. * Gets the glow layer (or null if not defined)
  146481. */
  146482. get glowLayer(): Nullable<GlowLayer>;
  146483. /**
  146484. * Enable or disable the chromaticAberration process from the pipeline
  146485. */
  146486. set chromaticAberrationEnabled(enabled: boolean);
  146487. get chromaticAberrationEnabled(): boolean;
  146488. /**
  146489. * Enable or disable the grain process from the pipeline
  146490. */
  146491. set grainEnabled(enabled: boolean);
  146492. get grainEnabled(): boolean;
  146493. /**
  146494. * @constructor
  146495. * @param name - The rendering pipeline name (default: "")
  146496. * @param hdr - If high dynamic range textures should be used (default: true)
  146497. * @param scene - The scene linked to this pipeline (default: the last created scene)
  146498. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  146499. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  146500. */
  146501. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  146502. /**
  146503. * Get the class name
  146504. * @returns "DefaultRenderingPipeline"
  146505. */
  146506. getClassName(): string;
  146507. /**
  146508. * Force the compilation of the entire pipeline.
  146509. */
  146510. prepare(): void;
  146511. private _hasCleared;
  146512. private _prevPostProcess;
  146513. private _prevPrevPostProcess;
  146514. private _setAutoClearAndTextureSharing;
  146515. private _depthOfFieldSceneObserver;
  146516. private _buildPipeline;
  146517. private _disposePostProcesses;
  146518. /**
  146519. * Adds a camera to the pipeline
  146520. * @param camera the camera to be added
  146521. */
  146522. addCamera(camera: Camera): void;
  146523. /**
  146524. * Removes a camera from the pipeline
  146525. * @param camera the camera to remove
  146526. */
  146527. removeCamera(camera: Camera): void;
  146528. /**
  146529. * Dispose of the pipeline and stop all post processes
  146530. */
  146531. dispose(): void;
  146532. /**
  146533. * Serialize the rendering pipeline (Used when exporting)
  146534. * @returns the serialized object
  146535. */
  146536. serialize(): any;
  146537. /**
  146538. * Parse the serialized pipeline
  146539. * @param source Source pipeline.
  146540. * @param scene The scene to load the pipeline to.
  146541. * @param rootUrl The URL of the serialized pipeline.
  146542. * @returns An instantiated pipeline from the serialized object.
  146543. */
  146544. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  146545. }
  146546. }
  146547. declare module BABYLON {
  146548. /** @hidden */
  146549. export var lensHighlightsPixelShader: {
  146550. name: string;
  146551. shader: string;
  146552. };
  146553. }
  146554. declare module BABYLON {
  146555. /** @hidden */
  146556. export var depthOfFieldPixelShader: {
  146557. name: string;
  146558. shader: string;
  146559. };
  146560. }
  146561. declare module BABYLON {
  146562. /**
  146563. * BABYLON.JS Chromatic Aberration GLSL Shader
  146564. * Author: Olivier Guyot
  146565. * Separates very slightly R, G and B colors on the edges of the screen
  146566. * Inspired by Francois Tarlier & Martins Upitis
  146567. */
  146568. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  146569. /**
  146570. * @ignore
  146571. * The chromatic aberration PostProcess id in the pipeline
  146572. */
  146573. LensChromaticAberrationEffect: string;
  146574. /**
  146575. * @ignore
  146576. * The highlights enhancing PostProcess id in the pipeline
  146577. */
  146578. HighlightsEnhancingEffect: string;
  146579. /**
  146580. * @ignore
  146581. * The depth-of-field PostProcess id in the pipeline
  146582. */
  146583. LensDepthOfFieldEffect: string;
  146584. private _scene;
  146585. private _depthTexture;
  146586. private _grainTexture;
  146587. private _chromaticAberrationPostProcess;
  146588. private _highlightsPostProcess;
  146589. private _depthOfFieldPostProcess;
  146590. private _edgeBlur;
  146591. private _grainAmount;
  146592. private _chromaticAberration;
  146593. private _distortion;
  146594. private _highlightsGain;
  146595. private _highlightsThreshold;
  146596. private _dofDistance;
  146597. private _dofAperture;
  146598. private _dofDarken;
  146599. private _dofPentagon;
  146600. private _blurNoise;
  146601. /**
  146602. * @constructor
  146603. *
  146604. * Effect parameters are as follow:
  146605. * {
  146606. * chromatic_aberration: number; // from 0 to x (1 for realism)
  146607. * edge_blur: number; // from 0 to x (1 for realism)
  146608. * distortion: number; // from 0 to x (1 for realism)
  146609. * grain_amount: number; // from 0 to 1
  146610. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  146611. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  146612. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  146613. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  146614. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  146615. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  146616. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  146617. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  146618. * }
  146619. * Note: if an effect parameter is unset, effect is disabled
  146620. *
  146621. * @param name The rendering pipeline name
  146622. * @param parameters - An object containing all parameters (see above)
  146623. * @param scene The scene linked to this pipeline
  146624. * @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)
  146625. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146626. */
  146627. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  146628. /**
  146629. * Get the class name
  146630. * @returns "LensRenderingPipeline"
  146631. */
  146632. getClassName(): string;
  146633. /**
  146634. * Gets associated scene
  146635. */
  146636. get scene(): Scene;
  146637. /**
  146638. * Gets or sets the edge blur
  146639. */
  146640. get edgeBlur(): number;
  146641. set edgeBlur(value: number);
  146642. /**
  146643. * Gets or sets the grain amount
  146644. */
  146645. get grainAmount(): number;
  146646. set grainAmount(value: number);
  146647. /**
  146648. * Gets or sets the chromatic aberration amount
  146649. */
  146650. get chromaticAberration(): number;
  146651. set chromaticAberration(value: number);
  146652. /**
  146653. * Gets or sets the depth of field aperture
  146654. */
  146655. get dofAperture(): number;
  146656. set dofAperture(value: number);
  146657. /**
  146658. * Gets or sets the edge distortion
  146659. */
  146660. get edgeDistortion(): number;
  146661. set edgeDistortion(value: number);
  146662. /**
  146663. * Gets or sets the depth of field distortion
  146664. */
  146665. get dofDistortion(): number;
  146666. set dofDistortion(value: number);
  146667. /**
  146668. * Gets or sets the darken out of focus amount
  146669. */
  146670. get darkenOutOfFocus(): number;
  146671. set darkenOutOfFocus(value: number);
  146672. /**
  146673. * Gets or sets a boolean indicating if blur noise is enabled
  146674. */
  146675. get blurNoise(): boolean;
  146676. set blurNoise(value: boolean);
  146677. /**
  146678. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  146679. */
  146680. get pentagonBokeh(): boolean;
  146681. set pentagonBokeh(value: boolean);
  146682. /**
  146683. * Gets or sets the highlight grain amount
  146684. */
  146685. get highlightsGain(): number;
  146686. set highlightsGain(value: number);
  146687. /**
  146688. * Gets or sets the highlight threshold
  146689. */
  146690. get highlightsThreshold(): number;
  146691. set highlightsThreshold(value: number);
  146692. /**
  146693. * Sets the amount of blur at the edges
  146694. * @param amount blur amount
  146695. */
  146696. setEdgeBlur(amount: number): void;
  146697. /**
  146698. * Sets edge blur to 0
  146699. */
  146700. disableEdgeBlur(): void;
  146701. /**
  146702. * Sets the amout of grain
  146703. * @param amount Amount of grain
  146704. */
  146705. setGrainAmount(amount: number): void;
  146706. /**
  146707. * Set grain amount to 0
  146708. */
  146709. disableGrain(): void;
  146710. /**
  146711. * Sets the chromatic aberration amount
  146712. * @param amount amount of chromatic aberration
  146713. */
  146714. setChromaticAberration(amount: number): void;
  146715. /**
  146716. * Sets chromatic aberration amount to 0
  146717. */
  146718. disableChromaticAberration(): void;
  146719. /**
  146720. * Sets the EdgeDistortion amount
  146721. * @param amount amount of EdgeDistortion
  146722. */
  146723. setEdgeDistortion(amount: number): void;
  146724. /**
  146725. * Sets edge distortion to 0
  146726. */
  146727. disableEdgeDistortion(): void;
  146728. /**
  146729. * Sets the FocusDistance amount
  146730. * @param amount amount of FocusDistance
  146731. */
  146732. setFocusDistance(amount: number): void;
  146733. /**
  146734. * Disables depth of field
  146735. */
  146736. disableDepthOfField(): void;
  146737. /**
  146738. * Sets the Aperture amount
  146739. * @param amount amount of Aperture
  146740. */
  146741. setAperture(amount: number): void;
  146742. /**
  146743. * Sets the DarkenOutOfFocus amount
  146744. * @param amount amount of DarkenOutOfFocus
  146745. */
  146746. setDarkenOutOfFocus(amount: number): void;
  146747. private _pentagonBokehIsEnabled;
  146748. /**
  146749. * Creates a pentagon bokeh effect
  146750. */
  146751. enablePentagonBokeh(): void;
  146752. /**
  146753. * Disables the pentagon bokeh effect
  146754. */
  146755. disablePentagonBokeh(): void;
  146756. /**
  146757. * Enables noise blur
  146758. */
  146759. enableNoiseBlur(): void;
  146760. /**
  146761. * Disables noise blur
  146762. */
  146763. disableNoiseBlur(): void;
  146764. /**
  146765. * Sets the HighlightsGain amount
  146766. * @param amount amount of HighlightsGain
  146767. */
  146768. setHighlightsGain(amount: number): void;
  146769. /**
  146770. * Sets the HighlightsThreshold amount
  146771. * @param amount amount of HighlightsThreshold
  146772. */
  146773. setHighlightsThreshold(amount: number): void;
  146774. /**
  146775. * Disables highlights
  146776. */
  146777. disableHighlights(): void;
  146778. /**
  146779. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  146780. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  146781. */
  146782. dispose(disableDepthRender?: boolean): void;
  146783. private _createChromaticAberrationPostProcess;
  146784. private _createHighlightsPostProcess;
  146785. private _createDepthOfFieldPostProcess;
  146786. private _createGrainTexture;
  146787. }
  146788. }
  146789. declare module BABYLON {
  146790. /** @hidden */
  146791. export var ssao2PixelShader: {
  146792. name: string;
  146793. shader: string;
  146794. };
  146795. }
  146796. declare module BABYLON {
  146797. /** @hidden */
  146798. export var ssaoCombinePixelShader: {
  146799. name: string;
  146800. shader: string;
  146801. };
  146802. }
  146803. declare module BABYLON {
  146804. /**
  146805. * Render pipeline to produce ssao effect
  146806. */
  146807. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  146808. /**
  146809. * @ignore
  146810. * The PassPostProcess id in the pipeline that contains the original scene color
  146811. */
  146812. SSAOOriginalSceneColorEffect: string;
  146813. /**
  146814. * @ignore
  146815. * The SSAO PostProcess id in the pipeline
  146816. */
  146817. SSAORenderEffect: string;
  146818. /**
  146819. * @ignore
  146820. * The horizontal blur PostProcess id in the pipeline
  146821. */
  146822. SSAOBlurHRenderEffect: string;
  146823. /**
  146824. * @ignore
  146825. * The vertical blur PostProcess id in the pipeline
  146826. */
  146827. SSAOBlurVRenderEffect: string;
  146828. /**
  146829. * @ignore
  146830. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146831. */
  146832. SSAOCombineRenderEffect: string;
  146833. /**
  146834. * The output strength of the SSAO post-process. Default value is 1.0.
  146835. */
  146836. totalStrength: number;
  146837. /**
  146838. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  146839. */
  146840. maxZ: number;
  146841. /**
  146842. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  146843. */
  146844. minZAspect: number;
  146845. private _samples;
  146846. /**
  146847. * Number of samples used for the SSAO calculations. Default value is 8
  146848. */
  146849. set samples(n: number);
  146850. get samples(): number;
  146851. private _textureSamples;
  146852. /**
  146853. * Number of samples to use for antialiasing
  146854. */
  146855. set textureSamples(n: number);
  146856. get textureSamples(): number;
  146857. /**
  146858. * Ratio object used for SSAO ratio and blur ratio
  146859. */
  146860. private _ratio;
  146861. /**
  146862. * Dynamically generated sphere sampler.
  146863. */
  146864. private _sampleSphere;
  146865. /**
  146866. * Blur filter offsets
  146867. */
  146868. private _samplerOffsets;
  146869. private _expensiveBlur;
  146870. /**
  146871. * If bilateral blur should be used
  146872. */
  146873. set expensiveBlur(b: boolean);
  146874. get expensiveBlur(): boolean;
  146875. /**
  146876. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  146877. */
  146878. radius: number;
  146879. /**
  146880. * The base color of the SSAO post-process
  146881. * The final result is "base + ssao" between [0, 1]
  146882. */
  146883. base: number;
  146884. /**
  146885. * Support test.
  146886. */
  146887. static get IsSupported(): boolean;
  146888. private _scene;
  146889. private _depthTexture;
  146890. private _normalTexture;
  146891. private _randomTexture;
  146892. private _originalColorPostProcess;
  146893. private _ssaoPostProcess;
  146894. private _blurHPostProcess;
  146895. private _blurVPostProcess;
  146896. private _ssaoCombinePostProcess;
  146897. /**
  146898. * Gets active scene
  146899. */
  146900. get scene(): Scene;
  146901. /**
  146902. * @constructor
  146903. * @param name The rendering pipeline name
  146904. * @param scene The scene linked to this pipeline
  146905. * @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 }
  146906. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146907. */
  146908. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  146909. /**
  146910. * Get the class name
  146911. * @returns "SSAO2RenderingPipeline"
  146912. */
  146913. getClassName(): string;
  146914. /**
  146915. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  146916. */
  146917. dispose(disableGeometryBufferRenderer?: boolean): void;
  146918. private _createBlurPostProcess;
  146919. /** @hidden */
  146920. _rebuild(): void;
  146921. private _bits;
  146922. private _radicalInverse_VdC;
  146923. private _hammersley;
  146924. private _hemisphereSample_uniform;
  146925. private _generateHemisphere;
  146926. private _createSSAOPostProcess;
  146927. private _createSSAOCombinePostProcess;
  146928. private _createRandomTexture;
  146929. /**
  146930. * Serialize the rendering pipeline (Used when exporting)
  146931. * @returns the serialized object
  146932. */
  146933. serialize(): any;
  146934. /**
  146935. * Parse the serialized pipeline
  146936. * @param source Source pipeline.
  146937. * @param scene The scene to load the pipeline to.
  146938. * @param rootUrl The URL of the serialized pipeline.
  146939. * @returns An instantiated pipeline from the serialized object.
  146940. */
  146941. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  146942. }
  146943. }
  146944. declare module BABYLON {
  146945. /** @hidden */
  146946. export var ssaoPixelShader: {
  146947. name: string;
  146948. shader: string;
  146949. };
  146950. }
  146951. declare module BABYLON {
  146952. /**
  146953. * Render pipeline to produce ssao effect
  146954. */
  146955. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  146956. /**
  146957. * @ignore
  146958. * The PassPostProcess id in the pipeline that contains the original scene color
  146959. */
  146960. SSAOOriginalSceneColorEffect: string;
  146961. /**
  146962. * @ignore
  146963. * The SSAO PostProcess id in the pipeline
  146964. */
  146965. SSAORenderEffect: string;
  146966. /**
  146967. * @ignore
  146968. * The horizontal blur PostProcess id in the pipeline
  146969. */
  146970. SSAOBlurHRenderEffect: string;
  146971. /**
  146972. * @ignore
  146973. * The vertical blur PostProcess id in the pipeline
  146974. */
  146975. SSAOBlurVRenderEffect: string;
  146976. /**
  146977. * @ignore
  146978. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  146979. */
  146980. SSAOCombineRenderEffect: string;
  146981. /**
  146982. * The output strength of the SSAO post-process. Default value is 1.0.
  146983. */
  146984. totalStrength: number;
  146985. /**
  146986. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  146987. */
  146988. radius: number;
  146989. /**
  146990. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  146991. * Must not be equal to fallOff and superior to fallOff.
  146992. * Default value is 0.0075
  146993. */
  146994. area: number;
  146995. /**
  146996. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  146997. * Must not be equal to area and inferior to area.
  146998. * Default value is 0.000001
  146999. */
  147000. fallOff: number;
  147001. /**
  147002. * The base color of the SSAO post-process
  147003. * The final result is "base + ssao" between [0, 1]
  147004. */
  147005. base: number;
  147006. private _scene;
  147007. private _depthTexture;
  147008. private _randomTexture;
  147009. private _originalColorPostProcess;
  147010. private _ssaoPostProcess;
  147011. private _blurHPostProcess;
  147012. private _blurVPostProcess;
  147013. private _ssaoCombinePostProcess;
  147014. private _firstUpdate;
  147015. /**
  147016. * Gets active scene
  147017. */
  147018. get scene(): Scene;
  147019. /**
  147020. * @constructor
  147021. * @param name - The rendering pipeline name
  147022. * @param scene - The scene linked to this pipeline
  147023. * @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 }
  147024. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  147025. */
  147026. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147027. /**
  147028. * Get the class name
  147029. * @returns "SSAORenderingPipeline"
  147030. */
  147031. getClassName(): string;
  147032. /**
  147033. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147034. */
  147035. dispose(disableDepthRender?: boolean): void;
  147036. private _createBlurPostProcess;
  147037. /** @hidden */
  147038. _rebuild(): void;
  147039. private _createSSAOPostProcess;
  147040. private _createSSAOCombinePostProcess;
  147041. private _createRandomTexture;
  147042. }
  147043. }
  147044. declare module BABYLON {
  147045. /** @hidden */
  147046. export var screenSpaceReflectionPixelShader: {
  147047. name: string;
  147048. shader: string;
  147049. };
  147050. }
  147051. declare module BABYLON {
  147052. /**
  147053. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  147054. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  147055. */
  147056. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  147057. /**
  147058. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  147059. */
  147060. threshold: number;
  147061. /**
  147062. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  147063. */
  147064. strength: number;
  147065. /**
  147066. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  147067. */
  147068. reflectionSpecularFalloffExponent: number;
  147069. /**
  147070. * 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]
  147071. */
  147072. step: number;
  147073. /**
  147074. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  147075. */
  147076. roughnessFactor: number;
  147077. private _geometryBufferRenderer;
  147078. private _enableSmoothReflections;
  147079. private _reflectionSamples;
  147080. private _smoothSteps;
  147081. /**
  147082. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  147083. * @param name The name of the effect.
  147084. * @param scene The scene containing the objects to calculate reflections.
  147085. * @param options The required width/height ratio to downsize to before computing the render pass.
  147086. * @param camera The camera to apply the render pass to.
  147087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147088. * @param engine The engine which the post process will be applied. (default: current engine)
  147089. * @param reusable If the post process can be reused on the same frame. (default: false)
  147090. * @param textureType Type of textures used when performing the post process. (default: 0)
  147091. * @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)
  147092. */
  147093. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147094. /**
  147095. * Gets wether or not smoothing reflections is enabled.
  147096. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147097. */
  147098. get enableSmoothReflections(): boolean;
  147099. /**
  147100. * Sets wether or not smoothing reflections is enabled.
  147101. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147102. */
  147103. set enableSmoothReflections(enabled: boolean);
  147104. /**
  147105. * Gets the number of samples taken while computing reflections. More samples count is high,
  147106. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147107. */
  147108. get reflectionSamples(): number;
  147109. /**
  147110. * Sets the number of samples taken while computing reflections. More samples count is high,
  147111. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147112. */
  147113. set reflectionSamples(samples: number);
  147114. /**
  147115. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  147116. * more the post-process will require GPU power and can generate a drop in FPS.
  147117. * Default value (5.0) work pretty well in all cases but can be adjusted.
  147118. */
  147119. get smoothSteps(): number;
  147120. set smoothSteps(steps: number);
  147121. private _updateEffectDefines;
  147122. }
  147123. }
  147124. declare module BABYLON {
  147125. /** @hidden */
  147126. export var standardPixelShader: {
  147127. name: string;
  147128. shader: string;
  147129. };
  147130. }
  147131. declare module BABYLON {
  147132. /**
  147133. * Standard rendering pipeline
  147134. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147135. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  147136. */
  147137. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147138. /**
  147139. * Public members
  147140. */
  147141. /**
  147142. * Post-process which contains the original scene color before the pipeline applies all the effects
  147143. */
  147144. originalPostProcess: Nullable<PostProcess>;
  147145. /**
  147146. * Post-process used to down scale an image x4
  147147. */
  147148. downSampleX4PostProcess: Nullable<PostProcess>;
  147149. /**
  147150. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  147151. */
  147152. brightPassPostProcess: Nullable<PostProcess>;
  147153. /**
  147154. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  147155. */
  147156. blurHPostProcesses: PostProcess[];
  147157. /**
  147158. * Post-process array storing all the vertical blur post-processes used by the pipeline
  147159. */
  147160. blurVPostProcesses: PostProcess[];
  147161. /**
  147162. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  147163. */
  147164. textureAdderPostProcess: Nullable<PostProcess>;
  147165. /**
  147166. * Post-process used to create volumetric lighting effect
  147167. */
  147168. volumetricLightPostProcess: Nullable<PostProcess>;
  147169. /**
  147170. * Post-process used to smooth the previous volumetric light post-process on the X axis
  147171. */
  147172. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  147173. /**
  147174. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  147175. */
  147176. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  147177. /**
  147178. * Post-process used to merge the volumetric light effect and the real scene color
  147179. */
  147180. volumetricLightMergePostProces: Nullable<PostProcess>;
  147181. /**
  147182. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  147183. */
  147184. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  147185. /**
  147186. * Base post-process used to calculate the average luminance of the final image for HDR
  147187. */
  147188. luminancePostProcess: Nullable<PostProcess>;
  147189. /**
  147190. * Post-processes used to create down sample post-processes in order to get
  147191. * the average luminance of the final image for HDR
  147192. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  147193. */
  147194. luminanceDownSamplePostProcesses: PostProcess[];
  147195. /**
  147196. * Post-process used to create a HDR effect (light adaptation)
  147197. */
  147198. hdrPostProcess: Nullable<PostProcess>;
  147199. /**
  147200. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  147201. */
  147202. textureAdderFinalPostProcess: Nullable<PostProcess>;
  147203. /**
  147204. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  147205. */
  147206. lensFlareFinalPostProcess: Nullable<PostProcess>;
  147207. /**
  147208. * Post-process used to merge the final HDR post-process and the real scene color
  147209. */
  147210. hdrFinalPostProcess: Nullable<PostProcess>;
  147211. /**
  147212. * Post-process used to create a lens flare effect
  147213. */
  147214. lensFlarePostProcess: Nullable<PostProcess>;
  147215. /**
  147216. * Post-process that merges the result of the lens flare post-process and the real scene color
  147217. */
  147218. lensFlareComposePostProcess: Nullable<PostProcess>;
  147219. /**
  147220. * Post-process used to create a motion blur effect
  147221. */
  147222. motionBlurPostProcess: Nullable<PostProcess>;
  147223. /**
  147224. * Post-process used to create a depth of field effect
  147225. */
  147226. depthOfFieldPostProcess: Nullable<PostProcess>;
  147227. /**
  147228. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147229. */
  147230. fxaaPostProcess: Nullable<FxaaPostProcess>;
  147231. /**
  147232. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  147233. */
  147234. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  147235. /**
  147236. * Represents the brightness threshold in order to configure the illuminated surfaces
  147237. */
  147238. brightThreshold: number;
  147239. /**
  147240. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  147241. */
  147242. blurWidth: number;
  147243. /**
  147244. * Sets if the blur for highlighted surfaces must be only horizontal
  147245. */
  147246. horizontalBlur: boolean;
  147247. /**
  147248. * Gets the overall exposure used by the pipeline
  147249. */
  147250. get exposure(): number;
  147251. /**
  147252. * Sets the overall exposure used by the pipeline
  147253. */
  147254. set exposure(value: number);
  147255. /**
  147256. * Texture used typically to simulate "dirty" on camera lens
  147257. */
  147258. lensTexture: Nullable<Texture>;
  147259. /**
  147260. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  147261. */
  147262. volumetricLightCoefficient: number;
  147263. /**
  147264. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  147265. */
  147266. volumetricLightPower: number;
  147267. /**
  147268. * Used the set the blur intensity to smooth the volumetric lights
  147269. */
  147270. volumetricLightBlurScale: number;
  147271. /**
  147272. * Light (spot or directional) used to generate the volumetric lights rays
  147273. * The source light must have a shadow generate so the pipeline can get its
  147274. * depth map
  147275. */
  147276. sourceLight: Nullable<SpotLight | DirectionalLight>;
  147277. /**
  147278. * For eye adaptation, represents the minimum luminance the eye can see
  147279. */
  147280. hdrMinimumLuminance: number;
  147281. /**
  147282. * For eye adaptation, represents the decrease luminance speed
  147283. */
  147284. hdrDecreaseRate: number;
  147285. /**
  147286. * For eye adaptation, represents the increase luminance speed
  147287. */
  147288. hdrIncreaseRate: number;
  147289. /**
  147290. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147291. */
  147292. get hdrAutoExposure(): boolean;
  147293. /**
  147294. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147295. */
  147296. set hdrAutoExposure(value: boolean);
  147297. /**
  147298. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  147299. */
  147300. lensColorTexture: Nullable<Texture>;
  147301. /**
  147302. * The overall strengh for the lens flare effect
  147303. */
  147304. lensFlareStrength: number;
  147305. /**
  147306. * Dispersion coefficient for lens flare ghosts
  147307. */
  147308. lensFlareGhostDispersal: number;
  147309. /**
  147310. * Main lens flare halo width
  147311. */
  147312. lensFlareHaloWidth: number;
  147313. /**
  147314. * Based on the lens distortion effect, defines how much the lens flare result
  147315. * is distorted
  147316. */
  147317. lensFlareDistortionStrength: number;
  147318. /**
  147319. * Configures the blur intensity used for for lens flare (halo)
  147320. */
  147321. lensFlareBlurWidth: number;
  147322. /**
  147323. * Lens star texture must be used to simulate rays on the flares and is available
  147324. * in the documentation
  147325. */
  147326. lensStarTexture: Nullable<Texture>;
  147327. /**
  147328. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  147329. * flare effect by taking account of the dirt texture
  147330. */
  147331. lensFlareDirtTexture: Nullable<Texture>;
  147332. /**
  147333. * Represents the focal length for the depth of field effect
  147334. */
  147335. depthOfFieldDistance: number;
  147336. /**
  147337. * Represents the blur intensity for the blurred part of the depth of field effect
  147338. */
  147339. depthOfFieldBlurWidth: number;
  147340. /**
  147341. * Gets how much the image is blurred by the movement while using the motion blur post-process
  147342. */
  147343. get motionStrength(): number;
  147344. /**
  147345. * Sets how much the image is blurred by the movement while using the motion blur post-process
  147346. */
  147347. set motionStrength(strength: number);
  147348. /**
  147349. * Gets wether or not the motion blur post-process is object based or screen based.
  147350. */
  147351. get objectBasedMotionBlur(): boolean;
  147352. /**
  147353. * Sets wether or not the motion blur post-process should be object based or screen based
  147354. */
  147355. set objectBasedMotionBlur(value: boolean);
  147356. /**
  147357. * List of animations for the pipeline (IAnimatable implementation)
  147358. */
  147359. animations: Animation[];
  147360. /**
  147361. * Private members
  147362. */
  147363. private _scene;
  147364. private _currentDepthOfFieldSource;
  147365. private _basePostProcess;
  147366. private _fixedExposure;
  147367. private _currentExposure;
  147368. private _hdrAutoExposure;
  147369. private _hdrCurrentLuminance;
  147370. private _motionStrength;
  147371. private _isObjectBasedMotionBlur;
  147372. private _floatTextureType;
  147373. private _camerasToBeAttached;
  147374. private _ratio;
  147375. private _bloomEnabled;
  147376. private _depthOfFieldEnabled;
  147377. private _vlsEnabled;
  147378. private _lensFlareEnabled;
  147379. private _hdrEnabled;
  147380. private _motionBlurEnabled;
  147381. private _fxaaEnabled;
  147382. private _screenSpaceReflectionsEnabled;
  147383. private _motionBlurSamples;
  147384. private _volumetricLightStepsCount;
  147385. private _samples;
  147386. /**
  147387. * @ignore
  147388. * Specifies if the bloom pipeline is enabled
  147389. */
  147390. get BloomEnabled(): boolean;
  147391. set BloomEnabled(enabled: boolean);
  147392. /**
  147393. * @ignore
  147394. * Specifies if the depth of field pipeline is enabed
  147395. */
  147396. get DepthOfFieldEnabled(): boolean;
  147397. set DepthOfFieldEnabled(enabled: boolean);
  147398. /**
  147399. * @ignore
  147400. * Specifies if the lens flare pipeline is enabed
  147401. */
  147402. get LensFlareEnabled(): boolean;
  147403. set LensFlareEnabled(enabled: boolean);
  147404. /**
  147405. * @ignore
  147406. * Specifies if the HDR pipeline is enabled
  147407. */
  147408. get HDREnabled(): boolean;
  147409. set HDREnabled(enabled: boolean);
  147410. /**
  147411. * @ignore
  147412. * Specifies if the volumetric lights scattering effect is enabled
  147413. */
  147414. get VLSEnabled(): boolean;
  147415. set VLSEnabled(enabled: boolean);
  147416. /**
  147417. * @ignore
  147418. * Specifies if the motion blur effect is enabled
  147419. */
  147420. get MotionBlurEnabled(): boolean;
  147421. set MotionBlurEnabled(enabled: boolean);
  147422. /**
  147423. * Specifies if anti-aliasing is enabled
  147424. */
  147425. get fxaaEnabled(): boolean;
  147426. set fxaaEnabled(enabled: boolean);
  147427. /**
  147428. * Specifies if screen space reflections are enabled.
  147429. */
  147430. get screenSpaceReflectionsEnabled(): boolean;
  147431. set screenSpaceReflectionsEnabled(enabled: boolean);
  147432. /**
  147433. * Specifies the number of steps used to calculate the volumetric lights
  147434. * Typically in interval [50, 200]
  147435. */
  147436. get volumetricLightStepsCount(): number;
  147437. set volumetricLightStepsCount(count: number);
  147438. /**
  147439. * Specifies the number of samples used for the motion blur effect
  147440. * Typically in interval [16, 64]
  147441. */
  147442. get motionBlurSamples(): number;
  147443. set motionBlurSamples(samples: number);
  147444. /**
  147445. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147446. */
  147447. get samples(): number;
  147448. set samples(sampleCount: number);
  147449. /**
  147450. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147451. * @constructor
  147452. * @param name The rendering pipeline name
  147453. * @param scene The scene linked to this pipeline
  147454. * @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)
  147455. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  147456. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147457. */
  147458. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  147459. private _buildPipeline;
  147460. private _createDownSampleX4PostProcess;
  147461. private _createBrightPassPostProcess;
  147462. private _createBlurPostProcesses;
  147463. private _createTextureAdderPostProcess;
  147464. private _createVolumetricLightPostProcess;
  147465. private _createLuminancePostProcesses;
  147466. private _createHdrPostProcess;
  147467. private _createLensFlarePostProcess;
  147468. private _createDepthOfFieldPostProcess;
  147469. private _createMotionBlurPostProcess;
  147470. private _getDepthTexture;
  147471. private _disposePostProcesses;
  147472. /**
  147473. * Dispose of the pipeline and stop all post processes
  147474. */
  147475. dispose(): void;
  147476. /**
  147477. * Serialize the rendering pipeline (Used when exporting)
  147478. * @returns the serialized object
  147479. */
  147480. serialize(): any;
  147481. /**
  147482. * Parse the serialized pipeline
  147483. * @param source Source pipeline.
  147484. * @param scene The scene to load the pipeline to.
  147485. * @param rootUrl The URL of the serialized pipeline.
  147486. * @returns An instantiated pipeline from the serialized object.
  147487. */
  147488. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  147489. /**
  147490. * Luminance steps
  147491. */
  147492. static LuminanceSteps: number;
  147493. }
  147494. }
  147495. declare module BABYLON {
  147496. /** @hidden */
  147497. export var stereoscopicInterlacePixelShader: {
  147498. name: string;
  147499. shader: string;
  147500. };
  147501. }
  147502. declare module BABYLON {
  147503. /**
  147504. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  147505. */
  147506. export class StereoscopicInterlacePostProcessI extends PostProcess {
  147507. private _stepSize;
  147508. private _passedProcess;
  147509. /**
  147510. * Initializes a StereoscopicInterlacePostProcessI
  147511. * @param name The name of the effect.
  147512. * @param rigCameras The rig cameras to be appled to the post process
  147513. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  147514. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  147515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147516. * @param engine The engine which the post process will be applied. (default: current engine)
  147517. * @param reusable If the post process can be reused on the same frame. (default: false)
  147518. */
  147519. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147520. }
  147521. /**
  147522. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  147523. */
  147524. export class StereoscopicInterlacePostProcess extends PostProcess {
  147525. private _stepSize;
  147526. private _passedProcess;
  147527. /**
  147528. * Initializes a StereoscopicInterlacePostProcess
  147529. * @param name The name of the effect.
  147530. * @param rigCameras The rig cameras to be appled to the post process
  147531. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  147532. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147533. * @param engine The engine which the post process will be applied. (default: current engine)
  147534. * @param reusable If the post process can be reused on the same frame. (default: false)
  147535. */
  147536. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147537. }
  147538. }
  147539. declare module BABYLON {
  147540. /** @hidden */
  147541. export var tonemapPixelShader: {
  147542. name: string;
  147543. shader: string;
  147544. };
  147545. }
  147546. declare module BABYLON {
  147547. /** Defines operator used for tonemapping */
  147548. export enum TonemappingOperator {
  147549. /** Hable */
  147550. Hable = 0,
  147551. /** Reinhard */
  147552. Reinhard = 1,
  147553. /** HejiDawson */
  147554. HejiDawson = 2,
  147555. /** Photographic */
  147556. Photographic = 3
  147557. }
  147558. /**
  147559. * Defines a post process to apply tone mapping
  147560. */
  147561. export class TonemapPostProcess extends PostProcess {
  147562. private _operator;
  147563. /** Defines the required exposure adjustement */
  147564. exposureAdjustment: number;
  147565. /**
  147566. * Creates a new TonemapPostProcess
  147567. * @param name defines the name of the postprocess
  147568. * @param _operator defines the operator to use
  147569. * @param exposureAdjustment defines the required exposure adjustement
  147570. * @param camera defines the camera to use (can be null)
  147571. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  147572. * @param engine defines the hosting engine (can be ignore if camera is set)
  147573. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  147574. */
  147575. constructor(name: string, _operator: TonemappingOperator,
  147576. /** Defines the required exposure adjustement */
  147577. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  147578. }
  147579. }
  147580. declare module BABYLON {
  147581. /** @hidden */
  147582. export var volumetricLightScatteringPixelShader: {
  147583. name: string;
  147584. shader: string;
  147585. };
  147586. }
  147587. declare module BABYLON {
  147588. /** @hidden */
  147589. export var volumetricLightScatteringPassVertexShader: {
  147590. name: string;
  147591. shader: string;
  147592. };
  147593. }
  147594. declare module BABYLON {
  147595. /** @hidden */
  147596. export var volumetricLightScatteringPassPixelShader: {
  147597. name: string;
  147598. shader: string;
  147599. };
  147600. }
  147601. declare module BABYLON {
  147602. /**
  147603. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  147604. */
  147605. export class VolumetricLightScatteringPostProcess extends PostProcess {
  147606. private _volumetricLightScatteringPass;
  147607. private _volumetricLightScatteringRTT;
  147608. private _viewPort;
  147609. private _screenCoordinates;
  147610. private _cachedDefines;
  147611. /**
  147612. * If not undefined, the mesh position is computed from the attached node position
  147613. */
  147614. attachedNode: {
  147615. position: Vector3;
  147616. };
  147617. /**
  147618. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  147619. */
  147620. customMeshPosition: Vector3;
  147621. /**
  147622. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  147623. */
  147624. useCustomMeshPosition: boolean;
  147625. /**
  147626. * If the post-process should inverse the light scattering direction
  147627. */
  147628. invert: boolean;
  147629. /**
  147630. * The internal mesh used by the post-process
  147631. */
  147632. mesh: Mesh;
  147633. /**
  147634. * @hidden
  147635. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  147636. */
  147637. get useDiffuseColor(): boolean;
  147638. set useDiffuseColor(useDiffuseColor: boolean);
  147639. /**
  147640. * Array containing the excluded meshes not rendered in the internal pass
  147641. */
  147642. excludedMeshes: AbstractMesh[];
  147643. /**
  147644. * Controls the overall intensity of the post-process
  147645. */
  147646. exposure: number;
  147647. /**
  147648. * Dissipates each sample's contribution in range [0, 1]
  147649. */
  147650. decay: number;
  147651. /**
  147652. * Controls the overall intensity of each sample
  147653. */
  147654. weight: number;
  147655. /**
  147656. * Controls the density of each sample
  147657. */
  147658. density: number;
  147659. /**
  147660. * @constructor
  147661. * @param name The post-process name
  147662. * @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)
  147663. * @param camera The camera that the post-process will be attached to
  147664. * @param mesh The mesh used to create the light scattering
  147665. * @param samples The post-process quality, default 100
  147666. * @param samplingModeThe post-process filtering mode
  147667. * @param engine The babylon engine
  147668. * @param reusable If the post-process is reusable
  147669. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  147670. */
  147671. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  147672. /**
  147673. * Returns the string "VolumetricLightScatteringPostProcess"
  147674. * @returns "VolumetricLightScatteringPostProcess"
  147675. */
  147676. getClassName(): string;
  147677. private _isReady;
  147678. /**
  147679. * Sets the new light position for light scattering effect
  147680. * @param position The new custom light position
  147681. */
  147682. setCustomMeshPosition(position: Vector3): void;
  147683. /**
  147684. * Returns the light position for light scattering effect
  147685. * @return Vector3 The custom light position
  147686. */
  147687. getCustomMeshPosition(): Vector3;
  147688. /**
  147689. * Disposes the internal assets and detaches the post-process from the camera
  147690. */
  147691. dispose(camera: Camera): void;
  147692. /**
  147693. * Returns the render target texture used by the post-process
  147694. * @return the render target texture used by the post-process
  147695. */
  147696. getPass(): RenderTargetTexture;
  147697. private _meshExcluded;
  147698. private _createPass;
  147699. private _updateMeshScreenCoordinates;
  147700. /**
  147701. * Creates a default mesh for the Volumeric Light Scattering post-process
  147702. * @param name The mesh name
  147703. * @param scene The scene where to create the mesh
  147704. * @return the default mesh
  147705. */
  147706. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  147707. }
  147708. }
  147709. declare module BABYLON {
  147710. interface Scene {
  147711. /** @hidden (Backing field) */
  147712. _boundingBoxRenderer: BoundingBoxRenderer;
  147713. /** @hidden (Backing field) */
  147714. _forceShowBoundingBoxes: boolean;
  147715. /**
  147716. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  147717. */
  147718. forceShowBoundingBoxes: boolean;
  147719. /**
  147720. * Gets the bounding box renderer associated with the scene
  147721. * @returns a BoundingBoxRenderer
  147722. */
  147723. getBoundingBoxRenderer(): BoundingBoxRenderer;
  147724. }
  147725. interface AbstractMesh {
  147726. /** @hidden (Backing field) */
  147727. _showBoundingBox: boolean;
  147728. /**
  147729. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  147730. */
  147731. showBoundingBox: boolean;
  147732. }
  147733. /**
  147734. * Component responsible of rendering the bounding box of the meshes in a scene.
  147735. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  147736. */
  147737. export class BoundingBoxRenderer implements ISceneComponent {
  147738. /**
  147739. * The component name helpfull to identify the component in the list of scene components.
  147740. */
  147741. readonly name: string;
  147742. /**
  147743. * The scene the component belongs to.
  147744. */
  147745. scene: Scene;
  147746. /**
  147747. * Color of the bounding box lines placed in front of an object
  147748. */
  147749. frontColor: Color3;
  147750. /**
  147751. * Color of the bounding box lines placed behind an object
  147752. */
  147753. backColor: Color3;
  147754. /**
  147755. * Defines if the renderer should show the back lines or not
  147756. */
  147757. showBackLines: boolean;
  147758. /**
  147759. * Observable raised before rendering a bounding box
  147760. */
  147761. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  147762. /**
  147763. * Observable raised after rendering a bounding box
  147764. */
  147765. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  147766. /**
  147767. * @hidden
  147768. */
  147769. renderList: SmartArray<BoundingBox>;
  147770. private _colorShader;
  147771. private _vertexBuffers;
  147772. private _indexBuffer;
  147773. private _fillIndexBuffer;
  147774. private _fillIndexData;
  147775. /**
  147776. * Instantiates a new bounding box renderer in a scene.
  147777. * @param scene the scene the renderer renders in
  147778. */
  147779. constructor(scene: Scene);
  147780. /**
  147781. * Registers the component in a given scene
  147782. */
  147783. register(): void;
  147784. private _evaluateSubMesh;
  147785. private _activeMesh;
  147786. private _prepareRessources;
  147787. private _createIndexBuffer;
  147788. /**
  147789. * Rebuilds the elements related to this component in case of
  147790. * context lost for instance.
  147791. */
  147792. rebuild(): void;
  147793. /**
  147794. * @hidden
  147795. */
  147796. reset(): void;
  147797. /**
  147798. * Render the bounding boxes of a specific rendering group
  147799. * @param renderingGroupId defines the rendering group to render
  147800. */
  147801. render(renderingGroupId: number): void;
  147802. /**
  147803. * In case of occlusion queries, we can render the occlusion bounding box through this method
  147804. * @param mesh Define the mesh to render the occlusion bounding box for
  147805. */
  147806. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  147807. /**
  147808. * Dispose and release the resources attached to this renderer.
  147809. */
  147810. dispose(): void;
  147811. }
  147812. }
  147813. declare module BABYLON {
  147814. interface Scene {
  147815. /** @hidden (Backing field) */
  147816. _depthRenderer: {
  147817. [id: string]: DepthRenderer;
  147818. };
  147819. /**
  147820. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  147821. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  147822. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  147823. * @returns the created depth renderer
  147824. */
  147825. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  147826. /**
  147827. * Disables a depth renderer for a given camera
  147828. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  147829. */
  147830. disableDepthRenderer(camera?: Nullable<Camera>): void;
  147831. }
  147832. /**
  147833. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  147834. * in several rendering techniques.
  147835. */
  147836. export class DepthRendererSceneComponent implements ISceneComponent {
  147837. /**
  147838. * The component name helpfull to identify the component in the list of scene components.
  147839. */
  147840. readonly name: string;
  147841. /**
  147842. * The scene the component belongs to.
  147843. */
  147844. scene: Scene;
  147845. /**
  147846. * Creates a new instance of the component for the given scene
  147847. * @param scene Defines the scene to register the component in
  147848. */
  147849. constructor(scene: Scene);
  147850. /**
  147851. * Registers the component in a given scene
  147852. */
  147853. register(): void;
  147854. /**
  147855. * Rebuilds the elements related to this component in case of
  147856. * context lost for instance.
  147857. */
  147858. rebuild(): void;
  147859. /**
  147860. * Disposes the component and the associated ressources
  147861. */
  147862. dispose(): void;
  147863. private _gatherRenderTargets;
  147864. private _gatherActiveCameraRenderTargets;
  147865. }
  147866. }
  147867. declare module BABYLON {
  147868. /** @hidden */
  147869. export var outlinePixelShader: {
  147870. name: string;
  147871. shader: string;
  147872. };
  147873. }
  147874. declare module BABYLON {
  147875. /** @hidden */
  147876. export var outlineVertexShader: {
  147877. name: string;
  147878. shader: string;
  147879. };
  147880. }
  147881. declare module BABYLON {
  147882. interface Scene {
  147883. /** @hidden */
  147884. _outlineRenderer: OutlineRenderer;
  147885. /**
  147886. * Gets the outline renderer associated with the scene
  147887. * @returns a OutlineRenderer
  147888. */
  147889. getOutlineRenderer(): OutlineRenderer;
  147890. }
  147891. interface AbstractMesh {
  147892. /** @hidden (Backing field) */
  147893. _renderOutline: boolean;
  147894. /**
  147895. * Gets or sets a boolean indicating if the outline must be rendered as well
  147896. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  147897. */
  147898. renderOutline: boolean;
  147899. /** @hidden (Backing field) */
  147900. _renderOverlay: boolean;
  147901. /**
  147902. * Gets or sets a boolean indicating if the overlay must be rendered as well
  147903. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  147904. */
  147905. renderOverlay: boolean;
  147906. }
  147907. /**
  147908. * This class is responsible to draw bothe outline/overlay of meshes.
  147909. * It should not be used directly but through the available method on mesh.
  147910. */
  147911. export class OutlineRenderer implements ISceneComponent {
  147912. /**
  147913. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  147914. */
  147915. private static _StencilReference;
  147916. /**
  147917. * The name of the component. Each component must have a unique name.
  147918. */
  147919. name: string;
  147920. /**
  147921. * The scene the component belongs to.
  147922. */
  147923. scene: Scene;
  147924. /**
  147925. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  147926. */
  147927. zOffset: number;
  147928. private _engine;
  147929. private _effect;
  147930. private _cachedDefines;
  147931. private _savedDepthWrite;
  147932. /**
  147933. * Instantiates a new outline renderer. (There could be only one per scene).
  147934. * @param scene Defines the scene it belongs to
  147935. */
  147936. constructor(scene: Scene);
  147937. /**
  147938. * Register the component to one instance of a scene.
  147939. */
  147940. register(): void;
  147941. /**
  147942. * Rebuilds the elements related to this component in case of
  147943. * context lost for instance.
  147944. */
  147945. rebuild(): void;
  147946. /**
  147947. * Disposes the component and the associated ressources.
  147948. */
  147949. dispose(): void;
  147950. /**
  147951. * Renders the outline in the canvas.
  147952. * @param subMesh Defines the sumesh to render
  147953. * @param batch Defines the batch of meshes in case of instances
  147954. * @param useOverlay Defines if the rendering is for the overlay or the outline
  147955. */
  147956. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  147957. /**
  147958. * Returns whether or not the outline renderer is ready for a given submesh.
  147959. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  147960. * @param subMesh Defines the submesh to check readyness for
  147961. * @param useInstances Defines wheter wee are trying to render instances or not
  147962. * @returns true if ready otherwise false
  147963. */
  147964. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147965. private _beforeRenderingMesh;
  147966. private _afterRenderingMesh;
  147967. }
  147968. }
  147969. declare module BABYLON {
  147970. /**
  147971. * Defines the basic options interface of a Sprite Frame Source Size.
  147972. */
  147973. export interface ISpriteJSONSpriteSourceSize {
  147974. /**
  147975. * number of the original width of the Frame
  147976. */
  147977. w: number;
  147978. /**
  147979. * number of the original height of the Frame
  147980. */
  147981. h: number;
  147982. }
  147983. /**
  147984. * Defines the basic options interface of a Sprite Frame Data.
  147985. */
  147986. export interface ISpriteJSONSpriteFrameData {
  147987. /**
  147988. * number of the x offset of the Frame
  147989. */
  147990. x: number;
  147991. /**
  147992. * number of the y offset of the Frame
  147993. */
  147994. y: number;
  147995. /**
  147996. * number of the width of the Frame
  147997. */
  147998. w: number;
  147999. /**
  148000. * number of the height of the Frame
  148001. */
  148002. h: number;
  148003. }
  148004. /**
  148005. * Defines the basic options interface of a JSON Sprite.
  148006. */
  148007. export interface ISpriteJSONSprite {
  148008. /**
  148009. * string name of the Frame
  148010. */
  148011. filename: string;
  148012. /**
  148013. * ISpriteJSONSpriteFrame basic object of the frame data
  148014. */
  148015. frame: ISpriteJSONSpriteFrameData;
  148016. /**
  148017. * boolean to flag is the frame was rotated.
  148018. */
  148019. rotated: boolean;
  148020. /**
  148021. * boolean to flag is the frame was trimmed.
  148022. */
  148023. trimmed: boolean;
  148024. /**
  148025. * ISpriteJSONSpriteFrame basic object of the source data
  148026. */
  148027. spriteSourceSize: ISpriteJSONSpriteFrameData;
  148028. /**
  148029. * ISpriteJSONSpriteFrame basic object of the source data
  148030. */
  148031. sourceSize: ISpriteJSONSpriteSourceSize;
  148032. }
  148033. /**
  148034. * Defines the basic options interface of a JSON atlas.
  148035. */
  148036. export interface ISpriteJSONAtlas {
  148037. /**
  148038. * Array of objects that contain the frame data.
  148039. */
  148040. frames: Array<ISpriteJSONSprite>;
  148041. /**
  148042. * object basic object containing the sprite meta data.
  148043. */
  148044. meta?: object;
  148045. }
  148046. }
  148047. declare module BABYLON {
  148048. /** @hidden */
  148049. export var spriteMapPixelShader: {
  148050. name: string;
  148051. shader: string;
  148052. };
  148053. }
  148054. declare module BABYLON {
  148055. /** @hidden */
  148056. export var spriteMapVertexShader: {
  148057. name: string;
  148058. shader: string;
  148059. };
  148060. }
  148061. declare module BABYLON {
  148062. /**
  148063. * Defines the basic options interface of a SpriteMap
  148064. */
  148065. export interface ISpriteMapOptions {
  148066. /**
  148067. * Vector2 of the number of cells in the grid.
  148068. */
  148069. stageSize?: Vector2;
  148070. /**
  148071. * Vector2 of the size of the output plane in World Units.
  148072. */
  148073. outputSize?: Vector2;
  148074. /**
  148075. * Vector3 of the position of the output plane in World Units.
  148076. */
  148077. outputPosition?: Vector3;
  148078. /**
  148079. * Vector3 of the rotation of the output plane.
  148080. */
  148081. outputRotation?: Vector3;
  148082. /**
  148083. * number of layers that the system will reserve in resources.
  148084. */
  148085. layerCount?: number;
  148086. /**
  148087. * number of max animation frames a single cell will reserve in resources.
  148088. */
  148089. maxAnimationFrames?: number;
  148090. /**
  148091. * number cell index of the base tile when the system compiles.
  148092. */
  148093. baseTile?: number;
  148094. /**
  148095. * boolean flip the sprite after its been repositioned by the framing data.
  148096. */
  148097. flipU?: boolean;
  148098. /**
  148099. * Vector3 scalar of the global RGB values of the SpriteMap.
  148100. */
  148101. colorMultiply?: Vector3;
  148102. }
  148103. /**
  148104. * Defines the IDisposable interface in order to be cleanable from resources.
  148105. */
  148106. export interface ISpriteMap extends IDisposable {
  148107. /**
  148108. * String name of the SpriteMap.
  148109. */
  148110. name: string;
  148111. /**
  148112. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  148113. */
  148114. atlasJSON: ISpriteJSONAtlas;
  148115. /**
  148116. * Texture of the SpriteMap.
  148117. */
  148118. spriteSheet: Texture;
  148119. /**
  148120. * The parameters to initialize the SpriteMap with.
  148121. */
  148122. options: ISpriteMapOptions;
  148123. }
  148124. /**
  148125. * Class used to manage a grid restricted sprite deployment on an Output plane.
  148126. */
  148127. export class SpriteMap implements ISpriteMap {
  148128. /** The Name of the spriteMap */
  148129. name: string;
  148130. /** The JSON file with the frame and meta data */
  148131. atlasJSON: ISpriteJSONAtlas;
  148132. /** The systems Sprite Sheet Texture */
  148133. spriteSheet: Texture;
  148134. /** Arguments passed with the Constructor */
  148135. options: ISpriteMapOptions;
  148136. /** Public Sprite Storage array, parsed from atlasJSON */
  148137. sprites: Array<ISpriteJSONSprite>;
  148138. /** Returns the Number of Sprites in the System */
  148139. get spriteCount(): number;
  148140. /** Returns the Position of Output Plane*/
  148141. get position(): Vector3;
  148142. /** Returns the Position of Output Plane*/
  148143. set position(v: Vector3);
  148144. /** Returns the Rotation of Output Plane*/
  148145. get rotation(): Vector3;
  148146. /** Returns the Rotation of Output Plane*/
  148147. set rotation(v: Vector3);
  148148. /** Sets the AnimationMap*/
  148149. get animationMap(): RawTexture;
  148150. /** Sets the AnimationMap*/
  148151. set animationMap(v: RawTexture);
  148152. /** Scene that the SpriteMap was created in */
  148153. private _scene;
  148154. /** Texture Buffer of Float32 that holds tile frame data*/
  148155. private _frameMap;
  148156. /** Texture Buffers of Float32 that holds tileMap data*/
  148157. private _tileMaps;
  148158. /** Texture Buffer of Float32 that holds Animation Data*/
  148159. private _animationMap;
  148160. /** Custom ShaderMaterial Central to the System*/
  148161. private _material;
  148162. /** Custom ShaderMaterial Central to the System*/
  148163. private _output;
  148164. /** Systems Time Ticker*/
  148165. private _time;
  148166. /**
  148167. * Creates a new SpriteMap
  148168. * @param name defines the SpriteMaps Name
  148169. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  148170. * @param spriteSheet is the Texture that the Sprites are on.
  148171. * @param options a basic deployment configuration
  148172. * @param scene The Scene that the map is deployed on
  148173. */
  148174. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  148175. /**
  148176. * Returns tileID location
  148177. * @returns Vector2 the cell position ID
  148178. */
  148179. getTileID(): Vector2;
  148180. /**
  148181. * Gets the UV location of the mouse over the SpriteMap.
  148182. * @returns Vector2 the UV position of the mouse interaction
  148183. */
  148184. getMousePosition(): Vector2;
  148185. /**
  148186. * Creates the "frame" texture Buffer
  148187. * -------------------------------------
  148188. * Structure of frames
  148189. * "filename": "Falling-Water-2.png",
  148190. * "frame": {"x":69,"y":103,"w":24,"h":32},
  148191. * "rotated": true,
  148192. * "trimmed": true,
  148193. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  148194. * "sourceSize": {"w":32,"h":32}
  148195. * @returns RawTexture of the frameMap
  148196. */
  148197. private _createFrameBuffer;
  148198. /**
  148199. * Creates the tileMap texture Buffer
  148200. * @param buffer normally and array of numbers, or a false to generate from scratch
  148201. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  148202. * @returns RawTexture of the tileMap
  148203. */
  148204. private _createTileBuffer;
  148205. /**
  148206. * Modifies the data of the tileMaps
  148207. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  148208. * @param pos is the iVector2 Coordinates of the Tile
  148209. * @param tile The SpriteIndex of the new Tile
  148210. */
  148211. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  148212. /**
  148213. * Creates the animationMap texture Buffer
  148214. * @param buffer normally and array of numbers, or a false to generate from scratch
  148215. * @returns RawTexture of the animationMap
  148216. */
  148217. private _createTileAnimationBuffer;
  148218. /**
  148219. * Modifies the data of the animationMap
  148220. * @param cellID is the Index of the Sprite
  148221. * @param _frame is the target Animation frame
  148222. * @param toCell is the Target Index of the next frame of the animation
  148223. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  148224. * @param speed is a global scalar of the time variable on the map.
  148225. */
  148226. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  148227. /**
  148228. * Exports the .tilemaps file
  148229. */
  148230. saveTileMaps(): void;
  148231. /**
  148232. * Imports the .tilemaps file
  148233. * @param url of the .tilemaps file
  148234. */
  148235. loadTileMaps(url: string): void;
  148236. /**
  148237. * Release associated resources
  148238. */
  148239. dispose(): void;
  148240. }
  148241. }
  148242. declare module BABYLON {
  148243. /**
  148244. * Class used to manage multiple sprites of different sizes on the same spritesheet
  148245. * @see http://doc.babylonjs.com/babylon101/sprites
  148246. */
  148247. export class SpritePackedManager extends SpriteManager {
  148248. /** defines the packed manager's name */
  148249. name: string;
  148250. /**
  148251. * Creates a new sprite manager from a packed sprite sheet
  148252. * @param name defines the manager's name
  148253. * @param imgUrl defines the sprite sheet url
  148254. * @param capacity defines the maximum allowed number of sprites
  148255. * @param scene defines the hosting scene
  148256. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  148257. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  148258. * @param samplingMode defines the smapling mode to use with spritesheet
  148259. * @param fromPacked set to true; do not alter
  148260. */
  148261. constructor(
  148262. /** defines the packed manager's name */
  148263. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  148264. }
  148265. }
  148266. declare module BABYLON {
  148267. /**
  148268. * Defines the list of states available for a task inside a AssetsManager
  148269. */
  148270. export enum AssetTaskState {
  148271. /**
  148272. * Initialization
  148273. */
  148274. INIT = 0,
  148275. /**
  148276. * Running
  148277. */
  148278. RUNNING = 1,
  148279. /**
  148280. * Done
  148281. */
  148282. DONE = 2,
  148283. /**
  148284. * Error
  148285. */
  148286. ERROR = 3
  148287. }
  148288. /**
  148289. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  148290. */
  148291. export abstract class AbstractAssetTask {
  148292. /**
  148293. * Task name
  148294. */ name: string;
  148295. /**
  148296. * Callback called when the task is successful
  148297. */
  148298. onSuccess: (task: any) => void;
  148299. /**
  148300. * Callback called when the task is not successful
  148301. */
  148302. onError: (task: any, message?: string, exception?: any) => void;
  148303. /**
  148304. * Creates a new AssetsManager
  148305. * @param name defines the name of the task
  148306. */
  148307. constructor(
  148308. /**
  148309. * Task name
  148310. */ name: string);
  148311. private _isCompleted;
  148312. private _taskState;
  148313. private _errorObject;
  148314. /**
  148315. * Get if the task is completed
  148316. */
  148317. get isCompleted(): boolean;
  148318. /**
  148319. * Gets the current state of the task
  148320. */
  148321. get taskState(): AssetTaskState;
  148322. /**
  148323. * Gets the current error object (if task is in error)
  148324. */
  148325. get errorObject(): {
  148326. message?: string;
  148327. exception?: any;
  148328. };
  148329. /**
  148330. * Internal only
  148331. * @hidden
  148332. */
  148333. _setErrorObject(message?: string, exception?: any): void;
  148334. /**
  148335. * Execute the current task
  148336. * @param scene defines the scene where you want your assets to be loaded
  148337. * @param onSuccess is a callback called when the task is successfully executed
  148338. * @param onError is a callback called if an error occurs
  148339. */
  148340. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148341. /**
  148342. * Execute the current task
  148343. * @param scene defines the scene where you want your assets to be loaded
  148344. * @param onSuccess is a callback called when the task is successfully executed
  148345. * @param onError is a callback called if an error occurs
  148346. */
  148347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148348. /**
  148349. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  148350. * This can be used with failed tasks that have the reason for failure fixed.
  148351. */
  148352. reset(): void;
  148353. private onErrorCallback;
  148354. private onDoneCallback;
  148355. }
  148356. /**
  148357. * Define the interface used by progress events raised during assets loading
  148358. */
  148359. export interface IAssetsProgressEvent {
  148360. /**
  148361. * Defines the number of remaining tasks to process
  148362. */
  148363. remainingCount: number;
  148364. /**
  148365. * Defines the total number of tasks
  148366. */
  148367. totalCount: number;
  148368. /**
  148369. * Defines the task that was just processed
  148370. */
  148371. task: AbstractAssetTask;
  148372. }
  148373. /**
  148374. * Class used to share progress information about assets loading
  148375. */
  148376. export class AssetsProgressEvent implements IAssetsProgressEvent {
  148377. /**
  148378. * Defines the number of remaining tasks to process
  148379. */
  148380. remainingCount: number;
  148381. /**
  148382. * Defines the total number of tasks
  148383. */
  148384. totalCount: number;
  148385. /**
  148386. * Defines the task that was just processed
  148387. */
  148388. task: AbstractAssetTask;
  148389. /**
  148390. * Creates a AssetsProgressEvent
  148391. * @param remainingCount defines the number of remaining tasks to process
  148392. * @param totalCount defines the total number of tasks
  148393. * @param task defines the task that was just processed
  148394. */
  148395. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  148396. }
  148397. /**
  148398. * Define a task used by AssetsManager to load meshes
  148399. */
  148400. export class MeshAssetTask extends AbstractAssetTask {
  148401. /**
  148402. * Defines the name of the task
  148403. */
  148404. name: string;
  148405. /**
  148406. * Defines the list of mesh's names you want to load
  148407. */
  148408. meshesNames: any;
  148409. /**
  148410. * Defines the root url to use as a base to load your meshes and associated resources
  148411. */
  148412. rootUrl: string;
  148413. /**
  148414. * Defines the filename or File of the scene to load from
  148415. */
  148416. sceneFilename: string | File;
  148417. /**
  148418. * Gets the list of loaded meshes
  148419. */
  148420. loadedMeshes: Array<AbstractMesh>;
  148421. /**
  148422. * Gets the list of loaded particle systems
  148423. */
  148424. loadedParticleSystems: Array<IParticleSystem>;
  148425. /**
  148426. * Gets the list of loaded skeletons
  148427. */
  148428. loadedSkeletons: Array<Skeleton>;
  148429. /**
  148430. * Gets the list of loaded animation groups
  148431. */
  148432. loadedAnimationGroups: Array<AnimationGroup>;
  148433. /**
  148434. * Callback called when the task is successful
  148435. */
  148436. onSuccess: (task: MeshAssetTask) => void;
  148437. /**
  148438. * Callback called when the task is successful
  148439. */
  148440. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  148441. /**
  148442. * Creates a new MeshAssetTask
  148443. * @param name defines the name of the task
  148444. * @param meshesNames defines the list of mesh's names you want to load
  148445. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  148446. * @param sceneFilename defines the filename or File of the scene to load from
  148447. */
  148448. constructor(
  148449. /**
  148450. * Defines the name of the task
  148451. */
  148452. name: string,
  148453. /**
  148454. * Defines the list of mesh's names you want to load
  148455. */
  148456. meshesNames: any,
  148457. /**
  148458. * Defines the root url to use as a base to load your meshes and associated resources
  148459. */
  148460. rootUrl: string,
  148461. /**
  148462. * Defines the filename or File of the scene to load from
  148463. */
  148464. sceneFilename: string | File);
  148465. /**
  148466. * Execute the current task
  148467. * @param scene defines the scene where you want your assets to be loaded
  148468. * @param onSuccess is a callback called when the task is successfully executed
  148469. * @param onError is a callback called if an error occurs
  148470. */
  148471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148472. }
  148473. /**
  148474. * Define a task used by AssetsManager to load text content
  148475. */
  148476. export class TextFileAssetTask extends AbstractAssetTask {
  148477. /**
  148478. * Defines the name of the task
  148479. */
  148480. name: string;
  148481. /**
  148482. * Defines the location of the file to load
  148483. */
  148484. url: string;
  148485. /**
  148486. * Gets the loaded text string
  148487. */
  148488. text: string;
  148489. /**
  148490. * Callback called when the task is successful
  148491. */
  148492. onSuccess: (task: TextFileAssetTask) => void;
  148493. /**
  148494. * Callback called when the task is successful
  148495. */
  148496. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  148497. /**
  148498. * Creates a new TextFileAssetTask object
  148499. * @param name defines the name of the task
  148500. * @param url defines the location of the file to load
  148501. */
  148502. constructor(
  148503. /**
  148504. * Defines the name of the task
  148505. */
  148506. name: string,
  148507. /**
  148508. * Defines the location of the file to load
  148509. */
  148510. url: string);
  148511. /**
  148512. * Execute the current task
  148513. * @param scene defines the scene where you want your assets to be loaded
  148514. * @param onSuccess is a callback called when the task is successfully executed
  148515. * @param onError is a callback called if an error occurs
  148516. */
  148517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148518. }
  148519. /**
  148520. * Define a task used by AssetsManager to load binary data
  148521. */
  148522. export class BinaryFileAssetTask extends AbstractAssetTask {
  148523. /**
  148524. * Defines the name of the task
  148525. */
  148526. name: string;
  148527. /**
  148528. * Defines the location of the file to load
  148529. */
  148530. url: string;
  148531. /**
  148532. * Gets the lodaded data (as an array buffer)
  148533. */
  148534. data: ArrayBuffer;
  148535. /**
  148536. * Callback called when the task is successful
  148537. */
  148538. onSuccess: (task: BinaryFileAssetTask) => void;
  148539. /**
  148540. * Callback called when the task is successful
  148541. */
  148542. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  148543. /**
  148544. * Creates a new BinaryFileAssetTask object
  148545. * @param name defines the name of the new task
  148546. * @param url defines the location of the file to load
  148547. */
  148548. constructor(
  148549. /**
  148550. * Defines the name of the task
  148551. */
  148552. name: string,
  148553. /**
  148554. * Defines the location of the file to load
  148555. */
  148556. url: string);
  148557. /**
  148558. * Execute the current task
  148559. * @param scene defines the scene where you want your assets to be loaded
  148560. * @param onSuccess is a callback called when the task is successfully executed
  148561. * @param onError is a callback called if an error occurs
  148562. */
  148563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148564. }
  148565. /**
  148566. * Define a task used by AssetsManager to load images
  148567. */
  148568. export class ImageAssetTask extends AbstractAssetTask {
  148569. /**
  148570. * Defines the name of the task
  148571. */
  148572. name: string;
  148573. /**
  148574. * Defines the location of the image to load
  148575. */
  148576. url: string;
  148577. /**
  148578. * Gets the loaded images
  148579. */
  148580. image: HTMLImageElement;
  148581. /**
  148582. * Callback called when the task is successful
  148583. */
  148584. onSuccess: (task: ImageAssetTask) => void;
  148585. /**
  148586. * Callback called when the task is successful
  148587. */
  148588. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  148589. /**
  148590. * Creates a new ImageAssetTask
  148591. * @param name defines the name of the task
  148592. * @param url defines the location of the image to load
  148593. */
  148594. constructor(
  148595. /**
  148596. * Defines the name of the task
  148597. */
  148598. name: string,
  148599. /**
  148600. * Defines the location of the image to load
  148601. */
  148602. url: string);
  148603. /**
  148604. * Execute the current task
  148605. * @param scene defines the scene where you want your assets to be loaded
  148606. * @param onSuccess is a callback called when the task is successfully executed
  148607. * @param onError is a callback called if an error occurs
  148608. */
  148609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148610. }
  148611. /**
  148612. * Defines the interface used by texture loading tasks
  148613. */
  148614. export interface ITextureAssetTask<TEX extends BaseTexture> {
  148615. /**
  148616. * Gets the loaded texture
  148617. */
  148618. texture: TEX;
  148619. }
  148620. /**
  148621. * Define a task used by AssetsManager to load 2D textures
  148622. */
  148623. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  148624. /**
  148625. * Defines the name of the task
  148626. */
  148627. name: string;
  148628. /**
  148629. * Defines the location of the file to load
  148630. */
  148631. url: string;
  148632. /**
  148633. * Defines if mipmap should not be generated (default is false)
  148634. */
  148635. noMipmap?: boolean | undefined;
  148636. /**
  148637. * Defines if texture must be inverted on Y axis (default is true)
  148638. */
  148639. invertY: boolean;
  148640. /**
  148641. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148642. */
  148643. samplingMode: number;
  148644. /**
  148645. * Gets the loaded texture
  148646. */
  148647. texture: Texture;
  148648. /**
  148649. * Callback called when the task is successful
  148650. */
  148651. onSuccess: (task: TextureAssetTask) => void;
  148652. /**
  148653. * Callback called when the task is successful
  148654. */
  148655. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  148656. /**
  148657. * Creates a new TextureAssetTask object
  148658. * @param name defines the name of the task
  148659. * @param url defines the location of the file to load
  148660. * @param noMipmap defines if mipmap should not be generated (default is false)
  148661. * @param invertY defines if texture must be inverted on Y axis (default is true)
  148662. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148663. */
  148664. constructor(
  148665. /**
  148666. * Defines the name of the task
  148667. */
  148668. name: string,
  148669. /**
  148670. * Defines the location of the file to load
  148671. */
  148672. url: string,
  148673. /**
  148674. * Defines if mipmap should not be generated (default is false)
  148675. */
  148676. noMipmap?: boolean | undefined,
  148677. /**
  148678. * Defines if texture must be inverted on Y axis (default is true)
  148679. */
  148680. invertY?: boolean,
  148681. /**
  148682. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148683. */
  148684. samplingMode?: number);
  148685. /**
  148686. * Execute the current task
  148687. * @param scene defines the scene where you want your assets to be loaded
  148688. * @param onSuccess is a callback called when the task is successfully executed
  148689. * @param onError is a callback called if an error occurs
  148690. */
  148691. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148692. }
  148693. /**
  148694. * Define a task used by AssetsManager to load cube textures
  148695. */
  148696. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  148697. /**
  148698. * Defines the name of the task
  148699. */
  148700. name: string;
  148701. /**
  148702. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148703. */
  148704. url: string;
  148705. /**
  148706. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148707. */
  148708. extensions?: string[] | undefined;
  148709. /**
  148710. * Defines if mipmaps should not be generated (default is false)
  148711. */
  148712. noMipmap?: boolean | undefined;
  148713. /**
  148714. * Defines the explicit list of files (undefined by default)
  148715. */
  148716. files?: string[] | undefined;
  148717. /**
  148718. * Gets the loaded texture
  148719. */
  148720. texture: CubeTexture;
  148721. /**
  148722. * Callback called when the task is successful
  148723. */
  148724. onSuccess: (task: CubeTextureAssetTask) => void;
  148725. /**
  148726. * Callback called when the task is successful
  148727. */
  148728. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  148729. /**
  148730. * Creates a new CubeTextureAssetTask
  148731. * @param name defines the name of the task
  148732. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148733. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148734. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148735. * @param files defines the explicit list of files (undefined by default)
  148736. */
  148737. constructor(
  148738. /**
  148739. * Defines the name of the task
  148740. */
  148741. name: string,
  148742. /**
  148743. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  148744. */
  148745. url: string,
  148746. /**
  148747. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  148748. */
  148749. extensions?: string[] | undefined,
  148750. /**
  148751. * Defines if mipmaps should not be generated (default is false)
  148752. */
  148753. noMipmap?: boolean | undefined,
  148754. /**
  148755. * Defines the explicit list of files (undefined by default)
  148756. */
  148757. files?: string[] | undefined);
  148758. /**
  148759. * Execute the current task
  148760. * @param scene defines the scene where you want your assets to be loaded
  148761. * @param onSuccess is a callback called when the task is successfully executed
  148762. * @param onError is a callback called if an error occurs
  148763. */
  148764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148765. }
  148766. /**
  148767. * Define a task used by AssetsManager to load HDR cube textures
  148768. */
  148769. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  148770. /**
  148771. * Defines the name of the task
  148772. */
  148773. name: string;
  148774. /**
  148775. * Defines the location of the file to load
  148776. */
  148777. url: string;
  148778. /**
  148779. * Defines the desired size (the more it increases the longer the generation will be)
  148780. */
  148781. size: number;
  148782. /**
  148783. * Defines if mipmaps should not be generated (default is false)
  148784. */
  148785. noMipmap: boolean;
  148786. /**
  148787. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148788. */
  148789. generateHarmonics: boolean;
  148790. /**
  148791. * 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)
  148792. */
  148793. gammaSpace: boolean;
  148794. /**
  148795. * Internal Use Only
  148796. */
  148797. reserved: boolean;
  148798. /**
  148799. * Gets the loaded texture
  148800. */
  148801. texture: HDRCubeTexture;
  148802. /**
  148803. * Callback called when the task is successful
  148804. */
  148805. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  148806. /**
  148807. * Callback called when the task is successful
  148808. */
  148809. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  148810. /**
  148811. * Creates a new HDRCubeTextureAssetTask object
  148812. * @param name defines the name of the task
  148813. * @param url defines the location of the file to load
  148814. * @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.
  148815. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148816. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148817. * @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)
  148818. * @param reserved Internal use only
  148819. */
  148820. constructor(
  148821. /**
  148822. * Defines the name of the task
  148823. */
  148824. name: string,
  148825. /**
  148826. * Defines the location of the file to load
  148827. */
  148828. url: string,
  148829. /**
  148830. * Defines the desired size (the more it increases the longer the generation will be)
  148831. */
  148832. size: number,
  148833. /**
  148834. * Defines if mipmaps should not be generated (default is false)
  148835. */
  148836. noMipmap?: boolean,
  148837. /**
  148838. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  148839. */
  148840. generateHarmonics?: boolean,
  148841. /**
  148842. * 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)
  148843. */
  148844. gammaSpace?: boolean,
  148845. /**
  148846. * Internal Use Only
  148847. */
  148848. reserved?: boolean);
  148849. /**
  148850. * Execute the current task
  148851. * @param scene defines the scene where you want your assets to be loaded
  148852. * @param onSuccess is a callback called when the task is successfully executed
  148853. * @param onError is a callback called if an error occurs
  148854. */
  148855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148856. }
  148857. /**
  148858. * Define a task used by AssetsManager to load Equirectangular cube textures
  148859. */
  148860. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  148861. /**
  148862. * Defines the name of the task
  148863. */
  148864. name: string;
  148865. /**
  148866. * Defines the location of the file to load
  148867. */
  148868. url: string;
  148869. /**
  148870. * Defines the desired size (the more it increases the longer the generation will be)
  148871. */
  148872. size: number;
  148873. /**
  148874. * Defines if mipmaps should not be generated (default is false)
  148875. */
  148876. noMipmap: boolean;
  148877. /**
  148878. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148879. * but the standard material would require them in Gamma space) (default is true)
  148880. */
  148881. gammaSpace: boolean;
  148882. /**
  148883. * Gets the loaded texture
  148884. */
  148885. texture: EquiRectangularCubeTexture;
  148886. /**
  148887. * Callback called when the task is successful
  148888. */
  148889. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  148890. /**
  148891. * Callback called when the task is successful
  148892. */
  148893. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  148894. /**
  148895. * Creates a new EquiRectangularCubeTextureAssetTask object
  148896. * @param name defines the name of the task
  148897. * @param url defines the location of the file to load
  148898. * @param size defines the desired size (the more it increases the longer the generation will be)
  148899. * If the size is omitted this implies you are using a preprocessed cubemap.
  148900. * @param noMipmap defines if mipmaps should not be generated (default is false)
  148901. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  148902. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  148903. * (default is true)
  148904. */
  148905. constructor(
  148906. /**
  148907. * Defines the name of the task
  148908. */
  148909. name: string,
  148910. /**
  148911. * Defines the location of the file to load
  148912. */
  148913. url: string,
  148914. /**
  148915. * Defines the desired size (the more it increases the longer the generation will be)
  148916. */
  148917. size: number,
  148918. /**
  148919. * Defines if mipmaps should not be generated (default is false)
  148920. */
  148921. noMipmap?: boolean,
  148922. /**
  148923. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  148924. * but the standard material would require them in Gamma space) (default is true)
  148925. */
  148926. gammaSpace?: boolean);
  148927. /**
  148928. * Execute the current task
  148929. * @param scene defines the scene where you want your assets to be loaded
  148930. * @param onSuccess is a callback called when the task is successfully executed
  148931. * @param onError is a callback called if an error occurs
  148932. */
  148933. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148934. }
  148935. /**
  148936. * This class can be used to easily import assets into a scene
  148937. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  148938. */
  148939. export class AssetsManager {
  148940. private _scene;
  148941. private _isLoading;
  148942. protected _tasks: AbstractAssetTask[];
  148943. protected _waitingTasksCount: number;
  148944. protected _totalTasksCount: number;
  148945. /**
  148946. * Callback called when all tasks are processed
  148947. */
  148948. onFinish: (tasks: AbstractAssetTask[]) => void;
  148949. /**
  148950. * Callback called when a task is successful
  148951. */
  148952. onTaskSuccess: (task: AbstractAssetTask) => void;
  148953. /**
  148954. * Callback called when a task had an error
  148955. */
  148956. onTaskError: (task: AbstractAssetTask) => void;
  148957. /**
  148958. * Callback called when a task is done (whatever the result is)
  148959. */
  148960. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  148961. /**
  148962. * Observable called when all tasks are processed
  148963. */
  148964. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  148965. /**
  148966. * Observable called when a task had an error
  148967. */
  148968. onTaskErrorObservable: Observable<AbstractAssetTask>;
  148969. /**
  148970. * Observable called when all tasks were executed
  148971. */
  148972. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  148973. /**
  148974. * Observable called when a task is done (whatever the result is)
  148975. */
  148976. onProgressObservable: Observable<IAssetsProgressEvent>;
  148977. /**
  148978. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  148979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  148980. */
  148981. useDefaultLoadingScreen: boolean;
  148982. /**
  148983. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  148984. * when all assets have been downloaded.
  148985. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  148986. */
  148987. autoHideLoadingUI: boolean;
  148988. /**
  148989. * Creates a new AssetsManager
  148990. * @param scene defines the scene to work on
  148991. */
  148992. constructor(scene: Scene);
  148993. /**
  148994. * Add a MeshAssetTask to the list of active tasks
  148995. * @param taskName defines the name of the new task
  148996. * @param meshesNames defines the name of meshes to load
  148997. * @param rootUrl defines the root url to use to locate files
  148998. * @param sceneFilename defines the filename of the scene file
  148999. * @returns a new MeshAssetTask object
  149000. */
  149001. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  149002. /**
  149003. * Add a TextFileAssetTask to the list of active tasks
  149004. * @param taskName defines the name of the new task
  149005. * @param url defines the url of the file to load
  149006. * @returns a new TextFileAssetTask object
  149007. */
  149008. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  149009. /**
  149010. * Add a BinaryFileAssetTask to the list of active tasks
  149011. * @param taskName defines the name of the new task
  149012. * @param url defines the url of the file to load
  149013. * @returns a new BinaryFileAssetTask object
  149014. */
  149015. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  149016. /**
  149017. * Add a ImageAssetTask to the list of active tasks
  149018. * @param taskName defines the name of the new task
  149019. * @param url defines the url of the file to load
  149020. * @returns a new ImageAssetTask object
  149021. */
  149022. addImageTask(taskName: string, url: string): ImageAssetTask;
  149023. /**
  149024. * Add a TextureAssetTask to the list of active tasks
  149025. * @param taskName defines the name of the new task
  149026. * @param url defines the url of the file to load
  149027. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149028. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  149029. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  149030. * @returns a new TextureAssetTask object
  149031. */
  149032. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  149033. /**
  149034. * Add a CubeTextureAssetTask to the list of active tasks
  149035. * @param taskName defines the name of the new task
  149036. * @param url defines the url of the file to load
  149037. * @param extensions defines the extension to use to load the cube map (can be null)
  149038. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149039. * @param files defines the list of files to load (can be null)
  149040. * @returns a new CubeTextureAssetTask object
  149041. */
  149042. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  149043. /**
  149044. *
  149045. * Add a HDRCubeTextureAssetTask to the list of active tasks
  149046. * @param taskName defines the name of the new task
  149047. * @param url defines the url of the file to load
  149048. * @param size defines the size you want for the cubemap (can be null)
  149049. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149050. * @param generateHarmonics defines if you want to automatically generate (true by default)
  149051. * @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)
  149052. * @param reserved Internal use only
  149053. * @returns a new HDRCubeTextureAssetTask object
  149054. */
  149055. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  149056. /**
  149057. *
  149058. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  149059. * @param taskName defines the name of the new task
  149060. * @param url defines the url of the file to load
  149061. * @param size defines the size you want for the cubemap (can be null)
  149062. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149063. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  149064. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  149065. * @returns a new EquiRectangularCubeTextureAssetTask object
  149066. */
  149067. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  149068. /**
  149069. * Remove a task from the assets manager.
  149070. * @param task the task to remove
  149071. */
  149072. removeTask(task: AbstractAssetTask): void;
  149073. private _decreaseWaitingTasksCount;
  149074. private _runTask;
  149075. /**
  149076. * Reset the AssetsManager and remove all tasks
  149077. * @return the current instance of the AssetsManager
  149078. */
  149079. reset(): AssetsManager;
  149080. /**
  149081. * Start the loading process
  149082. * @return the current instance of the AssetsManager
  149083. */
  149084. load(): AssetsManager;
  149085. /**
  149086. * Start the loading process as an async operation
  149087. * @return a promise returning the list of failed tasks
  149088. */
  149089. loadAsync(): Promise<void>;
  149090. }
  149091. }
  149092. declare module BABYLON {
  149093. /**
  149094. * Wrapper class for promise with external resolve and reject.
  149095. */
  149096. export class Deferred<T> {
  149097. /**
  149098. * The promise associated with this deferred object.
  149099. */
  149100. readonly promise: Promise<T>;
  149101. private _resolve;
  149102. private _reject;
  149103. /**
  149104. * The resolve method of the promise associated with this deferred object.
  149105. */
  149106. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  149107. /**
  149108. * The reject method of the promise associated with this deferred object.
  149109. */
  149110. get reject(): (reason?: any) => void;
  149111. /**
  149112. * Constructor for this deferred object.
  149113. */
  149114. constructor();
  149115. }
  149116. }
  149117. declare module BABYLON {
  149118. /**
  149119. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  149120. */
  149121. export class MeshExploder {
  149122. private _centerMesh;
  149123. private _meshes;
  149124. private _meshesOrigins;
  149125. private _toCenterVectors;
  149126. private _scaledDirection;
  149127. private _newPosition;
  149128. private _centerPosition;
  149129. /**
  149130. * Explodes meshes from a center mesh.
  149131. * @param meshes The meshes to explode.
  149132. * @param centerMesh The mesh to be center of explosion.
  149133. */
  149134. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  149135. private _setCenterMesh;
  149136. /**
  149137. * Get class name
  149138. * @returns "MeshExploder"
  149139. */
  149140. getClassName(): string;
  149141. /**
  149142. * "Exploded meshes"
  149143. * @returns Array of meshes with the centerMesh at index 0.
  149144. */
  149145. getMeshes(): Array<Mesh>;
  149146. /**
  149147. * Explodes meshes giving a specific direction
  149148. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  149149. */
  149150. explode(direction?: number): void;
  149151. }
  149152. }
  149153. declare module BABYLON {
  149154. /**
  149155. * Class used to help managing file picking and drag'n'drop
  149156. */
  149157. export class FilesInput {
  149158. /**
  149159. * List of files ready to be loaded
  149160. */
  149161. static get FilesToLoad(): {
  149162. [key: string]: File;
  149163. };
  149164. /**
  149165. * Callback called when a file is processed
  149166. */
  149167. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  149168. private _engine;
  149169. private _currentScene;
  149170. private _sceneLoadedCallback;
  149171. private _progressCallback;
  149172. private _additionalRenderLoopLogicCallback;
  149173. private _textureLoadingCallback;
  149174. private _startingProcessingFilesCallback;
  149175. private _onReloadCallback;
  149176. private _errorCallback;
  149177. private _elementToMonitor;
  149178. private _sceneFileToLoad;
  149179. private _filesToLoad;
  149180. /**
  149181. * Creates a new FilesInput
  149182. * @param engine defines the rendering engine
  149183. * @param scene defines the hosting scene
  149184. * @param sceneLoadedCallback callback called when scene is loaded
  149185. * @param progressCallback callback called to track progress
  149186. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  149187. * @param textureLoadingCallback callback called when a texture is loading
  149188. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  149189. * @param onReloadCallback callback called when a reload is requested
  149190. * @param errorCallback callback call if an error occurs
  149191. */
  149192. 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);
  149193. private _dragEnterHandler;
  149194. private _dragOverHandler;
  149195. private _dropHandler;
  149196. /**
  149197. * Calls this function to listen to drag'n'drop events on a specific DOM element
  149198. * @param elementToMonitor defines the DOM element to track
  149199. */
  149200. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  149201. /**
  149202. * Release all associated resources
  149203. */
  149204. dispose(): void;
  149205. private renderFunction;
  149206. private drag;
  149207. private drop;
  149208. private _traverseFolder;
  149209. private _processFiles;
  149210. /**
  149211. * Load files from a drop event
  149212. * @param event defines the drop event to use as source
  149213. */
  149214. loadFiles(event: any): void;
  149215. private _processReload;
  149216. /**
  149217. * Reload the current scene from the loaded files
  149218. */
  149219. reload(): void;
  149220. }
  149221. }
  149222. declare module BABYLON {
  149223. /**
  149224. * Defines the root class used to create scene optimization to use with SceneOptimizer
  149225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149226. */
  149227. export class SceneOptimization {
  149228. /**
  149229. * Defines the priority of this optimization (0 by default which means first in the list)
  149230. */
  149231. priority: number;
  149232. /**
  149233. * Gets a string describing the action executed by the current optimization
  149234. * @returns description string
  149235. */
  149236. getDescription(): string;
  149237. /**
  149238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149239. * @param scene defines the current scene where to apply this optimization
  149240. * @param optimizer defines the current optimizer
  149241. * @returns true if everything that can be done was applied
  149242. */
  149243. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149244. /**
  149245. * Creates the SceneOptimization object
  149246. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149247. * @param desc defines the description associated with the optimization
  149248. */
  149249. constructor(
  149250. /**
  149251. * Defines the priority of this optimization (0 by default which means first in the list)
  149252. */
  149253. priority?: number);
  149254. }
  149255. /**
  149256. * Defines an optimization used to reduce the size of render target textures
  149257. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149258. */
  149259. export class TextureOptimization extends SceneOptimization {
  149260. /**
  149261. * Defines the priority of this optimization (0 by default which means first in the list)
  149262. */
  149263. priority: number;
  149264. /**
  149265. * 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
  149266. */
  149267. maximumSize: number;
  149268. /**
  149269. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149270. */
  149271. step: number;
  149272. /**
  149273. * Gets a string describing the action executed by the current optimization
  149274. * @returns description string
  149275. */
  149276. getDescription(): string;
  149277. /**
  149278. * Creates the TextureOptimization object
  149279. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149280. * @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
  149281. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149282. */
  149283. constructor(
  149284. /**
  149285. * Defines the priority of this optimization (0 by default which means first in the list)
  149286. */
  149287. priority?: number,
  149288. /**
  149289. * 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
  149290. */
  149291. maximumSize?: number,
  149292. /**
  149293. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149294. */
  149295. step?: number);
  149296. /**
  149297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149298. * @param scene defines the current scene where to apply this optimization
  149299. * @param optimizer defines the current optimizer
  149300. * @returns true if everything that can be done was applied
  149301. */
  149302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149303. }
  149304. /**
  149305. * Defines an optimization used to increase or decrease the rendering resolution
  149306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149307. */
  149308. export class HardwareScalingOptimization extends SceneOptimization {
  149309. /**
  149310. * Defines the priority of this optimization (0 by default which means first in the list)
  149311. */
  149312. priority: number;
  149313. /**
  149314. * Defines the maximum scale to use (2 by default)
  149315. */
  149316. maximumScale: number;
  149317. /**
  149318. * Defines the step to use between two passes (0.5 by default)
  149319. */
  149320. step: number;
  149321. private _currentScale;
  149322. private _directionOffset;
  149323. /**
  149324. * Gets a string describing the action executed by the current optimization
  149325. * @return description string
  149326. */
  149327. getDescription(): string;
  149328. /**
  149329. * Creates the HardwareScalingOptimization object
  149330. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149331. * @param maximumScale defines the maximum scale to use (2 by default)
  149332. * @param step defines the step to use between two passes (0.5 by default)
  149333. */
  149334. constructor(
  149335. /**
  149336. * Defines the priority of this optimization (0 by default which means first in the list)
  149337. */
  149338. priority?: number,
  149339. /**
  149340. * Defines the maximum scale to use (2 by default)
  149341. */
  149342. maximumScale?: number,
  149343. /**
  149344. * Defines the step to use between two passes (0.5 by default)
  149345. */
  149346. step?: number);
  149347. /**
  149348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149349. * @param scene defines the current scene where to apply this optimization
  149350. * @param optimizer defines the current optimizer
  149351. * @returns true if everything that can be done was applied
  149352. */
  149353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149354. }
  149355. /**
  149356. * Defines an optimization used to remove shadows
  149357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149358. */
  149359. export class ShadowsOptimization extends SceneOptimization {
  149360. /**
  149361. * Gets a string describing the action executed by the current optimization
  149362. * @return description string
  149363. */
  149364. getDescription(): string;
  149365. /**
  149366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149367. * @param scene defines the current scene where to apply this optimization
  149368. * @param optimizer defines the current optimizer
  149369. * @returns true if everything that can be done was applied
  149370. */
  149371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149372. }
  149373. /**
  149374. * Defines an optimization used to turn post-processes off
  149375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149376. */
  149377. export class PostProcessesOptimization extends SceneOptimization {
  149378. /**
  149379. * Gets a string describing the action executed by the current optimization
  149380. * @return description string
  149381. */
  149382. getDescription(): string;
  149383. /**
  149384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149385. * @param scene defines the current scene where to apply this optimization
  149386. * @param optimizer defines the current optimizer
  149387. * @returns true if everything that can be done was applied
  149388. */
  149389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149390. }
  149391. /**
  149392. * Defines an optimization used to turn lens flares off
  149393. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149394. */
  149395. export class LensFlaresOptimization extends SceneOptimization {
  149396. /**
  149397. * Gets a string describing the action executed by the current optimization
  149398. * @return description string
  149399. */
  149400. getDescription(): string;
  149401. /**
  149402. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149403. * @param scene defines the current scene where to apply this optimization
  149404. * @param optimizer defines the current optimizer
  149405. * @returns true if everything that can be done was applied
  149406. */
  149407. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149408. }
  149409. /**
  149410. * Defines an optimization based on user defined callback.
  149411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149412. */
  149413. export class CustomOptimization extends SceneOptimization {
  149414. /**
  149415. * Callback called to apply the custom optimization.
  149416. */
  149417. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  149418. /**
  149419. * Callback called to get custom description
  149420. */
  149421. onGetDescription: () => string;
  149422. /**
  149423. * Gets a string describing the action executed by the current optimization
  149424. * @returns description string
  149425. */
  149426. getDescription(): string;
  149427. /**
  149428. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149429. * @param scene defines the current scene where to apply this optimization
  149430. * @param optimizer defines the current optimizer
  149431. * @returns true if everything that can be done was applied
  149432. */
  149433. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149434. }
  149435. /**
  149436. * Defines an optimization used to turn particles off
  149437. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149438. */
  149439. export class ParticlesOptimization extends SceneOptimization {
  149440. /**
  149441. * Gets a string describing the action executed by the current optimization
  149442. * @return description string
  149443. */
  149444. getDescription(): string;
  149445. /**
  149446. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149447. * @param scene defines the current scene where to apply this optimization
  149448. * @param optimizer defines the current optimizer
  149449. * @returns true if everything that can be done was applied
  149450. */
  149451. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149452. }
  149453. /**
  149454. * Defines an optimization used to turn render targets off
  149455. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149456. */
  149457. export class RenderTargetsOptimization extends SceneOptimization {
  149458. /**
  149459. * Gets a string describing the action executed by the current optimization
  149460. * @return description string
  149461. */
  149462. getDescription(): string;
  149463. /**
  149464. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149465. * @param scene defines the current scene where to apply this optimization
  149466. * @param optimizer defines the current optimizer
  149467. * @returns true if everything that can be done was applied
  149468. */
  149469. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149470. }
  149471. /**
  149472. * Defines an optimization used to merge meshes with compatible materials
  149473. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149474. */
  149475. export class MergeMeshesOptimization extends SceneOptimization {
  149476. private static _UpdateSelectionTree;
  149477. /**
  149478. * Gets or sets a boolean which defines if optimization octree has to be updated
  149479. */
  149480. static get UpdateSelectionTree(): boolean;
  149481. /**
  149482. * Gets or sets a boolean which defines if optimization octree has to be updated
  149483. */
  149484. static set UpdateSelectionTree(value: boolean);
  149485. /**
  149486. * Gets a string describing the action executed by the current optimization
  149487. * @return description string
  149488. */
  149489. getDescription(): string;
  149490. private _canBeMerged;
  149491. /**
  149492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149493. * @param scene defines the current scene where to apply this optimization
  149494. * @param optimizer defines the current optimizer
  149495. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  149496. * @returns true if everything that can be done was applied
  149497. */
  149498. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  149499. }
  149500. /**
  149501. * Defines a list of options used by SceneOptimizer
  149502. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149503. */
  149504. export class SceneOptimizerOptions {
  149505. /**
  149506. * Defines the target frame rate to reach (60 by default)
  149507. */
  149508. targetFrameRate: number;
  149509. /**
  149510. * Defines the interval between two checkes (2000ms by default)
  149511. */
  149512. trackerDuration: number;
  149513. /**
  149514. * Gets the list of optimizations to apply
  149515. */
  149516. optimizations: SceneOptimization[];
  149517. /**
  149518. * Creates a new list of options used by SceneOptimizer
  149519. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  149520. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  149521. */
  149522. constructor(
  149523. /**
  149524. * Defines the target frame rate to reach (60 by default)
  149525. */
  149526. targetFrameRate?: number,
  149527. /**
  149528. * Defines the interval between two checkes (2000ms by default)
  149529. */
  149530. trackerDuration?: number);
  149531. /**
  149532. * Add a new optimization
  149533. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  149534. * @returns the current SceneOptimizerOptions
  149535. */
  149536. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  149537. /**
  149538. * Add a new custom optimization
  149539. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  149540. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  149541. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149542. * @returns the current SceneOptimizerOptions
  149543. */
  149544. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  149545. /**
  149546. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  149547. * @param targetFrameRate defines the target frame rate (60 by default)
  149548. * @returns a SceneOptimizerOptions object
  149549. */
  149550. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149551. /**
  149552. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  149553. * @param targetFrameRate defines the target frame rate (60 by default)
  149554. * @returns a SceneOptimizerOptions object
  149555. */
  149556. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149557. /**
  149558. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  149559. * @param targetFrameRate defines the target frame rate (60 by default)
  149560. * @returns a SceneOptimizerOptions object
  149561. */
  149562. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149563. }
  149564. /**
  149565. * Class used to run optimizations in order to reach a target frame rate
  149566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149567. */
  149568. export class SceneOptimizer implements IDisposable {
  149569. private _isRunning;
  149570. private _options;
  149571. private _scene;
  149572. private _currentPriorityLevel;
  149573. private _targetFrameRate;
  149574. private _trackerDuration;
  149575. private _currentFrameRate;
  149576. private _sceneDisposeObserver;
  149577. private _improvementMode;
  149578. /**
  149579. * Defines an observable called when the optimizer reaches the target frame rate
  149580. */
  149581. onSuccessObservable: Observable<SceneOptimizer>;
  149582. /**
  149583. * Defines an observable called when the optimizer enables an optimization
  149584. */
  149585. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  149586. /**
  149587. * Defines an observable called when the optimizer is not able to reach the target frame rate
  149588. */
  149589. onFailureObservable: Observable<SceneOptimizer>;
  149590. /**
  149591. * Gets a boolean indicating if the optimizer is in improvement mode
  149592. */
  149593. get isInImprovementMode(): boolean;
  149594. /**
  149595. * Gets the current priority level (0 at start)
  149596. */
  149597. get currentPriorityLevel(): number;
  149598. /**
  149599. * Gets the current frame rate checked by the SceneOptimizer
  149600. */
  149601. get currentFrameRate(): number;
  149602. /**
  149603. * Gets or sets the current target frame rate (60 by default)
  149604. */
  149605. get targetFrameRate(): number;
  149606. /**
  149607. * Gets or sets the current target frame rate (60 by default)
  149608. */
  149609. set targetFrameRate(value: number);
  149610. /**
  149611. * Gets or sets the current interval between two checks (every 2000ms by default)
  149612. */
  149613. get trackerDuration(): number;
  149614. /**
  149615. * Gets or sets the current interval between two checks (every 2000ms by default)
  149616. */
  149617. set trackerDuration(value: number);
  149618. /**
  149619. * Gets the list of active optimizations
  149620. */
  149621. get optimizations(): SceneOptimization[];
  149622. /**
  149623. * Creates a new SceneOptimizer
  149624. * @param scene defines the scene to work on
  149625. * @param options defines the options to use with the SceneOptimizer
  149626. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  149627. * @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)
  149628. */
  149629. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  149630. /**
  149631. * Stops the current optimizer
  149632. */
  149633. stop(): void;
  149634. /**
  149635. * Reset the optimizer to initial step (current priority level = 0)
  149636. */
  149637. reset(): void;
  149638. /**
  149639. * Start the optimizer. By default it will try to reach a specific framerate
  149640. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  149641. */
  149642. start(): void;
  149643. private _checkCurrentState;
  149644. /**
  149645. * Release all resources
  149646. */
  149647. dispose(): void;
  149648. /**
  149649. * Helper function to create a SceneOptimizer with one single line of code
  149650. * @param scene defines the scene to work on
  149651. * @param options defines the options to use with the SceneOptimizer
  149652. * @param onSuccess defines a callback to call on success
  149653. * @param onFailure defines a callback to call on failure
  149654. * @returns the new SceneOptimizer object
  149655. */
  149656. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  149657. }
  149658. }
  149659. declare module BABYLON {
  149660. /**
  149661. * Class used to serialize a scene into a string
  149662. */
  149663. export class SceneSerializer {
  149664. /**
  149665. * Clear cache used by a previous serialization
  149666. */
  149667. static ClearCache(): void;
  149668. /**
  149669. * Serialize a scene into a JSON compatible object
  149670. * @param scene defines the scene to serialize
  149671. * @returns a JSON compatible object
  149672. */
  149673. static Serialize(scene: Scene): any;
  149674. /**
  149675. * Serialize a mesh into a JSON compatible object
  149676. * @param toSerialize defines the mesh to serialize
  149677. * @param withParents defines if parents must be serialized as well
  149678. * @param withChildren defines if children must be serialized as well
  149679. * @returns a JSON compatible object
  149680. */
  149681. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  149682. }
  149683. }
  149684. declare module BABYLON {
  149685. /**
  149686. * Class used to host texture specific utilities
  149687. */
  149688. export class TextureTools {
  149689. /**
  149690. * Uses the GPU to create a copy texture rescaled at a given size
  149691. * @param texture Texture to copy from
  149692. * @param width defines the desired width
  149693. * @param height defines the desired height
  149694. * @param useBilinearMode defines if bilinear mode has to be used
  149695. * @return the generated texture
  149696. */
  149697. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  149698. }
  149699. }
  149700. declare module BABYLON {
  149701. /**
  149702. * This represents the different options available for the video capture.
  149703. */
  149704. export interface VideoRecorderOptions {
  149705. /** Defines the mime type of the video. */
  149706. mimeType: string;
  149707. /** Defines the FPS the video should be recorded at. */
  149708. fps: number;
  149709. /** Defines the chunk size for the recording data. */
  149710. recordChunckSize: number;
  149711. /** The audio tracks to attach to the recording. */
  149712. audioTracks?: MediaStreamTrack[];
  149713. }
  149714. /**
  149715. * This can help with recording videos from BabylonJS.
  149716. * This is based on the available WebRTC functionalities of the browser.
  149717. *
  149718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  149719. */
  149720. export class VideoRecorder {
  149721. private static readonly _defaultOptions;
  149722. /**
  149723. * Returns whether or not the VideoRecorder is available in your browser.
  149724. * @param engine Defines the Babylon Engine.
  149725. * @returns true if supported otherwise false.
  149726. */
  149727. static IsSupported(engine: Engine): boolean;
  149728. private readonly _options;
  149729. private _canvas;
  149730. private _mediaRecorder;
  149731. private _recordedChunks;
  149732. private _fileName;
  149733. private _resolve;
  149734. private _reject;
  149735. /**
  149736. * True when a recording is already in progress.
  149737. */
  149738. get isRecording(): boolean;
  149739. /**
  149740. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  149741. * @param engine Defines the BabylonJS Engine you wish to record.
  149742. * @param options Defines options that can be used to customize the capture.
  149743. */
  149744. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  149745. /**
  149746. * Stops the current recording before the default capture timeout passed in the startRecording function.
  149747. */
  149748. stopRecording(): void;
  149749. /**
  149750. * Starts recording the canvas for a max duration specified in parameters.
  149751. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  149752. * If null no automatic download will start and you can rely on the promise to get the data back.
  149753. * @param maxDuration Defines the maximum recording time in seconds.
  149754. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  149755. * @return A promise callback at the end of the recording with the video data in Blob.
  149756. */
  149757. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  149758. /**
  149759. * Releases internal resources used during the recording.
  149760. */
  149761. dispose(): void;
  149762. private _handleDataAvailable;
  149763. private _handleError;
  149764. private _handleStop;
  149765. }
  149766. }
  149767. declare module BABYLON {
  149768. /**
  149769. * Class containing a set of static utilities functions for screenshots
  149770. */
  149771. export class ScreenshotTools {
  149772. /**
  149773. * Captures a screenshot of the current rendering
  149774. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149775. * @param engine defines the rendering engine
  149776. * @param camera defines the source camera
  149777. * @param size This parameter can be set to a single number or to an object with the
  149778. * following (optional) properties: precision, width, height. If a single number is passed,
  149779. * it will be used for both width and height. If an object is passed, the screenshot size
  149780. * will be derived from the parameters. The precision property is a multiplier allowing
  149781. * rendering at a higher or lower resolution
  149782. * @param successCallback defines the callback receives a single parameter which contains the
  149783. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149784. * src parameter of an <img> to display it
  149785. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149786. * Check your browser for supported MIME types
  149787. */
  149788. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  149789. /**
  149790. * Captures a screenshot of the current rendering
  149791. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149792. * @param engine defines the rendering engine
  149793. * @param camera defines the source camera
  149794. * @param size This parameter can be set to a single number or to an object with the
  149795. * following (optional) properties: precision, width, height. If a single number is passed,
  149796. * it will be used for both width and height. If an object is passed, the screenshot size
  149797. * will be derived from the parameters. The precision property is a multiplier allowing
  149798. * rendering at a higher or lower resolution
  149799. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  149800. * Check your browser for supported MIME types
  149801. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149802. * to the src parameter of an <img> to display it
  149803. */
  149804. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  149805. /**
  149806. * Generates an image screenshot from the specified camera.
  149807. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149808. * @param engine The engine to use for rendering
  149809. * @param camera The camera to use for rendering
  149810. * @param size This parameter can be set to a single number or to an object with the
  149811. * following (optional) properties: precision, width, height. If a single number is passed,
  149812. * it will be used for both width and height. If an object is passed, the screenshot size
  149813. * will be derived from the parameters. The precision property is a multiplier allowing
  149814. * rendering at a higher or lower resolution
  149815. * @param successCallback The callback receives a single parameter which contains the
  149816. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  149817. * src parameter of an <img> to display it
  149818. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149819. * Check your browser for supported MIME types
  149820. * @param samples Texture samples (default: 1)
  149821. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149822. * @param fileName A name for for the downloaded file.
  149823. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149824. */
  149825. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  149826. /**
  149827. * Generates an image screenshot from the specified camera.
  149828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  149829. * @param engine The engine to use for rendering
  149830. * @param camera The camera to use for rendering
  149831. * @param size This parameter can be set to a single number or to an object with the
  149832. * following (optional) properties: precision, width, height. If a single number is passed,
  149833. * it will be used for both width and height. If an object is passed, the screenshot size
  149834. * will be derived from the parameters. The precision property is a multiplier allowing
  149835. * rendering at a higher or lower resolution
  149836. * @param mimeType The MIME type of the screenshot image (default: image/png).
  149837. * Check your browser for supported MIME types
  149838. * @param samples Texture samples (default: 1)
  149839. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  149840. * @param fileName A name for for the downloaded file.
  149841. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  149842. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  149843. * to the src parameter of an <img> to display it
  149844. */
  149845. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  149846. /**
  149847. * Gets height and width for screenshot size
  149848. * @private
  149849. */
  149850. private static _getScreenshotSize;
  149851. }
  149852. }
  149853. declare module BABYLON {
  149854. /**
  149855. * Interface for a data buffer
  149856. */
  149857. export interface IDataBuffer {
  149858. /**
  149859. * Reads bytes from the data buffer.
  149860. * @param byteOffset The byte offset to read
  149861. * @param byteLength The byte length to read
  149862. * @returns A promise that resolves when the bytes are read
  149863. */
  149864. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  149865. /**
  149866. * The byte length of the buffer.
  149867. */
  149868. readonly byteLength: number;
  149869. }
  149870. /**
  149871. * Utility class for reading from a data buffer
  149872. */
  149873. export class DataReader {
  149874. /**
  149875. * The data buffer associated with this data reader.
  149876. */
  149877. readonly buffer: IDataBuffer;
  149878. /**
  149879. * The current byte offset from the beginning of the data buffer.
  149880. */
  149881. byteOffset: number;
  149882. private _dataView;
  149883. private _dataByteOffset;
  149884. /**
  149885. * Constructor
  149886. * @param buffer The buffer to read
  149887. */
  149888. constructor(buffer: IDataBuffer);
  149889. /**
  149890. * Loads the given byte length.
  149891. * @param byteLength The byte length to load
  149892. * @returns A promise that resolves when the load is complete
  149893. */
  149894. loadAsync(byteLength: number): Promise<void>;
  149895. /**
  149896. * Read a unsigned 32-bit integer from the currently loaded data range.
  149897. * @returns The 32-bit integer read
  149898. */
  149899. readUint32(): number;
  149900. /**
  149901. * Read a byte array from the currently loaded data range.
  149902. * @param byteLength The byte length to read
  149903. * @returns The byte array read
  149904. */
  149905. readUint8Array(byteLength: number): Uint8Array;
  149906. /**
  149907. * Read a string from the currently loaded data range.
  149908. * @param byteLength The byte length to read
  149909. * @returns The string read
  149910. */
  149911. readString(byteLength: number): string;
  149912. /**
  149913. * Skips the given byte length the currently loaded data range.
  149914. * @param byteLength The byte length to skip
  149915. */
  149916. skipBytes(byteLength: number): void;
  149917. }
  149918. }
  149919. declare module BABYLON {
  149920. /**
  149921. * Class for storing data to local storage if available or in-memory storage otherwise
  149922. */
  149923. export class DataStorage {
  149924. private static _Storage;
  149925. private static _GetStorage;
  149926. /**
  149927. * Reads a string from the data storage
  149928. * @param key The key to read
  149929. * @param defaultValue The value if the key doesn't exist
  149930. * @returns The string value
  149931. */
  149932. static ReadString(key: string, defaultValue: string): string;
  149933. /**
  149934. * Writes a string to the data storage
  149935. * @param key The key to write
  149936. * @param value The value to write
  149937. */
  149938. static WriteString(key: string, value: string): void;
  149939. /**
  149940. * Reads a boolean from the data storage
  149941. * @param key The key to read
  149942. * @param defaultValue The value if the key doesn't exist
  149943. * @returns The boolean value
  149944. */
  149945. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  149946. /**
  149947. * Writes a boolean to the data storage
  149948. * @param key The key to write
  149949. * @param value The value to write
  149950. */
  149951. static WriteBoolean(key: string, value: boolean): void;
  149952. /**
  149953. * Reads a number from the data storage
  149954. * @param key The key to read
  149955. * @param defaultValue The value if the key doesn't exist
  149956. * @returns The number value
  149957. */
  149958. static ReadNumber(key: string, defaultValue: number): number;
  149959. /**
  149960. * Writes a number to the data storage
  149961. * @param key The key to write
  149962. * @param value The value to write
  149963. */
  149964. static WriteNumber(key: string, value: number): void;
  149965. }
  149966. }
  149967. declare module BABYLON {
  149968. /**
  149969. * An interface for all Hit test features
  149970. */
  149971. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  149972. /**
  149973. * Triggered when new babylon (transformed) hit test results are available
  149974. */
  149975. onHitTestResultObservable: Observable<T[]>;
  149976. }
  149977. /**
  149978. * Options used for hit testing
  149979. */
  149980. export interface IWebXRLegacyHitTestOptions {
  149981. /**
  149982. * Only test when user interacted with the scene. Default - hit test every frame
  149983. */
  149984. testOnPointerDownOnly?: boolean;
  149985. /**
  149986. * The node to use to transform the local results to world coordinates
  149987. */
  149988. worldParentNode?: TransformNode;
  149989. }
  149990. /**
  149991. * Interface defining the babylon result of raycasting/hit-test
  149992. */
  149993. export interface IWebXRLegacyHitResult {
  149994. /**
  149995. * Transformation matrix that can be applied to a node that will put it in the hit point location
  149996. */
  149997. transformationMatrix: Matrix;
  149998. /**
  149999. * The native hit test result
  150000. */
  150001. xrHitResult: XRHitResult | XRHitTestResult;
  150002. }
  150003. /**
  150004. * The currently-working hit-test module.
  150005. * Hit test (or Ray-casting) is used to interact with the real world.
  150006. * For further information read here - https://github.com/immersive-web/hit-test
  150007. */
  150008. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  150009. /**
  150010. * options to use when constructing this feature
  150011. */
  150012. readonly options: IWebXRLegacyHitTestOptions;
  150013. private _direction;
  150014. private _mat;
  150015. private _onSelectEnabled;
  150016. private _origin;
  150017. /**
  150018. * The module's name
  150019. */
  150020. static readonly Name: string;
  150021. /**
  150022. * The (Babylon) version of this module.
  150023. * This is an integer representing the implementation version.
  150024. * This number does not correspond to the WebXR specs version
  150025. */
  150026. static readonly Version: number;
  150027. /**
  150028. * Populated with the last native XR Hit Results
  150029. */
  150030. lastNativeXRHitResults: XRHitResult[];
  150031. /**
  150032. * Triggered when new babylon (transformed) hit test results are available
  150033. */
  150034. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  150035. /**
  150036. * Creates a new instance of the (legacy version) hit test feature
  150037. * @param _xrSessionManager an instance of WebXRSessionManager
  150038. * @param options options to use when constructing this feature
  150039. */
  150040. constructor(_xrSessionManager: WebXRSessionManager,
  150041. /**
  150042. * options to use when constructing this feature
  150043. */
  150044. options?: IWebXRLegacyHitTestOptions);
  150045. /**
  150046. * execute a hit test with an XR Ray
  150047. *
  150048. * @param xrSession a native xrSession that will execute this hit test
  150049. * @param xrRay the ray (position and direction) to use for ray-casting
  150050. * @param referenceSpace native XR reference space to use for the hit-test
  150051. * @param filter filter function that will filter the results
  150052. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150053. */
  150054. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  150055. /**
  150056. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  150057. * @param event the (select) event to use to select with
  150058. * @param referenceSpace the reference space to use for this hit test
  150059. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150060. */
  150061. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150062. /**
  150063. * attach this feature
  150064. * Will usually be called by the features manager
  150065. *
  150066. * @returns true if successful.
  150067. */
  150068. attach(): boolean;
  150069. /**
  150070. * detach this feature.
  150071. * Will usually be called by the features manager
  150072. *
  150073. * @returns true if successful.
  150074. */
  150075. detach(): boolean;
  150076. /**
  150077. * Dispose this feature and all of the resources attached
  150078. */
  150079. dispose(): void;
  150080. protected _onXRFrame(frame: XRFrame): void;
  150081. private _onHitTestResults;
  150082. private _onSelect;
  150083. }
  150084. }
  150085. declare module BABYLON {
  150086. /**
  150087. * Options used for hit testing (version 2)
  150088. */
  150089. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  150090. /**
  150091. * Do not create a permanent hit test. Will usually be used when only
  150092. * transient inputs are needed.
  150093. */
  150094. disablePermanentHitTest?: boolean;
  150095. /**
  150096. * Enable transient (for example touch-based) hit test inspections
  150097. */
  150098. enableTransientHitTest?: boolean;
  150099. /**
  150100. * Offset ray for the permanent hit test
  150101. */
  150102. offsetRay?: Vector3;
  150103. /**
  150104. * Offset ray for the transient hit test
  150105. */
  150106. transientOffsetRay?: Vector3;
  150107. /**
  150108. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  150109. */
  150110. useReferenceSpace?: boolean;
  150111. }
  150112. /**
  150113. * Interface defining the babylon result of hit-test
  150114. */
  150115. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  150116. /**
  150117. * The input source that generated this hit test (if transient)
  150118. */
  150119. inputSource?: XRInputSource;
  150120. /**
  150121. * Is this a transient hit test
  150122. */
  150123. isTransient?: boolean;
  150124. /**
  150125. * Position of the hit test result
  150126. */
  150127. position: Vector3;
  150128. /**
  150129. * Rotation of the hit test result
  150130. */
  150131. rotationQuaternion: Quaternion;
  150132. /**
  150133. * The native hit test result
  150134. */
  150135. xrHitResult: XRHitTestResult;
  150136. }
  150137. /**
  150138. * The currently-working hit-test module.
  150139. * Hit test (or Ray-casting) is used to interact with the real world.
  150140. * For further information read here - https://github.com/immersive-web/hit-test
  150141. *
  150142. * Tested on chrome (mobile) 80.
  150143. */
  150144. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  150145. /**
  150146. * options to use when constructing this feature
  150147. */
  150148. readonly options: IWebXRHitTestOptions;
  150149. private _tmpMat;
  150150. private _tmpPos;
  150151. private _tmpQuat;
  150152. private _transientXrHitTestSource;
  150153. private _xrHitTestSource;
  150154. private initHitTestSource;
  150155. /**
  150156. * The module's name
  150157. */
  150158. static readonly Name: string;
  150159. /**
  150160. * The (Babylon) version of this module.
  150161. * This is an integer representing the implementation version.
  150162. * This number does not correspond to the WebXR specs version
  150163. */
  150164. static readonly Version: number;
  150165. /**
  150166. * When set to true, each hit test will have its own position/rotation objects
  150167. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  150168. * the developers will clone them or copy them as they see fit.
  150169. */
  150170. autoCloneTransformation: boolean;
  150171. /**
  150172. * Triggered when new babylon (transformed) hit test results are available
  150173. */
  150174. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  150175. /**
  150176. * Use this to temporarily pause hit test checks.
  150177. */
  150178. paused: boolean;
  150179. /**
  150180. * Creates a new instance of the hit test feature
  150181. * @param _xrSessionManager an instance of WebXRSessionManager
  150182. * @param options options to use when constructing this feature
  150183. */
  150184. constructor(_xrSessionManager: WebXRSessionManager,
  150185. /**
  150186. * options to use when constructing this feature
  150187. */
  150188. options?: IWebXRHitTestOptions);
  150189. /**
  150190. * attach this feature
  150191. * Will usually be called by the features manager
  150192. *
  150193. * @returns true if successful.
  150194. */
  150195. attach(): boolean;
  150196. /**
  150197. * detach this feature.
  150198. * Will usually be called by the features manager
  150199. *
  150200. * @returns true if successful.
  150201. */
  150202. detach(): boolean;
  150203. /**
  150204. * Dispose this feature and all of the resources attached
  150205. */
  150206. dispose(): void;
  150207. protected _onXRFrame(frame: XRFrame): void;
  150208. private _processWebXRHitTestResult;
  150209. }
  150210. }
  150211. declare module BABYLON {
  150212. /**
  150213. * Configuration options of the anchor system
  150214. */
  150215. export interface IWebXRAnchorSystemOptions {
  150216. /**
  150217. * a node that will be used to convert local to world coordinates
  150218. */
  150219. worldParentNode?: TransformNode;
  150220. /**
  150221. * If set to true a reference of the created anchors will be kept until the next session starts
  150222. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  150223. */
  150224. doNotRemoveAnchorsOnSessionEnded?: boolean;
  150225. }
  150226. /**
  150227. * A babylon container for an XR Anchor
  150228. */
  150229. export interface IWebXRAnchor {
  150230. /**
  150231. * A babylon-assigned ID for this anchor
  150232. */
  150233. id: number;
  150234. /**
  150235. * Transformation matrix to apply to an object attached to this anchor
  150236. */
  150237. transformationMatrix: Matrix;
  150238. /**
  150239. * The native anchor object
  150240. */
  150241. xrAnchor: XRAnchor;
  150242. /**
  150243. * if defined, this object will be constantly updated by the anchor's position and rotation
  150244. */
  150245. attachedNode?: TransformNode;
  150246. }
  150247. /**
  150248. * An implementation of the anchor system for WebXR.
  150249. * For further information see https://github.com/immersive-web/anchors/
  150250. */
  150251. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  150252. private _options;
  150253. private _lastFrameDetected;
  150254. private _trackedAnchors;
  150255. private _referenceSpaceForFrameAnchors;
  150256. private _futureAnchors;
  150257. /**
  150258. * The module's name
  150259. */
  150260. static readonly Name: string;
  150261. /**
  150262. * The (Babylon) version of this module.
  150263. * This is an integer representing the implementation version.
  150264. * This number does not correspond to the WebXR specs version
  150265. */
  150266. static readonly Version: number;
  150267. /**
  150268. * Observers registered here will be executed when a new anchor was added to the session
  150269. */
  150270. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  150271. /**
  150272. * Observers registered here will be executed when an anchor was removed from the session
  150273. */
  150274. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  150275. /**
  150276. * Observers registered here will be executed when an existing anchor updates
  150277. * This can execute N times every frame
  150278. */
  150279. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  150280. /**
  150281. * Set the reference space to use for anchor creation, when not using a hit test.
  150282. * Will default to the session's reference space if not defined
  150283. */
  150284. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  150285. /**
  150286. * constructs a new anchor system
  150287. * @param _xrSessionManager an instance of WebXRSessionManager
  150288. * @param _options configuration object for this feature
  150289. */
  150290. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  150291. private _tmpVector;
  150292. private _tmpQuaternion;
  150293. private _populateTmpTransformation;
  150294. /**
  150295. * Create a new anchor point using a hit test result at a specific point in the scene
  150296. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150297. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150298. *
  150299. * @param hitTestResult The hit test result to use for this anchor creation
  150300. * @param position an optional position offset for this anchor
  150301. * @param rotationQuaternion an optional rotation offset for this anchor
  150302. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150303. */
  150304. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  150305. /**
  150306. * Add a new anchor at a specific position and rotation
  150307. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  150308. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  150309. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150310. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150311. *
  150312. * @param position the position in which to add an anchor
  150313. * @param rotationQuaternion an optional rotation for the anchor transformation
  150314. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  150315. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150316. */
  150317. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  150318. /**
  150319. * detach this feature.
  150320. * Will usually be called by the features manager
  150321. *
  150322. * @returns true if successful.
  150323. */
  150324. detach(): boolean;
  150325. /**
  150326. * Dispose this feature and all of the resources attached
  150327. */
  150328. dispose(): void;
  150329. protected _onXRFrame(frame: XRFrame): void;
  150330. /**
  150331. * avoiding using Array.find for global support.
  150332. * @param xrAnchor the plane to find in the array
  150333. */
  150334. private _findIndexInAnchorArray;
  150335. private _updateAnchorWithXRFrame;
  150336. private _createAnchorAtTransformation;
  150337. }
  150338. }
  150339. declare module BABYLON {
  150340. /**
  150341. * Options used in the plane detector module
  150342. */
  150343. export interface IWebXRPlaneDetectorOptions {
  150344. /**
  150345. * The node to use to transform the local results to world coordinates
  150346. */
  150347. worldParentNode?: TransformNode;
  150348. /**
  150349. * If set to true a reference of the created planes will be kept until the next session starts
  150350. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  150351. */
  150352. doNotRemovePlanesOnSessionEnded?: boolean;
  150353. }
  150354. /**
  150355. * A babylon interface for a WebXR plane.
  150356. * A Plane is actually a polygon, built from N points in space
  150357. *
  150358. * Supported in chrome 79, not supported in canary 81 ATM
  150359. */
  150360. export interface IWebXRPlane {
  150361. /**
  150362. * a babylon-assigned ID for this polygon
  150363. */
  150364. id: number;
  150365. /**
  150366. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  150367. */
  150368. polygonDefinition: Array<Vector3>;
  150369. /**
  150370. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  150371. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  150372. */
  150373. transformationMatrix: Matrix;
  150374. /**
  150375. * the native xr-plane object
  150376. */
  150377. xrPlane: XRPlane;
  150378. }
  150379. /**
  150380. * The plane detector is used to detect planes in the real world when in AR
  150381. * For more information see https://github.com/immersive-web/real-world-geometry/
  150382. */
  150383. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  150384. private _options;
  150385. private _detectedPlanes;
  150386. private _enabled;
  150387. private _lastFrameDetected;
  150388. /**
  150389. * The module's name
  150390. */
  150391. static readonly Name: string;
  150392. /**
  150393. * The (Babylon) version of this module.
  150394. * This is an integer representing the implementation version.
  150395. * This number does not correspond to the WebXR specs version
  150396. */
  150397. static readonly Version: number;
  150398. /**
  150399. * Observers registered here will be executed when a new plane was added to the session
  150400. */
  150401. onPlaneAddedObservable: Observable<IWebXRPlane>;
  150402. /**
  150403. * Observers registered here will be executed when a plane is no longer detected in the session
  150404. */
  150405. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  150406. /**
  150407. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  150408. * This can execute N times every frame
  150409. */
  150410. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  150411. /**
  150412. * construct a new Plane Detector
  150413. * @param _xrSessionManager an instance of xr Session manager
  150414. * @param _options configuration to use when constructing this feature
  150415. */
  150416. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  150417. /**
  150418. * detach this feature.
  150419. * Will usually be called by the features manager
  150420. *
  150421. * @returns true if successful.
  150422. */
  150423. detach(): boolean;
  150424. /**
  150425. * Dispose this feature and all of the resources attached
  150426. */
  150427. dispose(): void;
  150428. protected _onXRFrame(frame: XRFrame): void;
  150429. private _init;
  150430. private _updatePlaneWithXRPlane;
  150431. /**
  150432. * avoiding using Array.find for global support.
  150433. * @param xrPlane the plane to find in the array
  150434. */
  150435. private findIndexInPlaneArray;
  150436. }
  150437. }
  150438. declare module BABYLON {
  150439. /**
  150440. * Options interface for the background remover plugin
  150441. */
  150442. export interface IWebXRBackgroundRemoverOptions {
  150443. /**
  150444. * Further background meshes to disable when entering AR
  150445. */
  150446. backgroundMeshes?: AbstractMesh[];
  150447. /**
  150448. * flags to configure the removal of the environment helper.
  150449. * If not set, the entire background will be removed. If set, flags should be set as well.
  150450. */
  150451. environmentHelperRemovalFlags?: {
  150452. /**
  150453. * Should the skybox be removed (default false)
  150454. */
  150455. skyBox?: boolean;
  150456. /**
  150457. * Should the ground be removed (default false)
  150458. */
  150459. ground?: boolean;
  150460. };
  150461. /**
  150462. * don't disable the environment helper
  150463. */
  150464. ignoreEnvironmentHelper?: boolean;
  150465. }
  150466. /**
  150467. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  150468. */
  150469. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  150470. /**
  150471. * read-only options to be used in this module
  150472. */
  150473. readonly options: IWebXRBackgroundRemoverOptions;
  150474. /**
  150475. * The module's name
  150476. */
  150477. static readonly Name: string;
  150478. /**
  150479. * The (Babylon) version of this module.
  150480. * This is an integer representing the implementation version.
  150481. * This number does not correspond to the WebXR specs version
  150482. */
  150483. static readonly Version: number;
  150484. /**
  150485. * registered observers will be triggered when the background state changes
  150486. */
  150487. onBackgroundStateChangedObservable: Observable<boolean>;
  150488. /**
  150489. * constructs a new background remover module
  150490. * @param _xrSessionManager the session manager for this module
  150491. * @param options read-only options to be used in this module
  150492. */
  150493. constructor(_xrSessionManager: WebXRSessionManager,
  150494. /**
  150495. * read-only options to be used in this module
  150496. */
  150497. options?: IWebXRBackgroundRemoverOptions);
  150498. /**
  150499. * attach this feature
  150500. * Will usually be called by the features manager
  150501. *
  150502. * @returns true if successful.
  150503. */
  150504. attach(): boolean;
  150505. /**
  150506. * detach this feature.
  150507. * Will usually be called by the features manager
  150508. *
  150509. * @returns true if successful.
  150510. */
  150511. detach(): boolean;
  150512. /**
  150513. * Dispose this feature and all of the resources attached
  150514. */
  150515. dispose(): void;
  150516. protected _onXRFrame(_xrFrame: XRFrame): void;
  150517. private _setBackgroundState;
  150518. }
  150519. }
  150520. declare module BABYLON {
  150521. /**
  150522. * Options for the controller physics feature
  150523. */
  150524. export class IWebXRControllerPhysicsOptions {
  150525. /**
  150526. * Should the headset get its own impostor
  150527. */
  150528. enableHeadsetImpostor?: boolean;
  150529. /**
  150530. * Optional parameters for the headset impostor
  150531. */
  150532. headsetImpostorParams?: {
  150533. /**
  150534. * The type of impostor to create. Default is sphere
  150535. */
  150536. impostorType: number;
  150537. /**
  150538. * the size of the impostor. Defaults to 10cm
  150539. */
  150540. impostorSize?: number | {
  150541. width: number;
  150542. height: number;
  150543. depth: number;
  150544. };
  150545. /**
  150546. * Friction definitions
  150547. */
  150548. friction?: number;
  150549. /**
  150550. * Restitution
  150551. */
  150552. restitution?: number;
  150553. };
  150554. /**
  150555. * The physics properties of the future impostors
  150556. */
  150557. physicsProperties?: {
  150558. /**
  150559. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  150560. * Note that this requires a physics engine that supports mesh impostors!
  150561. */
  150562. useControllerMesh?: boolean;
  150563. /**
  150564. * The type of impostor to create. Default is sphere
  150565. */
  150566. impostorType?: number;
  150567. /**
  150568. * the size of the impostor. Defaults to 10cm
  150569. */
  150570. impostorSize?: number | {
  150571. width: number;
  150572. height: number;
  150573. depth: number;
  150574. };
  150575. /**
  150576. * Friction definitions
  150577. */
  150578. friction?: number;
  150579. /**
  150580. * Restitution
  150581. */
  150582. restitution?: number;
  150583. };
  150584. /**
  150585. * the xr input to use with this pointer selection
  150586. */
  150587. xrInput: WebXRInput;
  150588. }
  150589. /**
  150590. * Add physics impostor to your webxr controllers,
  150591. * including naive calculation of their linear and angular velocity
  150592. */
  150593. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  150594. private readonly _options;
  150595. private _attachController;
  150596. private _controllers;
  150597. private _debugMode;
  150598. private _delta;
  150599. private _headsetImpostor?;
  150600. private _headsetMesh?;
  150601. private _lastTimestamp;
  150602. private _tmpQuaternion;
  150603. private _tmpVector;
  150604. /**
  150605. * The module's name
  150606. */
  150607. static readonly Name: string;
  150608. /**
  150609. * The (Babylon) version of this module.
  150610. * This is an integer representing the implementation version.
  150611. * This number does not correspond to the webxr specs version
  150612. */
  150613. static readonly Version: number;
  150614. /**
  150615. * Construct a new Controller Physics Feature
  150616. * @param _xrSessionManager the corresponding xr session manager
  150617. * @param _options options to create this feature with
  150618. */
  150619. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  150620. /**
  150621. * @hidden
  150622. * enable debugging - will show console outputs and the impostor mesh
  150623. */
  150624. _enablePhysicsDebug(): void;
  150625. /**
  150626. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  150627. * @param xrController the controller to add
  150628. */
  150629. addController(xrController: WebXRInputSource): void;
  150630. /**
  150631. * attach this feature
  150632. * Will usually be called by the features manager
  150633. *
  150634. * @returns true if successful.
  150635. */
  150636. attach(): boolean;
  150637. /**
  150638. * detach this feature.
  150639. * Will usually be called by the features manager
  150640. *
  150641. * @returns true if successful.
  150642. */
  150643. detach(): boolean;
  150644. /**
  150645. * Get the headset impostor, if enabled
  150646. * @returns the impostor
  150647. */
  150648. getHeadsetImpostor(): PhysicsImpostor | undefined;
  150649. /**
  150650. * Get the physics impostor of a specific controller.
  150651. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  150652. * @param controller the controller or the controller id of which to get the impostor
  150653. * @returns the impostor or null
  150654. */
  150655. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  150656. /**
  150657. * Update the physics properties provided in the constructor
  150658. * @param newProperties the new properties object
  150659. */
  150660. setPhysicsProperties(newProperties: {
  150661. impostorType?: number;
  150662. impostorSize?: number | {
  150663. width: number;
  150664. height: number;
  150665. depth: number;
  150666. };
  150667. friction?: number;
  150668. restitution?: number;
  150669. }): void;
  150670. protected _onXRFrame(_xrFrame: any): void;
  150671. private _detachController;
  150672. }
  150673. }
  150674. declare module BABYLON {
  150675. /**
  150676. * The motion controller class for all microsoft mixed reality controllers
  150677. */
  150678. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  150679. protected readonly _mapping: {
  150680. defaultButton: {
  150681. valueNodeName: string;
  150682. unpressedNodeName: string;
  150683. pressedNodeName: string;
  150684. };
  150685. defaultAxis: {
  150686. valueNodeName: string;
  150687. minNodeName: string;
  150688. maxNodeName: string;
  150689. };
  150690. buttons: {
  150691. "xr-standard-trigger": {
  150692. rootNodeName: string;
  150693. componentProperty: string;
  150694. states: string[];
  150695. };
  150696. "xr-standard-squeeze": {
  150697. rootNodeName: string;
  150698. componentProperty: string;
  150699. states: string[];
  150700. };
  150701. "xr-standard-touchpad": {
  150702. rootNodeName: string;
  150703. labelAnchorNodeName: string;
  150704. touchPointNodeName: string;
  150705. };
  150706. "xr-standard-thumbstick": {
  150707. rootNodeName: string;
  150708. componentProperty: string;
  150709. states: string[];
  150710. };
  150711. };
  150712. axes: {
  150713. "xr-standard-touchpad": {
  150714. "x-axis": {
  150715. rootNodeName: string;
  150716. };
  150717. "y-axis": {
  150718. rootNodeName: string;
  150719. };
  150720. };
  150721. "xr-standard-thumbstick": {
  150722. "x-axis": {
  150723. rootNodeName: string;
  150724. };
  150725. "y-axis": {
  150726. rootNodeName: string;
  150727. };
  150728. };
  150729. };
  150730. };
  150731. /**
  150732. * The base url used to load the left and right controller models
  150733. */
  150734. static MODEL_BASE_URL: string;
  150735. /**
  150736. * The name of the left controller model file
  150737. */
  150738. static MODEL_LEFT_FILENAME: string;
  150739. /**
  150740. * The name of the right controller model file
  150741. */
  150742. static MODEL_RIGHT_FILENAME: string;
  150743. profileId: string;
  150744. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150745. protected _getFilenameAndPath(): {
  150746. filename: string;
  150747. path: string;
  150748. };
  150749. protected _getModelLoadingConstraints(): boolean;
  150750. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150751. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150752. protected _updateModel(): void;
  150753. }
  150754. }
  150755. declare module BABYLON {
  150756. /**
  150757. * The motion controller class for oculus touch (quest, rift).
  150758. * This class supports legacy mapping as well the standard xr mapping
  150759. */
  150760. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  150761. private _forceLegacyControllers;
  150762. private _modelRootNode;
  150763. /**
  150764. * The base url used to load the left and right controller models
  150765. */
  150766. static MODEL_BASE_URL: string;
  150767. /**
  150768. * The name of the left controller model file
  150769. */
  150770. static MODEL_LEFT_FILENAME: string;
  150771. /**
  150772. * The name of the right controller model file
  150773. */
  150774. static MODEL_RIGHT_FILENAME: string;
  150775. /**
  150776. * Base Url for the Quest controller model.
  150777. */
  150778. static QUEST_MODEL_BASE_URL: string;
  150779. profileId: string;
  150780. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  150781. protected _getFilenameAndPath(): {
  150782. filename: string;
  150783. path: string;
  150784. };
  150785. protected _getModelLoadingConstraints(): boolean;
  150786. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150787. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150788. protected _updateModel(): void;
  150789. /**
  150790. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  150791. * between the touch and touch 2.
  150792. */
  150793. private _isQuest;
  150794. }
  150795. }
  150796. declare module BABYLON {
  150797. /**
  150798. * The motion controller class for the standard HTC-Vive controllers
  150799. */
  150800. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  150801. private _modelRootNode;
  150802. /**
  150803. * The base url used to load the left and right controller models
  150804. */
  150805. static MODEL_BASE_URL: string;
  150806. /**
  150807. * File name for the controller model.
  150808. */
  150809. static MODEL_FILENAME: string;
  150810. profileId: string;
  150811. /**
  150812. * Create a new Vive motion controller object
  150813. * @param scene the scene to use to create this controller
  150814. * @param gamepadObject the corresponding gamepad object
  150815. * @param handedness the handedness of the controller
  150816. */
  150817. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  150818. protected _getFilenameAndPath(): {
  150819. filename: string;
  150820. path: string;
  150821. };
  150822. protected _getModelLoadingConstraints(): boolean;
  150823. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  150824. protected _setRootMesh(meshes: AbstractMesh[]): void;
  150825. protected _updateModel(): void;
  150826. }
  150827. }
  150828. declare module BABYLON {
  150829. /**
  150830. * A cursor which tracks a point on a path
  150831. */
  150832. export class PathCursor {
  150833. private path;
  150834. /**
  150835. * Stores path cursor callbacks for when an onchange event is triggered
  150836. */
  150837. private _onchange;
  150838. /**
  150839. * The value of the path cursor
  150840. */
  150841. value: number;
  150842. /**
  150843. * The animation array of the path cursor
  150844. */
  150845. animations: Animation[];
  150846. /**
  150847. * Initializes the path cursor
  150848. * @param path The path to track
  150849. */
  150850. constructor(path: Path2);
  150851. /**
  150852. * Gets the cursor point on the path
  150853. * @returns A point on the path cursor at the cursor location
  150854. */
  150855. getPoint(): Vector3;
  150856. /**
  150857. * Moves the cursor ahead by the step amount
  150858. * @param step The amount to move the cursor forward
  150859. * @returns This path cursor
  150860. */
  150861. moveAhead(step?: number): PathCursor;
  150862. /**
  150863. * Moves the cursor behind by the step amount
  150864. * @param step The amount to move the cursor back
  150865. * @returns This path cursor
  150866. */
  150867. moveBack(step?: number): PathCursor;
  150868. /**
  150869. * Moves the cursor by the step amount
  150870. * If the step amount is greater than one, an exception is thrown
  150871. * @param step The amount to move the cursor
  150872. * @returns This path cursor
  150873. */
  150874. move(step: number): PathCursor;
  150875. /**
  150876. * Ensures that the value is limited between zero and one
  150877. * @returns This path cursor
  150878. */
  150879. private ensureLimits;
  150880. /**
  150881. * Runs onchange callbacks on change (used by the animation engine)
  150882. * @returns This path cursor
  150883. */
  150884. private raiseOnChange;
  150885. /**
  150886. * Executes a function on change
  150887. * @param f A path cursor onchange callback
  150888. * @returns This path cursor
  150889. */
  150890. onchange(f: (cursor: PathCursor) => void): PathCursor;
  150891. }
  150892. }
  150893. declare module BABYLON {
  150894. /** @hidden */
  150895. export var blurPixelShader: {
  150896. name: string;
  150897. shader: string;
  150898. };
  150899. }
  150900. declare module BABYLON {
  150901. /** @hidden */
  150902. export var pointCloudVertexDeclaration: {
  150903. name: string;
  150904. shader: string;
  150905. };
  150906. }
  150907. // Mixins
  150908. interface Window {
  150909. mozIndexedDB: IDBFactory;
  150910. webkitIndexedDB: IDBFactory;
  150911. msIndexedDB: IDBFactory;
  150912. webkitURL: typeof URL;
  150913. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  150914. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  150915. WebGLRenderingContext: WebGLRenderingContext;
  150916. MSGesture: MSGesture;
  150917. CANNON: any;
  150918. AudioContext: AudioContext;
  150919. webkitAudioContext: AudioContext;
  150920. PointerEvent: any;
  150921. Math: Math;
  150922. Uint8Array: Uint8ArrayConstructor;
  150923. Float32Array: Float32ArrayConstructor;
  150924. mozURL: typeof URL;
  150925. msURL: typeof URL;
  150926. VRFrameData: any; // WebVR, from specs 1.1
  150927. DracoDecoderModule: any;
  150928. setImmediate(handler: (...args: any[]) => void): number;
  150929. }
  150930. interface HTMLCanvasElement {
  150931. requestPointerLock(): void;
  150932. msRequestPointerLock?(): void;
  150933. mozRequestPointerLock?(): void;
  150934. webkitRequestPointerLock?(): void;
  150935. /** Track wether a record is in progress */
  150936. isRecording: boolean;
  150937. /** Capture Stream method defined by some browsers */
  150938. captureStream(fps?: number): MediaStream;
  150939. }
  150940. interface CanvasRenderingContext2D {
  150941. msImageSmoothingEnabled: boolean;
  150942. }
  150943. interface MouseEvent {
  150944. mozMovementX: number;
  150945. mozMovementY: number;
  150946. webkitMovementX: number;
  150947. webkitMovementY: number;
  150948. msMovementX: number;
  150949. msMovementY: number;
  150950. }
  150951. interface Navigator {
  150952. mozGetVRDevices: (any: any) => any;
  150953. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150954. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150955. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  150956. webkitGetGamepads(): Gamepad[];
  150957. msGetGamepads(): Gamepad[];
  150958. webkitGamepads(): Gamepad[];
  150959. }
  150960. interface HTMLVideoElement {
  150961. mozSrcObject: any;
  150962. }
  150963. interface Math {
  150964. fround(x: number): number;
  150965. imul(a: number, b: number): number;
  150966. }
  150967. interface WebGLRenderingContext {
  150968. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  150969. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  150970. vertexAttribDivisor(index: number, divisor: number): void;
  150971. createVertexArray(): any;
  150972. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  150973. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  150974. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  150975. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  150976. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  150977. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  150978. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  150979. // Queries
  150980. createQuery(): WebGLQuery;
  150981. deleteQuery(query: WebGLQuery): void;
  150982. beginQuery(target: number, query: WebGLQuery): void;
  150983. endQuery(target: number): void;
  150984. getQueryParameter(query: WebGLQuery, pname: number): any;
  150985. getQuery(target: number, pname: number): any;
  150986. MAX_SAMPLES: number;
  150987. RGBA8: number;
  150988. READ_FRAMEBUFFER: number;
  150989. DRAW_FRAMEBUFFER: number;
  150990. UNIFORM_BUFFER: number;
  150991. HALF_FLOAT_OES: number;
  150992. RGBA16F: number;
  150993. RGBA32F: number;
  150994. R32F: number;
  150995. RG32F: number;
  150996. RGB32F: number;
  150997. R16F: number;
  150998. RG16F: number;
  150999. RGB16F: number;
  151000. RED: number;
  151001. RG: number;
  151002. R8: number;
  151003. RG8: number;
  151004. UNSIGNED_INT_24_8: number;
  151005. DEPTH24_STENCIL8: number;
  151006. MIN: number;
  151007. MAX: number;
  151008. /* Multiple Render Targets */
  151009. drawBuffers(buffers: number[]): void;
  151010. readBuffer(src: number): void;
  151011. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  151012. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  151013. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  151014. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  151015. // Occlusion Query
  151016. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  151017. ANY_SAMPLES_PASSED: number;
  151018. QUERY_RESULT_AVAILABLE: number;
  151019. QUERY_RESULT: number;
  151020. }
  151021. interface WebGLProgram {
  151022. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  151023. }
  151024. interface EXT_disjoint_timer_query {
  151025. QUERY_COUNTER_BITS_EXT: number;
  151026. TIME_ELAPSED_EXT: number;
  151027. TIMESTAMP_EXT: number;
  151028. GPU_DISJOINT_EXT: number;
  151029. QUERY_RESULT_EXT: number;
  151030. QUERY_RESULT_AVAILABLE_EXT: number;
  151031. queryCounterEXT(query: WebGLQuery, target: number): void;
  151032. createQueryEXT(): WebGLQuery;
  151033. beginQueryEXT(target: number, query: WebGLQuery): void;
  151034. endQueryEXT(target: number): void;
  151035. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  151036. deleteQueryEXT(query: WebGLQuery): void;
  151037. }
  151038. interface WebGLUniformLocation {
  151039. _currentState: any;
  151040. }
  151041. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  151042. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  151043. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  151044. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151045. interface WebGLRenderingContext {
  151046. readonly RASTERIZER_DISCARD: number;
  151047. readonly DEPTH_COMPONENT24: number;
  151048. readonly TEXTURE_3D: number;
  151049. readonly TEXTURE_2D_ARRAY: number;
  151050. readonly TEXTURE_COMPARE_FUNC: number;
  151051. readonly TEXTURE_COMPARE_MODE: number;
  151052. readonly COMPARE_REF_TO_TEXTURE: number;
  151053. readonly TEXTURE_WRAP_R: number;
  151054. readonly HALF_FLOAT: number;
  151055. readonly RGB8: number;
  151056. readonly RED_INTEGER: number;
  151057. readonly RG_INTEGER: number;
  151058. readonly RGB_INTEGER: number;
  151059. readonly RGBA_INTEGER: number;
  151060. readonly R8_SNORM: number;
  151061. readonly RG8_SNORM: number;
  151062. readonly RGB8_SNORM: number;
  151063. readonly RGBA8_SNORM: number;
  151064. readonly R8I: number;
  151065. readonly RG8I: number;
  151066. readonly RGB8I: number;
  151067. readonly RGBA8I: number;
  151068. readonly R8UI: number;
  151069. readonly RG8UI: number;
  151070. readonly RGB8UI: number;
  151071. readonly RGBA8UI: number;
  151072. readonly R16I: number;
  151073. readonly RG16I: number;
  151074. readonly RGB16I: number;
  151075. readonly RGBA16I: number;
  151076. readonly R16UI: number;
  151077. readonly RG16UI: number;
  151078. readonly RGB16UI: number;
  151079. readonly RGBA16UI: number;
  151080. readonly R32I: number;
  151081. readonly RG32I: number;
  151082. readonly RGB32I: number;
  151083. readonly RGBA32I: number;
  151084. readonly R32UI: number;
  151085. readonly RG32UI: number;
  151086. readonly RGB32UI: number;
  151087. readonly RGBA32UI: number;
  151088. readonly RGB10_A2UI: number;
  151089. readonly R11F_G11F_B10F: number;
  151090. readonly RGB9_E5: number;
  151091. readonly RGB10_A2: number;
  151092. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  151093. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  151094. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  151095. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  151096. readonly DEPTH_COMPONENT32F: number;
  151097. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  151098. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  151099. 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;
  151100. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  151101. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  151102. readonly TRANSFORM_FEEDBACK: number;
  151103. readonly INTERLEAVED_ATTRIBS: number;
  151104. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  151105. createTransformFeedback(): WebGLTransformFeedback;
  151106. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  151107. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  151108. beginTransformFeedback(primitiveMode: number): void;
  151109. endTransformFeedback(): void;
  151110. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  151111. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151112. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151113. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151114. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  151115. }
  151116. interface ImageBitmap {
  151117. readonly width: number;
  151118. readonly height: number;
  151119. close(): void;
  151120. }
  151121. interface WebGLQuery extends WebGLObject {
  151122. }
  151123. declare var WebGLQuery: {
  151124. prototype: WebGLQuery;
  151125. new(): WebGLQuery;
  151126. };
  151127. interface WebGLSampler extends WebGLObject {
  151128. }
  151129. declare var WebGLSampler: {
  151130. prototype: WebGLSampler;
  151131. new(): WebGLSampler;
  151132. };
  151133. interface WebGLSync extends WebGLObject {
  151134. }
  151135. declare var WebGLSync: {
  151136. prototype: WebGLSync;
  151137. new(): WebGLSync;
  151138. };
  151139. interface WebGLTransformFeedback extends WebGLObject {
  151140. }
  151141. declare var WebGLTransformFeedback: {
  151142. prototype: WebGLTransformFeedback;
  151143. new(): WebGLTransformFeedback;
  151144. };
  151145. interface WebGLVertexArrayObject extends WebGLObject {
  151146. }
  151147. declare var WebGLVertexArrayObject: {
  151148. prototype: WebGLVertexArrayObject;
  151149. new(): WebGLVertexArrayObject;
  151150. };
  151151. // Type definitions for WebVR API
  151152. // Project: https://w3c.github.io/webvr/
  151153. // Definitions by: six a <https://github.com/lostfictions>
  151154. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151155. interface VRDisplay extends EventTarget {
  151156. /**
  151157. * Dictionary of capabilities describing the VRDisplay.
  151158. */
  151159. readonly capabilities: VRDisplayCapabilities;
  151160. /**
  151161. * z-depth defining the far plane of the eye view frustum
  151162. * enables mapping of values in the render target depth
  151163. * attachment to scene coordinates. Initially set to 10000.0.
  151164. */
  151165. depthFar: number;
  151166. /**
  151167. * z-depth defining the near plane of the eye view frustum
  151168. * enables mapping of values in the render target depth
  151169. * attachment to scene coordinates. Initially set to 0.01.
  151170. */
  151171. depthNear: number;
  151172. /**
  151173. * An identifier for this distinct VRDisplay. Used as an
  151174. * association point in the Gamepad API.
  151175. */
  151176. readonly displayId: number;
  151177. /**
  151178. * A display name, a user-readable name identifying it.
  151179. */
  151180. readonly displayName: string;
  151181. readonly isConnected: boolean;
  151182. readonly isPresenting: boolean;
  151183. /**
  151184. * If this VRDisplay supports room-scale experiences, the optional
  151185. * stage attribute contains details on the room-scale parameters.
  151186. */
  151187. readonly stageParameters: VRStageParameters | null;
  151188. /**
  151189. * Passing the value returned by `requestAnimationFrame` to
  151190. * `cancelAnimationFrame` will unregister the callback.
  151191. * @param handle Define the hanle of the request to cancel
  151192. */
  151193. cancelAnimationFrame(handle: number): void;
  151194. /**
  151195. * Stops presenting to the VRDisplay.
  151196. * @returns a promise to know when it stopped
  151197. */
  151198. exitPresent(): Promise<void>;
  151199. /**
  151200. * Return the current VREyeParameters for the given eye.
  151201. * @param whichEye Define the eye we want the parameter for
  151202. * @returns the eye parameters
  151203. */
  151204. getEyeParameters(whichEye: string): VREyeParameters;
  151205. /**
  151206. * Populates the passed VRFrameData with the information required to render
  151207. * the current frame.
  151208. * @param frameData Define the data structure to populate
  151209. * @returns true if ok otherwise false
  151210. */
  151211. getFrameData(frameData: VRFrameData): boolean;
  151212. /**
  151213. * Get the layers currently being presented.
  151214. * @returns the list of VR layers
  151215. */
  151216. getLayers(): VRLayer[];
  151217. /**
  151218. * Return a VRPose containing the future predicted pose of the VRDisplay
  151219. * when the current frame will be presented. The value returned will not
  151220. * change until JavaScript has returned control to the browser.
  151221. *
  151222. * The VRPose will contain the position, orientation, velocity,
  151223. * and acceleration of each of these properties.
  151224. * @returns the pose object
  151225. */
  151226. getPose(): VRPose;
  151227. /**
  151228. * Return the current instantaneous pose of the VRDisplay, with no
  151229. * prediction applied.
  151230. * @returns the current instantaneous pose
  151231. */
  151232. getImmediatePose(): VRPose;
  151233. /**
  151234. * The callback passed to `requestAnimationFrame` will be called
  151235. * any time a new frame should be rendered. When the VRDisplay is
  151236. * presenting the callback will be called at the native refresh
  151237. * rate of the HMD. When not presenting this function acts
  151238. * identically to how window.requestAnimationFrame acts. Content should
  151239. * make no assumptions of frame rate or vsync behavior as the HMD runs
  151240. * asynchronously from other displays and at differing refresh rates.
  151241. * @param callback Define the eaction to run next frame
  151242. * @returns the request handle it
  151243. */
  151244. requestAnimationFrame(callback: FrameRequestCallback): number;
  151245. /**
  151246. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  151247. * Repeat calls while already presenting will update the VRLayers being displayed.
  151248. * @param layers Define the list of layer to present
  151249. * @returns a promise to know when the request has been fulfilled
  151250. */
  151251. requestPresent(layers: VRLayer[]): Promise<void>;
  151252. /**
  151253. * Reset the pose for this display, treating its current position and
  151254. * orientation as the "origin/zero" values. VRPose.position,
  151255. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  151256. * updated when calling resetPose(). This should be called in only
  151257. * sitting-space experiences.
  151258. */
  151259. resetPose(): void;
  151260. /**
  151261. * The VRLayer provided to the VRDisplay will be captured and presented
  151262. * in the HMD. Calling this function has the same effect on the source
  151263. * canvas as any other operation that uses its source image, and canvases
  151264. * created without preserveDrawingBuffer set to true will be cleared.
  151265. * @param pose Define the pose to submit
  151266. */
  151267. submitFrame(pose?: VRPose): void;
  151268. }
  151269. declare var VRDisplay: {
  151270. prototype: VRDisplay;
  151271. new(): VRDisplay;
  151272. };
  151273. interface VRLayer {
  151274. leftBounds?: number[] | Float32Array | null;
  151275. rightBounds?: number[] | Float32Array | null;
  151276. source?: HTMLCanvasElement | null;
  151277. }
  151278. interface VRDisplayCapabilities {
  151279. readonly canPresent: boolean;
  151280. readonly hasExternalDisplay: boolean;
  151281. readonly hasOrientation: boolean;
  151282. readonly hasPosition: boolean;
  151283. readonly maxLayers: number;
  151284. }
  151285. interface VREyeParameters {
  151286. /** @deprecated */
  151287. readonly fieldOfView: VRFieldOfView;
  151288. readonly offset: Float32Array;
  151289. readonly renderHeight: number;
  151290. readonly renderWidth: number;
  151291. }
  151292. interface VRFieldOfView {
  151293. readonly downDegrees: number;
  151294. readonly leftDegrees: number;
  151295. readonly rightDegrees: number;
  151296. readonly upDegrees: number;
  151297. }
  151298. interface VRFrameData {
  151299. readonly leftProjectionMatrix: Float32Array;
  151300. readonly leftViewMatrix: Float32Array;
  151301. readonly pose: VRPose;
  151302. readonly rightProjectionMatrix: Float32Array;
  151303. readonly rightViewMatrix: Float32Array;
  151304. readonly timestamp: number;
  151305. }
  151306. interface VRPose {
  151307. readonly angularAcceleration: Float32Array | null;
  151308. readonly angularVelocity: Float32Array | null;
  151309. readonly linearAcceleration: Float32Array | null;
  151310. readonly linearVelocity: Float32Array | null;
  151311. readonly orientation: Float32Array | null;
  151312. readonly position: Float32Array | null;
  151313. readonly timestamp: number;
  151314. }
  151315. interface VRStageParameters {
  151316. sittingToStandingTransform?: Float32Array;
  151317. sizeX?: number;
  151318. sizeY?: number;
  151319. }
  151320. interface Navigator {
  151321. getVRDisplays(): Promise<VRDisplay[]>;
  151322. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  151323. }
  151324. interface Window {
  151325. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  151326. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  151327. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  151328. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151329. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151330. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  151331. }
  151332. interface Gamepad {
  151333. readonly displayId: number;
  151334. }
  151335. type XRSessionMode =
  151336. | "inline"
  151337. | "immersive-vr"
  151338. | "immersive-ar";
  151339. type XRReferenceSpaceType =
  151340. | "viewer"
  151341. | "local"
  151342. | "local-floor"
  151343. | "bounded-floor"
  151344. | "unbounded";
  151345. type XREnvironmentBlendMode =
  151346. | "opaque"
  151347. | "additive"
  151348. | "alpha-blend";
  151349. type XRVisibilityState =
  151350. | "visible"
  151351. | "visible-blurred"
  151352. | "hidden";
  151353. type XRHandedness =
  151354. | "none"
  151355. | "left"
  151356. | "right";
  151357. type XRTargetRayMode =
  151358. | "gaze"
  151359. | "tracked-pointer"
  151360. | "screen";
  151361. type XREye =
  151362. | "none"
  151363. | "left"
  151364. | "right";
  151365. type XREventType =
  151366. | "devicechange"
  151367. | "visibilitychange"
  151368. | "end"
  151369. | "inputsourceschange"
  151370. | "select"
  151371. | "selectstart"
  151372. | "selectend"
  151373. | "squeeze"
  151374. | "squeezestart"
  151375. | "squeezeend"
  151376. | "reset";
  151377. interface XRSpace extends EventTarget {
  151378. }
  151379. interface XRRenderState {
  151380. depthNear?: number;
  151381. depthFar?: number;
  151382. inlineVerticalFieldOfView?: number;
  151383. baseLayer?: XRWebGLLayer;
  151384. }
  151385. interface XRInputSource {
  151386. handedness: XRHandedness;
  151387. targetRayMode: XRTargetRayMode;
  151388. targetRaySpace: XRSpace;
  151389. gripSpace: XRSpace | undefined;
  151390. gamepad: Gamepad | undefined;
  151391. profiles: Array<string>;
  151392. }
  151393. interface XRSessionInit {
  151394. optionalFeatures?: string[];
  151395. requiredFeatures?: string[];
  151396. }
  151397. interface XRSession {
  151398. addEventListener: Function;
  151399. removeEventListener: Function;
  151400. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  151401. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  151402. requestAnimationFrame: Function;
  151403. end(): Promise<void>;
  151404. renderState: XRRenderState;
  151405. inputSources: Array<XRInputSource>;
  151406. // hit test
  151407. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  151408. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  151409. // legacy AR hit test
  151410. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151411. // legacy plane detection
  151412. updateWorldTrackingState(options: {
  151413. planeDetectionState?: { enabled: boolean; }
  151414. }): void;
  151415. }
  151416. interface XRReferenceSpace extends XRSpace {
  151417. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  151418. onreset: any;
  151419. }
  151420. type XRPlaneSet = Set<XRPlane>;
  151421. type XRAnchorSet = Set<XRAnchor>;
  151422. interface XRFrame {
  151423. session: XRSession;
  151424. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  151425. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  151426. // AR
  151427. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  151428. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  151429. // Anchors
  151430. trackedAnchors?: XRAnchorSet;
  151431. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  151432. // Planes
  151433. worldInformation: {
  151434. detectedPlanes?: XRPlaneSet;
  151435. };
  151436. }
  151437. interface XRViewerPose extends XRPose {
  151438. views: Array<XRView>;
  151439. }
  151440. interface XRPose {
  151441. transform: XRRigidTransform;
  151442. emulatedPosition: boolean;
  151443. }
  151444. interface XRWebGLLayerOptions {
  151445. antialias?: boolean;
  151446. depth?: boolean;
  151447. stencil?: boolean;
  151448. alpha?: boolean;
  151449. multiview?: boolean;
  151450. framebufferScaleFactor?: number;
  151451. }
  151452. declare var XRWebGLLayer: {
  151453. prototype: XRWebGLLayer;
  151454. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  151455. };
  151456. interface XRWebGLLayer {
  151457. framebuffer: WebGLFramebuffer;
  151458. framebufferWidth: number;
  151459. framebufferHeight: number;
  151460. getViewport: Function;
  151461. }
  151462. declare class XRRigidTransform {
  151463. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  151464. position: DOMPointReadOnly;
  151465. orientation: DOMPointReadOnly;
  151466. matrix: Float32Array;
  151467. inverse: XRRigidTransform;
  151468. }
  151469. interface XRView {
  151470. eye: XREye;
  151471. projectionMatrix: Float32Array;
  151472. transform: XRRigidTransform;
  151473. }
  151474. interface XRInputSourceChangeEvent {
  151475. session: XRSession;
  151476. removed: Array<XRInputSource>;
  151477. added: Array<XRInputSource>;
  151478. }
  151479. interface XRInputSourceEvent extends Event {
  151480. readonly frame: XRFrame;
  151481. readonly inputSource: XRInputSource;
  151482. }
  151483. // Experimental(er) features
  151484. declare class XRRay {
  151485. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  151486. origin: DOMPointReadOnly;
  151487. direction: DOMPointReadOnly;
  151488. matrix: Float32Array;
  151489. }
  151490. declare enum XRHitTestTrackableType {
  151491. "point",
  151492. "plane"
  151493. }
  151494. interface XRHitResult {
  151495. hitMatrix: Float32Array;
  151496. }
  151497. interface XRTransientInputHitTestResult {
  151498. readonly inputSource: XRInputSource;
  151499. readonly results: Array<XRHitTestResult>;
  151500. }
  151501. interface XRHitTestResult {
  151502. getPose(baseSpace: XRSpace): XRPose | undefined;
  151503. // When anchor system is enabled
  151504. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  151505. }
  151506. interface XRHitTestSource {
  151507. cancel(): void;
  151508. }
  151509. interface XRTransientInputHitTestSource {
  151510. cancel(): void;
  151511. }
  151512. interface XRHitTestOptionsInit {
  151513. space: XRSpace;
  151514. entityTypes?: Array<XRHitTestTrackableType>;
  151515. offsetRay?: XRRay;
  151516. }
  151517. interface XRTransientInputHitTestOptionsInit {
  151518. profile: string;
  151519. entityTypes?: Array<XRHitTestTrackableType>;
  151520. offsetRay?: XRRay;
  151521. }
  151522. interface XRAnchor {
  151523. anchorSpace: XRSpace;
  151524. delete(): void;
  151525. }
  151526. interface XRPlane {
  151527. orientation: "Horizontal" | "Vertical";
  151528. planeSpace: XRSpace;
  151529. polygon: Array<DOMPointReadOnly>;
  151530. lastChangedTime: number;
  151531. }